I stumbled upon this while working with Juce 8.0.7, on Windows 11 Pro 24H2
This issue occurs when you Alt-Tab back to the main window after focus was lost by clicking outside it, while a popup menu hovered by the mouse was still open.
A mouseDown event is then systematically triggered on the main window, followed by mouseDrags, not followed by any mouseUp until the next user click input.
Below is a gif of the issue reproduced with Projuicer, Juce v8.0.8, built 2 jun 2025.
As you can see, drop downs are triggered instantly when alt-tabbing back into the window despite no user click input, with some visible highlight issues.
Now on windows with no native titlebars, this can cause some more harmful behavior (such as the window sticking to the mouse, even if full screen was activated)
A workaround for us was to modify ComponentPeer::globalFocusChanged(…) to include a call to getNativeRealtimeModifiers().
But this is far from perfect, as globalFocusChanged is called kinda late, thus leaving half a second of the bug occurring anyway.
This feels like a regression, since we started to notice it only after updating to Juce 8.
Thanks in advance for taking a look!
I’ve pushed an update to the develop branch that’s intended to address this issue. Please try it out and let us know if you encounter any further problems.
Hi reuk, thanks for your work on the issue.
Indeed the Window in its windowed state doesn’t follow the cursor anymore when focus was lost while a popup menu was active.
Unfortunately even with this fix I succeeded at reproducing the buggy mouseDown event when alt tabbing into the window. Below a gif of the comportment that I hope is more explicit than in my first post
As you can see, if my mouse hover the top bar when I alt-tab, it grabs it even if i didn’t click my rmb. This is the comportment that i reproduced in my first gif in the projucer
For reference, here’s a second gif of the issue occurring when I alt-tab back into the software while another window was on top of it :
Note that the bug is limited in time thanks to the workaround that I explicated in my first post
I don’t want to overcomplicate this report, but I believe there’s a closely related issue that could be linked :
When clicking to resize the window while a popup menu was open, the window also sticks to the cursor. Note that I don’t reproduce this one in the Projucer, so take it with a grain of salt
Let me know if you need further information
Thanks again
Sorry about that, it looks like I missed that case in testing. I can repro this in the case that the mouse is over the titlebar immediately after alt-tabbing.
So far I’ve not been able to repro this. I tried testing with the MenusDemo, both with a native and non-native titlebar. Perhaps this is related in some way to your custom window decorations. Are you using a subclass of TopLevelWindow, or are you just calling addToDesktop on your own Component subclass? I note in the final recording that the window doesn’t seem to have a system-provided drop shadow, which suggests you’re using your own top-level window type.
Edit: I’ve managed to repro something similar to the second issue, but not very consistently, and I’m not sure what causes it yet.
I’ve had another go at addressing these issues. Please could you try applying the attached patch and see whether it fixes the problems you’ve been seeing? Thanks!