# FVWM-Crystal: Fullscreen
# Written by: Dominique Michel 2008-2020
# <dominique_libre@users.sourceforge.net>
# replace the Fullscreen functions written when fvwm did not have native Fs support.
# but now (2019) fvwm have that support, so rewrite things around.
#
# How to use:
# Bind "Fullscreen" command somewhere, example:
#
# 	Key KP_Multiply		A $[Mod1] Fullscreen
#
# Disappear overview
# When using this function, Fvwm-Crystal will cycle through all the fullscreened
# windows and the workbench on the current page.
# To use it, bind "Disappear" command somewhere.
#
# 	Key KP_Multiply		A $[Mod2] Disappear
#
# The other window size functions are into Window-Buttons.

# Fullscreen functions {{{1
# "State 4" is used by Icon-Thumbnails.
# Browser Workaround: We need a wrapper for the "modern" browser windows, because we want fvwm-crystal
#     Fullscreen function to have a higher priority than the browwser F11 key or FS video mode.
#     We use "State 6" for that. We must insure 2 conditions:
#       1) When a browser window is put in FS by fvwm-crysstal, it must remain in that state or visualy fake this behavior.
#       2) It must be no screen flickering when the browser interfere with "Maximize Fullscreen". For that,
#          we need to manage the title bar and borders with State 6.
# Some other software begun to use the F11 fulscreen mode, so we generalize that workaround to all wwindows,
# which anyway is simpler to do and imply less maintenancee, than to test each individual software window.

# Fullscreen {{{1
# TODO: system to add windows we do not want in Fullscreen
# ex: firefox download window: 	Name: Bibliothèque
#				Icon Name: Bibliothèque
#				Class: firefox
#				Resource: Places
# => variable with preference
# also used down in Fullscreen-Rearrange
DestroyFunc Fullscreen
AddToFunc Fullscreen
+ I ThisWindow (!FvwmButtons, !FvwmPager, !FvwmMiniConsoleNeedsUniqueName, !QuakeConsoleNeedsUniqueName, !FvwmIconMan, !Places, !MPlayer) ToggleFullscreen

DestroyFunc PutInFSProp
AddToFunc PutInFSProp
+ I WindowStyle !Borders, !Title
+ I UpdateStyles
+ I State 6 True
+ I Maximize FullScreen True

DestroyFunc PutOutFSProp
AddToFunc PutOutFSProp
+ I WindowStyle Borders, Title
+ I UpdateStyles
+ I State 6 False
+ I Maximize FullScreen False

DestroyFunc ToggleFullscreen
AddToFunc ToggleFullscreen
+ I ThisWindow (State 6) PutOutFSProp
+ I TestRc (NoMatch) PutInFSProp

# Disapear functions {{{1
DestroyFunc Disappear
AddToFunc Disappear
+ I Next (CurrentPage, State 6, Iconic) Disappear-Off
+ I TestRc (NoMatch) All (CurrentPage, State 6) Disappear-On

DestroyFunc Disappear-On
AddToFunc Disappear-On
+ I WindowStyle NoIcon
+ I UpdateStyles
+ I Iconify true

DestroyFunc Disappear-Off
AddToFunc Disappear-Off
+ I Iconify false
+ I WindowStyle Icon
+ I UpdateStyles

# Rearrange in fullscreen {{{1
DestroyFunc Fullscreen-Rearrange
AddToFunc Fullscreen-Rearrange
+ I All (CurrentPage, !Iconic, !FvwmButtons, !FvwmPager, !FvwmMiniConsoleNeedsUniqueName, !QuakeConsoleNeedsUniqueName, !FvwmIconMan, !Places, !MPlayer) ToggleFullscreen

# Start in full screen at application statup {{{1
# Generate the Window-AutoFS function from the user preferences:
PipeRead '$[FVWM_SYSTEMDIR]/scripts/FSApps'

# Event {{{2
DestroyModuleConfig FvwmEvent-Window-Fullscreen-Auto: *
*FvwmEvent-Window-FullScreen-Auto: PassId
*FvwmEvent-Window-FullScreen-Auto: add_window Window-AutoFS
Module FvwmEvent FvwmEvent-Window-Fullscreen-Auto

# vim:ft=fvwm
