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 / util.py
100644 34 lines (28 sloc) 1.028 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
# Written by Nick Welch in the years 2005-2008. Author disclaims copyright.
 
from Xlib import X
import select, errno
 
def configure_request_changes(ev):
    changes = {}
    if ev.value_mask & X.CWX: changes["x"] = ev.x
    if ev.value_mask & X.CWY: changes["y"] = ev.y
    if ev.value_mask & X.CWWidth: changes["width"] = ev.width
    if ev.value_mask & X.CWHeight: changes["height"] = ev.height
    if ev.value_mask & X.CWSibling: changes["sibling"] = ev.above
    if ev.value_mask & X.CWStackMode:
        changes["stack_mode"] = ev.stack_mode
    return changes
 
def window_type(wm, window):
    if window == wm.root:
        return "root"
    elif wm.find_client(window):
        return "client"
    return "unmanaged"
 
def lenient_select(r, w, x, timeout):
    # sigchld for example will interrupt select() and cause an unhandled
    # socket.error exception.
    try:
        return select.select(r, w, x, timeout)
    except select.error, e:
        if e[0] == errno.EINTR:
            return [], [], []
        raise