i3 icon indicating copy to clipboard operation
i3 copied to clipboard

Expand `focus_follows_mouse` to determine focus when closing windows or changing workspaces

Open itsfarseen opened this issue 3 years ago • 12 comments

I'm submitting a…

[ ] Bug
[x] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Reproduction Instructions

  • Enable focus_follows_mouse
  • Open three terminal windows.
  • Make one of them floating.
  • Focus the floating window using mouse.
  • Focus one of the non-floating terminals using mouse.
  • Press Ctrl-D to close it.
    • Mouse is now on the non-floating terminal, but the floating terminal is focused.
  • Move the mouse around while on top of the non-floating terminal.
    • Focus is still on floating terminal.
  • Type something.
    • Input goes to the floating terminal.

Current Behavior

  • Focus shifts to the last focused window regardless of which one the mouse is over.

Expected Behavior

Either one of:

  • Focus the window which is under the mouse.
  • Warp the mouse to the center of whichever window is focused.

Environment

Output of i3 --moreversion 2>&-:

i3 version: 4.20.1
Config file
force_focus_wrapping no
focus_follows_mouse yes
focus_on_window_activation smart
mouse_warping output
- Linux Distribution & Version: NixOS Unstable
- Are you using a compositor (e.g., xcompmgr or compton): Picom

itsfarseen avatar Apr 29 '22 18:04 itsfarseen

I don’t see a link to logs.i3wm.org. Did you follow https://i3wm.org/docs/debugging.html? (In case you actually provided a link to a logfile, please ignore me.)

i3bot avatar Apr 29 '22 18:04 i3bot

Focus follows mouse refers to focus following the mouse as you move it across window boundaries, see the userguide's description:

[…] window focus follows your mouse movements as the mouse crosses window borders.

This doesn't happen here, though, because when closing the first window you are not moving it at all, and when you move it inside the (not focused) window, you are not crossing boundaries.

As such, this isn't really a bug, but intended (and well established) behavior. I can understand where you're coming from, though, and would rather classify this as a feature request.

Airblader avatar May 02 '22 09:05 Airblader

I have updated the checkmark in the first post to be a feature request.

itsfarseen avatar May 02 '22 09:05 itsfarseen

I often run into a similar situation like this.

  • With focus_follows_mouse enabled, open two windows in tiling mode.
  • Focus window A on the left with the mouse.
  • Then shift focus to window B on the right with the keyboard.
  • The mouse cursor is still over window A.
  • When moving the mouse now, the focus is still on window B.
  • To shift focus to window A with the mouse, I have to either click or move the cursor over the border of window A.

If there is an option to shift focus to the window under the cursor when the cursor is moved, it will be useful.

Mudskipper875 avatar May 14 '22 04:05 Mudskipper875

I have a similar issue when switching workspaces:

  • Open two windows (A and B) in tiling mode
  • Focus A with the mouse
  • Switch to a new workspace
  • Move mouse over where window B would be
  • Switch back to the first workspace
    • Mouse is over window B but window A is still focused

As previously stated it seems like this is technically intended behaviour but it isn't very intuitive, it would be great to be able to always have whatever window is currently under the cursor focused.

Jachdich avatar Nov 17 '22 13:11 Jachdich

FWIW I accidentally encountered the same scenario as @Jachdich several times over the last few days (since i switched to i3) and typed to the wrong window.

I would greatly appreciate a feature to focus de window under the pointer when changing workspace.

I also understand that the current behavior is intended, but I have trouble remembering which window was in focus in each workspace I leave, and rediscovering which window is in focus whenever I change workspace feels like unnecessary mental friction.

faelys avatar Feb 26 '23 17:02 faelys

I also understand that the current behavior is intended, but I have trouble remembering which window was in focus in each workspace I leave, and rediscovering which window is in focus whenever I change workspace feels like unnecessary mental friction.

The last focused window should get focus when you switch workspaces

orestisfl avatar Feb 28 '23 08:02 orestisfl

The last focused window should get focus when you switch workspaces

The window under the pointer should get focus when you switch workspaces. Otherwise focus_follows_pointer is a lie.

faelys avatar Mar 01 '23 06:03 faelys

The last focused window should get focus when you switch workspaces

The window under the pointer should get focus when you switch workspaces. Otherwise focus_follows_pointer is a lie.

In i3 it is called focus_follows_mouse. And the docs say:

By default, window focus follows your mouse movements as the mouse crosses window borders.

If you switch workspaces, this doesn't always mean that the mouse moves and crosses window borders. Thus, the last focused window on the workspace you switched to gets focused if you switched workspaces with a keybinding.

okraits avatar Mar 01 '23 07:03 okraits

In i3 it is called focus_follows_mouse. And the docs say:

By default, window focus follows your mouse movements as the mouse crosses window borders.

Indeed, the docs say how it is currently, as they should be. But some users would find i3 greatly enhanced if the focus actually followed the mouse, even when the window under the pointer change for some other reason than the pointer crossing window borders.

faelys avatar Mar 01 '23 07:03 faelys

I believe this is the minimal change required for what you want https://github.com/i3/i3/commit/2c8f0a9a658ee07cf5549034fbbac0e0101d5c4d . I would think we'd change the config switch focus_follows_mouse to be something like focus_follows_mouse always & focus_follows_mouse borders, or something to that effect, so that both functionalities could be used. I wanted to hear some input about this before making a more complete effort at implementing this feature. Specifically, how should the configuration options be named, and is handle_motion_notify the right place for this?

slyshot avatar Jun 05 '23 21:06 slyshot

I would very much appreciate a new config option for this. I split my workspaces and it happens often to me that the focus isn't where I expect it to be (below the cursor) after switching to a new workspace.

jsegitz avatar Feb 29 '24 16:02 jsegitz