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/tree | |
| 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/tree')
| -rw-r--r-- | sway/tree/root.c | 26 | ||||
| -rw-r--r-- | sway/tree/view.c | 11 | 
2 files changed, 34 insertions, 3 deletions
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); diff --git a/sway/tree/view.c b/sway/tree/view.c index 7d4dbaeb..b66dc2f8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -746,6 +746,9 @@ static void handle_foreign_destroy(  			listener, view, foreign_destroy);  	wl_list_remove(&view->foreign_activate_request.link); +	if (view->foreign_minimize.notify) { +		wl_list_remove(&view->foreign_minimize.link); +	}  	wl_list_remove(&view->foreign_fullscreen_request.link);  	wl_list_remove(&view->foreign_close_request.link);  	wl_list_remove(&view->foreign_destroy.link); @@ -819,9 +822,11 @@ 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 (config->scratchpad_minimize) { +		view->foreign_minimize.notify = handle_foreign_minimize; +		wl_signal_add(&view->foreign_toplevel->events.request_minimize, +				&view->foreign_minimize); +	}  	struct sway_container *container = view->container;  | 
