105 Commits

Author SHA1 Message Date
Ethan Lee
ae67c7d2da Implemented SDL_SetWindowMouseRect() on Wayland 2021-11-09 01:34:02 -05:00
Väinö Mäkelä
ad5205739e wayland: Only dispatch frame events in Wayland_GLES_SwapWindow
Dispatching all events in Wayland_GLES_SwapWindow leads to resizes being
acked before the program has a chance to handle the resize. This change
reduces jumping on fullscreen transition with apps that call
SDL_PollEvent before issuing any render calls.
2021-10-07 05:12:00 -04:00
Sam Lantinga
9672d58119 Need to check structure version before setting xdg_toplevel to NULL 2021-09-26 14:22:11 -07:00
Cacodemon345
b592e78f93 wayland: Expose xdg_toplevel to SysWM 2021-09-26 05:53:21 -04:00
Ethan Lee
ae7ee2a59c wayland: Ignore stateless/sizeless configs when starting in fullscreen mode 2021-08-11 11:02:33 -04:00
Ethan Lee
7be970db31 wayland: Avoid setting floating width/height when re-entering fullscreen 2021-08-06 19:51:27 -04:00
Ethan Lee
10979d37fb wayland: Always assume configure is wrong for non-resizable windows.
Configure events from compositors have an extremely annoying habit of giving us
completely bogus sizes, from all sorts of places. Thankfully, the protocol
gives us the ability to completely ignore the width/height and just stick with
what we know, so for all windows that are not meant to be resized, pretend we
never even got the width/height at all, the compositor is required to respect
our dimensions whether they match configure's suggestion or not.
2021-08-05 17:19:11 -04:00
Ethan Lee
32f909f7e3 wayland: Remove redundant waylanddyn.h includes.
All files including waylanddyn.h already include waylandvideo.h first.
2021-08-03 14:57:22 -04:00
Ethan Lee
7082fb04af wayland: Only dispatch on fullscreen set when the window is visible.
Fixes hang-on-startup described in #4572.
2021-08-02 22:42:30 -04:00
Ethan Lee
0f5b8a99f0 wayland: For libdecor, dispatch immediately after setting fullscreen
Reference: #4578
2021-08-02 19:48:31 -04:00
Ethan Lee
4562da622c wayland: Make libdecor configure match xdg_toplevel 2021-08-02 18:56:14 -04:00
Ethan Lee
1fb1aa1983 wayland: Keep the fullscreen check for maximize/restore events 2021-08-02 12:57:28 -04:00
Ethan Lee
584673a5a1 wayland: Don't ignore configs for non-fullscreen, non-resizable windows.
This was causing configure events to not inform SDL of window size
changes, even when they were based on resizes that we fully expected. The
result was fullscreen->windowed not working at all, because it would
retain the desktop resolution instead of reverting to the floating size
that it had before moving to fullscreen mode.

Fixes Super Hexagon fullscreen toggling.
2021-08-02 12:54:39 -04:00
Sebastian Krzyszkowiak
2506729893 wayland: Flush in SetWindowFullscreen
The flush has been removed in e5f9fae034df8ca305241c5a666e7702fcf9958f.
Unfortunately, even though ideally the flush shouldn't be necessary,
our resize sequence isn't... well, perfect, and removing that flush causes
tons of troubles.

We're also still flushing in other paths where the window size can be
changed by the compositor and where we may potentially have to obey that
change, like in Wayland_MaximizeWindow.

