public
Description: A dynamic, hackable window manager written in Python
Homepage: http://incise.org/whimsy.html
Clone URL: git://github.com/mackstann/whimsy.git
mackstann (author)
Wed Dec 17 00:45:49 -0800 2008
commit  2c742ca6b26b35670a2e7df4d65ddfc4af985065
tree    c805c40f131a6b250c9d0445e03a697cb441f0c3
parent  9079b0e248731161d341555d2e43effeabd90e0b
whimsy / whimsy / base_config.py
100644 101 lines (76 sloc) 3.069 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Written by Nick Welch in the years 2005-2008. Author disclaims copyright.
 
from Xlib import X
 
from whimsy import main
from whimsy.actions import ewmh
from whimsy.actions.builtins import *
from whimsy.actions.transformers import *
from whimsy.actions.event_handling import *
from whimsy.actions.flipping import *
from whimsy.filters.bindings import *
from whimsy.filters import *
from whimsy.x11.modifiers import modifier_mask, modifier_core
 
app = main.main()
dpy = app.dpy
hub = app.hub
wm = app.wm
xec = app.xec
ticker = app.ticker
 
modcore = modifier_core(dpy)
 
makemod = lambda raw_modifier: modifier_mask(modcore, raw_modifier)
 
Any = makemod(X.AnyModifier)
 
M1 = Mod1 = makemod(X.Mod1Mask)
M2 = Mod2 = makemod(X.Mod2Mask)
M3 = Mod3 = makemod(X.Mod3Mask)
M4 = Mod4 = makemod(X.Mod4Mask)
M5 = Mod5 = makemod(X.Mod5Mask)
 
S = Shift = makemod(X.ShiftMask)
C = Control = makemod(X.ControlMask)
 
A = Alt = Mod1
 
Button1Mask = makemod(X.Button1Mask)
Button2Mask = makemod(X.Button2Mask)
Button3Mask = makemod(X.Button3Mask)
Button4Mask = makemod(X.Button4Mask)
Button5Mask = makemod(X.Button5Mask)
ButtonMask = Button1Mask+Button2Mask+Button3Mask+Button4Mask+Button5Mask
 
root_geometry = app.wm.root.get_geometry()
W = root_geometry.width
H = root_geometry.height
 
ewmh.net_supported(hub, wm)
ewmh.net_supporting_wm_check(hub, wm)
ewmh.net_number_of_desktops(hub, wm)
ewmh.net_current_desktop(hub, wm)
ewmh.net_desktop_geometry(hub, wm)
ewmh.net_client_list(hub, wm)
ewmh.net_client_list_stacking(hub, wm)
ewmh.net_desktop_viewport(hub, wm)
ewmh.net_desktop_names(hub, wm)
ewmh.net_active_window(hub, wm)
ewmh.net_wm_strut_partial(hub, wm)
 
chains = [
    ('wm_manage_after', discover_existing_windows()),
 
    ('existing_window_discovered', if_should_manage_existing_window,
                                   lambda wm, win, **kw: wm.manage_window(win)),
 
    ('map_request', if_unmanaged,
                    if_should_manage_new_window,
                    lambda wm, win, **kw: wm.manage_window(win)),
 
    ('map_request', if_client, client_method('focus')),
    ('enter_notify', if_client, client_method('focus')),
 
    #('enter_notify', if_root, lambda wm, **kw: wm.focus_root()),
 
    ('destroy_notify', if_client, unmanage_window()),
    ('unmap_notify', if_client, unmanage_window()),
    ('focus_in', if_client, update_client_list_focus()),
    ('property_notify', if_client, update_client_property()),
 
    ('destroy_notify', focus_last_focused()),
    ('colormap_notify', install_colormap()),
    ('configure_request', configure_request_handler()), # rename this function
 
    ('client_init_after', client_method('configure', border_width=0)),
    ('client_init_after', ewmh.confine_window_to_workarea),
    ('client_init_after', client_method('map_normal')),
 
    ('workarea_changed', ewmh.confine_to_workarea),
    ('after_viewport_move', ewmh.confine_to_workarea),
 
    ('client_message', ewmh.handle_client_message),
]
 
for chaininfo in chains:
    name = chaininfo[0]
    chain = chaininfo[1:]
    hub.attach(name, *chain)