SFML community forums
Help => Window => Topic started by: rtlprmft on May 13, 2024, 08:35:32 pm
-
I have switched my SFML window to fullscreen mode (desktop resolution). If, for example, I switch application (Alt-Tab), my application is still visible in the background, but the window of the new application overlays it and is usable. Now instead of switching away, I want to switch to a gkt2 window (gtk native file dialog) from my SFML application. The gtk2 window is properly displayed and I can use the keyboard to interact with it, however, it does not see any mouse events. This make a file selection dialog quite unusable. The most obvious solution is to switch back to windowed mode, but this seem a lot of code for not real purpose. Instead, I would prefer to have an option to "suspend" fullscreen mode properly, either (like in the alt-tab case) with my application still in the background or by minimizing my application until the modal gtk2 dialog has finished. I tried to use setVisible(false), but the only difference is that now the task-bar overlaps the SFML application graphics in the background - but there is still no mouse event passed through to the gtk2 dialog window.
I read in the docs, that in fullscreen the mouse is always grabbed. I assume that this is what interferes here. So if there is no way to minimize a fullscreen window (setVisible(false)), maybe there could be a way to suspend mouse grabbing in fullscreen mode. Using setMouseCursorGrabbed(false) obviously won't work, because it is ignored in fullscreen mode.
-
Have you tried using the Lost Focus event?
https://www.sfml-dev.org/documentation/2.6.1/classsf_1_1Event.php#af41fa9ed45c02449030699f671331d4aabd7877b5011a337268357c973e8347bd
I would expect alt-tabbing to a different window would cause the original window to lose focus so this event should be received. You could reform the window as a normal window without fullscreen or hide it. You could also create a new window (or reuse the main one if you'd like) to allow access back or even should a smaller version of the main fullscreen window!
The opposite event, Gained Focus, could also be used when alt-tabbing back (or just clicking on the window) where you could then un-hide the full window (or reform it again if needed).
-
What OS and window manager do you use?
SFML doesn't seem to handle alt-tabbing from fullscreen very well, see also https://github.com/SFML/SFML/issues/306
-
Thanks for the reply. I am using Ubuntu 22.04 with KDE Plasma 5 and Qt 5 on X11.
I actually have another strange problem with the mouse. I use a hotkey to enable mouse grabbing and make it invisible, and the another hot key to release mouse grabbing and make it visible again. Turning this feature (invisible/grabbed) on and off works perfectly when used the first time. The second time I turn it on, the mouse becomes invisible but is not grabbed (so moves visibly out of the window once the window border is crossed, although invisible in the window).
I have tried many different ways to solve that (different order of the calls to setVisible and setMouseCursorGrabbed), doing it in Gained-/LostFocus instead of the hotkey handler. The only thing that made the mousegrab feature work again, was to minimize the window in between turning it off an on again.
I am mentioning that because it might be related.