From 559bf941e546fa1ae4febc1ee89eafacc9a7678f Mon Sep 17 00:00:00 2001 From: William Barsse Date: Wed, 4 May 2022 17:40:34 +0200 Subject: [PATCH] Add a "nop" command The "nop" command, as the name implies, doesn't do anything. The change isn't entirely frivolous ;-) Sending a "nop" command interrupts any in-progress "prev-next" sequence without any other side effects. Until a sequence is interrupted, all next/prev-window commands navigate the windows in the LRU order captured at the time of the first command in the sequence. A "nop" command can be useful if bound to a particular key _release_ event in Sway. For instance, if is bound to "nop" while and are bound to the "prev/next-window" commands, then releasing will be enough to refresh the LRU sequence for the next use of these next/prev bindings. This behavior feels more intuitive (at least to me) than the non-nop variation. One caveat though: there is currently an [outstanding bug in sway on release bindings](https://github.com/swaywm/sway/issues/6456) which prevents the described scenario from working exactly as described because the Tab/S-Tab key presses actually cancel the outstanding release action. There is however also a (non-merged) PR available that addresses the issue. --- swayr/src/cmds.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/swayr/src/cmds.rs b/swayr/src/cmds.rs index 89662d4..ec445c3 100644 --- a/swayr/src/cmds.rs +++ b/swayr/src/cmds.rs @@ -67,6 +67,9 @@ pub enum ConsiderWindows { #[derive(clap::Parser, Debug, Deserialize, Serialize)] pub enum SwayrCommand { + /// No-operation. Interrupts any in-progress prev/next sequence but has + /// no other effect + Nop, /// Switch to next urgent window (if any) or to last recently used window. SwitchToUrgentOrLRUWindow, /// Switch to the given app (given by app_id or window class) if that's not @@ -264,6 +267,7 @@ pub fn exec_swayr_cmd(args: ExecSwayrCmdArgs) { } match args.cmd { + SwayrCommand::Nop => {} SwayrCommand::SwitchToUrgentOrLRUWindow => { switch_to_urgent_or_lru_window(&*props.read().unwrap()) }