This also removes the hack introduced in 7f261d3b7667978ced93a4fdc6aec2380df3d87f,
which introduces problems with protocol violations and seems to not be
necessary when flushing.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak
ea28187cd5 wayland: Hack surface resize into compliance with set_window_geometry
We have issues with correct resize sequence and happen to commit old-sized
buffers even after configure event for the new size has been already
acknowledged. While the reason for that stays unknown, let's at least
workaround the problem by faking window geometry into expected size.
This does not fix visual glitch on e.g. fullscreen toggling, but having
a split-second glitch is still a much better outcome than being
terminated by the compositor for protocol violation.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak
b5210cac44 wayland: Initialize floating size at window creation
This allows the windowed size to be restored for windows initially
created already in non-floating state.
2021-08-02 12:11:06 -04:00
Ethan Lee
dab33844e3 wayland: Fix a warning in handle_configure_xdg_toplevel 2021-08-02 12:05:13 -04:00
Ethan Lee
754aa2d321 Mostly revert cfcdfb7be9f5c97a51ddef9ad3677a604856266b.
This was causing window changes to completely break, resulting in broken
decorations and bizarre frame timing, I don't know what exactly it's doing
but it's not good. Kept the libdecor_frame_is_floating logic, at least.
2021-08-02 12:05:10 -04:00
Ethan Lee
8803589fc3 wayland: Avoid redundant SetWindowBordered for libdecor 2021-08-02 12:05:06 -04:00
Sebastian Krzyszkowiak
b4c4060ad2 wayland: Clean up Wayland_HandlePendingResize
Commit 871c11191bfc7214061a3da37c112522a102ddf5 removed delayed
resize handling, but it left the whole structure untouched that
now became unnecessary. To help with code clarity, get rid
of the structure where pending resize state used to be stored
and pass all the data directly to Wayland_HandlePendingResize
(now renamed to Wayland_HandleResize, since it's not "pending"
anymore but applied immediately)
2021-08-01 21:07:51 -07:00
Sebastian Krzyszkowiak
9bb24ad0cf wayland: Always call Wayland_SetWindowBordered when showing the window
Otherwise our windows have no window decoration on compositors that
support xdg-decoration-unstable-v1, but default to client-side mode.

Contrary to what the comment was stating, there is nothing in the protocol
that would make redundant calls to zxdg_toplevel_decoration_v1::set_mode
problematic.
2021-08-01 21:07:14 -07:00
Christian Rauch
cfcdfb7be9 libdecor: use same fullscreen/maximised restore logic as for xdg-toplevel 2021-08-01 15:14:44 -07:00
Christian Rauch
42452f8ca5 wayland: store and restore floating states
Some Wayland compositors send (0,0) as "suggested" configure event sizes to
indicate that the client has to decide on its own which sizes to used. This
is commonly done when restoring from maximised, fullscreen or tiles states
to fullscreen.
We now store the last known floating states in a new set of variables and
restore them when we receive such a (0,0) configure event.
2021-08-01 15:14:44 -07:00
Ethan Lee
71897cc1c9 wayland: Always trigger a resize when handling a configure event.
When we removed the OpenGL resize workaround it introduced a problem for
fullscreen windows in particular: When leaving fullscreen we tried to send a
resize event, but UpdateFullscreenMode would send a SIZE_CHANGED immediately
after, deleting our resize event and causing the following configure event's
resize to be ignored. This timing issue resulted in fullscreen windows not
being resized at all when becoming a floating window.

By always forcing resize events from configure events, we ensure that RESIZED
always makes it through. SetWindowSize-type changes should be unaffected as
they do not fire configure events.
2021-07-30 16:05:06 -04:00
Ethan Lee
c20ab7dae9 wayland: Fix GetWindowWMInfo for <2.0.15 2021-07-30 00:16:52 -07:00
Christian Rauch
f20a85818c commit after setting/unsetting limits 2021-07-29 14:55:03 -07:00
Ethan Lee
ad310d3900 wayland: libdecor support for SetWindowModalFor 2021-07-28 09:45:10 -07:00
Ethan Lee
93976ade3b wayland: libdecor support for GetWindowWMInfo 2021-07-28 09:45:10 -07:00
David Gow
21cba92423 wayland: Don't create zxdg toplevel decoration twice
Each window can have at most one zxdg toplevel decoration, but as of
[1], we accidentally create two. (If libdecor is not in use). This
causes wayland windows with server-side decorations (e.g. on KDE/KWin)
to crash with the message:

zxdg_decoration_manager_v1@7: error 1: decoration has been already constructed

