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
Fix for #5620 #6870
Fix for #5620 #6870
Conversation
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.
Is there a way to get an AppImage of this to test, or do I have to build it myself? It would be great to get this fix into the 2.4.0. |
I honestly don't know, I use SuperSlicer myself. |
Perhaps we can request a review from @bubnikv ? |
I asked @lukasmatena to look into it. |
Thanks. BTW, in terms of specific cases to help reproduce issues with focus-follows-mouse, not all extra windows seem to trigger the problems. For example, opening "Help -> About PrusaSlicer" opens the dialog in front of the main window and it says there. Whereas right clicking on an object on the plate and selecting "Add settings -> Advanced" opens a dialog that is immediately pushed behind the main window. |
@RealDeuce I tried several times but never managed to reproduce either of the issues. However, removing the CallAfter reintroduces the original problem (why we started messing with focus in the first place) for me: after adding a model through Open file dialog, canvas does not get focus and e.g. pressing R to activate 'Rotate' does nothing. This is not visible when that awesome 'Focus follows mouse' function is active, but merging this PR as it is would probably break it for everyone not using it. |
#5141 sounds like it was about fixing for Windows but it introduced this regression on Linux. @lukasmatena When you say that removing the CallAfter reintroduces the original problem, do you mean on Linux or Windows? This PR as it currently is shouldn't change the behaviour on Windows. |
@Lenbok Sorry. I was talking about Linux. I know what you mean: we didn't need the CallAfter on Linux before, why would we need it now. The behavior may have changed with some of the wxWidgets updates. But I don't know, really. |
I have issues when not using focus follows mouse. When I use Alt-Tab to change to a different program, PrusaSlicer often steals focus back from the program I switched to. That is to say I'm using PrusaSlicer, and press Alt-Tab to switch to my browser, the browser gets focus then focus immediately changes back to PrusaSlicer with no action on my part, effectively forcing me to use the mouse to switch away from using PrusaSlicer. This is completely unacceptable behaviour for any program. Scheduling a focus change for "a (slightly) later time" as CallAfter() does is an inherently dangerous thing to do because it very much matters when the focus change occurs, and CallAfter() makes no guarantees about that. It's completely believable that on some systems it causes many problems and on other systems there's no problem at all. |
I'm unfortunately unable to reproduce it.
None of the Btw, are you all guys running our AppImages, or only a distro-provided/self-compiled binaries? |
@lukasmatena I am running your AppImages, on Ubuntu 20.04 LTS. |
I was running a self-compiled binary. |
Also for what it's worth, I use the XFCE4 desktop environment. |
@lukasmatena Is it possible to commit this in a way that we can turn it on via some preference file? #5620 is so unbelievably frustrating it makes me want to stop using PrusaSlicer :-(. (It would be super useful if this repo had build actions that would let you download an AppImage corresponding to a PR to allow much easier PR testing) (edit: get right bug number) |
We need to reproduce the issue first. None of us developers have this issue on Linux and the issue seems to be very rare judging from the number of people reporting it (two). @RealDeuce Is there anything special about your XFCE4 desktop configuration? |
There is nothing special about my XFCE4 configuration, but it's only triggered when I use ALT-Tab to switch windows, not when I use the mouse, and it's not triggered every time. In general, I can never rely on the keyboard to behave in any predictable way in PrusaSlicer, mostly because the 3D view will eat focus any time the cursor comes close to it. I find it highly irritating, but assume that's how the developers want it. As a result, I generally lump all irritating focus behaviours together with that and don't bother reporting them. The only reason I bothered reporting this is because someone else was impacted such that PrusaSlicer was made unusable and I happened to have fixed it in my copy. If I thought it was helpful, I'm sure I could get dozens of people to pile on and chime in with a nonhelpful "me too" on this issue, but we generally just accept that the Slic3r fork interfaces behave in strange ways and live with it. |
@RealDeuce PrusaSlicer relies on wxWidgets toolkit providing the "Activate" callback, we are not doing anything special. PrusaSlicer only moves focus inside PrusaSlicer main window if the main window gets activated. Nothing rotten here if you ask me. We need to reproduce and then to debug and dig around. |
I actually keep a local branch with every call to SetFocus() removed so I can check if any specific focus weirdness is explicitly desired by the developers. With that branch, ALT-Tab works every time, and moving the mouse over the platter does not take focus away from the input box. In every case of focus weirdness that's irritated me, it's been due to a call to SetFocus() in the code indicating that it's explicitly what the developer wanted to happen. Except in this specific case where the focus change happens when the PrusaSlicer app doesn't have focus at all (due to being delayed), it's clearly by design and just because I find something irritating doesn't make it a bug. It's certainly not "rotten", it's just irritating to me personally, and is just a known quirk of using Slic3r forks... as someone said in chat when I asked if anyone else had focus weirdness "Yeah that's a thing, and has been for as long as I've been using SS. I just assumed that's how it works and kept that in mind." |
@bubnikv I am using Ubuntu 20.04 with the Windowmaker window manager, with the input focus mode in the WPrefs app to focus follows mouse. My PC is several years old. It sounds like CallAfter is doing some asynchronous call and perhaps is susceptible to timing issues? |
@bubnikv I was easily able to reproduce the problem in a fresh VirtualBox VM. Setup:
Example 1:
Example 2:
Example 3:
(I also tested the 2.4.0-beta2 appimage and got the same result) (edit: Actually, focus-follows-mouse doesn't seem to be needed for these above examples - they still give problems if I revert the WPrefs setting back to click to focus) |
Would you please test the current master? |
Can someone please make a build for me to try? I tried building myself off master following the linux build instructions and it fails with:
|
https://prusaslicer:slicer@slicerbuilds.prusa3d.com/files/PrusaSlicer-2.4.0-beta2+94-linux-x64-gfdc4ee7-202112040013.AppImage You may want to enter user name "prusaslicer" password "slicer" if a login window opens. |
I have tried both the regular and GTK3 AppImage builds and they both seem to be working perfectly so far for me! Thanks @bubnikv! |
@Lenbok Thanks for testing. I just hope that the fix did not break anyone's workflow. |
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.
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.