I want to be able to detect if my app has been set to fullscreen by the user. I know I can use the gtk.window.fullscreen()
method to make the window go fullscreen from the code, and the the action also emits a window-state-event signal, but when I wrote the callback I had no way of distinguishing between when the event was activated by a fullscreen request or by a different event like for example minimizing the window to the start bar. How can I detect whether the window has been changed to full screen?
You just need to check the event details.
changed_mask
.new_window_state
.Usually this translates into the following code:
# Did the user actually toggle fullscreen, or was it
# a different window-state event (e.g. maximize)?
if event.changed_mask & gtk.gdk.WINDOW_STATE_FULLSCREEN:
# What's the new state?
print bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN)