Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping Alt+grave #218

Closed
RedBearAK opened this issue Jun 17, 2020 · 5 comments
Closed

Mapping Alt+grave #218

RedBearAK opened this issue Jun 17, 2020 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@RedBearAK
Copy link
Contributor

RedBearAK commented Jun 17, 2020

Edit 2020-08-13: Possible partial solution for XFCE, MATE and Cinnamon? See issue #260

======================
I am attempting to get Alt+grave to map to the physical Alt+grave keys while Kinto is running. At the moment Alt+grave is of course shifted to Win+grave.

I assume that "grave" in the code refers to what I have always called the "backtick/tilde" key, just above the Tab key on a US keyboard.

When it is left as "Alt+grave" in IceWM it behaves as expected on the physical Win+grave key combo. It task switches between only "related" windows, such as all terminal windows if a terminal has focus. This is very similar to the behavior of Cmd+grave on a Mac.

However, at the same time, the physical Alt+grave combo acts like reverse cycle windows (reverse Alt+Tabbing). When I attempt to change the IceWM preferences to accept "Ctrl+grave" as the shortcut, the Win+grave physical key combo stops working, but the physical Alt+grave combo continues to act like reverse cycle windows.

It is as if I am not using the correct key mapping or key names. Or Kinto's remaps are interfering with the use of this specific shortcut.

This bit of code in kinto.py makes me wonder:

K("RC-Tab"): K("RC-backslash"), # xfce4
K("RC-Shift-Tab"): K("RC-Shift-backslash"), # xfce4
K("RC-Grave"): K("RC-Shift-backslash"), # xfce4

I notice here which I never paid much attention to before, that Kinto is mapping two different shortcuts to a single "RC-Shift-backslash", which would in my case be Ctrl+Shift+backslash which is "Cycle windows (Reverse)" in XFCE and KeySysSwitchBack in IceWM.

Does the grave shortcut not exist in XFCE? Why is Kinto mapping two shortcuts to one?

@RedBearAK RedBearAK added the question Further information is requested label Jun 17, 2020
@rbreaves
Copy link
Owner

rbreaves commented Jun 17, 2020

Because in macOS Cmd+Grave, after pressing Cmd+Tab and holding down Cmd still, will activate the reverse app cycling (without grouping context). Now it is true that Cmd+Grave or tilde does not do that unless Cmd+Tab was pressed first.. I don't have the time to work out the logic for such a small detail - but technically it should only activate if Tab was pressed first while still on that same Cmd key press.

This behavior actually does need to be updated, updated to using app groupings - if it is a feature available available in XFCE - I do not recall if it is or isn't so I will keep this ticket open until I can confirm it one way or another. This commit was added to address a similar ticket awhile back and changes were made for KDE, and gnome DEs to use App group cycling instead of back cycling on Cmd+Grave (tilde).

5da4925

#151

Ideally though both possibilities will be handled fully later on via xkeysnail one way or another.

@RedBearAK
Copy link
Contributor Author

RedBearAK commented Jun 17, 2020

Wow, I have been using Cmd+grave to cycle between open windows within a single application on Mac for many years now and never realized it had that secondary behavior. And I've rarely found reverse window cycling to be nearly as useful as the way macOS treats app switching as a hierachy where each application is treated as a group. When I finally understood this paradigm after moving from Windows and Linux to first BeOS and then to Mac OS X, it fundamentally changed how I interact with applications and windows.

XFCE is a little weird. The normal "Cycle windows" brings up the task switching display and lets you cycle through all open windows. There is also something below it in Window Manager -> Keyboard called "Switch application". I tried it but it inexplicably completely ignored one of the windows I had open. It was Window Manager itself, I just couldn't switch to it with "Switch application". So "Switch application" in XFCE seems to be a somewhat broken paradigm. Also, if I remember right it doesn't bring up the onscreen task display when switching. So I went right back to "Cycle windows".

Also, in re-testing "Switch application" just now, it seems to get irrevocably "stuck" whenever I switch to a terminal. Which is weird because the other thing I was complaining about with terminals, the inability to cut/copy/paste with Alt+X/C/V, has seemingly stopped being a problem. I can Alt+C in a browser and then Alt+V in a terminal now, and vice versa. Before yesterday that only ever seemed to work on the Raspberry Pi, not the MX laptop.

