diff --git a/src/view-impl-common.c b/src/view-impl-common.c index cf23a798..65b6f1b9 100644 --- a/src/view-impl-common.c +++ b/src/view-impl-common.c @@ -3,6 +3,7 @@ #include "view-impl-common.h" #include "foreign-toplevel/foreign.h" #include "labwc.h" +#include "output.h" #include "view.h" #include "window-rules.h" @@ -74,6 +75,22 @@ resizing_edge(struct view *view, enum lab_edge edge) && (server->resize_edges & edge); } +static void +center_fullscreen_view(struct view *view, int w, int h) +{ + int x = 0, y = 0; + if (view_compute_centered_position(view, NULL, w, h, &x, &y)) { + view_move(view, x, y); + } +} + +static bool +surface_is_smaller_than_output(struct view *view, int w, int h) +{ + struct wlr_output *output = view->output->wlr_output; + return w < output->width || h < output->height; +} + void view_impl_apply_geometry(struct view *view, int w, int h) { @@ -118,4 +135,14 @@ view_impl_apply_geometry(struct view *view, int w, int h) if (!wlr_box_equal(current, &old)) { view_moved(view); } + + /* + * Centre fullscreen windows if smaller than output, for example Wine + * game SWAT4. See issue #2779 + */ + if (view->fullscreen && !view->current.x && !view->current.y) { + if (surface_is_smaller_than_output(view, w, h)) { + center_fullscreen_view(view, w, h); + } + } } diff --git a/src/xdg.c b/src/xdg.c index 809046dd..48179a6d 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -132,24 +132,6 @@ do_late_positioning(struct view *view) /* TODO: reorder so this forward declaration isn't needed */ 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 handle_commit(struct wl_listener *listener, void *data) { @@ -293,16 +275,6 @@ handle_commit(struct wl_listener *listener, void *data) toplevel->scheduled.height = view->current.height; } } - - /* - * Centre fullscreen windows if smaller than output, for example Wine - * game SWAT4. See issue #2779 - */ - if (view->fullscreen && !view->current.x && !view->current.y) { - if (surface_is_smaller_than_output(view, &size)) { - center_fullscreen_view(view, &size); - } - } } static int