diff --git a/alternative_wmiircs/python/pygmi/event.py b/alternative_wmiircs/python/pygmi/event.py index 0f367dd9..8e2e0139 100644 --- 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 index cc088c45..d252d4a1 100644 --- 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 index 41581c6f..feebe24d 100644 --- a/cmd/tray/dat.h +++ b/cmd/tray/dat.h @@ -6,6 +6,7 @@ #include #include #include +#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 index 0cf9b3ef..7f3614df 100644 --- 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 index 090ee90f..9cbce8b1 100644 --- 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
] [-NESW] [-HV] [-p ] [-s ] [-t tags]\n" + fprint(2, "usage: %s [-a
] [-NESW] [-HVn] [-p ] [-s ] [-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 index 32f15815..a3509825 100644 --- 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 new file mode 100644 index 00000000..944836ee --- /dev/null +++ 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 index 351f3472..a8dac897 100644 --- 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 Sets the padding between icons and around the edge of the tray. In pixels.