sbmpost / AutoRaise

AutoRaise (and focus) a window when hovering over it with the mouse
GNU General Public License v3.0
1.48k stars 60 forks source link

Flicker Issue #80

Closed hasantahir closed 2 years ago

hasantahir commented 2 years ago

On version 3.1 compiled with the EXPERIMENTAL_FOCUS_FIRST flag, I noticed a weird flicker in the Preview app when I tried to adjust the colours through the histogram. In the GIF below, one can observe the flickering when I hover the cursor around the histograms. In order to reduce the size of the GIF, I had to reduce the framerate but one can still see the histogram disappearing.

Kapture 2022-06-06 at 11 16 02

sbmpost commented 2 years ago

@hasantahir Thanks for the video. The problem is that this is a window which has no focusable elements (you can't use the keyboard anywhere in the window). So we try to focus the window, but that fails and another window gets the focus. Then after you move the mouse, we try again and fail again, and so on. Most windows without focusable elements have an empty title, and are therefore excluded from raising, see also here:

https://github.com/sbmpost/AutoRaise/blob/6e7c4ca8d0fb8f7449d71f3d787c7829ccfd0ceb/AutoRaise.mm#L912

However this window has a title and therefore is not excluded. Perhaps the loop can be broken by remembering the window that AutoRaise tried to focus last and compare it with the window about to be focused. Such a solution might come with other problems (this needs to be investigated). Note that setting delay = 1 (enabling raise), will stop this problem. There is a reason the FOCUS_FIRST feature is experimental ;-). Thanks for reporting!

hasantahir commented 2 years ago

Thanks for your feedback @sbmpost

In fact, this is the only instance of abnormal behaviour that I have come across so far. The Experimental feature is indeed quite robust.

I will play around with the suggested change and report back. Thanks

sbmpost commented 2 years ago

@hasantahir

I will play around with the suggested change and report back

I have made a branch that should partially fix it. It will reduce the problem in the sense that you will see 3 flickers at most. Fixing this completely is difficult because there are other cases where AutoRaise needs to retry 3 times before it can successfully focus and/or raise a window.

You can download the updated version using this link. After unzipping, you can do this in the unpacked folder:

make CXXFLAGS="-DEXPERIMENTAL_FOCUS_FIRST" && make install

Before starting, make sure there are no previous AutoRaise instances running. Also I noticed that sometimes it is necessary to remove AutoRaise from the "System Preferences|Security & Privacy|Privacy|Accessibility" pane before starting it again.

hasantahir commented 2 years ago

Thanks @sbmpost for looking into this. The flicker, as you described is still there but it is a single, rare case.

sbmpost commented 2 years ago

@hasantahir so the problem should at least be reduced with the latest code in this branch (only 3 flickers each time you hover, instead of it flickering constantly). Note also the discussion in #82. The changes I discuss there have been made part of this branch as well.

sbmpost commented 2 years ago

@hasantahir Closing this issue as the fix (mitigation actually) is now part of the master branch.