This extra zxdg_decoration_manager_v1.get_toplevel_decoration() call was
introduced while deprecating wl-shell and xdg-shell-stable[1] support,
and possibly was a bad interaction with [2], which moved the decoration
creation around.

Fixes: 6aae5b44f8 ("Remove wl-shell and xdg-shell-unstable-v6 support (#4323)")

[1]: https://github.com/libsdl-org/SDL/pull/4323
[2]: https://github.com/libsdl-org/SDL/pull/4374
2021-07-28 04:12:39 -07:00
Ethan Lee
7b239edb83 wayland: Assign frame_callback on window creation.
Fixes a crash when creating and destroying a window without calling SwapWindow.
2021-07-28 00:48:05 -07:00
Ethan Lee
03185e748b wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use 2021-07-27 16:05:53 -07:00
Ryan C. Gordon
871c11191b wayland: handle pending resizes immediately, not on SwapWindow.
This was originally a workaround for an old Mesa bug, since fixed, apparently,
and causes other problems.

Fixes #4326.
2021-07-27 18:24:09 -04:00
Ethan Lee
a3eb297ec2 wayland: Rework enter/leave and update_scale_factor to avoid bogus wl_output data.
Also remove get_window_scale_factor() which was just pointless indirection.
2021-07-27 14:21:32 -07:00
Simon Zeni
6aae5b44f8
Remove wl-shell and xdg-shell-unstable-v6 support (#4323)
* wayland-protocol: update wayland.xml to 1.19.0

* wayland: remove shell_surface field from SDL_SysWMinfo

* wayland: remove wl_shell support

* waypand-protocols: update xdg-shell.xml to 1.20

* wayland: remove xdg-shell-unstable-v6 support

* wayland: deprecate wl shell surface syswm info, add xdg surface
2021-07-27 14:12:26 -07:00
Christian Rauch
ac904b8e95 wayland: ignore resize in fullscreen or maximised mode 2021-07-25 14:54:12 -07:00
Christian Rauch
ee062c644a wayland: implement toggling decorations 2021-07-25 14:54:12 -07:00
Christian Rauch
2b3cf36fd9 wayland: forward window events 2021-07-25 14:54:12 -07:00
Christian Rauch
48066984b7 wayland: enable/disable ACTION_RESIZE for fullscreen 2021-07-25 14:54:12 -07:00
Christian Rauch
9e6fcbe72c wayland: client-side decoration 2021-07-25 14:54:12 -07:00
Christian Rauch
e5f9fae034 wayland: don't flush after setting fullscreen 2021-07-25 14:54:12 -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
meyraud705
4ada14a267 Replace libc functions to SDL equivalent in wayland video subsystem
Wayland video subsystem uses a mix of libc and SDL function.
This patch switches libc functions to SDL ones and fixes a mismatch in memory
allocation/dealoccation of SDL_Cursor in SDL_waylandmouse.c (calloc on line 201
and SDL_free on line 313) which caused memory corruption if custom memory
allocator where provided to SDL.
2021-07-21 09:28:38 -07:00
Ethan Lee
7f261d3b76 wayland: Fix returning to a window from fullscreen without calling SetWindowSize 2021-06-15 09:00:18 -07:00
Ethan Lee
d956636c85 wayland: Implement FlashWindow 2021-06-04 16:26:03 -07:00
Ethan Lee
2af3f64ecf wayland: Activate the window on first ShowWindow, if possible 2021-06-02 12:59:07 -07:00
Ethan Lee
151f953815 wayland: Implement RaiseWindow with xdg-activation 2021-06-02 12:59:07 -07:00
Ethan Lee
d32440359a wayland: Add support for maximized/restored events 2021-06-01 15:33:45 -07:00
Ethan Lee
f2f451a59d wayland: Call SetWindowBordered at the end of ShowWindow 2021-05-10 11:11:38 -07:00
Ethan Lee
efbb6ff9d7 wayland: Create the server decorations after the toplevel has been configured 2021-05-10 12:49:26 -04:00