mirror of https://github.com/libsdl-org/SDL.git
wayland: Consolidate window creation logic
The fractional scale manager and viewport are both created for a surface under the same circumstances, so consolidate the logic.
This commit is contained in:
parent
2e96307b27
commit
fbf10afb31
|
|
@ -1228,7 +1228,7 @@ static void Wayland_MaybeUpdateScaleFactor(SDL_WindowData *window)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* If the fractional scale protocol is present or the core protocol supports the
|
/* If the fractional scale protocol is present or the core protocol supports the
|
||||||
* preferred buffer scale event, the compositor will tell explicitly the application
|
* preferred buffer scale event, the compositor will explicitly tell the application
|
||||||
* what scale it wants via these events, so don't try to determine the scale factor
|
* what scale it wants via these events, so don't try to determine the scale factor
|
||||||
* from which displays the surface has entered.
|
* from which displays the surface has entered.
|
||||||
*/
|
*/
|
||||||
|
|
@ -2216,12 +2216,18 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
|
||||||
Wayland_AddWindowDataToExternalList(data);
|
Wayland_AddWindowDataToExternalList(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Always attach a viewport if available and the surface is not custom/external,
|
/* Always attach a viewport and fractional scale manager if available and the surface is not custom/external,
|
||||||
* or the custom/extern surface was explicitly flagged as high pixel density aware,
|
* or the custom/external surface was explicitly flagged as high pixel density aware, which signals that the
|
||||||
* which signals that the application wants SDL to handle DPI scaling.
|
* application wants SDL to handle scaling.
|
||||||
*/
|
*/
|
||||||
if (c->viewporter && (!custom_surface_role || (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY))) {
|
if (!custom_surface_role || (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY)) {
|
||||||
data->viewport = wp_viewporter_get_viewport(c->viewporter, data->surface);
|
if (c->viewporter) {
|
||||||
|
data->viewport = wp_viewporter_get_viewport(c->viewporter, data->surface);
|
||||||
|
}
|
||||||
|
if (c->fractional_scale_manager) {
|
||||||
|
data->fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(c->fractional_scale_manager, data->surface);
|
||||||
|
wp_fractional_scale_v1_add_listener(data->fractional_scale, &fractional_scale_listener, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must be called before EGL configuration to set the drawable backbuffer size. */
|
/* Must be called before EGL configuration to set the drawable backbuffer size. */
|
||||||
|
|
@ -2272,18 +2278,6 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Propert
|
||||||
Wayland_input_lock_pointer(c->input);
|
Wayland_input_lock_pointer(c->input);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't attach a fractional scale manager to custom or external surfaces unless
|
|
||||||
* they are flagged as DPI-aware. Under non-scaled operation, the scale will always
|
|
||||||
* be 1.0, and external/custom surfaces may already have, or will try to attach,
|
|
||||||
* their own fractional scale manager, which will result in a protocol violation.
|
|
||||||
*/
|
|
||||||
if (c->fractional_scale_manager &&
|
|
||||||
((!custom_surface_role && !external_surface) || (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY))) {
|
|
||||||
data->fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(c->fractional_scale_manager, data->surface);
|
|
||||||
wp_fractional_scale_v1_add_listener(data->fractional_scale,
|
|
||||||
&fractional_scale_listener, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We may need to create an idle inhibitor for this new window */
|
/* We may need to create an idle inhibitor for this new window */
|
||||||
Wayland_SuspendScreenSaver(_this);
|
Wayland_SuspendScreenSaver(_this);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue