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

Window keeps raising itself, slow to react to focus gain/loss #5620

Closed
VanessaE opened this issue Dec 29, 2020 · 6 comments
Closed

Window keeps raising itself, slow to react to focus gain/loss #5620

VanessaE opened this issue Dec 29, 2020 · 6 comments

Comments

@VanessaE
Copy link

Version

commit d2b45c2 (git tag version_2.3.0-rc2)

Operating system type + version

Debian bullseye/testing

3D printer brand / version + firmware version (if known)

N/A

Behavior

Like a large portion of Linux users, my desktop is set to focus-follows-mouse, and to never to raise a window without my explicit action.

However, Prusaslicer likes to raise itself to the top if for example I give it focus, do nothing at all, and then hide it behind some other window. Often, if it gains focus, and I then bury it behind something else, it'll raise itself right away and it'll take me a few tries to get it to stay buried. If I give it focus, and then wait a few seconds before I bury the window, usually it will stay down.

A simple way to reproduce this: put a terminal on top of the Prusaslicer window and simply waggle the mouse from one to the other a couple of times, without clicking anything. When you stop moving the mouse, leave the mouse pointer on the terminal, and Prusaslicer will raise itself after a second. If your window manager is anything like XFCE/xfwm4, it will clearly show that focus is following the mouse, and its own decorations will react to the focus changes exactly as you've configured it to, and the terminal will show to have focus at the moment Prusaslicer raises itself.

This may be related to another oddity: whenever Prusaslicer gains focus, it takes about 1 second for it to react (for example, if the gtk3 theme changes the colors of the buttons et al. dependent on focus), and similarly about 1 second to react when it loses focus, during which time the prusa-slicer process spins at 100%, so the above test will peg a CPU core until you stop.

Meanwhile other programs, even complex ones like Chrome, display normal window stacking behavior and normal focus behavior.

@Lenbok
Copy link

Lenbok commented Jun 30, 2021

Agreed, this is ridiculously annoying for anyone using focus follows mouse. To add to the injury, Prusaslicer (I am using 2.3.1) brings the main window to the front of its own dialogs, thus hiding them and making them impossible to interact with unless you move the main window out of the way!

@RealDeuce
Copy link

Looks like it was introduced with this commit: 20f5b7a

"Keep your fingers crossed that it will not break something else."

@RealDeuce
Copy link

Specifically, adding CallAfter() appears to be the cause... calling them immediately rather than using CallAfter() appears to work.

Maybe @bubnikv can shed some light on why CallAfter() was added in that patch.

RealDeuce added a commit to RealDeuce/PrusaSlicer that referenced this issue Sep 2, 2021
The CallAfter() on Linux causes weird window focus issues.

For me, using ALT-Tab to switch away from PrusaSlicer would cause
PrusaSlicer to take back focus after about one second.  Stranger
things reportedly occur with focus-follows-mouse.

The #ifdef is there because it is assumed the CallAfter() was added
in 20f5b7a for a good reason.
@RealDeuce
Copy link

Submitted PR #6870 which takes the ultra-conservative path to a fix.

@bubnikv bubnikv closed this as completed in 3622f06 Dec 3, 2021
@bubnikv
Copy link
Collaborator

bubnikv commented Dec 4, 2021

Please test the builds attached to #6870 (comment)

@bubnikv bubnikv reopened this Dec 4, 2021
@Lenbok Lenbok mentioned this issue Dec 4, 2021
@bubnikv
Copy link
Collaborator

bubnikv commented Dec 4, 2021

Fixed with 3622f06

@bubnikv bubnikv closed this as completed Dec 4, 2021
bubnikv added a commit that referenced this issue Dec 5, 2021
Work around 3D scene focus after de-activation of the main
window without having to resort to CallAfter(), which breaks
on Linux with some window managers that follow mouser cursor.
Fixes #5620 #6870 #6992

3622f06 was not a correct solution,
it broke focus for non-modal windows.
Fixes #7419

The actual issue seems to be caused by wxProgressDialog not playing
well with modal dialogs closed just before wxProgressDialog opens.
If wxProgressDialog parent was not a main frame, keyboard focus
was not restored correctly after the wxProgressDialog closed.
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

No branches or pull requests

4 participants