wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 7eb2bef1bdb5e96516cd0541372014d757f498f5
parent 67cb8d196e4a07de2e2c3d14cb3907bcc67a2636
Author: Kris Maglione <kris@suckless.org>
Date:   Mon, 19 Sep 2011 20:24:32 -0400

Add -n flag to witray to opt out of replacing existing systray.

Diffstat:
alternative_wmiircs/python/pygmi/event.py | 5++++-
alternative_wmiircs/python/pyxp/client.py | 2++
cmd/tray/dat.h | 14+-------------
cmd/tray/fns.h | 3---
cmd/tray/main.c | 9+++++++--
cmd/tray/selection.c | 6+++++-
cmd/tray/selection.h | 18++++++++++++++++++
man/witray.man1 | 3+++
8 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/alternative_wmiircs/python/pygmi/event.py b/alternative_wmiircs/python/pygmi/event.py @@ -105,7 +105,10 @@ class Events(): if ary is not None: action(*ary) except Exception, e: - traceback.print_exc(sys.stderr) + try: + traceback.print_exc(sys.stderr) + except: + pass def loop(self): """ diff --git a/alternative_wmiircs/python/pyxp/client.py b/alternative_wmiircs/python/pyxp/client.py @@ -278,6 +278,7 @@ class File(object): if offset is None: self.offset = offs return ''.join(res) + def readlines(self): last = None while True: @@ -293,6 +294,7 @@ class File(object): last = lines[-1] if last: yield last + def write(self, data, offset=None): if offset is None: offset = self.offset diff --git a/cmd/tray/dat.h b/cmd/tray/dat.h @@ -6,6 +6,7 @@ #include <ixp.h> #include <stuff/x.h> #include <stuff/util.h> +#include "selection.h" #ifndef EXTERN # define EXTERN extern @@ -25,7 +26,6 @@ enum TrayOpcodes { typedef struct Client Client; typedef struct Message Message; -typedef struct Selection Selection; typedef struct XEmbed XEmbed; struct Client { @@ -43,18 +43,6 @@ struct Message { IxpMsg msg; }; -struct Selection { - Window* owner; - char* selection; - ulong time_start; - ulong time_end; - void (*cleanup)(Selection*); - void (*message)(Selection*, XClientMessageEvent*); - void (*request)(Selection*, XSelectionRequestEvent*); - long timer; - ulong oldowner; -}; - struct XEmbed { Window* w; Window* owner; diff --git a/cmd/tray/fns.h b/cmd/tray/fns.h @@ -11,9 +11,6 @@ int main(int, char*[]); void message(Selection*, XClientMessageEvent*); void message_cancel(Client*, long); void restrut(Window*, int); -Selection* selection_create(char*, ulong, void (*)(Selection*, XSelectionRequestEvent*), void (*)(Selection*)); -Selection* selection_manage(char*, ulong, void (*)(Selection*, XClientMessageEvent*), void (*)(Selection*)); -void selection_release(Selection*); void tray_init(void); void tray_resize(Rectangle); void tray_update(void); diff --git a/cmd/tray/main.c b/cmd/tray/main.c @@ -18,7 +18,7 @@ static struct sigaction sa; static void usage(void) { - fprint(2, "usage: %s [-a <address>] [-NESW] [-HV] [-p <padding>] [-s <iconsize>] [-t tags]\n" + fprint(2, "usage: %s [-a <address>] [-NESW] [-HVn] [-p <padding>] [-s <iconsize>] [-t tags]\n" " %s -v\n", argv0, argv0); exit(1); } @@ -112,6 +112,7 @@ ErrorCode ignored_xerrors[] = { int main(int argc, char *argv[]) { static char* address; + bool steal; program_args = argv; @@ -119,6 +120,7 @@ main(int argc, char *argv[]) { fmtinstall('r', errfmt); fmtinstall('E', fmtevent); + steal = true; tray.orientation = OHorizontal; tray.tags = "/./"; tray.padding = 1; @@ -142,6 +144,9 @@ main(int argc, char *argv[]) { case 'V': tray.orientation = OVertical; break; + case 'n': + steal = false; + break; case 'p': if(!getulong(EARGF(usage()), &tray.padding)) usage(); @@ -179,7 +184,7 @@ main(int argc, char *argv[]) { event_updatextime(); tray.selection = selection_manage(sxprint(Net("SYSTEM_TRAY_S%d"), scr.screen), - event_xtime, message, cleanup); + event_xtime, message, cleanup, steal); if(tray.selection == nil) fatal("Another system tray is already running."); if(tray.selection->oldowner) diff --git a/cmd/tray/selection.c b/cmd/tray/selection.c @@ -70,12 +70,16 @@ timeout(long timer, void *v) { Selection* selection_manage(char *selection, ulong time, void (*message)(Selection*, XClientMessageEvent*), - void (*cleanup)(Selection*)) { + void (*cleanup)(Selection*), + bool steal) { Selection *s; Window *w; XWindow old; if((old = XGetSelectionOwner(display, xatom(selection)))) { + if (!steal) + return nil; + w = emallocz(sizeof *w); w->type = WWindow; w->xid = old; diff --git a/cmd/tray/selection.h b/cmd/tray/selection.h @@ -0,0 +1,18 @@ +typedef struct Selection Selection; + +struct Selection { + Window* owner; + char* selection; + ulong time_start; + ulong time_end; + void (*cleanup)(Selection*); + void (*message)(Selection*, XClientMessageEvent*); + void (*request)(Selection*, XSelectionRequestEvent*); + long timer; + ulong oldowner; +}; + +Selection* selection_create(char*, ulong, void (*)(Selection*, XSelectionRequestEvent*), void (*)(Selection*)); +Selection* selection_manage(char*, ulong, void (*)(Selection*, XClientMessageEvent*), void (*)(Selection*), bool); +void selection_release(Selection*); + diff --git a/man/witray.man1 b/man/witray.man1 @@ -38,6 +38,9 @@ to configure, and generally Just Works. Specifies whether icons are to be aligned horizontally or vertically, respectively. Also determines from which edge of the screen windows are shunted to make room for the tray. +: -n + Only create a new tray if a previous tray manager is not + already running. : -p <padding> Sets the padding between icons and around the edge of the tray. In pixels.