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

Feature: add option to enable/disable "multimonitor focus follows mouse" #755

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

jtaala
Copy link
Collaborator

@jtaala jtaala commented Jan 20, 2024

Resolves #389.

When using multiple monitors, by default, PaperWM focuses/activates a monitor when the mouse cursor enters said monitor.

This PR makes this behaviour a user settable option:
image

@jtaala jtaala requested a review from Lythenas January 20, 2024 08:15
@jtaala jtaala linked an issue Jan 20, 2024 that may be closed by this pull request
@jtaala jtaala requested a review from Thesola10 January 21, 2024 10:13
@jtaala jtaala added the merging soon Label for PRs that are planned to be merged soon (usually within the next week) label Jan 21, 2024
in another space on another monitor) - if space is shown on that monitor
don't do gnome workspace switch animation.
Copy link
Collaborator

@Thesola10 Thesola10 left a comment

Choose a reason for hiding this comment

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

Switching between monitors on touch is entirely broken (#655 behavior), regardless of what the "monitor focus follows mouse" setting is set to.

@Thesola10 Thesola10 dismissed their stale review January 22, 2024 17:05

Disregard, broken behavior seems to have appeared prior.

@Lythenas
Copy link
Collaborator

One thing I noticed it that the mouse move/position does not seem to be passed to windows on other monitors. I.e. I can hover over tabs on a firefox window that is not active in the current workspace but I can't hover over tabs on a firefox window on the other monitor.

This also means the first click is not passed to the application. So you always have to click twice, once to activate the other monitor and the second time to actually click where you want to click. I think this is a major inconvenience.

I'm not sure if this is something that is cause by this PR or not. But given that we no longer have a click overlay I would have expected this to work.

I also got the following error in the logs when dnd-ing windows (always happens from one monitor to another, sometimes happens when staying on one monitor). I checked terminator and files:

Jan 23 20:41:43 anarchy gnome-shell[45313]: meta_window_set_stack_position_no_sync: assertion 'window->stack_position >= 0' failed
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x5575082f4b40), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x5575082f4b40' has no handler with id '114818'
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x5575061c8930), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x5575061c8930' has no handler with id '114819'
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x557506208750), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x557506208750' has no handler with id '114820'
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x55750822ecb0), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x55750822ecb0' has no handler with id '114821'
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x55750784c5a0), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x55750784c5a0' has no handler with id '114822'
Jan 23 20:42:44 anarchy gnome-shell[45313]: Object Meta.BackgroundActor (0x55750b551ac0), has been already disposed — impossible to access it. This might be caused by the object having been destroyed from C code using something such as destroy(), dispose(), or remove() vfuncs.
                                            == Stack trace for context 0x55750372eeb0 ==
                                            #0   7ffcc29ce5b0 b   resource:///org/gnome/gjs/modules/core/overrides/GObject.js:708 (14ed3819c1f0 @ 25)
                                            #1   7ffcc29ce660 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0ce0 @ 20)
                                            #2   7ffcc29ce760 b   self-hosted:203 (14ed38196a60 @ 245)
                                            #3   7ffcc29ce840 b   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/utils.js:419 (2d116cfe0c90 @ 285)
                                            #4   5575037f9f98 i   file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/grab.js:354 (2d116cfea100 @ 73)
                                            #5   5575037f9f08 i   resource:///org/gnome/shell/ui/init.js:21 (14ed38170ba0 @ 48)
Jan 23 20:42:44 anarchy gnome-shell[45313]: ../glib/gobject/gsignal.c:2777: instance '0x55750b551ac0' has no handler with id '114823'

But I haven't noticed any issues, just the error in the log.

Also I noticed sometimes the window does not end up where I dropped it.

Not sure if all of this is caused by this PR, but I haven't seen that before. But then again I don't dnd windows.

monitor-focus-follow-mouse is disabled (first click enables space, 2nd
virtual click happens after).
@jtaala
Copy link
Collaborator Author

jtaala commented Jan 24, 2024

