[wip] xdg.c: center fullscreen surface if smaller than output

This commit is contained in:
Johan Malm 2025-11-24 21:40:45 +00:00
parent 6521067171
commit 859a4d799d

View file

@ -132,6 +132,24 @@ do_late_positioning(struct view *view)
/* TODO: reorder so this forward declaration isn't needed */ /* TODO: reorder so this forward declaration isn't needed */
static void set_pending_configure_serial(struct view *view, uint32_t serial); static void set_pending_configure_serial(struct view *view, uint32_t serial);
static void
center_fullscreen_view(struct view *view, struct wlr_box *size)
{
int x = 0, y = 0;
if (view_compute_centered_position(view, NULL, size->width, size->height, &x, &y)) {
view_move(view, x, y);
}
}
static bool
surface_is_smaller_than_output(struct view *view, struct wlr_box *size)
{
struct wlr_output *output = view->output->wlr_output;
wlr_log(WLR_ERROR, "output->width=%d, output->height=%d", output->width, output->height);
wlr_log(WLR_ERROR, "size->width=%d, size->height=%d", size->width, size->height);
return size->width < output->width || size->height < output->height;
}
static void static void
handle_commit(struct wl_listener *listener, void *data) handle_commit(struct wl_listener *listener, void *data)
{ {
@ -275,6 +293,16 @@ handle_commit(struct wl_listener *listener, void *data)
toplevel->scheduled.height = view->current.height; toplevel->scheduled.height = view->current.height;
} }
} }
/*
* Centre fullscreen windows if smaller than output, for example Wine
* game SWAT4. See issue #2779
*/
if (view->fullscreen) {
if (surface_is_smaller_than_output(view, &size)) {
center_fullscreen_view(view, &size);
}
}
} }
static int static int