From 520d22c38feabad0234a86ba8c0ab7dcaccf752c Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Fri, 10 Feb 2023 13:08:38 +0100 Subject: [PATCH] src/xdg.c: spawn initially maximized views on cursor output --- src/xdg.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/xdg.c b/src/xdg.c index f4991853..084ab919 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -169,6 +169,29 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { struct view *view = wl_container_of(listener, view, request_maximize); + if (!view->been_mapped) { + /* + * The client asks for the target size for future mapping. + * + * Make sure we are using the position and dimensions of + * the output where the cursor is currently on so the + * maximized view will show up there as well once mapped. + * + * view_maximize() will set view->natural_geometry to + * the fallback geometry as view->pending is unset at + * this point. + * + * So once this function returns we will have set + * - [x] pending (with the maximized size and position) + * - [ ] current (will be set on commit for the follwing map) + * - [x] natural (set to the fallback geometry) + * + * Additionally we will have a configure request pending + * which includes the maximized size on the output the + * cursor is on. + */ + view_move_to_output(view, NULL, /* apply_layout */ false); + } view_maximize(view, xdg_toplevel_from_view(view)->requested.maximized, /*store_natural_geometry*/ true); } @@ -178,8 +201,13 @@ handle_request_fullscreen(struct wl_listener *listener, void *data) { struct view *view = wl_container_of(listener, view, request_fullscreen); struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view); - view_set_fullscreen(view, xdg_toplevel->requested.fullscreen, - xdg_toplevel->requested.fullscreen_output); + struct wlr_output *wlr_output = xdg_toplevel->requested.fullscreen_output; + + if (!view->been_mapped && !wlr_output) { + /* Move view to the output where the cursor is currently on */ + view_move_to_output(view, NULL, /* apply_layout */ false); + } + view_set_fullscreen(view, xdg_toplevel->requested.fullscreen, wlr_output); } static void