Commit Graph

106 Commits

Author SHA1 Message Date
Sylvain ce5da5d579
Don't compare pointer against '0', but NULL 2022-11-16 21:47:43 +01:00
Sam Lantinga 4556074e18 Re-set the maximize state if we were maximized while fullscreen 2022-10-29 09:35:07 -07:00
Sam Lantinga ab06a307dc Don't report windows being maximized when fullscreen on X11
This is a functional state for some window managers (tested using stock Ubuntu 22.04.1), and removing that state, e.g. using SDL_RestoreWindow(), results in a window centered and floating, and not visually covering the rest of the desktop.
2022-10-29 09:21:17 -07:00
Ryan C. Gordon c8d20f96ba shape: Free platform-specific shaped window data.
Fixes #2128.
2022-10-26 13:57:49 -04:00
Ryan C. Gordon 4ca7b378c5
x11: Specify windowed dimensions when creating fullscreen windows.
This lets the window manager adjust the window correctly if it ever
leaves fullscreen mode.

Fixes #5725.
2022-08-21 11:35:14 -04:00
Sam Lantinga 8acb4e45b3 Fixed interactions between mouse capture and grab on X11
Fixes https://github.com/libsdl-org/SDL/issues/6072
2022-08-17 14:26:34 -07:00
Simon McVittie 63b3b9a558 Fix some typos in diagnostic messages
Detected by Debian's packaging QA tool, Lintian.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 08:33:27 -07:00
Ryan C. Gordon b75cd2b36d
x11: Force window back to expected size after SDL_SetWindowBordered.
This helps if the window manager decided to let it fill the space that
an existing border was using before its removal.

Fixes #5718.
2022-06-10 14:13:07 -04:00
Simon McVittie 412ceb84d4 video: Only check major version in SDL_GetWindowWMInfo
Since #5602, SDL is intended to have the same ABI across the whole
major-version 2 cycle, so we should not check that the minor version
matches the one that was used to compile an application.

There are two checks that could make sense here.

