Commit Graph

46 Commits

Author SHA1 Message Date
Ryan C. Gordon 7d7ec9c951
x11: Remove XVidMode and Xinerama support.
Fixes #1782.
2022-04-26 23:17:13 -04:00
Ryan C. Gordon 1c7bf478ae
x11: Ignore BadValue for extremely small XRRSetScreenSize resolutions.
Reference Issue #4840.
2022-03-31 10:09:47 -04:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain b4aeaa30a1 Use SDL_calloc / SDL_free 2021-11-22 08:38:46 -08:00
Sylvain d31251b014 use SDL's functions version inplace of libc version 2021-11-22 08:38:46 -08:00
Ryan C. Gordon d5fe9c308a x11: Log a warning if we decide to use XVidMode.
Reference issue #1782.
2021-08-24 14:29:39 -04:00
Simon McVittie 25cd749adb x11: Don't change mode if we are already in the correct mode
If we are already in the desired mode, changing it is a no-op at best,
and harmful at worst: on Xwayland, it sometimes happens that we disable
the crtc and cannot re-enable it.

Resolves: https://github.com/libsdl-org/SDL/issues/4630
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-12 12:23:40 -07:00
Sam Lantinga b033cd0d2e Fixed XSync sequence to match other cases where we set the X11 error handler 2021-07-31 16:01:48 -07:00
Ryan C. Gordon 4c7825f6bd
x11: XSync while trying to catch XRRSetScreenSize error.
Reference issue #4561
2021-07-31 18:27:14 -04:00
Ryan C. Gordon d0effadf68
x11: Don't let XRRSetScreenSize fire a BadMatch error.
This is a workaround and not a proper fix, but this is possibly complicated,
and possibly a corner case, so this will do for 2.0.16, if not the
foreseeable future.

Reference issue #4561
2021-07-31 15:58:31 -04:00
Austin Shafer 16e3bfe807 SetDisplayMode: Call XRRSetScreenSize before setting CRTC config
X11_SetDisplayMode currently calls X11_XRRSetCrtcConfig alone. This results
in the monitor's viewport getting changed, but the underlying screen dimensions
stay the same.

The spec indicates that RRSetCrtcConfig only changes the crtc mode and has no effect
on the screen dimensions, only mentioning that the new crtc must fit entirely within the
screen size. For the size to change, RRSetScreenSize also needs to be called.

This affects Metro Exodus on Linux, when changing the resolution in the in-game settings
Metro gets stuck in a loop waiting for the size of its vulkan surface to change. Because
XRRSetScreenSize is not called the screen size is never changed, the vulkan surface dimensions
do not change, and Metro hangs forever watching for a surface size update that will
never come.

This change disables the CRTC, calls XRRSetScreenSize, and then updates the
CRTC configuration. This fixes changing the resolution from the Metro settings.

Tested with:
Metro Exodus, Portal 2
2021-07-08 08:41:29 -07:00
Kyle Schaefer 4522cb1df9 Changing variable from float to int, this way we can check it's value without having to do an unnecessary conversion. Then do explicit conversions later on if we need. 2021-06-01 16:53:39 -07:00
Kyle Schaefer c289bad900 In x11, GetDisplayDPI can give incorrect or unusable DPI information. Using XGetDefaults to get the Xft DPI if it's available and returning that. This could allow you to figure out DPI scale. 2021-06-01 16:53:39 -07:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga 93ccdee8c1 Fixed bug 5404 - stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf
Cameron Cawley

stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf

The default implementation is based on the one used in the Windows RT video driver.
2020-12-23 13:47:49 -08:00
Sam Lantinga 76980e30f2 Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Sam Lantinga c5429bd975 Fixed bug 3939 - Remove static vm_error and vm_event from SDL_x11modes.c
tomwardio

Remove static int vm_error and vm_event, use local variables instead.

This fixes unused variable errors when compiling with SDL_VIDEO_DRIVER_X11_XINERAMA undefined.

src/video/x11/SDL_x11modes.c:505:22: error: unused variable 'vm_error' [-Werror,-Wunused-variable]

src/video/x11/SDL_x11modes.c:505:12: error: unused variable 'vm_event' [-Werror,-Wunused-variable]
2017-11-04 22:06:40 -07:00
Sam Lantinga 0782f9be51 Fixed bug 3273 - Fix for slow video subsystem initialization when using XRandR.
Mart?n Golini

