changeset: 2804:ecf4c7217989
tag: tip
user: Kris Maglione <kris_AT_suckless.org>
date: Mon Sep 19 20:24:32 2011 -0400
files: alternative_wmiircs/python/pygmi/event.py alternative_wmiircs/python/pyxp/client.py cmd/tray/dat.h cmd/tray/fns.h cmd/tray/main.c cmd/tray/selection.c cmd/tray/selection.h man/witray.man1
description:
Add -n flag to witray to opt out of replacing existing systray.
diff -r 33150b2df4ae -r ecf4c7217989 alternative_wmiircs/python/pygmi/event.py
--- a/alternative_wmiircs/python/pygmi/event.py Mon Sep 19 16:49:52 2011 -0400
+++ b/alternative_wmiircs/python/pygmi/event.py Mon Sep 19 20:24:32 2011 -0400
@@ -105,7 +105,10 @@
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 -r 33150b2df4ae -r ecf4c7217989 alternative_wmiircs/python/pyxp/client.py
--- a/alternative_wmiircs/python/pyxp/client.py Mon Sep 19 16:49:52 2011 -0400
+++ b/alternative_wmiircs/python/pyxp/client.py Mon Sep 19 20:24:32 2011 -0400
@@ -278,6 +278,7 @@
if offset is None:
self.offset = offs
return ''.join(res)
+
def readlines(self):
last = None
while True:
@@ -293,6 +294,7 @@
last = lines[-1]
if last:
yield last
+
def write(self, data, offset=None):
if offset is None:
offset = self.offset
diff -r 33150b2df4ae -r ecf4c7217989 cmd/tray/dat.h
--- a/cmd/tray/dat.h Mon Sep 19 16:49:52 2011 -0400
+++ b/cmd/tray/dat.h Mon Sep 19 20:24:32 2011 -0400
@@ -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 @@
typedef struct Client Client;
typedef struct Message Message;
-typedef struct Selection Selection;
typedef struct XEmbed XEmbed;
struct Client {
@@ -43,18 +43,6 @@
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 -r 33150b2df4ae -r ecf4c7217989 cmd/tray/fns.h
--- a/cmd/tray/fns.h Mon Sep 19 16:49:52 2011 -0400
+++ b/cmd/tray/fns.h Mon Sep 19 20:24:32 2011 -0400
@@ -11,9 +11,6 @@
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 -r 33150b2df4ae -r ecf4c7217989 cmd/tray/main.c
--- a/cmd/tray/main.c Mon Sep 19 16:49:52 2011 -0400
+++ b/cmd/tray/main.c Mon Sep 19 20:24:32 2011 -0400
@@ -18,7 +18,7 @@
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 @@
int
main(int argc, char *argv[]) {
static char* address;
+ bool steal;
program_args = argv;
@@ -119,6 +120,7 @@
fmtinstall('r', errfmt);
fmtinstall('E', fmtevent);
+ steal = true;
tray.orientation = OHorizontal;
tray.tags = "/./";
tray.padding = 1;
@@ -142,6 +144,9 @@
case 'V':
tray.orientation = OVertical;
break;
+ case 'n':
+ steal = false;
+ break;
case 'p':
if(!getulong(EARGF(usage()), &tray.padding))
usage();
@@ -179,7 +184,7 @@
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 -r 33150b2df4ae -r ecf4c7217989 cmd/tray/selection.c
--- a/cmd/tray/selection.c Mon Sep 19 16:49:52 2011 -0400
+++ b/cmd/tray/selection.c Mon Sep 19 20:24:32 2011 -0400
@@ -70,12 +70,16 @@
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 -r 33150b2df4ae -r ecf4c7217989 cmd/tray/selection.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/tray/selection.h Mon Sep 19 20:24:32 2011 -0400
@@ -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 -r 33150b2df4ae -r ecf4c7217989 man/witray.man1
--- a/man/witray.man1 Mon Sep 19 16:49:52 2011 -0400
+++ b/man/witray.man1 Mon Sep 19 20:24:32 2011 -0400
@@ -38,6 +38,9 @@
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.
Received on Tue Sep 20 2011 - 02:24:39 CEST
This archive was generated by hypermail 2.2.0 : Tue Sep 20 2011 - 02:36:04 CEST