diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-03-28 21:16:03 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-03-28 21:16:03 +0100 |
commit | a69127756f609a9c10db7f2693e96079bb1c3a63 (patch) | |
tree | c3d470d79a1225a229983c6fc998e75ace1573f7 /src | |
parent | add sprintf and colour_aware_len (diff) | |
download | xpybar-a69127756f609a9c10db7f2693e96079bb1c3a63.tar.gz xpybar-a69127756f609a9c10db7f2693e96079bb1c3a63.tar.bz2 xpybar-a69127756f609a9c10db7f2693e96079bb1c3a63.tar.xz |
add get_event_mask and get_override_redirect
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/x.py | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -98,6 +98,31 @@ def get_screen(): return screen +def get_event_mask(): + ''' + For `create_panel`, return which events should be caught + + @return :int Mask of events that should be caught + ''' + return (Xlib.X.StructureNotifyMask | + Xlib.X.ButtonPressMask | + Xlib.X.ButtonReleaseMask | + Xlib.X.ExposureMask) + + +def get_override_redirect(): + ''' + For `create_panel`, figure out whether override_redirect should be set + + @return :bool Whether override_redirect should be set + ''' + if 'DESKTOP_SESSION' in os.environ: + desktop = os.environ['DESKTOP_SESSION'] + if desktop in ('xmonad',): + return False + return True + + def create_panel(width, height, left, ypos, panel_height, at_top): ''' Create a docked panel, not mapped yet @@ -116,14 +141,9 @@ def create_panel(width, height, left, ypos, panel_height, at_top): Xlib.X.CopyFromParent, Xlib.X.InputOutput, Xlib.X.CopyFromParent, - event_mask = ( - Xlib.X.StructureNotifyMask | - Xlib.X.ButtonPressMask | - Xlib.X.ButtonReleaseMask | - Xlib.X.ExposureMask - ), + event_mask = get_event_mask(), colormap = Xlib.X.CopyFromParent, - override_redirect = True) + override_redirect = get_override_redirect()) top_ = lambda x, y, w, h : [0, 0, y + h, 0, 0, 0, 0, 0, x, x + w, 0, 0] bottom_ = lambda x, y, w, h : [0, 0, 0, y + h, 0, 0, 0, 0, 0, 0, x, x + w] |