hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.7k stars 835 forks source link

Focus behaviour #976

Open etrnal70 opened 1 year ago

etrnal70 commented 1 year ago

I got some question while porting my config to hyprland, particularly on focus behaviour in multi monitor situation

  1. Is there a way to do movefocus to empty workspace ? Sometimes when connecting to a monitor i need to move cursor to focus there
  2. Exec keybind seems to follow mouse focus. Example is using rofi. Is there a way to change this to follow keyboard focus ?
vaxerski commented 1 year ago
  1. workspace dispatcher or focusmonitor
  2. wat
Gustash commented 1 year ago
  1. workspace dispatcher or focusmonitor

  2. wat

I think what they mean on the second point is that focus always tracks the mouse.

I actually have this issue as well with rofi. If I open rofi but my cursor isn't on top of rofi, the keypresses go to the window below the cursor, not rofi.

On Sway this is not an issue and rofi takes over the keyboard until dismissed

EDIT:

I just noticed the layers_hog_keyboard_focus option, which seems to default to true, so it looks like either the default is not set properly or the option is not working as intended here.

Gustash commented 1 year ago

Actually, the same thing happens if I open a terminal, for example. If the way it splits ends up with the cursor not on top of the new terminal, I need to manually move my cursor to it to be able to start typing.

Maybe a good solution would be to automatically move focus to the newly opened window regardless of mouse position, and only focus which window the cursor is on when the mouse is moved after that point

vaxerski commented 1 year ago

I just noticed the layers_hog_keyboard_focus option, which seems to default to true, so it looks like either the default is not set properly or the option is not working as intended here.

LAYERS. Rofi is not a layer, because you're refusing to switch to a wayland native app launcher. There is a rofi fork for wayland (unsure whether it makes a LS tho) Use stuff like bemenu, wofi, tofi, etc.

Maybe a good solution would be to automatically move focus to the newly opened window regardless of mouse position, and only focus which window the cursor is on when the mouse is moved after that point

That's how it already works for me.

Gustash commented 1 year ago
  1. I'm using a wayland port of rofi, it does render rofi as a layer (Layer 3). I opened an issue about it recently, where I can't disable animations for it exactly because it's a layer and not a window.

  2. I just tried every follow_mouse option and even with 0 the behaviour is the same. I'm specifically using the master layout, and if my cursor is on top of one of the small tiles, the master tile gets the keyboard input for a second or two and then the focus shifts right back to the smaller tile. I'm not moving the mouse during all this, btw

vaxerski commented 1 year ago
  1. then idk what's happening, works on my end with wofi. As long as you dont click anywhere, the keyboard focus is on wofi.

  2. does it also happen with dwindle? I use dwindle.

Gustash commented 1 year ago
  1. then idk what's happening, works on my end with wofi. As long as you dont click anywhere, the keyboard focus is on wofi.

So both of these issues seem related to the master layout, specifially with the new_is_master option enabled. Dwindle works as intended even with force_split set to 2. Master layout works as well with new_is_master set to false.

By the way, I tried wofi and the behaviour observed with rofi is the same when layout is set to master and new_is_master is enabled.

  1. does it also happen with dwindle? I use dwindle.

See above.

heisfer commented 1 year ago

I too have same problem with master layout. I think I have talked with you before @vaxerski

tralph3 commented 1 year ago

I have the same issue. Both on master and dwindle layouts, if the cursor is on top of a window and I try to focus some other window with the keyboard, focus is shifted for a split second and snaps right back to the window with the cursor on top. Even if I drag the cursor to a corner, same behavior.

What's even the point of have a keyboard centric WM if the cursor won't let me use the keyboard anyway?

jade-tea-h commented 1 year ago

@tralph3 Have you set the input:follow_mouse option to 2 or 3?

tralph3 commented 1 year ago

follow_mouse is on 1. Setting it to 2 or 3 gives the same result.

jonhoo commented 1 year ago

I can reproduce a subset of this with rofi:

  1. Set follow_mouse = 0
  2. Set a keybind to execute rofi
  3. Open a browser (say, Firefox)
  4. Press the rofi keybind
  5. Press Esc to close rofi
  6. The browser now has keyboard focus (keyboard shortcuts like Ctrl+P) work, but not mouse focus (hover effects aren't triggered, scroll wheel does nothing).
  7. Clicking the browser window restores mouse focus