This also means the first click is not passed to the application

I noticed this. I'm not sure what to do about the position not being passed (it's not the ClickOverlay but I believe the background element eats events until the workspace is activated).

We can do something about needing two clicks through - I've added a virtual click afterwards (i.e. first click activates space, followed by another click on the actual cursor position.

Pull the latest to try it out.

@jtaala
Copy link
Collaborator Author

jtaala commented Jan 24, 2024

P.S. I knew about the log errors - it's a signals cleanup issue after grab/drag finish, doesn't cause any actual issues so will look at that one later.

@Thesola10
Copy link
Collaborator

Thesola10 commented Jan 24, 2024

Oh, uh 21efa47 did the trick it turns out, thanks @jtaala

However, moving the mouse doesn't hand focus back to the display the mouse was on, as it did before. (I have enabled "focus follows mouse")

@Lythenas
Copy link
Collaborator

While the first click is fixed.

One thing I noticed it that the mouse move/position does not seem to be passed to windows on other monitors.

This also means that you e.g. can't drag firefox tabs between different firefox windows on different monitors. Instead it just creates a new window on the original monitor. This is a major inconvenience.

Also I use the Search Light extension. And I noticed it immediately closes again when I try to open it on an empty monitor. It works if I enable "Monitor focus follows mouse" or if a floating window is open anywhere or if the monitor has a tiled window.

@jtaala jtaala removed the merging soon Label for PRs that are planned to be merged soon (usually within the next week) label Jan 24, 2024
activated by other means then pointer check remains valid).
@tadfisher
Copy link
Contributor

tadfisher commented Jan 24, 2024

I think this is from #751, but hovering over any window element that causes the mouse cursor to change results in a constant 2Hz flickering between the changed cursor and the default one. For example, hovering over this comment box in Firefox.

Sorry, I'm on the release branch, so not applicable to this PR.

@jtaala
Copy link
Collaborator Author

jtaala commented Jan 24, 2024

Oh, uh 21efa47 did the trick it turns out, thanks @jtaala

However, moving the mouse doesn't hand focus back to the display the mouse was on, as it did before. (I have enabled "focus follows mouse")

Thanks @Thesola10 - I believe I know what that likely is. Can you check the latest on this PR?

@Lythenas @Thesola10, it's looking like this approach to focusing (or not focusing monitors by mouse movement) might not be feasible as PaperWM tiling seems to need a space activated to properly focus elements (which is likely why the "monitor focus follows mouse" approach was implemented in the first place.

In any case, let's put this one on hold until we can get the touch stuff working again.

@Thesola10, let me know if the last commit fixed the issue with "moving mouse back to monitor not focusing" issue. If so, we'll get those changes in first before looking at this PR again.

@jtaala
Copy link
Collaborator Author

jtaala commented Jan 24, 2024

I think this is from #751, but hovering over any window element that causes the mouse cursor to change results in a constant 2Hz flickering between the changed cursor and the default one. For example, hovering over this comment box in Firefox.

Sorry, I'm on the release branch, so not applicable to this PR.

That's weird though - haven't seen that myself. Create an issue for sure to see if others are seeing this (and def run gather-system-info.sh to help debug that one).

Yeah, if you're on release then it wouldn't be #751 (I haven't merged that into release branch yet - it's still only in develop branch).

@jtaala
Copy link
Collaborator Author

jtaala commented Jan 25, 2024

Hey all, see comment on why this PR's approach isn't currently feasible with PaperWM's multimonitor approach (not without some issues anyway):

#389 (comment)

Thoughts?

jtaala added a commit that referenced this pull request Jan 26, 2024
This PR implements some fixes for a regression to touchscreen support by
#751.

It also includes some smaller fixes implemented during development of
#755. Lastly, it includes replacing deprecated methods (which are
entirely removed int Gnome 46).

@Thesola10, can you give this branch a test and let me know if touch is
working again?
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.

current windows lost focus when mouse move across monitor
4 participants