Closed JCallicoat closed 2 years ago
Thanks for another great PR!
That's a neat feature.
backandforth
seems like a reasonable thing to call it given that's what it's called elsewhere. I'd almost be tempted to make it the default and maybe not configurable given that it doesn't do anything right now, though I suppose that could be confusing for some.
Hello again! I have been using JWM for the past week as my daily driver and I really love how much functionality is packed into such a small and fast window manager. One thing I have been missing is a feature i3 calls
workspace_auto_back_and_forth
and xfce callstoggle_workspaces
.The basic idea is that when you try to switch to the currently active desktop using the
desktop#
action, it will instead switch to the previously active desktop rather than being a no-op. This is very convenient to quickly switch back and forth when working on something between two desktops (e.g., a terminal and a chat application).For example, if I have a terminal open in desktop 1 and slack open in desktop 2, desktop 1 is currently active, and I have a keybinding like
I can press mod4+2 to switch to desktop 2, and then press mod4+2 again to switch back to desktop 1. It's even more convenient when I am working between, say, desktop 5 and 1 and only need to press mod4+1 to switch back and forth.
This PR adds a
backandforth
attribute to the Desktops tag to configure this functionality. Possible values are "on" and "off" (the default). If set to "off" (or unset) the current behavior of doing nothing when switching to the currently active desktop is retained. When set to "on", the previously active desktop will be switched to instead.There are a couple of things I am unsure about:
backandforth
is the best name for the attribute, I basically just copied i3's naming because I couldn't think of anything better to express the idea.Note that the checking for current desktop and swapping in the previous desktop needs to be done in
ProcessBinding
in event.c and not inChangeDesktop
in desktop.c, so that it only applies to our own calls from thedesktop#
action and is not executed when external pagers or tools like wmctl and xdotool request to change the _NET_CURRENT_DESKTOP property. This unfortunately means the check forcurrentDesktop == desktop
is duplicated in both places, but I do not see a way to avoid that.