Skip to content

Commit c6a5ba0

Browse files
authored
Wayland: Fix fullscreen window offset/incorrect sizing (#18717)
Co-authored-by: PoloniumRain <[email protected]>
1 parent f97a19a commit c6a5ba0

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

gfx/drivers_context/wayland_ctx.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
403403
EGLint *attr = egl_fill_attribs(
404404
(gfx_ctx_wayland_data_t*)data, egl_attribs);
405405

406+
/* Set buffer scale before creating wl_egl_window.
407+
* Fixes incorrect size/offset on HiDPI/fullscreen. */
408+
if (!wl->fractional_scale &&
409+
wl_compositor_get_version(wl->compositor) >=
410+
WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
411+
wl_surface_set_buffer_scale(wl->surface, wl->buffer_scale);
412+
406413
wl->win = wl_egl_window_create(wl->surface,
407414
wl->buffer_width,
408415
wl->buffer_height);
@@ -419,6 +426,11 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
419426
egl_set_swap_interval(&wl->egl, wl->egl.interval);
420427
#endif
421428

429+
/* Fullscreen is compositor-sized on Wayland.
430+
* Do not ignore configure events in fullscreen. */
431+
if (fullscreen)
432+
wl->ignore_configuration = false;
433+
422434
if (!gfx_ctx_wl_set_video_mode_common_fullscreen(wl, fullscreen))
423435
goto error;
424436

gfx/drivers_context/wayland_vk_ctx.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,25 @@ static bool gfx_ctx_wl_set_video_mode(void *data,
191191
if (!gfx_ctx_wl_set_video_mode_common_size(wl, width, height, fullscreen))
192192
goto error;
193193

194+
/* Set buffer scale before creating the Vulkan WSI surface.
195+
* Fixes incorrect size/offset on HiDPI/fullscreen. */
196+
if (!wl->fractional_scale &&
197+
wl_compositor_get_version(wl->compositor) >=
198+
WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION)
199+
wl_surface_set_buffer_scale(wl->surface, wl->buffer_scale);
200+
194201
if (!vulkan_surface_create(&wl->vk, VULKAN_WSI_WAYLAND,
195202
wl->input.dpy, wl->surface,
196203
wl->buffer_width,
197204
wl->buffer_height,
198205
wl->swap_interval))
199206
goto error;
200207

208+
/* Fullscreen is compositor-sized on Wayland.
209+
* Do not ignore configure events in fullscreen. */
210+
if (fullscreen)
211+
wl->ignore_configuration = false;
212+
201213
if (!gfx_ctx_wl_set_video_mode_common_fullscreen(wl, fullscreen))
202214
goto error;
203215

0 commit comments

Comments
 (0)