From a69127756f609a9c10db7f2693e96079bb1c3a63 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 28 Mar 2015 21:16:03 +0100 Subject: add get_event_mask and get_override_redirect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/x.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/x.py b/src/x.py index da8c0f6..300bb06 100644 --- a/src/x.py +++ b/src/x.py @@ -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] -- cgit v1.2.3-70-g09d2