src/video/wayland


Log

Author Commit Date CI Message
Sylvain 17515f4a 2023-02-04T15:51:37 Backport simplify flags PR #7220
Frank Praznik ea179abd 2023-01-16T13:39:26 wayland: Enforce or override libdecor minimum window size libdecor plugins can change the min/max window size values internally to enforce a minimum window size, and errors and crashes can result if the window size is below the internal limit. On versions of libdecor >= 0.1.1, the minimum width and height can be queried and the minimum required window size will be enforced. The application requested window size is still respected, however, the actual window may be slightly larger than the drawable area to accommodate the required libdecor minimum size. On version 0.1.0 of libdecor, which lacks the function to retrieve the minimum size, the internal limits are overridden before committing a frame, so that the internal limits always match the window size as a workaround, even if the window is technically smaller than the plugin would normally allow. (cherry picked from commit 423a82cd4b65cf72668551093bfdf58d49bce9ce)
Guldoman 7b8f0ba8 2023-01-19T21:12:51 wayland: Set `APPLICATION` scancode name to `Menu` This mimics the behavior of the other platforms. (cherry picked from commit 6c06f5ce93c55fe0f5779d5aeb68bec1bd935455)
Frank Praznik f836b465 2023-01-12T20:44:16 Revert "wayland: Don't try to restore non-resizable windows" This reverts commit e35c3872dc6a8f7741baba8b786b202cef7503ac. (cherry picked from commit 180afcdf3998e5175b744d3f2d87147802809450)
Frank Praznik a47a0451 2023-01-12T16:32:04 wayland: Don't try to restore non-resizable windows Libdecor can crash if attempting to un-maximize a window that was not set as resizable. (cherry picked from commit e35c3872dc6a8f7741baba8b786b202cef7503ac)
Frank Praznik e8ae1555 2023-01-12T15:36:35 wayland: Perform a round trip when maximizing and restoring windows Perform a round trip when maximizing and restoring windows so the changes have already taken effect when the associated functions return. (cherry picked from commit 50f2eb7d41fbba7c82630e55ead4ecf9c32f4c69)
Sam Lantinga 0479df53 2023-01-09T09:48:21 Updated copyright for 2023
Guldoman ad0d1e2a 2023-01-04T18:47:16 wayland: Fallback to default cursor if chosen one wasn't found (cherry picked from commit 5a4283134542d4bdb3d968a836387a750ce80517)
Sylvain 0a9f61fb 2023-01-03T16:35:51 Wayland / Drag and Drop: find the current window
Frank Praznik dfd7efaf 2022-12-05T15:33:01 wayland: Set xdg surface geometry It was previously thought that these function calls were unnecessary as the initial bug and reproduction case that necessitated their addition seemed to be fixed, but apparently there are still cases where this needs to be set explicitly. Set the xdg surface geometry at creation time and when the window size changes. Partially reverts #6361. This is not needed in the libdecor path, as libdecor calls this for the content surface internally. (cherry picked from commit 90a964f132c63b07cf85e5687041d214fdea60f6)
Frank Praznik 8b74be46 2022-12-08T10:56:55 wayland: Handle the Num Lock and Caps Lock modifiers via modifier events Num Lock and Caps Lock always need to be explicitly handled by the modifier handler function, or they won't be correctly set if active at application startup, or if the lock state is changed while the application lacks focus since a key press for these keys will never be received. In these cases, the internal SDL modifier state can end up the inverse of the actual modifier state. (cherry picked from commit 653e484da17d773f40bff94121a23a3b38f47a0a)
Frank Praznik b5483f2c 2022-12-01T18:03:36 Fix formatting on Wayland and Pipewire function signatures Fixes the formatting on some function signatures that clang-format missed. (cherry picked from commit 378b1c286a9c3206e827a47f0147384e92c4c2b2)
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
David Edmundson d7664a6e 2022-07-11T19:28:37 Support wayland fractional scale protocol The new protocol adds support for more native communication of fractional scaling. Everything in the wayland backend already existed only our fractional scale was calculated implicitly through a combination of output size guesswork for fullscreen windows. This new protocol makes that explicit, providing a more robust solution and a solution for non-fullscreen surfaces. The fallback code is still left in place for now whilst compositors gain support.
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Frank Praznik 66bd1555 2022-11-23T23:11:25 wayland: Fix build when not using the shared Wayland libraries Explicitly include the Wayland protocol headers when statically linking against the Wayland libraries or older system headers might be used instead of the local versions. (cherry picked from commit 836eb224428aca3bdab2a6bf56d347262e475b15)
Frank Praznik 3eaf5689 2022-11-23T18:11:50 wayland: Fix libdecor_dispatch signature The function returns an int, not a bool. (cherry picked from commit f47169fcba8a27bb0740b6b4993989ff9262c21f)
Frank Praznik fe396e30 2022-11-19T11:28:31 wayland: Use the cached window size when switching from non-floating to floating window state When changing the window state from non-floating to floating (e.g. leaving fullscreen), libdecor can send bogus content sizes that are +/- the height of the window title bar and start 'walking' the window height in one direction or the other with every transition. The floating window size is known, so use the cached value instead of the size reported by libdecor when restoring the floating state.
David Gow 81479d87 2022-11-18T21:08:36 wayland: keyboard: Cache text input parameters. Some applications (and embarrassingly, testime is one of them) call SDL_StartTextInput() or SDL_SetTextInputRect() every frame. On KDE/KWin with fcitx5, this causes there to be several preedit events every frame (particularly given some of the workarounds in Wayland_StartTextInput), which slows testime down to an unusable crawl. Instead, make SDL_StartTextInput() a no-op if text input is already enabled, and cache the input rect, only changing it when the new rect is actually different. With these changes, we only get preedit events (and hence SDL_TEXTEDITING events) when the preedit string actually changes. This matches the behaviour under XWayland, and works very smoothly.
Frank Praznik 903301c6 2022-11-16T02:04:59 wayland: Always use integer scaling for cursors. Cursors don't get fractionally scaled, so always scale system cursor sizes to the next whole integer.
Frank Praznik c8551847 2022-11-04T12:41:46 wayland: Handle virtual keyboards that don't fit the X mapping SDL is built around the concept of keyboards having a fixed layout with scancodes that correspond to physical keys no matter what linguistic layout is used. Virtual keyboards don't have this concept and can present an arbitrary layout of keys with arbitrary scancodes and names, which don't fit the SDL model. When one of these keyboards is encountered, it requires special handling: use the keysym of the pressed keys to derive their ANSI keyboard scancode equivalents for control keys and ASCII characters. All other characters are passed through as text events only.
Frank Praznik eef4d3c8 2022-11-13T16:56:04 wayland: Clamp wl_seat version on older versions of libwayland Clamp the wl_seat max version to 5 if being built against a version of libwayland below 1.21.0, or containers that bundle newer versions of SDL with older versions of libwayland can break if the compositor advertises support for a protocol version above 5.
Hubert Maier 5dc93451 2022-11-06T20:49:37 JANITORIAL : Correct some more spelling mistakes (#6489)
David Edmundson 689218eb 2022-11-04T12:07:20 Fix wayland reconnection paths Most of this code is disabled out for now. - For mouse cursors we have a wl_surface for both system and custom cursors which needs recreating. - The other patch is about nullification after deletions
Guldoman 70a41f9b 2022-11-01T09:59:16 wayland: Read `window` data only if `window` is valid
Frank Praznik 33a43005 2022-10-31T12:23:51 wayland: Don't modify the mouse capture flag in relative mode If relative mouse mode is explicitly enabled, don't modify the capture flag on button events or the window might report having lost mouse focus if a button is pressed while moving the cursor.
Ethan Lee 571ff1a3 2022-10-30T00:19:09 wayland: Prepare cursor implementation for reconnect support Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>
Ethan Lee 9c8b1fd8 2022-10-29T22:34:05 wayland: Cleanup work to aid reconnect support Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>
Frank Praznik 4223e6ac 2022-10-26T13:14:50 wayland: Early-out sooner when requesting fullscreen on a popup Exit the fullscreen sequence sooner if it is requested that a popup window be fullscreen. The surface commit formerly in this path is irrelevant and can be removed as previous changes made it so that SetFullscreen() is no longer called from anywhere except Wayland_SetWindowFullscreen().
Frank Praznik 30c2dac7 2022-10-25T20:00:38 wayland: Remove duplicate #include statement
David Jacewicz 7c7cd2a6 2022-10-17T14:04:29 Fix issue #6037 (incorrect modifier flags on Wayland)
Frank Praznik ed412c13 2022-10-15T14:05:35 wayland: Cleanup event source comments, headers, and error reporting Replace instances of fprintf(stderr, ...) with SDL_SetError(), replace C++ comments with C style, use a uniform format for multi-line comments, and remove unused headers as poll and select aren't used in this file (the SDL function which calls them is used instead).
Frank Praznik 62047686 2022-10-13T16:24:13 wayland: Don't block on libdecor_dispatch() libdecor_dispatch() needs to be called, as libdecor plugins might do some required internal processing within, however care must be taken to avoid double-blocking in the case of a timeout, which can occur if libdecor_dispatch() and the SDL event processing both work on the main Wayland queue. Additionally, assumptions that libdecor will always dispatch the main queue or not process zero-length queues (can occur if a wait is interrupted by the application queueing an event) should not be made, as this behavior is outside the control of SDL and can change. SDL handles polling for Wayland events and then calls libdecor to do its internal processing and dispatch. If libdecor operates on the main queue, it will dispatch the queued events and the additional wl_display_dispatch_pending() call will be a NOP. If a libdecor plugin uses its own, separate queue, then the wl_display_dispatch_pending() call will ensure that the main queue is always dispatched.
Frank Praznik e89389ba 2022-10-14T20:41:10 wayland: Use MAP_PRIVATE when mapping the keyboard keymap file descriptor Per the Wayland spec, this must be mapped with MAP_PRIVATE in version 7 of the protocol and higher.
Sam Lantinga 99f2a503 2022-10-13T22:40:24 X11 scancode mapping cleanup * Consolidated scancode mapping tables into a single location for all backends * Verified that the xfree86_scancode_table2 is largely identical to the Linux scancode table * Updated the Linux scancode table with the latest kernel keycodes (still unmapped) * Route X11 keysym -> scancode mapping through the linux scancode table (which a few hand-written exceptions), which will allow mappings to automatically get picked up as they are added in the Linux scancode table * Disabled verbose reporting of missing keysym mappings, we have enough data for now
Ethan Lee be2cb000 2022-10-11T11:16:52 wayland: Check for the input handle before checking the keyboard handle
Frank Praznik 0b88e609 2022-10-11T07:40:35 wayland: Raise wl_seat maximum version to 8 Version 8 is required for supporting axis_value120 high-resolution scroll events.
Frank Praznik 6391ad97 2022-10-09T11:11:55 wayland: Factor out common libdecor frame commit code The pattern of: libdecor_state_new() libdecor_frame_commit() libdecor_state_free() was used in several places. Factor it out into a common function.
Frank Praznik b0a9396b 2022-10-09T11:06:20 wayland: Remove XDG surface geometry calls These were needed to fix some buggy behavior regarding committing old buffer sizes when entering fullscreen that has since been corrected. Remove them.
Guldoman b91ddbc3 2022-10-09T06:15:18 wayland: null-terminate drop data
Frank Praznik 914a65e0 2022-10-06T12:39:36 wayland: Don't unset min/max values when entering fullscreen via a compositor event If the compositor is entering fullscreen and hasn't removed any constraints itself, it's already too late at this point. Remove the unnecessary call. Restoring the limits when exiting fullscreen is still required, though, as they may have been removed when entering fullscreen via an SDL request.
Frank Praznik 69cf5fb0 2022-10-04T13:09:35 wayland: Remove surface type helpers These were remnants of a time before the surface type was explicitly stored, so they can be removed per the TODO note.
Frank Praznik c2b0c41c 2022-10-04T12:59:26 wayland: Set/unset the opaque regions on surfaces when transparency is toggled Caches the SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY hint at init time and registers a callback, which is fired when the hint is changed during runtime and toggles the opaque region for existing surfaces.
Frank Praznik ea595800 2022-10-03T18:31:15 wayland: Set the damage buffer size when supported The preferred method for setting the damage region on compositor protocol versions 4 and above is to use wl_surface.damage_buffer. Use this when available and only fall back to wl_surface.damage on older versions. Bumps the highest supported version of wl_compositor to version 4.
Frank Praznik a8cb7bbe 2022-10-01T11:31:26 wayland: Add dedupe logic to window geometry configuration Adds deduplication logic to ConfigureWindowGeometry() to avoid setting redundant backbuffer, viewport and surface opaque region dimensions. State is now only set when the window and/or backbuffer dimensions change. This repurposes the viewport rect to always hold the actual size of the window, which can differ from the SDL size if things are being scaled. The SDL_Rect was removed in favor of two ints, as the x/y members of the struct were never used, so they just wasted space. Since the internal variables always have the true window size, the width/height getter functions are no longer required and can be removed.
David Gow ad29875e 2022-04-18T17:03:05 Wayland: Emulate mouse warp using relative mouse mode Several games (including Source and GoldSrc games, and Bioshock Infinite) attempt to "fake" relative mouse mode by repeatedly warping the cursor to the centre of the screen. Since mouse warping is not supported under Wayland, the viewport ends up "stuck" in a rectangular area. Detect this case (mouse warp while the cursor is not visible), and enable relative mouse mode, which tracks the cursor position independently, and so can Warp successfully. This is behind the SDL_HINT_VIDEO_WAYLAND_EMULATE_MOUSE_WARP hint, which is enabled by default, unless the application enables relative mouse mode itself using SDL_SetRelativeMouseMode(SDL_TRUE). Note that there is a behavoural difference, in that relative mouse mode typically doesn't take mouse accelleration into account, but the repeated-warping technique does, so mouse movement can seem very slow with this (unless the game has its own mouse accelleration option, such as in Portal 2).
Frank Praznik e17f0c28 2022-09-27T10:59:28 wayland: Call the Wayland hide/show functions directly when changing decoration modes Calling SDL_HideWindow() to destroy the window is a NOP if the SDL_WINDOW_SHOWN flag was never set. Bypass it and call the Wayland-specific function directly to ensure that the window is always destroyed before switching from server-side to client-side decorations, even if it hasn't been shown yet. Likewise, call Wayland_ShowWindow() directly when the window isn't explicitly hidden to ensure that it is always recreated since the SDL_WINDOW_SHOWN flag won't be cleared, which, when set, renders SDL_ShowWindow() a NOP.
Frank Praznik 4a06cc0f 2022-09-22T13:03:09 wayland: Apply modifier changes to the text of repeated keys The text component of a repeated keystroke is initially set when a key is first pressed and the cached value remains static until the repeated key is released and another repeatable key is pressed. If the state of a modifier such as shift or capslock is changed while a key is being repeated, the text emitted will not have the modifier applied to it until the repeated key is released and pressed again. Update the text to be repeated by a key if a modifier is changed while a key is actively being repeated.
Frank Praznik 467c82c7 2022-09-23T12:31:40 wayland: Add mappings for the Escape and NumLock keys The XKB keysym to SDL keycode mappings were missing for the Escape and NumLock keys, which prevented them from being remapped. Add them to the table so that the remapping of these keys will work.
Frank Praznik 399cb2f0 2022-09-21T13:20:39 wayland: Only clear the key repeat flag when the repeated key is released If multiple keys were simultaneously depressed and one was being repeated, the repeat flag was being cleared when any of the pressed keys were released, even if the released key wasn't the one being repeated. This tracks the key currently being repeated and only clears the repeat flag when the particular key being repeated is released.
DS ac5b9bc4 2022-09-14T18:28:35 Add support for X11 primary selection (#6132) X11 has a so-called primary selection, which you can use by marking text and middle-clicking elsewhere to copy the marked text. There are 3 new API functions in `SDL_clipboard.h`, which work exactly like their clipboard equivalents. ## Test Instructions * Run the tests (just a copy of the clipboard tests): `$ ./test/testautomation --filter Clipboard` * Build and run this small application: <details> ```C #include <SDL.h> #include <unistd.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> void print_error(const char *where) { const char *errstr = SDL_GetError(); if (errstr == NULL || errstr[0] == '\0') return; fprintf(stderr, "SDL Error after '%s': %s\n", where, errstr); SDL_ClearError(); } int main() { char text_buf[256]; srand(time(NULL)); SDL_Init(SDL_INIT_VIDEO); print_error("SDL_INIT()"); SDL_Window *window = SDL_CreateWindow("Primary Selection Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 400, 400, SDL_WINDOW_SHOWN); print_error("SDL_CreateWindow()"); SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); print_error("SDL_CreateRenderer()"); bool quit = false; unsigned int do_render = 0; while (!quit) { SDL_Event event; while (SDL_PollEvent(&event)) { print_error("SDL_PollEvent()"); switch (event.type) { case SDL_QUIT: { quit = true; break; } case SDL_KEYDOWN: { switch (event.key.keysym.sym) { case SDLK_ESCAPE: case SDLK_q: quit = true; break; case SDLK_c: snprintf(text_buf, sizeof(text_buf), "foo%d", rand()); SDL_SetClipboardText(text_buf); print_error("SDL_SetClipboardText()"); printf("clipboard: set_to=\"%s\"\n", text_buf); break; case SDLK_v: { printf("clipboard: has=%d, ", SDL_HasClipboardText()); print_error("SDL_HasClipboardText()"); char *text = SDL_GetClipboardText(); print_error("SDL_GetClipboardText()"); printf("text=\"%s\"\n", text); SDL_free(text); break; } case SDLK_d: snprintf(text_buf, sizeof(text_buf), "bar%d", rand()); SDL_SetPrimarySelectionText(text_buf); print_error("SDL_SetPrimarySelectionText()"); printf("primselec: set_to=\"%s\"\n", text_buf); break; case SDLK_f: { printf("primselec: has=%d, ", SDL_HasPrimarySelectionText()); print_error("SDL_HasPrimarySelectionText()"); char *text = SDL_GetPrimarySelectionText(); print_error("SDL_GetPrimarySelectionText()"); printf("text=\"%s\"\n", text); SDL_free(text); break; } default: break; } break; } default: { break; }} } // create less noise with WAYLAND_DEBUG=1 if (do_render == 0) { SDL_RenderPresent(renderer); print_error("SDL_RenderPresent()"); } do_render += 1; usleep(12000); } SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); print_error("quit"); return 0; } ``` </details> * Use c,v,d,f to get and set the clipboard and primary selection. * Mark text and middle-click also in other applications. * For wayland under x: * `$ mutter --wayland --no-x11 --nested` * `$ XDG_SESSION_TYPE=wayland SDL_VIDEODRIVER=wayland ./<path_to_test_appl_binary>`
Frank Praznik 929d5b80 2022-09-12T22:39:44 wayland: Use the backbuffer size for determining if a resize event is required In some cases, a backbuffer size update may not be accompanied by a resize event if the window size and/or scale were updated before the new backbuffer size was recomputed. Instead of the scale, use the old/new backbuffer sizes to determine if a resize event is required so that a backbuffer size change will always be followed by a resize event.
Frank Praznik edfb00c2 2022-09-09T14:26:44 wayland: Only commit on move if the display was changed Only commit on a move event if the display was changed for a fullscreen window and the compositor has returned bad dimensions.
Frank Praznik 97a5e744 2022-09-06T17:08:27 wayland: Remove duplicate code Wayland_SetWindowSize() can be simplified with the common CommitWindowGeometry() function.
Frank Praznik 78f843f7 2022-09-06T13:19:23 wayland: Remove unnecessary function parameter SetFullscreen() is never called in a case where the commit parameter is false anymore, so the parameter is unnecessary.
Frank Praznik 768b6728 2022-09-04T23:39:05 wayland: Compare against the old scale when resizing Compare against the old scale instead of the new or the conditional will always be true.
Frank Praznik 07aea476 2022-09-03T13:30:49 wayland: Ignore content sizes from libdecor when hiding a window When hiding a window, libdecor can report bogus content region sizes that are +/- the height of the title bar. Ignore any size values from libdecor when hiding a window, or the size may be incorrect when restored.
Frank Praznik 6de12b4a 2022-09-06T13:30:19 wayland: Update the internal state when the compositor moves a fullscreen window The compositor can arbitrarily move windows between displays, including fullscreen windows. Update the internal state when a fullscreen window is moved so the internal SDL state accurately reflects the window location, and resize the window to fit the new display. This also fixes an edge case where the compositor can make a window fullscreen on a different display than SDL thinks it will be on (usually when a window is made fullscreen by the compositor while straddling multiple displays), which can result in the window being incorrectly sized.
Frank Praznik a7d34595 2022-09-03T13:11:29 wayland: Trigger a commit on fullscreen update If additional fullscreen requests are received when the window is already fullscreen, it is typically due to the fullscreen flags or emulated video mode being changed. A commit must be explicitly triggered or the requested changes won't take effect until some other event, such as a resize or focus change, causes the changes to be committed.
Frank Praznik 707b561f 2022-09-03T12:37:02 wayland: Enable compositor fullscreen toggling The compositor can toggle the fullscreen state (via a hotkey or otherwise), so the internal SDL state must be updated accordingly when it does. When toggling fullscreen via the compositor, SDL will attempt to use the last fullscreen flag explicitly set. If no flag was previously set, SDL_WINDOW_FULLSCREEN will be used if a window video mode was set, otherwise SDL_WINDOW_FULLSCREEN_DESKTOP will be used. If the previous flag was SDL_WINDOW_FULLSCREEN and the window video mode was cleared, it will revert to SDL_WINDOW_FULLSCREEN_DESKTOP.
Frank Praznik 31979e2d 2022-09-02T18:41:21 wayland: Add missing static qualifiers
Taiko2k 1c88a052 2022-09-09T16:03:17 Update Wayland cursors to match X11 cursors
Anonymous Maarten ce227aa6 2022-08-26T01:57:09 wayland: fix build with SDL_WAYLAND_SHARED=OFF/--enable-wayland-shared=no
Noel Berry 00452e47 2022-08-24T11:25:13 Adding SDL_GetWindowSizeInPixels for window size in pixels (#6112)
Sam Lantinga d166f5ef 2022-08-22T14:10:54 Fixed uninitialized variable warning
Frank Praznik d731ad76 2022-07-15T10:44:38 wayland: Fix include order when building with libdecor The libdecor header internally includes wayland-client.h, which pulls in the wayland-client-protocol.h file from the system include path and overrides the local one generated from the included Wayland protocol spec files. Move the Wayland protocol header inclusion above the libdecor header inclusion to ensure that the locally generated protocol header is used instead.
Frank Praznik 057086e3 2022-07-15T13:44:49 wayland: Add high resolution scroll wheel support Update the Wayland core protocol spec file and add support for the new axis_value120 event to handle high resolution scroll wheels. The axis_value120 replaces the axis_discrete event, which is no longer sent as of version 8 of the protocol. Note that unlike the axis_discrete event, no mention in the spec is made regarding how many axis_value120 events may occur per-axis per-frame, so the values are accumulated and committed when the pointer frame event occurs.
Sam Lantinga 6e007c36 2022-08-18T19:05:55 Add null termination to Wayland_data_source_get_data() if requested Fixes https://github.com/libsdl-org/SDL/issues/6083
Sam Lantinga 948dbe7d 2022-08-18T16:24:20 Don't include the null terminator in Wayland clipboard text Fixes https://github.com/libsdl-org/SDL/issues/6083
Frank Praznik 3bae2d57 2022-08-18T12:39:47 wayland: Set the libdecor app ID after visibility calls Set the frame app ID after toggling visibility or the name displayed in window manager task switchers may not display correctly.
Frank Praznik 7da74eb5 2022-08-17T14:59:23 wayland: Never commit with an undefined window title If libdecor performs a commit with the frame title being undefined, a crash can occur within the library or its plugins. Always ensure that the title is set to a valid string to avoid this.
Frank Praznik 650612fd 2022-08-13T16:54:27 wayland: Eliminate excessive calls to SetFullscreen Eliminate excessive calls to SetFullscreen by removing the calls in the libdecor and xdg-toplevel config callbacks. These calls were being made there in case something explicitly called the window minimization function from within SDL, which unsets fullscreen, and as minimizing a window in Wayland is just a suggestion to the compositor and doesn't actually change the window state or communicate anything back to the application, it was necessary to call SetFullscreen in every call to the config functions just in case something minimized a window via SDL_MinimizeWindow() and later needed to restore it. GNOME in particular had issues when fullscreen set/unset operations were being hammered, leading to overlapping acks and commits when switching to fullscreen. With the new video system flag to disable unsetting fullscreen when minimizing a window, these calls in the configuration functions are no longer needed and can be removed. This significantly reduces calls to the SetFullscreen() function, reverts #6044 while fixing the issue, and fixes a similar problem when hiding and showing a window initially created with fullscreen flags.
Frank Praznik cc9cc202 2022-08-13T16:43:15 video: Add video device quirk flags and apply them to the video subsystem Add quirk flags to the video device struct and add flags to allow video backend drivers to disable mode switching and disable unsetting the fullscreen mode when minimizing a window. As certain platforms can have multiple video backends compiled in at once, #ifdefs, as used by other platforms, aren't suitable as different backends on the same platform may not need the same quirks. This replaces the formerly dedicated 'disable_display_mode_switching' boolean as additional quirks are needed by the Wayland backend. Helper functions have also been added to simplify reading the flag states.
Frank Praznik 74bdb211 2022-08-12T22:01:12 wayland: Don't roundtrip in ShowWindow unless restoring a hidden window Don't call the roundtrip in ShowWindow unless restoring a previously hidden window. This fixes a regression in GNOME when creating a window with the fullscreen flag set, as the fullscreen window will be positioned down the screen by the height of the top bar if the window is made fullscreen on the primary display and the roundtrip is called when initially displaying the window.
Cameron Gutman 1b08cd20 2022-08-12T18:55:05 wayland: Add roundtrip in SetWindowFullscreen() to get new size The video core assumes that window->w/h will be updated before returning from SetWindowFullscreen(). This is needed to generate a resize event with the correct window size when exiting fullscreen. The roundtrip allows us to receive the configure callback that informs us of the new window size before returning. Fixes #6043
Cameron Gutman 780b031b 2022-08-12T16:39:39 wayland: Avoid duplicate resize events when entering fullscreen
Guldoman 5f682e77 2022-08-10T20:01:15 wayland: Remove freed display from `SDL_WaylandOutputData->output_list`
Frank Praznik dd2e3182 2022-08-06T12:31:06 wayland: Use libdecor visibility toggle for hiding/showing the window The current method of toggling the libdecor window visibility by destroying and recreating the frame results in a race where a use-after-free bug can manifest itself within libdecor when window visibility is toggled quickly. Instead, use the libdecor function for toggling visibility instead of destroying and recreating the frame every time.
Ryan C. Gordon f600364b 2022-08-06T09:19:52 wayland: Mark window as MOUSE_CAPTURE while a mouse button is down. Wayland works like SDL's "auto capture" feature already, tracking the mouse globally only while a drag is occuring, and this is the only way to get mouse input outside the window. Setting this flag ourselves lets SDL_CaptureMouse() work in the most common use case without actually implementing CaptureMouse for the backend, including SDL's auto capture feature. Fixes #6010.
Ryan C. Gordon a6179e85 2022-08-05T21:23:39 wayland: Don't double-free clipboard sources if ours gets cancelled. Fixes #6007.
Frank Praznik 3685c64e 2022-08-05T16:16:31 wayland: Round trip after window show/hide operations. Perform a round trip after showing/hiding the window to avoid protocol errors when ShowWindow() is called immediately after HideWindow().
Frank Praznik 0b9868b0 2022-08-02T12:56:56 wayland: Use D-Bus to retrieve the cursor size and theme on GNOME GNOME exposes the cursor size and theme via the org.freedesktop.portal.Settings interface of the xdg-desktop portal, so query these values via D-Bus, if available. The XCURSOR_SIZE/XCURSOR_THEME envvars will be tried first, so as not to override any user specified sizes or themes, then D-Bus, then, failing that, it will fall back to default values.
Cameron Gutman 8b438f7b 2022-07-31T15:34:03 keyboard: Only send SDL_KEYMAPCHANGED when the keymap actually changes
Sam Lantinga 21100006 2022-07-30T16:22:24 Don't conflict with usage of stdout as a stdio macro Patch inspired by http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/pkgsrc/devel/SDL2/patches/patch-src_video_wayland_SDL__waylandmessagebox.c?rev=1.1&content-type=text/plain
Ryan C. Gordon 20a76b0e 2022-07-25T23:06:58 video: removed unused devindex argument from bootstrap's create method.
Sebastian Krzyszkowiak 041666e6 2022-07-24T05:45:59 video: wayland: Don't switch to libdecor path for borderless windows We actually request CSD mode with xdg-decoration for borderless windows, so we get what we wanted there and there's no point in going into fallback paths.
Sebastian Krzyszkowiak 405d1f65 2022-07-24T10:16:20 video: wayland: Roundtrip after falling back to libdecor in xdg-decoration handler Otherwise libdecor doesn't have a chance to acquire xdg-toplevel after libdecor_new before we attempt to use it in Wayland_ShowWindow. Fixes #5952
David Gow 78bad667 2022-07-16T22:12:08 video: wayland: Resize the window before sending the SDL_RESIZE event Currently, the SDL_WINDOWEVENT_RESIZED event is sent before the actual window is resized (and various internal state, such as the desired GL/Vulkan backbuffer size, are updated). This makes sense, as SDL will discard a no-op resize, which would be the case if we had resized before sending the event (indeed, there are existing hacks to prevent this). However, this means that SDL_{GL,Vulkan}_GetDrawableSize() will still use the old size in the SDL_WINDOWEVENT_RESIZED handler. In the case of SDL_Renderer, this means the drawable size it uses will be wrong, and the viewport will get "updated" to the old value. This then results in bug #5899.
rohlem b085c182 2022-07-04T16:38:05 make SDL_SetTextInputRect take a pointer to const The documentation doesn't state that the argument is ever modified, and no implementation does so currently. This is a non-breaking change to guarantee as much to callers.
Cameron Cawley 78089e65 2022-07-01T13:08:31 Remove unused internal header SDL_sysevents.h
Frank Praznik c11bdeeb 2022-06-21T13:28:14 wayland: Round fractional backbuffer sizes halfway away from zero Use SDL_lroundf() to round fractional backbuffer sizes halfway away from zero, as this is the rounding method recommended by the forthcoming Wayland fractional scaling protocol.
Sam Lantinga 5f6d0abe 2022-06-18T12:57:27 SDL_SendEditingText() has int parameters, so use that type for parameter calculation We might want to use ssize_t as @Guldoman suggested, but that's a larger internal API change, and still requires casting of the SDL_utf8strnlen() result. Fixes https://github.com/libsdl-org/SDL/pull/5821
Sam Lantinga adc68758 2022-06-17T10:22:28 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!) Closes https://github.com/libsdl-org/SDL/pull/5811
takase1121 f8ae3ef1 2022-06-15T22:01:59 wayland: use libdecor resize edge enums for libdecor
Frank Praznik e427e80b 2022-06-14T10:41:18 wayland: Use the output descriptions from xdg-output when available Some compositors will provide 'nicer' / 'human readable' output descriptions via the xdg-output protocol. Use these description strings, when available, instead of the model name provided by wl-output. On compositors such as GNOME where this is provided, the display names provided to applications by SDL will now match those in the desktop display settings panel. On compositors where this data isn't provided, the old behavior of using the model string provided by wl-output will remain unchanged. Additionally, per the protocol spec, output data provided by xdg-output should supersede wl-output data, so this is the recommended behavior in general.
Frank Praznik 4a3277b0 2022-05-19T15:13:02 wayland: Always commit window constraints before entering fullscreen XDG-toplevel min/max size values are double-buffered data and must be committed before entering the fullscreen state, or a max window size value smaller than the display dimensions may cause the compositor to incorrectly configure the fullscreen window size. This fixes windowed->fullscreen transitions on GNOME, where, previously, certain combinations of window flags and min/max size values could cause entering fullscreen mode to fail with odd window sizes and/or offsets due to the new max size values not being committed before entering fullscreen, causing the compositor to clamp to the old values. In the case of libdecor, it has its own layer of buffering on top of the xdg-toplevel surface for the min/max window dimensions, so both a frame commit and surface commit are required to set the state properly.
Frank Praznik 78698a0b 2022-05-17T12:37:16 wayland: Use a separate frame callback for setting the surface damage region Previously, the surface damage region was being set in the same callback used for preventing render hangs in the GL backend when the surface was not visible. This was not ideal, as the callback was never fired in the case of using a different render backend or having a swap interval of 0. Use a separate frame callback for setting the surface damage region to ensure that it fires reliably, regardless of the backend being used or swap interval.
Frank Praznik 146ea9b0 2022-05-16T18:18:55 wayland: Only set the surface opaque region if EGL transparency is disabled Check if the "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY" hint is enabled and don't mark surfaces as opqaue if it is.
Frank Praznik a20516d4 2022-05-16T10:35:56 wayland: Swap emulated mode dimensions in more cases Some compositors (GNOME for example) don't set the transform flag when dealing with portrait mode displays, so the video modes won't have the width/height swapped in all cases where they should be. Check for both the 90/270 degree transform flag and if the display is taller than it is wide when determining whether to swap the width and height of the emulated video modes, and adjust the comparison logic when size testing against the native mode to account for this.