diff options
author | Erik Reider <[email protected]> | 2023-03-26 17:44:21 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-03-26 11:44:21 -0400 |
commit | f2d29ceb6b831a07ce2bce4534fe6fec1f16eee3 (patch) | |
tree | d90b5fd546d6f55c7be7d0af43863f8f9262b4db /sway/desktop/xdg_shell.c | |
parent | 7d5d7a3022eb17835cea7af7290b1a5d2fe4b03a (diff) |
Extend minimize logic to work with XWayland and XDG applications (#132)
* Extend minimize logic
* Removed redundant xwayland minimize logic
* minor fixes
* Fixed not properly checking if window is ran though XWayland
* Added config option with default being off
* Set scratchpad_minimize to true by default
* Improve config dependant logic
* Switch to using enable|disable instead of on|off
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r-- | sway/desktop/xdg_shell.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 8da922d5..2d79727d 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -332,6 +332,24 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { wlr_xdg_surface_schedule_configure(toplevel->base); } +/* Minimize to scratchpad */ +static void handle_request_minimize(struct wl_listener *listener, void *data) { + struct sway_xdg_shell_view *xdg_shell_view = + wl_container_of(listener, xdg_shell_view, request_minimize); + struct sway_container *container = xdg_shell_view->view.container; + if (!container->pending.workspace) { + while (container->pending.parent) { + container = container->pending.parent; + } + } + if (!container->scratchpad) { + root_scratchpad_add_container(container, NULL); + } else if (container->pending.workspace) { + root_scratchpad_hide(container); + } + transaction_commit_dirty(); +} + static void handle_request_fullscreen(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, request_fullscreen); @@ -406,6 +424,9 @@ static void handle_unmap(struct wl_listener *listener, void *data) { wl_list_remove(&xdg_shell_view->commit.link); wl_list_remove(&xdg_shell_view->new_popup.link); wl_list_remove(&xdg_shell_view->request_maximize.link); + if (xdg_shell_view->request_minimize.notify) { + wl_list_remove(&xdg_shell_view->request_minimize.link); + } wl_list_remove(&xdg_shell_view->request_fullscreen.link); wl_list_remove(&xdg_shell_view->request_move.link); wl_list_remove(&xdg_shell_view->request_resize.link); @@ -458,6 +479,12 @@ static void handle_map(struct wl_listener *listener, void *data) { wl_signal_add(&toplevel->events.request_maximize, &xdg_shell_view->request_maximize); + if (config->scratchpad_minimize) { + xdg_shell_view->request_minimize.notify = handle_request_minimize; + wl_signal_add(&toplevel->events.request_minimize, + &xdg_shell_view->request_minimize); + } + xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen; wl_signal_add(&toplevel->events.request_fullscreen, &xdg_shell_view->request_fullscreen); |