The first check is that the major version matches the expected major
version. This is usually unnecessary and is not usually done (if we're
calling into the wrong library we'll likely crash anyway), but since we
have the information, we might as well continue to use it.

The second check is whether the version provided by the caller is
equal to or greater than a threshold version at which additional fields
were added to the struct. If it is, we should populate those fields;
if it is not, then we cannot. This is only useful on platforms where
additional fields have genuinely been added during the lifetime of
SDL 2, like Windows and DirectFB (but not X11).

This commit changes the first check to be consistent about only looking
at the minor version, while leaving the second check using SDL_VERSIONNUM
(which will be removed or widened in SDL 3, but it's fine for now).

Resolves: https://github.com/libsdl-org/SDL/issues/5711
Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-24 08:56:23 -07:00
Ryan C. Gordon 9edd411a83
x11: send move/resize events when waiting on fullscreen change.
Otherwise we ignore the Configure/etc events when they come in because
the window is already in an identical state as far as SDL is concerned.

Fixes #5593.

May also fix:
Issue #5572.
Issue #5595.
2022-05-19 17:19:52 -04:00
Ryan C. Gordon 7d7ec9c951
x11: Remove XVidMode and Xinerama support.
Fixes #1782.
2022-04-26 23:17:13 -04:00
Ryan C. Gordon 53dea98309
x11: revert checks for _NET_WM_STATE_FULLSCREEN changes.
This reverts commit 85977354fb.
This reverts commit 0249df9d96.

Fixes #5572.
Reopens #5390.
2022-04-25 14:00:04 -04:00
Ryan C. Gordon 49a2e4b0ea
x11: Revert "Fix keymap updating for X11 backend"
This reverts commit de6d290266.

This patch had multiple issues, discussed in #5520.
2022-04-19 00:37:39 -04:00
Ryan C. Gordon 85977354fb
x11: Treat WM setting the window "fullscreen" like FULLSCREEN_DESKTOP.
Fixes #5390.
2022-04-07 09:15:27 -04:00
Ryan C. Gordon 0249df9d96
x11: Try to keep SDL_WINDOW_FULLSCREEN* in sync with window manager.
So if Gnome/KDE/etc have a keyboard shortcut or titlebar decoration to
make any window go fullscreen (with the _NET_WM_FULLSCREEN flag on the
_NET_WM_STATE property), we update the SDL window flag.

Fixes #5390.
2022-04-05 23:18:10 -04:00
Ryan C. Gordon 8bae343f25
x11: when waiting on fullscreen changes, not window position _and_ size.
This makes sure the window doesn't have outdated values if you try to access
them (or call something that does, like SDL_SetWindowMinimumSize).

Fixes #5233.
2022-04-05 22:21:57 -04:00
Ryan C. Gordon a5672b858e
x11: Wait a bit to see if window pos changes when changing fullscreen.
Helps prevent window from moving to 0,0 when leaving fullscreen.

Fixes #4749.
2022-04-05 11:10:41 -04:00
Ryan C. Gordon 7e15ad2fc4
x11: Catch X11 errors in X11_SetWindowPosition and X11_SetWindowSize.
The functions can go south if other operations are in progress, like
X11_SetWindowBordered, which might be doing something traumatic behind the
scenes of the window manager.

We can't make these tasks totally synchronous, which would fix the problem,
because not only can the window manager block however long it wants, it might
also decide to deny our requests without any notification, so we'd be waiting
forever for a window change that isn't coming.  :(

Fixes #5274.
2022-03-30 14:23:51 -04:00
Sylvain 85e6500065
X11 Segmentation fault with multiple windows and renderers (see #5256) 2022-02-11 11:08:08 +01:00
Ryan C. Gordon 42302d0a59
x11: Let apps specify a custom _NET_WM_WINDOW_TYPE.
Fixes #5185.
2022-01-11 21:17:21 -05:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
David Gow f6fdbc1e37 video: x11: Fix an invalid SDL_LogError() call
This fixes a compile warning — and possible invalid memory read —
introduced in 9c03d255 ("Add back X11 legacy WM_NAME encodings"), which
was part of PR #5029, fixing Bug #4924.

The issue is with one of the added warnings in X11_GetWindowTitle().
Basically, the "title" variable passed to SDL_LogError() hasn't been
initialised yet: we could pass propdata in directly, but it's better to
move the SDL_LogError() call until after title is set, IMHO.

This fixes the following warning from gcc (SUSE Linux) 11.2.1:
In file included from /home/david/Development/SDL/src/video/x11/../../SDL_internal.h:45,
                 from /home/david/Development/SDL/src/video/x11/SDL_x11window.c:21:
/home/david/Development/SDL/src/video/x11/SDL_x11window.c: In function 'X11_GetWindowTitle':
/home/david/Development/SDL/src/video/x11/../../dynapi/SDL_dynapi_overrides.h:33:22: warning: '%s' directive argument is null [-Wformat-overflow=]
   33 | #define SDL_LogDebug SDL_LogDebug_REAL
/home/david/Development/SDL/src/video/x11/SDL_x11window.c:720:13: note: in expansion of macro 'SDL_LogDebug'
  720 |             SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title);
      |             ^~~~~~~~~~~~
2021-11-29 07:13:25 -08:00
Fredrick Brennan b5d47aa297 Fix comment style for old compilers (`//`⇒`/**/`) 2021-11-28 21:00:29 -08:00
Fredrick Brennan 367684b0c2 Add patches suggested by @slouken in round 1 review 2021-11-28 21:00:29 -08:00
Fredrick Brennan 9c03d25543 Add back X11 legacy WM_NAME encodings
Closes #4924.

Based on patches of the past, such as this work by James Cloos in July
2010:
d7d98751b7,
as well as code comments in the Perl module X11::Protocol::WM
(https://metacpan.org/pod/X11::Protocol::WM) and even the code to Xlib
itself, which taught me that we should never have been using
`XStoreName`, all it does is call `XChangeProperty`, hardcoded to
`XA_STRING`!

What can I say, when the task is old school, the sources are too 😂
2021-11-28 21:00:29 -08:00
Sylvain fae7034901
Fix warnings: static, include, un-initialized vairables 2021-11-23 10:33:12 +01:00
Sylvain d31251b014 use SDL's functions version inplace of libc version 2021-11-22 08:38:46 -08:00
Sam Lantinga 7d21322df1 Implemented SDL_SetWindowMouseRect() on Windows 2021-11-08 16:29:19 -08:00
Ethan Lee 4b42c05ba1 video: Add SDL_SetWindowMouseRect.
This API and implementation comes from the Unreal Engine branch of SDL, which
originally called this "SDL_ConfineCursor".

Some minor cleanup and changes for consistency with the rest of SDL_video, but
there are two major changes:

1. The coordinate system has been changed so that `rect` is _window_ relative
   and not _screen_ relative, making it easier to implement without having
   global access to the display.
2. The UE version unset all rects when passing `NULL` as a parameter for
   `window`, this has been removed as it was an unused feature anyhow.

Currently this is only implemented for X, but can be supported on Wayland and
Windows at minimum too.
2021-11-08 14:16:54 -08:00
Sam Lantinga 6c56e27511 Set both _NET_WM_NAME and WM_NAME so SDL windows can be shared in the browser.
Fixes https://github.com/libsdl-org/SDL/issues/4924
2021-11-08 07:05:17 -08:00
Cacodemon345 19dee1cd16
Add SDL_GetWindowICCProfile(). (#4314)
* Add SDL_GetWindowICCProfile

* Add new SDL display events

* Implement ICC profile change event for macOS

* Implement ICC profile notification for Windows

* Fix SDL_GetWindowICCProfile() for X11

* Fix compile errors
2021-10-21 17:37:20 -07:00
Mathieu Eyraud 8e604a5f12 Fix error handling in X11_SetWindowTitle
X11_XChangeProperty return 1 on success.
2021-07-25 14:51:33 -07:00
Sam Lantinga ff1b5e1bf7 Implemented the window flash operations for X11 2021-07-24 15:11:36 -07:00
Sam Lantinga f1633127d1 Added a window flash operation to be explicit about window flash behavior 2021-07-24 13:42:19 -07:00
Sam Lantinga e1c3a25034 Changed SDL_FlashWindow() so it doesn't take a flash count, and added the hint SDL_HINT_WINDOW_FLASH_COUNT to control behavior on Windows 2021-07-24 12:11:27 -07:00
Ryan C. Gordon e65a658320
x11: Add a hint to force override-redirect.
Fixes #3776.
2021-06-09 22:10:20 -04:00
Jupeyy 64724db0a1 Implement bare minimum for SDL_FlashWindow 2021-06-04 15:07:55 -07:00
Sylvain 531d83bf6a
X11: allow using touchscreen, while pointer is grabbed (see bug #3978) 2021-05-12 23:13:48 +02:00
Fredrick Brennan c5dd9964c1 Copied X11 error handler code from SDL_x11opengl.c
Avoids needing to malloc to hold the error string.
2021-05-10 13:31:39 -04:00
Fredrick Brennan b3b4677e32 (X11) Set _NET_WM_NAME properly, fixes Unicode window titles
Removes deprecated code meant to support extremely ancient, pre-UTF-8
versions of Xorg. Uses new xlib API's for doing this same thing.

Closes #4288.
2021-05-10 13:31:39 -04:00
Ryan C. Gordon 1f482174b5
x11: Mark backing_store as NotUseful when creating windows.
This can give some performance boost, and save some resources, as there's no
reason to keep a copy of an SDL window's contents on the server: most SDL
apps are redrawing completely every frame, and the API allows for expose
events to tell an app a redraw is needed anyhow.

(And compositors are free to ignore this setting if it makes sense to do so,
according to the Xlib docs.)

Reference Issue #3776.
2021-04-25 12:44:35 -04:00
Ryan C. Gordon 9c063468d6
x11: call XSync before XSetInputFocus during SDL_ShowWindow.
This only happens when using a non-NET_WM window manager, as we might try to
set the focus before the window is mapped.

Fixes #3949.
2021-04-24 19:55:41 -04:00
Cacodemon345 0838f53d5a Implement SDL_SetWindowAlwaysOnTop for X11 2021-04-21 13:09:10 -04:00
ReNoM de6d290266 Fix keymap updating for X11 backend 2021-04-19 15:54:09 -04:00
Cameron Gutman 6b057c6783 Expose separate keyboard and mouse grab support
This adds SDL_SetWindowKeyboardGrab(), SDL_GetWindowKeyboardGrab(),
SDL_SetWindowMouseGrab(), SDL_GetWindowMouseGrab(), and new
SDL_WINDOW_KEYBOARD_GRABBED flag. It also updates the test harness to exercise
this functionality and makes a minor fix to X11 that I missed in
https://hg.libsdl.org/SDL/rev/02a2d609369b

To fit in with this new support, SDL_WINDOW_INPUT_CAPTURE has been renamed to
SDL_WINDOW_MOUSE_CAPTURE with the old name remaining as an alias for backwards
compatibility with older code.
2021-02-10 10:22:17 -05:00
Cameron Gutman a0d3c6c63c Rename SetWindowGrab() to SetWindowMouseGrab() 2021-02-10 10:22:16 -05:00
Cameron Gutman e1f73e642b Refactor keyboard grab to be managed by the video core
This gives us flexibility to add others hints to control keyboard grab behavior
without having to touch all of the backends. It also allows us to possibly
expose keyboard grab separately from mouse grab for applications that want to
manage those independently.
2021-02-10 10:22:16 -05:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Ryan C. Gordon 0ff5d55a07 x11: Don't try to grab the pointer on an unmapped window (thanks, Lee!)
Fixes Bugzilla #5352.
2020-11-23 21:07:28 -05:00