I'm having a very slow initialization of the video subsystem that locks the window creation for about 500 ms ( tested in at least 4 different systems ). What i found is that X11_InitModes_XRandR is using XRRGetScreenResources, that explicitly ask to poll the hardware for changes. This is not really necessary since if the data is already available you can use XRRGetScreenResourcesCurrent.
I attached a tentative patch that fix this issue. With the patch there's no lock when the subsystem is initialized and the window creation is instant in my applications. The patch only uses XRRGetScreenResourcesCurrent in X11_InitModes_XRandR but it could be potentially used in X11_GetDisplayModes and X11_SetDisplayMode.
2017-09-05 08:24:38 -07:00
Brandon Schaefer 17453d495a x11: Move screen_w/h inside the only ifdef they are referenced in to avoid compiler warnings 2017-08-21 23:44:46 -07:00
Sam Lantinga 082f32d198 Fixed bug 3722 - Fall back to xinerama/xvidmode if xrandr modes initialization fails
Levi Bard

In some environments, xrandr modes initialization can fail even though xrandr support is present and of a sufficient version.
(The one I encountered was an AWS instance running a virtual display)

The attached patch allows SDL to keep trying other methods if xrandr modes initialization fails (still subject to SDL_VIDEO_X11_REQUIRE_XRANDR).
2017-08-02 10:28:13 -07:00
Ryan C. Gordon 61a3ba303c Replaced a few single-line "//" comments. 2017-01-07 17:09:14 -05:00
Ryan C. Gordon 9d04205263 x11: deal with xrandr display size in millimeters being zero.
Xquartz on macOS reports a zero size, which leads to a division by zero here.
2017-01-04 09:33:47 -05:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga 57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga 74e1dd4c6f Define _GNU_SOURCE when building SDL 2016-11-11 13:14:00 -08:00
Sam Lantinga d780031277 Fixed bug 3476 - round() needs _GNU_SOURCE on some old systems
Ozkan Sezer

On systems with old glibc, such mine with glibc-2.8, the following warning
is issued and is fixed easily by defining _GNU_SOURCE:

/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c: In function 'CalculateXRandRRefreshRate':
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: implicit declaration of function 'round'
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: incompatible implicit declaration of built-in function 'round'
2016-11-06 09:30:06 -08:00
Sam Lantinga 27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Sam Lantinga 0250eb3c4f Fixed bug 3134 - CalculateXRandRRefreshRate() returns incorrect refresh rate due to floating point truncation.
Michael

In SDL_x11modes.c the CalculateXRandRRefreshRate() function performs integer math on values that may return fractional results. This causes a value that would be calculated as 59.99972... to be returned as 59. In Linux the xrandr command returns 60Hz for this particular display mode yet SDL returns 59Hz.

I suggest this function be updated to correctly round the result of the calculation instead of truncating the result.
2016-10-01 14:16:04 -07:00
Philipp Wiesemann 81235118ab X11: Fixed missing error message if SDL_GetDisplayDPI() failed. 2016-05-20 22:14:40 +02:00
Ryan C. Gordon eeb899999f Patched to compile. 2016-01-05 05:22:35 -05:00
Ryan C. Gordon 7605ccf68a Use SDL's stdinc functions instead of C runtime calls. 2016-01-05 02:29:16 -05:00
Ryan C. Gordon c3114975db Added SDL_GetDisplayUsableBounds(). 2016-01-04 23:52:40 -05:00
Ryan C. Gordon 81209acbd8 x11: Let apps specify that video init should fail if XRandR is unavailable.
Notably: it sets the error string to inform you that your custom SDL is built
without xrandr support, which apparently has been a support issue for
Unreal Engine 4 developers.
2016-01-04 23:44:27 -05:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Ryan C. Gordon 18c7d6df21 XRandR: fixed primary output detection logic (thanks, "winterknight"!).
Fixes Bugzilla #3185.
2015-12-29 02:16:14 -05:00
Philipp Wiesemann 32147ba780 X11: Fixed memory leak when initializing multiple screens. 2015-12-05 17:08:07 +01:00
Ryan C. Gordon 5224dfcc9a X11: Let XRandR respect multiple screens (DISPLAY=:0.0 vs :0.1, etc). 2015-11-17 12:15:35 -05:00
Ryan C. Gordon c67213f331 X11: Fixed XRandR display detection.
Previously this only worked on X11 when Xinerama was carrying the weight.

Fixes Bugzilla #3062.
2015-08-07 01:02:35 -04:00
Ryan C. Gordon ca46804210 X11: Fixed a memory leak when adding duplicate display modes. 2015-08-07 00:59:31 -04:00
Alfred Reynolds dc2e9ba13b Fix build. 2015-07-29 17:19:04 -07:00
Alfred Reynolds 51c72e10f7 Add X11 implementation of SDL_GetDisplayDPI. 2015-07-29 17:19:02 -07:00
Ryan C. Gordon 1e3c28ac64 X11: Added a test for a weird X11 error we get with Xinerama, rarely. 2015-06-30 15:00:48 -04:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00