Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to 'suspend' fullscreen mode?  (Read 3439 times)

0 Members and 1 Guest are viewing this topic.

rtlprmft

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
How to 'suspend' fullscreen mode?
« 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to 'suspend' fullscreen mode?
« Reply #1 on: May 13, 2024, 11:07:41 pm »
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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: How to 'suspend' fullscreen mode?
« Reply #2 on: May 14, 2024, 08:00:08 am »
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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

rtlprmft

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: How to 'suspend' fullscreen mode?
« Reply #3 on: May 14, 2024, 10:42:05 am »
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.

 

anything