dawsers / hyprscroller

Hyprland layout plugin providing a scrolling layout like PaperWM
MIT License
201 stars 12 forks source link

148a1fd breaks mouse focus #74

Closed cpiber closed 2 hours ago

cpiber commented 3 hours ago

Since 148a1fd0f48789760b358e9786b953520ff1e128, whenever a popup (any floating window) closes, the focus is moved to the lower window, moving my mouse to the center of that window. It's extremely annoying, especially with xwayland windows like IntelliJ IDE's where each tooltip is a window.

cpiber commented 2 hours ago

This simple thing fixes it, and it still solves #68:

--- a/src/scroller.cpp
+++ b/src/scroller.cpp
@@ -408,13 +408,7 @@ static void toggle_window_fullscreen_internal(PHLWINDOW window, eFullscreenMode
 }

 static void force_focus_to_window(PHLWINDOW window) {
-    g_pInputManager->unconstrainMouse();
     g_pCompositor->focusWindow(window);
-    g_pCompositor->warpCursorTo(window->middle());
-
-    g_pInputManager->m_pForcedFocus = window;
-    g_pInputManager->simulateMouseMovement();
-    g_pInputManager->m_pForcedFocus.reset();
 }

 static void switch_to_window(PHLWINDOW from, PHLWINDOW to)

I'm not sure why you originally had the mouse move stuff there? But it's never a good idea to move the user's mouse without their explicit action.

In case it helps, the mouse stuff was introduced in fa8f73e, before this you just had focusWindow

dawsers commented 2 hours ago

Thank you for the report. I am working on a fix. It will be committed soon.

The reason why I move the mouse is because I want the mouse in the window where I am typing. I use follow_mouse =1, so if don't warp the cursor, when I move the mouse, it will change focus to the window where it is at that time.

cpiber commented 2 hours ago

Makes sense. But that should really only happen in response to a dispatcher, no? Moving the mouse when a window closes is just annoying (at least to me), if the user pressed the button to do that then it's fine

dawsers commented 2 hours ago

Yes, it should happen only when the user wants it, and the floating window close thing you are seeing shouldn't happen.

dawsers commented 2 hours ago

Try cb5935603555b9a6601ab6383ee5855d8d88f87e. I think it should work the way you expect. If there are other side-issues you see, please let me know.

Thanks!

cpiber commented 2 hours ago

Works perfectly, thank you!

cpiber commented 2 hours ago

That said, I was trying around a bit, I think some calculations with moving the cursor are incorrect, maybe that's due to the animation still running? When I move left and right with the dispatcher, the mouse isn't exactly in the center, but rather offset in the direction I was moving, see this recording

https://github.com/user-attachments/assets/c57d418e-83c7-4a26-82c7-4a456ec73cd4

dawsers commented 2 hours ago

Yes. I use Hyprland's CWindow::middle(), and it uses the "real" size and position, so it's affected by the animation.

But I think it doesn't matter much. If you find an edge case where it matters, I can write my own function.