| 1 |
# FVWM-Crystal: Fullscreen |
| 2 |
# Written by: Maciej Delmanowski <[email protected]> |
| 3 |
# Modifications: Thomas Adam <[email protected]> |
| 4 |
# Bug fixes, disappear and restart functions: Dominique Michel 2008-2013 |
| 5 |
# <[email protected]> |
| 6 |
# |
| 7 |
# Fullscreen overview: |
| 8 |
# After using this function, current window will lose it's border and title |
| 9 |
# and will be maximized to the full screen (wow). After using Fullscreen |
| 10 |
# function on a "full-screened" window it will return to it's previous size and |
| 11 |
# position and border/title will be brought back. |
| 12 |
# |
| 13 |
# How to use: |
| 14 |
# Bind "Fullscreen" command somewhere, example: |
| 15 |
# |
| 16 |
# Key KP_Multiply A $[Mod1] Fullscreen |
| 17 |
# |
| 18 |
# Disappear overview |
| 19 |
# When using this function, Fvwm-Crystal will cycle through all the fullscreened |
| 20 |
# windows and the workbench on the current page. |
| 21 |
# To use it, bind "Disappear" command somewhere. |
| 22 |
# |
| 23 |
# Key KP_Multiply A $[Mod2] Disappear |
| 24 |
# |
| 25 |
# The other window size functions are into Window-Buttons. |
| 26 |
# |
| 27 |
# 'Fullscreen-Start' and 'Fullscreen-Stop' functions shouldn't be called |
| 28 |
# directly, use 'Fullscreen' function instead. |
| 29 |
# 'Disappear-On' and 'Disappear-Off' functions shouldn't be called |
| 30 |
# directly, use 'Disappear' function instead. |
| 31 |
# |
| 32 |
# Know bugs, limitations: |
| 33 |
# - some terminals and gvim does not scale properly in full-screen. This is because |
| 34 |
# they use characters instead of pixels to adjust their width. |
| 35 |
# Sometime, it work well the second time you put the window in full screen. |
| 36 |
# It also depend on the terminal's font and the screnn's width. |
| 37 |
# - tell me how I can get the State attributes in the FS function to work |
| 38 |
# after a Restart, or provide a patch. that in order to get ride of |
| 39 |
# the temporary files. |
| 40 |
|
| 41 |
InfoStoreAdd TmpDirectory "/tmp" |
| 42 |
|
| 43 |
# Wrapper function {{{1 |
| 44 |
# State 19 = FS (fullscreen), State 20 = visible |
| 45 |
DestroyFunc Fullscreen |
| 46 |
AddToFunc Fullscreen |
| 47 |
+ I ThisWindow (State 19, !FvwmButtons, !FvwmPager, !FvwmMiniConsoleNeedsUniqueName, !QuakeConsoleNeedsUniqueName, !FvwmIconMan, !MPlayer) Fullscreen-Stop |
| 48 |
+ I TestRc (NoMatch) ThisWindow (!State 19, !FvwmButtons, !FvwmPager, !FvwmMiniConsoleNeedsUniqueName, !QuakeConsoleNeedsUniqueName, !FvwmIconMan, !MPlayer) Fullscreen-Start |
| 49 |
|
| 50 |
# fullscreen {{{2 |
| 51 |
DestroyFunc Fullscreen-Start |
| 52 |
AddToFunc Fullscreen-Start |
| 53 |
+ I WindowStyle !Title, !Borders, !Handles, Iconifiable, ResizeHintOverride |
| 54 |
+ I UpdateStyles |
| 55 |
+ I WindowStyle State 19 |
| 56 |
+ I WindowStyle State 20 |
| 57 |
+ I Maximize ewmhiwa True 100 100 |
| 58 |
+ I WindowStyle !Maximizable, FixedSize, FixedPosition |
| 59 |
+ I UpdateStyles |
| 60 |
# We need 1 temporary file for restoring the window state after restart |
| 61 |
+ I Exec exec touch $[infostore.TmpDirectory]/fullscreen.19.$[w.id].$[page.nx].$[page.ny].tmp |
| 62 |
|
| 63 |
# quit fullscreen {{{2 |
| 64 |
DestroyFunc Fullscreen-Stop |
| 65 |
AddToFunc Fullscreen-Stop |
| 66 |
+ I WindowStyle Title, Borders, Handles, HandleWidth $[infostore.handle_width], Iconifiable, !ResizeHintOverride |
| 67 |
+ I WindowStyle Maximizable, !FixedSize, !FixedPosition |
| 68 |
+ I WindowStyle !State 19 |
| 69 |
+ I WindowStyle !State 20 |
| 70 |
+ I Test (f $[infostore.TmpDirectory]/fullscreen.19.$[w.id].$[page.nx].$[page.ny].tmp) Exec exec rm -f $[infostore.TmpDirectory]/fullscreen.19.$[w.id].$[page.nx].$[page.ny].tmp |
| 71 |
+ I UpdateStyles |
| 72 |
+ I NS-Default |
| 73 |
|
| 74 |
# Wrapper function {{{1 |
| 75 |
DestroyFunc Disappear |
| 76 |
AddToFunc Disappear |
| 77 |
# if FS; then if !State20; then show; else hide all; fi |
| 78 |
+ I PipeRead 'if [ "$(ls $[infostore.TmpDirectory]/fullscreen.19.0x?*.$[page.nx].$[page.ny].tmp 2>/dev/null)" != "" ]; then \ |
| 79 |
for i in $(ls $[infostore.TmpDirectory]/fullscreen.19.0x?*.$[page.nx].$[page.ny].tmp 2>/dev/null); \ |
| 80 |
do file=`echo "${i}"|sed -e \'s:fullscreen.19:fullscreen.20:\'`; \ |
| 81 |
if [ -e "${file}" ]; then echo "WindowId $(echo $file | cut -d . -f 3) Disappear-Off"; exit; \ |
| 82 |
fi; \ |
| 83 |
done; \ |
| 84 |
for i in $(ls $[infostore.TmpDirectory]/fullscreen.19.0x?*.$[page.nx].$[page.ny].tmp 2>/dev/null); \ |
| 85 |
do echo "WindowId $(echo $i | cut -d . -f 3) Disappear-On"; done; fi' |
| 86 |
|
| 87 |
# disappear {{{2 |
| 88 |
# file tmp_dir/fuulscreen.20.* = hidden |
| 89 |
DestroyFunc Disappear-On |
| 90 |
AddToFunc Disappear-On |
| 91 |
# Those 2 lines are needed if we want to cycle onto the windows original pages |
| 92 |
+ I WarpToWindow $[pointer.x]p $[pointer.y]p |
| 93 |
+ I Exec exec touch $[infostore.TmpDirectory]/fullscreen.20.$[w.id].$[page.nx].$[page.ny].tmp |
| 94 |
+ I WindowStyle !State 20 |
| 95 |
+ I WindowStyle NoIcon |
| 96 |
+ I UpdateStyles |
| 97 |
+ I Iconify true |
| 98 |
|
| 99 |
# appear {{{2 |
| 100 |
DestroyFunc Disappear-Off |
| 101 |
AddToFunc Disappear-Off |
| 102 |
+ I ThisWindow MoveToPage $[page.nx] 0 |
| 103 |
+ I Iconify false |
| 104 |
+ I WindowStyle State 20 |
| 105 |
+ I WindowStyle Icon |
| 106 |
+ I UpdateStyles |
| 107 |
+ I Test (f $[infostore.TmpDirectory]/fullscreen.20.$[w.id].$[page.nx].$[page.ny].tmp) Exec exec rm -f $[infostore.TmpDirectory]/fullscreen.20.$[w.id].$[page.nx].$[page.ny].tmp |
| 108 |
|
| 109 |
# Restore Fullscreen after restart {{{1 |
| 110 |
# Called by StartFunction |
| 111 |
DestroyFunc Fullscreen-Recover |
| 112 |
AddToFunc Fullscreen-Recover |
| 113 |
+ I WindowStyle !Title, !Borders, !Handles, Iconifiable, ResizeHintOverride |
| 114 |
+ I UpdateStyles |
| 115 |
+ I WindowStyle State 19 |
| 116 |
+ I WindowStyle State 20 |
| 117 |
+ I Maximize ewmhiwa True 100 100 |
| 118 |
+ I WindowStyle !Maximizable, FixedSize |
| 119 |
+ I UpdateStyles |
| 120 |
|
| 121 |
DestroyFunc Disappear-Recover |
| 122 |
AddToFunc Disappear-Recover |
| 123 |
+ I WindowStyle !State 20 |
| 124 |
+ I WindowStyle NoIcon |
| 125 |
+ I UpdateStyles |
| 126 |
+ I Iconify true |
| 127 |
|
| 128 |
DestroyFunc Disappear-Test |
| 129 |
AddToFunc Disappear-Test |
| 130 |
+ I Test (F $[infostore.TmpDirectory]/fullscreen.20.$[w.id].$[page.nx].$[page.ny].tmp) WindowId $[w.id] Disappear-Recover |
| 131 |
|
| 132 |
# wrapper {{{2 |
| 133 |
DestroyFunc RecoverFullscreen |
| 134 |
AddToFunc RecoverFullscreen |
| 135 |
PipeRead 'for i in $[infostore.TmpDirectory]/fullscreen.19.*; do wid=`basename "$i" | awk --field-separator . \'{print $$3}\'`; echo "+ I WindowId ${wid} Fullscreen-Recover"; done' |
| 136 |
PipeRead "for i in $[infostore.TmpDirectory]/fullscreen.20.*; do wid=`basename $i | awk --field-separator . '{print $$3}'`; echo \"+ I WindowId ${wid} Disappear-Recover\"; done" |
| 137 |
|
| 138 |
AddToFunc StartFunction I Schedule 1000 RecoverFullscreen |
| 139 |
|
| 140 |
AddToFunc ExitFunction I Test (!ToRestart) Exec rm -f $[infostore.TmpDirectory]/fullscreen.19.* |
| 141 |
AddToFunc ExitFunction I Test (!ToRestart) Exec rm -f $[infostore.TmpDirectory]/fullscreen.20.* |
| 142 |
AddToFunc ExitFunction I Test (Quit) Exec rm -f $[infostore.TmpDirectory]/fullscreen.* |
| 143 |
|
| 144 |
# Be sure the temporary files are destroyed when a window is closed |
| 145 |
DestroyFunc Window-Fullscreen-Destroy |
| 146 |
AddToFunc Window-Fullscreen-Destroy |
| 147 |
+ i PipeRead 'for file in /tmp/fullscreen.??.$[w.id].?.?.tmp; do rm $file 2>/dev/null; done' |
| 148 |
|
| 149 |
DestroyModuleConfig FvwmEvent-Window-Fullscreen-Destroy: * |
| 150 |
*FvwmEvent-Window-FullScreen-Destroy: destroy_window Window-Fullscreen-Destroy |
| 151 |
Module FvwmEvent FvwmEvent-Window-Fullscreen-Destroy |
| 152 |
|
| 153 |
# Rearrange in fullscreen |
| 154 |
DestroyFunc Fullscreen-Rearrange |
| 155 |
AddToFunc Fullscreen-Rearrange |
| 156 |
+ I All (CurrentPage, !Iconic, !FvwmButtons, !FvwmPager, !FvwmConsoleNeedsUniqueName, !QuakeConsoleNeedsUniqueName, !FvwmIconMan, !MPlayer) Fullscreen |
| 157 |
|
| 158 |
# Start in full screen at application statup |
| 159 |
DestroyFunc Window-AutoFS |
| 160 |
AddToFunc Window-AutoFS |
| 161 |
PipeRead '$[FVWM_SYSTEMDIR]/scripts/FSApps' |
| 162 |
|
| 163 |
DestroyModuleConfig FvwmEvent-Window-Fullscreen-Auto: * |
| 164 |
*FvwmEvent-Window-FullScreen-Auto: add_window Window-AutoFS |
| 165 |
Module FvwmEvent FvwmEvent-Window-Fullscreen-Auto |
| 166 |
|
| 167 |
# vim:ft=fvwm |