From f2d29ceb6b831a07ce2bce4534fe6fec1f16eee3 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sun, 26 Mar 2023 17:44:21 +0200 Subject: 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 --- sway/tree/root.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sway/tree/root.c') diff --git a/sway/tree/root.c b/sway/tree/root.c index 8934721f..636a3b75 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -55,6 +55,17 @@ void root_destroy(struct sway_root *root) { free(root); } +/* Set minimized state from scratchpad container `show` state */ +static void root_scratchpad_set_minimize(struct sway_container *con, bool minimize) { + struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel = con->view->foreign_toplevel; + if (wlr_surface_is_xwayland_surface(con->view->surface)) { + struct wlr_xwayland_surface *xsurface = wlr_xwayland_surface_from_wlr_surface(con->view->surface); + wlr_xwayland_surface_set_minimized(xsurface, minimize); + } else if (foreign_toplevel) { + wlr_foreign_toplevel_handle_v1_set_minimized(foreign_toplevel, minimize); + } +} + void root_scratchpad_add_container(struct sway_container *con, struct sway_workspace *ws) { if (!sway_assert(!con->scratchpad, "Container is already in scratchpad")) { return; @@ -96,6 +107,11 @@ void root_scratchpad_add_container(struct sway_container *con, struct sway_works seat_set_focus(seat, new_focus); } + // Set minimize state to minimized + if (config->scratchpad_minimize) { + root_scratchpad_set_minimize(con, true); + } + ipc_event_window(con, "move"); } @@ -141,6 +157,11 @@ void root_scratchpad_show(struct sway_container *con) { } workspace_add_floating(new_ws, con); + // Set minimize state to normalized + if (config->scratchpad_minimize) { + root_scratchpad_set_minimize(con, false); + } + // Make sure the container's center point overlaps this workspace double center_lx = con->pending.x + con->pending.width / 2; double center_ly = con->pending.y + con->pending.height / 2; @@ -172,6 +193,11 @@ void root_scratchpad_hide(struct sway_container *con) { return; } + // Set minimize state to minimized + if (config->scratchpad_minimize) { + root_scratchpad_set_minimize(con, true); + } + disable_fullscreen(con, NULL); container_for_each_child(con, disable_fullscreen, NULL); container_detach(con); -- cgit v1.2.3