Add backandforth attribute to Desktops tag #558
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.