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

MOD keys not working properly in-game #1741

Open
Faugus opened this issue Apr 21, 2024 · 14 comments
Open

MOD keys not working properly in-game #1741

Faugus opened this issue Apr 21, 2024 · 14 comments

Comments

@Faugus
Copy link

Faugus commented Apr 21, 2024

I was playing World of Warcraft today and I noticed some issues when using the ALT key.

In World of Warcraft, if I hold ALT and press the Arrow Up key, I can navigate through the previous messages I typed in the chat.
For some reason it's not working on Labwc. Also if I hold ALT, I can't move the camera with my mouse.

I tried on GNOME and KDE and it works normally.

Is there something I could try to fix this?

EDIT:
I just noticed another problem right now.
I can't paste a text with CTRL+V in the game's chat, so the problem is not with the ALT key only.

@Faugus Faugus changed the title ALT key doesn't work properly in-game MOD keys not working properly in-game Apr 21, 2024
@ahesford
Copy link
Member

Have you used the ToggleKeybinds action to prevent labwc from trying to interpret keypresses when the affected game is active?

@Faugus
Copy link
Author

Faugus commented Apr 21, 2024

@ahesford No, I never used it. this is my rc.xml file:

<?xml version="1.0"?>
<!--
  This is a very simple config file with many options missing. For a complete
  set of options with comments, see docs/rc.xml.all
-->
<labwc_config>
  <core>
    <gap>10</gap>
    <adaptiveSync>fullscreen</adaptiveSync>
    <!--<allowTearing>fullscreen</allowTearing>-->
  </core>
  <theme>
    <name>Onyx</name>
    <cornerRadius>0</cornerRadius>
    <font name="Noto Sans Regular" size="10"/>
  </theme>
  <keyboard>
    <default/>
    <keybind key="W-s">
      <action name="Execute" command="sh -c 'grim -o DP-1 - | swappy -f -'"/>
    </keybind>
    <keybind key="W-S-s">
      <action name="Execute">
        <command>sh -c 'grim -g "$(slurp)" - | swappy -f -'</command>
      </action>
    </keybind>
    <keybind key="C-F11">
      <action name="ToggleTearing" />
    </keybind>
    <keybind key="C-F12">
      <action name="Execute" command="sh -c 'pkill pw-loopback || pw-loopback -m '[[FL FR]]' --playback-props='[media.class=Audio/Source]''"/>
    </keybind>
    <keybind key="C-A-t">
      <action name="Execute" command="kitty"/>
    </keybind>
    <keybind key="W-r">
      <action name="Execute" command="sh -c 'pkill rofi || rofi -show drun'"/>
    </keybind>
    <keybind key="W-e">
      <action name="Execute" command="nautilus"/>
    </keybind>
    <keybind key="W-d">
      <action name="Iconify" />
    </keybind>
    <keybind key="XF86_AudioLowerVolume">
      <action name="Execute" command="pactl set-sink-volume @DEFAULT_SINK@ -5%"/>
    </keybind>
    <keybind key="XF86_AudioRaiseVolume">
      <action name="Execute" command="pactl set-sink-volume @DEFAULT_SINK@ +5%"/>
    </keybind>
  </keyboard>
  <libinput>
    <device category="Logitech G703 LS">
      <accelProfile>flat</accelProfile>
      <naturalScroll>no</naturalScroll>
    </device>
    <device category="Logitech G703 LIGHTSPEED Wireless Gaming Mouse w/ HERO">
      <accelProfile>flat</accelProfile>
      <naturalScroll>no</naturalScroll>
    </device>
  </libinput>
</labwc_config>

@ahesford
Copy link
Member

Try binding a key (I like W-k) to

<action name="ToggleKeybinds" />

When you launch your game, press that hotkey and the game window will receive all key events without labwc trying to grab them. (Except the same hotkey, which will disable that mode if pressed again.)

@Faugus
Copy link
Author

Faugus commented Apr 21, 2024

@ahesford it didn't work, unfortunately.

@johanmalm
Copy link
Collaborator

I can't easily replicate, so hard to fault find here.

Do you think the keyboard-focus is moving away from the window you're inputting into - or is it just the modifiers that are not received.

IIRC XWayland clients have 'mysterious waysof ascertaining what modifiers are pressed/released (on top of what we explicitly send from thelabwc` end), so there might be something deeper going on here.

I feel I'm grasping at straws, but detective work could include:

  1. Does it work on other wlroots compositors? We are very similar to sway in many ways, so if you can get steam working on sway that would be a useful comparison.
  2. Running WAYLAND_DEBUG=1 steam from terminal to modifier press/release events
  3. Testing if the wlroots patch in this MR makes a difference: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4496 That would basically send modifiers to all clients (not just the one with keyboard focus). Adding that patch to wlroots is unlikely to be the way forward, but we could probably achieve the same internally within labwc.
  4. Establish if kwin / mutter broadcast modifiers (i.e. send them to all clients - not just the one with keyboard focus). Should be easy to test with WAYLAND_DEBUG=1 foot (or whatever). Again, I can't easily do it, because I don't have a kwin instance and I've broken my mutter-wayland partition.
  5. If you think that steam is moving focus around and that may be the problem, try a window rule to stop that by adding something like the snippet below to rc.xml:
