]> git.decadent.org.uk Git - ion3.git/blob - debian/cfg_kludge_flash.lua
54fca80aa219f62e44b06ff9425daa73dd06eb21
[ion3.git] / debian / cfg_kludge_flash.lua
1 -- Flash player opens full-screen windows from Firefox with size
2 -- request 200x200.  It closes them if they lose focus, but also if
3 -- they get focus too quickly.  Therefore set focus 200 ms after
4 -- such a window is mapped (this may need to be adjusted on slower
5 -- computers).
6
7 _NET_WM_STATE = ioncore.x_intern_atom('_NET_WM_STATE', false)
8 _NET_WM_STATE_FULLSCREEN = ioncore.x_intern_atom('_NET_WM_STATE_FULLSCREEN',
9                                                  false)
10
11 function is_fullscreen(cwin)
12     local state = ioncore.x_get_window_property(cwin:xid(), _NET_WM_STATE, 4,
13                                                 1, true)
14     if state then
15         for k, v in pairs(state) do
16             if v == _NET_WM_STATE_FULLSCREEN then
17                 return true
18             end
19         end
20     end
21     return false
22 end
23
24 defwinprop {
25     class = 'Firefox-bin',
26     match = function(prop, cwin, id)
27                 local geom = cwin:geom()
28                 return is_fullscreen(cwin) and geom.w == 200 and geom.h == 200
29             end,
30     switchto = false,
31     flash_fullscreen = true,
32 }
33
34 ioncore.get_hook('clientwin_do_manage_alt'):add(
35     function(cwin, table)
36         local winprop = ioncore.getwinprop(cwin)
37         if winprop and winprop.flash_fullscreen then
38             local timer = ioncore.create_timer()
39             timer:set(200, function() cwin:goto() end)
40             return true
41         else
42             return false
43         end
44     end
45 )