mirror of
https://github.com/0intro/wmii
synced 2024-11-21 13:22:51 +03:00
Add -n flag to witray to opt out of replacing existing systray.
This commit is contained in:
parent
67cb8d196e
commit
7eb2bef1bd
@ -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):
|
||||
"""
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
18
cmd/tray/selection.h
Normal file
18
cmd/tray/selection.h
Normal file
@ -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*);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user