<windowRules>
  <windowRule identifier="foo" ignoreFocusRequest="yes"/>
</windowRules>

@kode54 @Joshua-Ashton - if you have time + ability to run that game, any change of leaning in?

@Faugus
Copy link
Author

Faugus commented Apr 21, 2024

@johanmalm
1- I just installed Sway to test and it works normally as well.

5- Setting the windowRule didn't work.

@Consolatis
Copy link
Member

Consolatis commented Apr 22, 2024

I was playing World of Warcraft today and I noticed some issues when using the ALT key.

In World of Warcraft, if I hold ALT and press the Arrow Up key, I can navigate through the previous messages I typed in the chat. For some reason it's not working on Labwc. Also if I hold ALT, I can't move the camera with my mouse.

A-Up and A-LMB/ / A-RMB + moving the mouse are default bindings in labwc.
You can disable them via

<keyboard>
	<default />
	<keybind key="A-Up" />
</keyboard>
<mouse>
	<default />
	<context name="Frame">
		<mousebind button="A-Left" action="Press" />
		<mousebind button="A-Left" action="Drag" />
		<mousebind button="A-Right" action="Press" />
		<mousebind button="A-Right" action="Drag" />
	</context>
</mouse>

Not sure about Ctrl-v not working, does it work when you copy something from another xwayland client and then paste it into WoW? You can verify what backend a specific window uses in the A-Tab menu, first column.

@Faugus
Copy link
Author

Faugus commented Apr 22, 2024

@Consolatis This worked:

<keyboard>
	<default />
	<keybind key="A-Up" />
        <keybind key="A-Down" />
</keyboard>
<mouse>
	<default />
	<context name="Frame">
		<mousebind button="A-Left" action="Press" />
		<mousebind button="A-Left" action="Drag" />
		<mousebind button="A-Right" action="Press" />
		<mousebind button="A-Right" action="Drag" />
	</context>
</mouse>

does it work when you copy something from another xwayland client and then paste it into WoW?

Yes, it works.

Is there an easy way to disable all the keybinds and manually enable only the ones I want?

@Consolatis
Copy link
Member

Consolatis commented Apr 22, 2024

This worked

nice :)

Is there an easy way to disable all the keybinds and manually enable only the ones I want?

Depends on your definition of easy.
The <default /> loads the hardcoded default bindings (which should be the same as listed in docs/rc.xml.all).
So you could not use <default /> but instead copy over the bindings from rc.xml.all and remove those that you don't want. That results in a pretty messy config though.

Another theoretical option would be to use ToggleKeybinds as suggested by @ahesford earlier in the thread.
However, that one doesn't handle the mousebinds as it would make it basically impossible to switch to another window.
It should work for the A-Up and A-Down keyboard input though. Maybe we could think about making ToggleKeybinds ignore the "Frame" context for mousebinds (as that is the only one that eats the mouse events).

does it work when you copy something from another xwayland client and then paste it into WoW?

Yes, it works.

Hm, but wayland native ([xdg-shell]) to WoW does not work?
I think there was some issue in wlroots regarding syncing the clipboard in one of the directions but that might have long been fixed. Or that was about drag and drop, really not sure right now.

@Faugus
Copy link
Author

Faugus commented Apr 22, 2024

@Consolatis

Hm, but wayland native ([xdg-shell]) to WoW does not work?

It doesn't work.

I think there was some issue in wlroots regarding syncing the clipboard in one of the directions but that might have long been fixed. Or that was about drag and drop, really not sure right now.

But it works on Sway, so it shouldn't be a wlroots problem, right?

@Consolatis
Copy link
Member

But it works on Sway, so it shouldn't be a wlroots problem, right?

Yeah, that is a good point. Really not sure what this could be about, I can paste from [xdg-shell] (foot) to [xwayland] (chromium) without issues.

@Flrian
Copy link
Contributor

Flrian commented Apr 26, 2024

Also if I hold ALT, I can't move the camera with my mouse.

Some additional context from me for this part of the issue that could apply:
I just started playing a new game where you have to use Alt + Left mouse button to complete an action, and that didn't work in labwc but it did in sway. So I tried a bunch of stuff and it turns out I have to add

      <mousebind button="A-Left" action="Press">
        <action name="None"/>
      </mousebind>

to my config to get it to work ingame. I personally use W+Left/Right for moving/resizing windows with the mouse, which is why disabling that doesn't bother me.

Also I never thought about it, but ToggleKeybinds doesn't disable mousebinds, so that didn't help me here.

@Faugus
Copy link
Author

Faugus commented Apr 26, 2024

After I removed the default keybinds, everything work fine, except the ctrl+c ctrl+v.

@Flrian
Copy link
Contributor

Flrian commented Apr 26, 2024

Ah woops, I completely missed that part of the thread. 😳

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

No branches or pull requests

5 participants