public
Description: A dynamic, hackable window manager written in Python
Homepage: http://incise.org/whimsy.html
Clone URL: git://github.com/mackstann/whimsy.git
don't assume events have a .window -- fixes mappingnotify problem reported by 
jek
mackstann (author)
Mon Jul 14 10:02:42 -0700 2008
commit  8f6e3350a49c710fcba72ec0362d7ca7c2a60307
tree    5458b55586ea0601b850309468a452d4c77e35e6
parent  5e0ac8fdc0e78638e57cd947c078ad37aa327a3b
...
21
22
23
 
 
 
24
25
26
27
28
29
 
 
 
 
30
...
21
22
23
24
25
26
27
28
 
 
 
 
29
30
31
32
33
0
@@ -21,10 +21,13 @@ class x_event_controller(object):
0
 
0
     def emit_next_event(self):
0
         ev = self.dpy.next_event()
0
+        kw = dict(ev=ev)
0
+        if hasattr(ev, 'window'):
0
+            kw['win'] = ev.window
0
         # the specific event name, like button_press (converted from ButtonPress)
0
         lowered = capital_letter_re.sub('_\\1', ev.__class__.__name__).lower()
0
-        self.hub.signal('event_begin', ev=ev, win=ev.window)
0
-        self.hub.signal(lowered,       ev=ev, win=ev.window)
0
-        self.hub.signal('event',       ev=ev, win=ev.window)
0
-        self.hub.signal('event_done',  ev=ev, win=ev.window)
0
+        self.hub.signal('event_begin', **kw)
0
+        self.hub.signal(lowered,       **kw)
0
+        self.hub.signal('event',       **kw)
0
+        self.hub.signal('event_done',  **kw)
0
     
...
12
13
14
15
 
16
17
18
19
20
 
21
22
 
23
24
25
26
27
 
28
29
30
...
38
39
40
41
42
 
 
43
44
45
46
 
47
48
49
...
12
13
14
 
15
16
 
 
 
 
17
18
 
19
20
 
 
 
 
21
22
23
24
...
32
33
34
 
 
35
36
37
38
39
 
40
41
42
43
0
@@ -12,19 +12,13 @@ class if_event_type(object):
0
     def __call__(self, ev, **kw):
0
         return ev.type in self.evtypes
0
 
0
-def if_client(wm, win, ev, **kw):
0
+def if_client(wm, ev, **kw):
0
     'true if the window is an application window managed by the window manager'
0
-    return (
0
-        hasattr(ev, 'window') and
0
-        util.window_type(wm, win) == 'client'
0
-    )
0
+    return 'win' in kw and util.window_type(wm, kw['win']) == 'client'
0
 
0
-def if_root(wm, win, ev, **kw):
0
+def if_root(wm, ev, **kw):
0
     'true if the window is the root window (desktop/background)'
0
-    return (
0
-        hasattr(ev, 'window') and
0
-        util.window_type(wm, win) == 'root'
0
-    )
0
+    return 'win' in kw and util.window_type(wm, kw['win']) == 'root'
0
 
0
 class if_state(object):
0
     'true if modifier (shift/control/etc) keys currently match mods'
0
@@ -38,12 +32,12 @@ class if_(object):
0
     def __init__(self, evtype, wintype=None):
0
         self.evtype = evtype
0
         self.wintype = wintype
0
-    def __call__(self, wm, win, ev, **kw):
0
-        if ev.type != self.evtype:
0
+    def __call__(self, wm, ev, **kw):
0
+        if ev.type != self.evtype or 'win' not in kw:
0
             return False
0
         if self.wintype is None:
0
             return True
0
-        return util.window_type(wm, win) == self.wintype
0
+        return util.window_type(wm, kw['win']) == self.wintype
0
 
0
 class click_counter(object):
0
     """built like an action but yields a filter which is its main purpose -- to

Comments