Skip to content

Sending keyboard modifier state to inactive and layer-shell views with mouse clicks #891

@dkondor

Description

@dkondor

Hi,

I'm opening this as a question, since this has become a complicated problem for a simple issue :)

My main problem is detecting if one of the modifier keys are pressed during a mouse click. This does not seem to work for non-focused views, including layer-shell views without the keyboard-interactivity option set.

E.g. cairo-dock has the feature where holding the shift key while clicking on the icon of a running app starts a second instance. This does not work on Wayfire, since the fact that shift is pressed is not reported. Separately, Ctrl-click on a currently unfocused view does not work (e.g. open a link in a new tab on Firefox).

After a bit of investigating, I see two causes:

  1. Keyboard focus for layer-shell surfaces is too restricted in my opinion. If a layer-shell surface is on the top layer, it either grabs all keyboard events or nothing (depending whether keyboard interactivity is set ). This makes sense for views in the overlay layer, such as a lock screen, but I think there is rationale for layer-shell views that behave similarly to "always-on-top" views, i.e. allow the keyboard focus to be lost. (alternatively, a layer-shell surface could set / unset keyboard interactivity whenever the pointer enters / leaves, but that goes against the typical behavior for keyboard focus). I believe any change here would require changing the protocol definition -- I can open a separate issue for this on wlr-protocols.

  2. Non-focused views do not receive active modifiers with mouse clicks and also, setting keyboard focus on click only works if no modifiers are pressed. This is true for non-layer-shell views as well, so left-clicking on a view sets the focus, but e.g. clicking with shift or ctrl pressed will not, since that does not match the focus change binding here. In this case, the view receives the mouse click, but not the state of the modifier (since it never receives keyboard focus). This can be tested e.g. with Firefox, where ctrl + click should open a link in a new tab, but this does not work if Firefox is not the active view.

Let me know if I can provide more info or examples. So far, I've made a hack that always sends modifiers to layer-shell surfaces, mostly fixing my issue with shift-click on cairo-dock, but I don't think it's a good idea for general usage.

Thanks!

ps Related issues:
#640
#657

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions