From 1afedcb94c0517b5434e2220e63b997cf01427bd Mon Sep 17 00:00:00 2001 From: ftilde Date: Sat, 12 Dec 2020 00:11:58 +0100 Subject: Fix for_window criteria and mouse button bindings Previously, the special case handling of scratchpad and unmark commands was (probably accidentally) limited to criteria directly handled in the execute_command function. This would exclude: 1. for_window criteria, as these are handled externally for views and 2. and mouse bindings which select target the node currently under the mouse cursor. As a concrete example `for_window [app_id="foobar"] move scratchpad, scratchpad show` would show (or hide due to the toggling functionality) another window from the scratchpad, instead of showing the window with app_id "foobar". This commit replaces the "using_criteria" flag with "node_overridden" with the more general notion of signifying that the node (and container/workspace) in the current command handler context of the sway config is not defined by the currently focused node, but instead overridden by other means, i.e., criteria or mouse position. --- sway/commands/scratchpad.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sway/commands/scratchpad.c') diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index a1285df5..c995f2f0 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -105,12 +105,12 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Scratchpad is empty"); } - if (config->handler_context.using_criteria) { + if (config->handler_context.node_overridden) { struct sway_container *con = config->handler_context.container; // If the container is in a floating split container, // operate on the split container instead of the child. - if (container_is_floating_or_child(con)) { + if (con && container_is_floating_or_child(con)) { while (con->pending.parent) { con = con->pending.parent; } @@ -118,8 +118,9 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { // If using criteria, this command is executed for every container which // matches the criteria. If this container isn't in the scratchpad, - // we'll just silently return a success. - if (!con->scratchpad) { + // we'll just silently return a success. The same is true if the + // overridden node is not a container. + if (!con || !con->scratchpad) { return cmd_results_new(CMD_SUCCESS, NULL); } scratchpad_toggle_container(con); -- cgit v1.2.3-54-g00ecf