There is also something in between these two options in Window Manager somewhat confusingly called "Switch window for same application". This seems to behave similarly to Cmd+grave on the Mac. However, I have only been able to get this function to work when setting the keyboard shortcut to physical Win+grave (logical Alt+grave). Trying to set it to Ctrl+grave (or anything else I've tried like Super+Tab, Super+grave) results in that function not working. Even after commenting out the line in kinto.py that maps RC+Grave to RC+Shift+backslash, that function won't work on Ctrl+grave (physical Alt+grave).

But in either case, with or without that line commented out in kinto.py, the function works fine when it's on Alt+grave (physical Win+grave). In both XFCE and IceWM.

So the base function of cycling between windows within a single application does seem to be available on both XFCE and IceWM. I just can't get it to work when it's set to Ctrl+grave (physical Alt+grave).

I know this is not quite the same as the Alt+Tab mapping issue I was having, with Kinto simply not working quite right on my system. But it would be pretty nifty to get this working. Other than Cmd+X/C/V and Cmd+Tab, Cmd+grave is probably one of the shortcuts I use most frequently on any Mac.

So for IceWM in ~/.icewm/preferences there is:

KeySysSwitchNext="Ctrl+backslash"
KeySysSwitchBack="Shift+Ctrl+backslash"
KeySysSwitchClass="Alt+grave"

And in XFCE in Window Manager -> Keyboard the equivalent settings are:

Cycle Windows = "Ctrl+Backslash"
Cycle windows (Reverse) = "Shift+Ctrl+Backslash" (or "Shift+Ctrl+| if I set it manually)
Switch window for same application = "Alt+grave" (or "Alt+`" if I set it manually)

I finally remembered to try xbindkeys again, but this is one of those key combos that it appears to be unable to capture, because the switching function overrides the capture. This is in XFCE at the moment.

Edit: Same happens in IceWM.

@rbreaves
Copy link
Owner

Makes sense, thanks for doing the testing. I will try to get to it soon, not sure if I have time to do so today. I did add a quick update earlier though, there Windows install part was broken, someone reported that to me via another forum - but that was unrelated to this.

As far as copy and paste goes, no real changes have happened there, don't really understand how that ever had an issue tbh. As long as the basic system-wide remaps happen correctly and the terminal is one accounted for I don't tend to ever see issues with that.

@RedBearAK
Copy link
Contributor Author

Just an FYI note to say that the Alt+Grave shifting between only related windows seems to work just fine on elementary OS 5.1.6. I guess they are using the Pantheon window manager currently.

The following is probably expected behavior, but it also restricts itself to only cycling between related windows on a single display. If I'm cycling between terminal windows and there is another terminal window on a second display, then the terminal windows on the second display are ignored. This is not the case with Alt+Tab switching, which jumps between all open windows on all displays. Kind of an interesting feature.

I am unable to identify any visible shortcut setting listed in the Keyboard preferences in the eOS Settings app that would explain why this works. The not-xfce4 options are uncommented in kinto.py, so Grave appears to be mapped to F6:

define_keymap(None,{
    # Basic App hotkey functions
    K("RC-Q"): K("Alt-F4"),
    K("RC-H"): K("Alt-F9"),
    # Cmd Tab - App Switching Default
    K("RC-Tab"): K("RC-F13"),                     # Default not-xfce4
    K("RC-Shift-Tab"): K("RC-Shift-F13"),         # Default not-xfce4
    K("RC-Grave"): K("M-F6"),                     # Default not-xfce4
    K("RC-Shift-Grave"): K("M-Shift-F6"),         # Default not-xfce4
    # K("RC-Tab"): K("RC-backslash"),               # xfce4
    # K("RC-Shift-Tab"): K("RC-Shift-backslash"),   # xfce4
    # K("RC-Grave"): K("RC-Shift-backslash"),       # xfce4
    # In-App Tab switching
    # K("M-Tab"): K("C-Tab"),                       # Chromebook - In-App Tab switching
    # K("M-Shift-Tab"): K("C-Shift-Tab"),           # Chromebook - In-App Tab switching
    # K("M-Grave") : K("C-Shift-Tab"),              # Chromebook - In-App Tab switching
    K("Super-Tab"): K("LC-Tab"),                  # Default not-chromebook
    K("Super-Shift-Tab"): K("LC-Shift-Tab"),      # Default not-chromebook

This behavior of Alt+Grave is desirable in all DEs, to more closely mimic macOS.

@rbreaves
Copy link
Owner

I tested Cmd-Grave and it appeared to work fine and as expected in v1.2 and even earlier I thought. Many of the odd system level remappings that were happening have been removed where possible in v1.2. Please retest and let me know if that does not hold true.

v1.2 will not remap any existing hotkeys, it uses what is there the best that it can atm, and even that might under go some serious improvements yet again to make even more flexible across any distro based on a known DE.

Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants