diff options
author | Will McKinnon <[email protected]> | 2021-10-17 21:56:25 -0400 |
---|---|---|
committer | Will McKinnon <[email protected]> | 2021-10-17 21:59:49 -0400 |
commit | f6aac41efee81c3edfda14be8ddb375827c81d9e (patch) | |
tree | 8b3ccc06dcb447b1625b1eaec6e7dd9663c5227c | |
parent | 119f31edb4f0c61fd074229040dd93e047ff7cb4 (diff) |
treat scratchpad as minimize
-rw-r--r-- | include/sway/tree/view.h | 1 | ||||
-rw-r--r-- | sway/tree/view.c | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 008361f7..ee34af48 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -102,6 +102,7 @@ struct sway_view { struct wl_listener foreign_fullscreen_request; struct wl_listener foreign_close_request; struct wl_listener foreign_destroy; + struct wl_listener foreign_minimize; bool destroying; diff --git a/sway/tree/view.c b/sway/tree/view.c index b2f70d70..ed8c50f8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -688,6 +688,29 @@ static void handle_foreign_fullscreen_request( transaction_commit_dirty(); } +static void handle_foreign_minimize( + struct wl_listener *listener, void *data) { + struct sway_view *view = wl_container_of( + listener, view, foreign_minimize); + struct wlr_foreign_toplevel_handle_v1_minimized_event *event = data; + struct sway_container *container = view->container; + if (!container->pending.workspace) { + while (container->pending.parent) { + container = container->pending.parent; + } + } + if(event->minimized) { + if (!container->scratchpad) { + root_scratchpad_add_container(container, NULL); + } else if (container->pending.workspace) { + root_scratchpad_hide(container); + } + } else { + if(container->scratchpad) + root_scratchpad_show(container); + } +} + static void handle_foreign_close_request( struct wl_listener *listener, void *data) { struct sway_view *view = wl_container_of( @@ -748,6 +771,10 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, view->foreign_destroy.notify = handle_foreign_destroy; wl_signal_add(&view->foreign_toplevel->events.destroy, &view->foreign_destroy); + view->foreign_minimize.notify = handle_foreign_minimize; + wl_signal_add(&view->foreign_toplevel->events.request_minimize, + &view->foreign_minimize); + // If we're about to launch the view into the floating container, then // launch it as a tiled view in the root of the workspace instead. |