wayland: Rework scale-to-display

This extends the display scaling mode to be global and work in terms of pixels everywhere, with the content scale value set on displays. The per-window property had some issues, and has been removed in favor of retaining only the global hint that changes all coordinates to pixel values, sets the content scale on the displays, and generally makes the Wayland backend behave similarly to Win32 or X11.

Some additional work was needed to fix cases where displays can appear to overlap, since Wayland desktops are always described in logical coordinates, and attempting to adjust the display positions so that they don't overlap can get very ugly in all but the simplest cases, as large gaps between displays can result.
This commit is contained in:
Frank Praznik
2024-05-13 12:59:37 -04:00
parent c7087fea01
commit df3fea87d6
9 changed files with 62 additions and 50 deletions

View File

@@ -3093,6 +3093,7 @@ extern "C" {
/**
* A variable forcing non-DPI-aware Wayland windows to output at 1:1 scaling.
* This must be set before initializing the video subsystem.
*
* When this hint is set, Wayland windows that are not flagged as being
* DPI-aware will be output with scaling designed to force 1:1 pixel mapping.
@@ -3102,12 +3103,12 @@ extern "C" {
* configurations, as this forces the window to behave in a way that Wayland
* desktops were not designed to accommodate:
*
* - Rounding errors can result with odd window sizes and/or desktop scales.
* - The window may be unusably small.
* - The window may jump in size at times.
* - The window may appear to be larger than the desktop size to the
* application.
* - Possible loss of cursor precision.
* - Rounding errors can result with odd window sizes and/or desktop scales,
* which can cause the window contents to appear slightly blurry.
* - The window may be unusably small on scaled desktops.
* - The window may jump in size when moving between displays of different scale factors.
* - Displays may appear to overlap when using a multi-monitor setup with scaling enabled.
* - Possible loss of cursor precision due to the logical size of the window being reduced.
*
* New applications should be designed with proper DPI awareness handling
* instead of enabling this.

View File

@@ -958,18 +958,6 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreatePopupWindow(SDL_Window *parent, in
*
* These are additional supported properties on Wayland:
*
* - `SDL_PROP_WINDOW_CREATE_WAYLAND_SCALE_TO_DISPLAY_BOOLEAN` - true if the
* window should use forced scaling designed to produce 1:1 pixel mapping if
* not flagged as being DPI-aware. This is intended to allow legacy
* applications to be displayed without desktop scaling being applied, and
* has issues with certain display configurations, as this forces the window
* to behave in a way that Wayland desktops were not designed to
* accommodate. Potential issues include, but are not limited to: rounding
* errors can result when odd window sizes/scales are used, the window may
* be unusably small, the window may jump in visible size at times, the
* window may appear to be larger than the desktop space, and possible loss
* of cursor precision can occur. New applications should be designed with
* proper DPI awareness and handling instead of enabling this.
* - `SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN` - true if
* the application wants to use the Wayland surface for a custom role and
* does not want it attached to an XDG toplevel window. See
@@ -1038,7 +1026,6 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_CreateWindowWithProperties(SDL_Propertie
#define SDL_PROP_WINDOW_CREATE_Y_NUMBER "y"
#define SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER "cocoa.window"
#define SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER "cocoa.view"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_SCALE_TO_DISPLAY_BOOLEAN "wayland.scale_to_display"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN "wayland.surface_role_custom"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN "wayland.create_egl_window"
#define SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER "wayland.wl_surface"