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

Fix greedy mouse grab from keyboard_interactive layer #4401

Merged

Conversation

earboxer
Copy link
Contributor

@earboxer earboxer commented Jan 10, 2024

Describe your PR, what does it fix/add?

Fixes #2017

This allows you to use your mouse on other (not covered) surfaces even when you have a keyboard_interactive layer active.

The bug was that a keyboard_interactive layer would always take precedence over everything else (even without KEYBOARD_INTERACTIVITY_EXCLUSIVE). The fix makes that layer not take precedence, and instead makes refocus respect KEYBOARD_INTERACTIVITY_EXCLUSIVE (i.e. the correct behavior).

So, you can

  • use wvkbd to type into bemenu
    • click on an eww element even when rofi is open
  • click or scroll another window when (some other keyboard_interactive layer) is open
    • this will not steal the keyboard focus from a KEYBOARD_INTERACTIVITY_EXCLUSIVE layer

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

One case I found where the KEYBOARD_INTERACTIVITY_EXCLUSIVE is not respected:

  • keyboard focus will still be stolen (from the layer to a window) when you switch focus using movefocus (e.g. $mainMod, left)

this is an existing bug/feature (it may be intended behavior). Maybe it should be fixed now (so KEYBOARD_INTERACTIVITY_EXCLUSIVE layers keep the keyboard), or maybe fix it some other day?

Is it ready for merging, or does it need work?

This is ready. It fixes the unexpected and incorrect behavior that bothers me. (the existing movefocus behavior can be changed some other time, if that's what we want.)

@earboxer earboxer changed the title Fix greedy mouse grab on keyboard focus Fix greedy mouse grab from keyboard-interactive layer Jan 10, 2024
@earboxer earboxer changed the title Fix greedy mouse grab from keyboard-interactive layer Fix greedy mouse grab from keyboard_interactive layer Jan 10, 2024
@vaxerski
Copy link
Member

from a glimpse I don't think this will work well?

Some cases:

  • open a launcher, hit a keybind to movefocus,l to a window. LS will get completely unfocused...?
  • open a launcher and click on an OSK, will the launcher still have kb focus?

@earboxer
Copy link
Contributor Author

earboxer commented Jan 10, 2024 via email

@vaxerski
Copy link
Member

fair enough.

@earboxer earboxer force-pushed the 2017-fix-greedy-mouse-grab-on-keyboard-focus branch from a3d3543 to 1ff9571 Compare January 10, 2024 19:33
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vaxerski vaxerski merged commit c4da4b0 into hyprwm:main Jan 12, 2024
11 checks passed
@feschber
Copy link

#4465

@feschber
Copy link

feschber commented Jan 17, 2024

Edit: Ignore this comment, its wrong - see #4465


From my testing, the offending change is this:

diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 8bfdb65c..ce7e2b30 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -359,7 +359,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
 
     bool allowKeyboardRefocus = true;
 
-    if (g_pCompositor->m_pLastFocus) {
+    if (!refocus && g_pCompositor->m_pLastFocus) {
         const auto PLS = g_pCompositor->getLayerSurfaceFromSurface(g_pCompositor->m_pLastFocus);
 
         if (PLS && PLS->layerSurface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)

@earboxer
Copy link
Contributor Author

There is a partial regression from the two commits discussed here

#4465 (comment)

(If I open bemenu/rofi/nwggrid while there's no window open, it won't get keyboard events from wvkbd)

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

Successfully merging this pull request may close these issues.

Strange mouse grab on layers with keyboard interactivity
3 participants