tweak formatting
This commit is contained in:
parent
1af2175f2e
commit
b0fb6654c8
14 changed files with 1214 additions and 735 deletions
|
@ -3,11 +3,12 @@ IndentWidth: 2
|
||||||
ContinuationIndentWidth: 2
|
ContinuationIndentWidth: 2
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
AllowShortBlocksOnASingleLine: Always
|
AllowShortBlocksOnASingleLine: Always
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortEnumsOnASingleLine: true
|
AllowShortEnumsOnASingleLine: true
|
||||||
AllowShortIfStatementsOnASingleLine: true
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
AllowShortLoopsOnASingleLine: true
|
AllowShortLoopsOnASingleLine: false
|
||||||
AlwaysBreakAfterDefinitionReturnType: TopLevel
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 255
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
AlignAfterOpenBracket: AlwaysBreak
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
@ -16,3 +17,7 @@ BinPackArguments: false
|
||||||
PointerAlignment: Left
|
PointerAlignment: Left
|
||||||
BreakBeforeBraces: Attach
|
BreakBeforeBraces: Attach
|
||||||
SortIncludes: false
|
SortIncludes: false
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
|
||||||
|
|
124
client.c
124
client.c
|
@ -13,11 +13,11 @@
|
||||||
Client* clients;
|
Client* clients;
|
||||||
Client* current;
|
Client* current;
|
||||||
|
|
||||||
void
|
void setactive(Client* c, int on) {
|
||||||
setactive(Client* c, int on) {
|
|
||||||
/* dbg("setactive client %x %d", c->window, c->on); */
|
/* dbg("setactive client %x %d", c->window, c->on); */
|
||||||
|
|
||||||
if (c->parent == c->screen->root) return;
|
if (c->parent == c->screen->root)
|
||||||
|
return;
|
||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
XUngrabButton(dpy, AnyButton, AnyModifier, c->parent);
|
XUngrabButton(dpy, AnyButton, AnyModifier, c->parent);
|
||||||
|
@ -43,8 +43,7 @@ setactive(Client* c, int on) {
|
||||||
draw_border(c, on);
|
draw_border(c, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void draw_border(Client* c, int active) {
|
||||||
draw_border(Client* c, int active) {
|
|
||||||
unsigned long pixel;
|
unsigned long pixel;
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
|
@ -71,35 +70,39 @@ draw_border(Client* c, int active) {
|
||||||
XClearWindow(dpy, c->parent);
|
XClearWindow(dpy, c->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void active(Client* c) {
|
||||||
active(Client* c) {
|
|
||||||
Client* cc;
|
Client* cc;
|
||||||
|
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
fprintf(stderr, "ryudo: active(c==0)\n");
|
fprintf(stderr, "ryudo: active(c==0)\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c == current) return;
|
if (c == current)
|
||||||
|
return;
|
||||||
#ifdef AUTOSTICK
|
#ifdef AUTOSTICK
|
||||||
if (isautostick(c)) return;
|
if (isautostick(c))
|
||||||
|
return;
|
||||||
#endif
|
#endif
|
||||||
if (current) {
|
if (current) {
|
||||||
setactive(current, 0);
|
setactive(current, 0);
|
||||||
if (current->screen != c->screen) cmapnofocus(current->screen);
|
if (current->screen != c->screen)
|
||||||
|
cmapnofocus(current->screen);
|
||||||
}
|
}
|
||||||
setactive(c, 1);
|
setactive(c, 1);
|
||||||
for (cc = clients; cc; cc = cc->next)
|
for (cc = clients; cc; cc = cc->next)
|
||||||
if (cc->revert == c) cc->revert = c->revert;
|
if (cc->revert == c)
|
||||||
|
cc->revert = c->revert;
|
||||||
c->revert = current;
|
c->revert = current;
|
||||||
while (c->revert && !normal(c->revert)) c->revert = c->revert->revert;
|
while (c->revert && !normal(c->revert))
|
||||||
|
c->revert = c->revert->revert;
|
||||||
current = c;
|
current = c;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug) dump_revert();
|
if (debug)
|
||||||
|
dump_revert();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void nofocus(void) {
|
||||||
nofocus(void) {
|
|
||||||
static Window w = 0;
|
static Window w = 0;
|
||||||
int mask;
|
int mask;
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
|
@ -138,8 +141,7 @@ nofocus(void) {
|
||||||
XSetInputFocus(dpy, w, RevertToPointerRoot, timestamp());
|
XSetInputFocus(dpy, w, RevertToPointerRoot, timestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void top(Client* c) {
|
||||||
top(Client* c) {
|
|
||||||
Client **l, *cc;
|
Client **l, *cc;
|
||||||
|
|
||||||
l = &clients;
|
l = &clients;
|
||||||
|
@ -155,16 +157,18 @@ top(Client* c) {
|
||||||
fprintf(stderr, "rio: %p not on client list in top()\n", (void*)c);
|
fprintf(stderr, "rio: %p not on client list in top()\n", (void*)c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client*
|
Client* getclient(Window w, int create) {
|
||||||
getclient(Window w, int create) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
if (w == 0 || getscreen(w)) return 0;
|
if (w == 0 || getscreen(w))
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (c = clients; c; c = c->next)
|
for (c = clients; c; c = c->next)
|
||||||
if (c->window == w || c->parent == w) return c;
|
if (c->window == w || c->parent == w)
|
||||||
|
return c;
|
||||||
|
|
||||||
if (!create) return 0;
|
if (!create)
|
||||||
|
return 0;
|
||||||
|
|
||||||
c = (Client*)malloc(sizeof(Client));
|
c = (Client*)malloc(sizeof(Client));
|
||||||
memset(c, 0, sizeof(Client));
|
memset(c, 0, sizeof(Client));
|
||||||
|
@ -188,20 +192,24 @@ getclient(Window w, int create) {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void rmclient(Client* c) {
|
||||||
rmclient(Client* c) {
|
|
||||||
Client* cc;
|
Client* cc;
|
||||||
|
|
||||||
for (cc = current; cc && cc->revert; cc = cc->revert)
|
for (cc = current; cc && cc->revert; cc = cc->revert)
|
||||||
if (cc->revert == c) cc->revert = cc->revert->revert;
|
if (cc->revert == c)
|
||||||
|
cc->revert = cc->revert->revert;
|
||||||
|
|
||||||
if (c == clients) clients = c->next;
|
if (c == clients)
|
||||||
|
clients = c->next;
|
||||||
for (cc = clients; cc && cc->next; cc = cc->next)
|
for (cc = clients; cc && cc->next; cc = cc->next)
|
||||||
if (cc->next == c) cc->next = cc->next->next;
|
if (cc->next == c)
|
||||||
|
cc->next = cc->next->next;
|
||||||
|
|
||||||
if (hidden(c)) unhidec(c, 0);
|
if (hidden(c))
|
||||||
|
unhidec(c, 0);
|
||||||
|
|
||||||
if (c->parent != c->screen->root) XDestroyWindow(dpy, c->parent);
|
if (c->parent != c->screen->root)
|
||||||
|
XDestroyWindow(dpy, c->parent);
|
||||||
|
|
||||||
c->parent = c->window = None; /* paranoia */
|
c->parent = c->window = None; /* paranoia */
|
||||||
if (current == c) {
|
if (current == c) {
|
||||||
|
@ -209,7 +217,8 @@ rmclient(Client* c) {
|
||||||
if (current == 0)
|
if (current == 0)
|
||||||
nofocus();
|
nofocus();
|
||||||
else {
|
else {
|
||||||
if (current->screen != c->screen) cmapnofocus(c->screen);
|
if (current->screen != c->screen)
|
||||||
|
cmapnofocus(c->screen);
|
||||||
setactive(current, 1);
|
setactive(current, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,33 +226,42 @@ rmclient(Client* c) {
|
||||||
XFree((char*)c->cmapwins);
|
XFree((char*)c->cmapwins);
|
||||||
free((char*)c->wmcmaps);
|
free((char*)c->wmcmaps);
|
||||||
}
|
}
|
||||||
if (c->iconname != 0) XFree((char*)c->iconname);
|
if (c->iconname != 0)
|
||||||
if (c->name != 0) XFree((char*)c->name);
|
XFree((char*)c->iconname);
|
||||||
if (c->instance != 0) XFree((char*)c->instance);
|
if (c->name != 0)
|
||||||
if (c->class != 0) XFree((char*)c->class);
|
XFree((char*)c->name);
|
||||||
|
if (c->instance != 0)
|
||||||
|
XFree((char*)c->instance);
|
||||||
|
if (c->class != 0)
|
||||||
|
XFree((char*)c->class);
|
||||||
memset(c, 0, sizeof(Client)); /* paranoia */
|
memset(c, 0, sizeof(Client)); /* paranoia */
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void
|
void dump_revert(void) {
|
||||||
dump_revert(void) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
for (c = current; c; c = c->revert) {
|
for (c = current; c; c = c->revert) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "%s(%x:%d)", c->label ? c->label : "?", (int)c->window, c->state);
|
stderr,
|
||||||
if (i++ > 100) break;
|
"%s(%x:%d)",
|
||||||
if (c->revert) fprintf(stderr, " -> ");
|
c->label ? c->label : "?",
|
||||||
|
(int)c->window,
|
||||||
|
c->state);
|
||||||
|
if (i++ > 100)
|
||||||
|
break;
|
||||||
|
if (c->revert)
|
||||||
|
fprintf(stderr, " -> ");
|
||||||
}
|
}
|
||||||
if (current == 0) fprintf(stderr, "empty");
|
if (current == 0)
|
||||||
|
fprintf(stderr, "empty");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void dump_clients(void) {
|
||||||
dump_clients(void) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
for (c = clients; c; c = c->next)
|
for (c = clients; c; c = c->next)
|
||||||
|
@ -257,22 +275,25 @@ dump_clients(void) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void shuffle(int up) {
|
||||||
shuffle(int up) {
|
|
||||||
Client **l, *c;
|
Client **l, *c;
|
||||||
|
|
||||||
if (clients == 0 || clients->next == 0) return;
|
if (clients == 0 || clients->next == 0)
|
||||||
|
return;
|
||||||
if (!up) {
|
if (!up) {
|
||||||
c = 0;
|
c = 0;
|
||||||
/*for(c=clients; c->next; c=c->next) */
|
/*for(c=clients; c->next; c=c->next) */
|
||||||
/* ; */
|
/* ; */
|
||||||
for (l = &clients; (*l)->next; l = &(*l)->next)
|
for (l = &clients; (*l)->next; l = &(*l)->next)
|
||||||
#ifdef AUTOSTICK
|
#ifdef AUTOSTICK
|
||||||
if ((*l)->state == 1 && !isautostick(*l)) c = *l;
|
if ((*l)->state == 1 && !isautostick(*l))
|
||||||
|
c = *l;
|
||||||
#else
|
#else
|
||||||
if ((*l)->state == 1) c = *l;
|
if ((*l)->state == 1)
|
||||||
|
c = *l;
|
||||||
#endif
|
#endif
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
XMapRaised(dpy, c->parent);
|
XMapRaised(dpy, c->parent);
|
||||||
top(c);
|
top(c);
|
||||||
active(c);
|
active(c);
|
||||||
|
@ -291,13 +312,14 @@ shuffle(int up) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AUTOSTICK
|
#ifdef AUTOSTICK
|
||||||
int
|
int isautostick(Client* c) {
|
||||||
isautostick(Client* c) {
|
|
||||||
static char* autostick[] = AUTOSTICK;
|
static char* autostick[] = AUTOSTICK;
|
||||||
char** a = autostick;
|
char** a = autostick;
|
||||||
|
|
||||||
while (*a) {
|
while (*a) {
|
||||||
if (c && c->class && strstr(c->class, *a)) { return 1; }
|
if (c && c->class && strstr(c->class, *a)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
++a;
|
++a;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
3
color.c
3
color.c
|
@ -7,8 +7,7 @@
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
unsigned long
|
unsigned long colorpixel(
|
||||||
colorpixel(
|
|
||||||
Display* dpy, ScreenInfo* s, int depth, unsigned long rgb,
|
Display* dpy, ScreenInfo* s, int depth, unsigned long rgb,
|
||||||
unsigned long def) {
|
unsigned long def) {
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
|
18
cursor.c
18
cursor.c
|
@ -147,9 +147,23 @@ ScreenInfo* s;
|
||||||
Pixmap f, m;
|
Pixmap f, m;
|
||||||
|
|
||||||
f = XCreatePixmapFromBitmapData(
|
f = XCreatePixmapFromBitmapData(
|
||||||
dpy, s->root, (char*)c->fore, c->width, c->width, 1, 0, 1);
|
dpy,
|
||||||
|
s->root,
|
||||||
|
(char*)c->fore,
|
||||||
|
c->width,
|
||||||
|
c->width,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1);
|
||||||
m = XCreatePixmapFromBitmapData(
|
m = XCreatePixmapFromBitmapData(
|
||||||
dpy, s->root, (char*)c->mask, c->width, c->width, 1, 0, 1);
|
dpy,
|
||||||
|
s->root,
|
||||||
|
(char*)c->mask,
|
||||||
|
c->width,
|
||||||
|
c->width,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
1);
|
||||||
return XCreatePixmapCursor(dpy, f, m, &bl, &wh, c->hot[0], c->hot[1]);
|
return XCreatePixmapCursor(dpy, f, m, &bl, &wh, c->hot[0], c->hot[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
41
error.c
41
error.c
|
@ -10,16 +10,14 @@
|
||||||
|
|
||||||
int ignore_badwindow;
|
int ignore_badwindow;
|
||||||
|
|
||||||
void
|
void fatal(char* s) {
|
||||||
fatal(char* s) {
|
|
||||||
fprintf(stderr, "ryudo: ");
|
fprintf(stderr, "ryudo: ");
|
||||||
perror(s);
|
perror(s);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int handler(Display* d, XErrorEvent* e) {
|
||||||
handler(Display* d, XErrorEvent* e) {
|
|
||||||
char msg[80], req[80], number[80];
|
char msg[80], req[80], number[80];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -40,7 +38,8 @@ handler(Display* d, XErrorEvent* e) {
|
||||||
XGetErrorText(d, e->error_code, msg, sizeof(msg));
|
XGetErrorText(d, e->error_code, msg, sizeof(msg));
|
||||||
sprintf(number, "%d", e->request_code);
|
sprintf(number, "%d", e->request_code);
|
||||||
XGetErrorDatabaseText(d, "XRequest", number, "", req, sizeof(req));
|
XGetErrorDatabaseText(d, "XRequest", number, "", req, sizeof(req));
|
||||||
if (req[0] == '\0') sprintf(req, "<request-code-%d>", (int)e->request_code);
|
if (req[0] == '\0')
|
||||||
|
sprintf(req, "<request-code-%d>", (int)e->request_code);
|
||||||
|
|
||||||
fprintf(stderr, "ryudo: %s(0x%x): %s\n", req, (int)e->resourceid, msg);
|
fprintf(stderr, "ryudo: %s(0x%x): %s\n", req, (int)e->resourceid, msg);
|
||||||
|
|
||||||
|
@ -51,18 +50,28 @@ handler(Display* d, XErrorEvent* e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void graberror(char* f, int err) {
|
||||||
graberror(char* f, int err) {
|
|
||||||
#ifdef DEBUG /* sick of "bug" reports; grab errors "just happen" */
|
#ifdef DEBUG /* sick of "bug" reports; grab errors "just happen" */
|
||||||
char* s;
|
char* s;
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case GrabNotViewable: s = "not viewable"; break;
|
case GrabNotViewable:
|
||||||
case AlreadyGrabbed: s = "already grabbed"; break;
|
s = "not viewable";
|
||||||
case GrabFrozen: s = "grab frozen"; break;
|
break;
|
||||||
case GrabInvalidTime: s = "invalid time"; break;
|
case AlreadyGrabbed:
|
||||||
case GrabSuccess: return;
|
s = "already grabbed";
|
||||||
default: fprintf(stderr, "ryudo: %s: grab error: %d\n", f, err); return;
|
break;
|
||||||
|
case GrabFrozen:
|
||||||
|
s = "grab frozen";
|
||||||
|
break;
|
||||||
|
case GrabInvalidTime:
|
||||||
|
s = "invalid time";
|
||||||
|
break;
|
||||||
|
case GrabSuccess:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "ryudo: %s: grab error: %d\n", f, err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "ryudo: %s: grab error: %s\n", f, s);
|
fprintf(stderr, "ryudo: %s: grab error: %s\n", f, s);
|
||||||
#endif
|
#endif
|
||||||
|
@ -74,9 +83,9 @@ graberror(char* f, int err) {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
void
|
void dotrace(char* s, Client* c, XEvent* e) {
|
||||||
dotrace(char* s, Client* c, XEvent* e) {
|
if (debug == 0)
|
||||||
if (debug == 0) return;
|
return;
|
||||||
setbuf(stdout, 0);
|
setbuf(stdout, 0);
|
||||||
fprintf(stderr, "ryudo: %s: c=%p", s, (void*)c);
|
fprintf(stderr, "ryudo: %s: c=%p", s, (void*)c);
|
||||||
if (c)
|
if (c)
|
||||||
|
|
265
event.c
265
event.c
|
@ -17,8 +17,7 @@
|
||||||
#include "patchlevel.h"
|
#include "patchlevel.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
void
|
void mainloop(int shape_event) {
|
||||||
mainloop(int shape_event) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -38,19 +37,44 @@ mainloop(int shape_event) {
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "ryudo: unknown ev.type %d\n", ev.type);
|
fprintf(stderr, "ryudo: unknown ev.type %d\n", ev.type);
|
||||||
break;
|
break;
|
||||||
case KeyPress: keypress(&ev.xkey); break;
|
case KeyPress:
|
||||||
case KeyRelease: keyrelease(&ev.xkey); break;
|
keypress(&ev.xkey);
|
||||||
case ButtonPress: button(&ev.xbutton); break;
|
break;
|
||||||
case ButtonRelease: break;
|
case KeyRelease:
|
||||||
case MapRequest: mapreq(&ev.xmaprequest); break;
|
keyrelease(&ev.xkey);
|
||||||
case ConfigureRequest: configurereq(&ev.xconfigurerequest); break;
|
break;
|
||||||
case CirculateRequest: circulatereq(&ev.xcirculaterequest); break;
|
case ButtonPress:
|
||||||
case UnmapNotify: unmap(&ev.xunmap); break;
|
button(&ev.xbutton);
|
||||||
case CreateNotify: newwindow(&ev.xcreatewindow); break;
|
break;
|
||||||
case DestroyNotify: destroy(ev.xdestroywindow.window); break;
|
case ButtonRelease:
|
||||||
case ClientMessage: clientmesg(&ev.xclient); break;
|
break;
|
||||||
case ColormapNotify: cmap(&ev.xcolormap); break;
|
case MapRequest:
|
||||||
case PropertyNotify: property(&ev.xproperty); break;
|
mapreq(&ev.xmaprequest);
|
||||||
|
break;
|
||||||
|
case ConfigureRequest:
|
||||||
|
configurereq(&ev.xconfigurerequest);
|
||||||
|
break;
|
||||||
|
case CirculateRequest:
|
||||||
|
circulatereq(&ev.xcirculaterequest);
|
||||||
|
break;
|
||||||
|
case UnmapNotify:
|
||||||
|
unmap(&ev.xunmap);
|
||||||
|
break;
|
||||||
|
case CreateNotify:
|
||||||
|
newwindow(&ev.xcreatewindow);
|
||||||
|
break;
|
||||||
|
case DestroyNotify:
|
||||||
|
destroy(ev.xdestroywindow.window);
|
||||||
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
clientmesg(&ev.xclient);
|
||||||
|
break;
|
||||||
|
case ColormapNotify:
|
||||||
|
cmap(&ev.xcolormap);
|
||||||
|
break;
|
||||||
|
case PropertyNotify:
|
||||||
|
property(&ev.xproperty);
|
||||||
|
break;
|
||||||
case SelectionClear:
|
case SelectionClear:
|
||||||
fprintf(stderr, "ryudo: SelectionClear (this should not happen)\n");
|
fprintf(stderr, "ryudo: SelectionClear (this should not happen)\n");
|
||||||
break;
|
break;
|
||||||
|
@ -60,11 +84,21 @@ mainloop(int shape_event) {
|
||||||
case SelectionRequest:
|
case SelectionRequest:
|
||||||
fprintf(stderr, "ryudo: SelectionRequest (this should not happen)\n");
|
fprintf(stderr, "ryudo: SelectionRequest (this should not happen)\n");
|
||||||
break;
|
break;
|
||||||
case EnterNotify: enter(&ev.xcrossing); break;
|
case EnterNotify:
|
||||||
case LeaveNotify: leave(&ev.xcrossing); break;
|
enter(&ev.xcrossing);
|
||||||
case ReparentNotify: reparent(&ev.xreparent); break;
|
break;
|
||||||
case FocusIn: focusin(&ev.xfocus); break;
|
case LeaveNotify:
|
||||||
case MotionNotify: motionnotify(&ev.xmotion); break;
|
leave(&ev.xcrossing);
|
||||||
|
break;
|
||||||
|
case ReparentNotify:
|
||||||
|
reparent(&ev.xreparent);
|
||||||
|
break;
|
||||||
|
case FocusIn:
|
||||||
|
focusin(&ev.xfocus);
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
motionnotify(&ev.xmotion);
|
||||||
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
case NoExpose:
|
case NoExpose:
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
@ -79,8 +113,7 @@ mainloop(int shape_event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void configurereq(XConfigureRequestEvent* e) {
|
||||||
configurereq(XConfigureRequestEvent* e) {
|
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
|
@ -91,11 +124,16 @@ configurereq(XConfigureRequestEvent* e) {
|
||||||
e->value_mask &= ~CWSibling;
|
e->value_mask &= ~CWSibling;
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
if (e->value_mask & CWX) c->x = e->x;
|
if (e->value_mask & CWX)
|
||||||
if (e->value_mask & CWY) c->y = e->y;
|
c->x = e->x;
|
||||||
if (e->value_mask & CWWidth) c->dx = e->width;
|
if (e->value_mask & CWY)
|
||||||
if (e->value_mask & CWHeight) c->dy = e->height;
|
c->y = e->y;
|
||||||
if (e->value_mask & CWBorderWidth) c->border = e->border_width;
|
if (e->value_mask & CWWidth)
|
||||||
|
c->dx = e->width;
|
||||||
|
if (e->value_mask & CWHeight)
|
||||||
|
c->dy = e->height;
|
||||||
|
if (e->value_mask & CWBorderWidth)
|
||||||
|
c->border = e->border_width;
|
||||||
|
|
||||||
if (c->dx >= c->screen->width && c->dy >= c->screen->height)
|
if (c->dx >= c->screen->width && c->dy >= c->screen->height)
|
||||||
c->border = 0;
|
c->border = 0;
|
||||||
|
@ -144,8 +182,7 @@ configurereq(XConfigureRequestEvent* e) {
|
||||||
XConfigureWindow(dpy, c->window, e->value_mask, &wc);
|
XConfigureWindow(dpy, c->window, e->value_mask, &wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void mapreq(XMapRequestEvent* e) {
|
||||||
mapreq(XMapRequestEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -160,7 +197,8 @@ mapreq(XMapRequestEvent* e) {
|
||||||
"ryudo: bad mapreq c %p w %x, rescanning\n",
|
"ryudo: bad mapreq c %p w %x, rescanning\n",
|
||||||
(void*)c,
|
(void*)c,
|
||||||
(int)e->window);
|
(int)e->window);
|
||||||
for (i = 0; i < num_screens; i++) scanwins(&screens[i]);
|
for (i = 0; i < num_screens; i++)
|
||||||
|
scanwins(&screens[i]);
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c == 0 || c->window != e->window) {
|
if (c == 0 || c->window != e->window) {
|
||||||
fprintf(stderr, "ryudo: window not found after rescan\n");
|
fprintf(stderr, "ryudo: window not found after rescan\n");
|
||||||
|
@ -171,7 +209,8 @@ mapreq(XMapRequestEvent* e) {
|
||||||
switch (c->state) {
|
switch (c->state) {
|
||||||
case WithdrawnState:
|
case WithdrawnState:
|
||||||
if (c->parent == c->screen->root) {
|
if (c->parent == c->screen->root) {
|
||||||
if (!manage(c, 0)) return;
|
if (!manage(c, 0))
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
XReparentWindow(dpy, c->window, c->parent, BORDER - 1, BORDER - 1);
|
XReparentWindow(dpy, c->window, c->parent, BORDER - 1, BORDER - 1);
|
||||||
|
@ -182,14 +221,16 @@ mapreq(XMapRequestEvent* e) {
|
||||||
XMapRaised(dpy, c->parent);
|
XMapRaised(dpy, c->parent);
|
||||||
top(c);
|
top(c);
|
||||||
setstate(c, NormalState);
|
setstate(c, NormalState);
|
||||||
if (c->trans != None && current && c->trans == current->window) active(c);
|
if (c->trans != None && current && c->trans == current->window)
|
||||||
|
active(c);
|
||||||
|
break;
|
||||||
|
case IconicState:
|
||||||
|
unhidec(c, 1);
|
||||||
break;
|
break;
|
||||||
case IconicState: unhidec(c, 1); break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unmap(XUnmapEvent* e) {
|
||||||
unmap(XUnmapEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
|
@ -203,28 +244,29 @@ unmap(XUnmapEvent* e) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NormalState:
|
case NormalState:
|
||||||
if (c == current) nofocus();
|
if (c == current)
|
||||||
if (!c->reparenting) withdraw(c);
|
nofocus();
|
||||||
|
if (!c->reparenting)
|
||||||
|
withdraw(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c->reparenting = 0;
|
c->reparenting = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void circulatereq(XCirculateRequestEvent* e) {
|
||||||
circulatereq(XCirculateRequestEvent* e) {
|
|
||||||
fprintf(stderr, "It must be the warlock Krill!\n"); /* ☺ */
|
fprintf(stderr, "It must be the warlock Krill!\n"); /* ☺ */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void newwindow(XCreateWindowEvent* e) {
|
||||||
newwindow(XCreateWindowEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
static XWindowAttributes ra;
|
static XWindowAttributes ra;
|
||||||
XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra);
|
XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra);
|
||||||
|
|
||||||
/* we don't set curtime as nothing here uses it */
|
/* we don't set curtime as nothing here uses it */
|
||||||
if (e->override_redirect) return;
|
if (e->override_redirect)
|
||||||
|
return;
|
||||||
c = getclient(e->window, 1);
|
c = getclient(e->window, 1);
|
||||||
if (c && c->window == e->window && (s = getscreen(e->parent))) {
|
if (c && c->window == e->window && (s = getscreen(e->parent))) {
|
||||||
c->x = e->x;
|
c->x = e->x;
|
||||||
|
@ -233,28 +275,34 @@ newwindow(XCreateWindowEvent* e) {
|
||||||
c->dy = e->height;
|
c->dy = e->height;
|
||||||
c->border = e->border_width;
|
c->border = e->border_width;
|
||||||
c->screen = s;
|
c->screen = s;
|
||||||
if (c->parent == None) c->parent = c->screen->root;
|
if (c->parent == None)
|
||||||
|
c->parent = c->screen->root;
|
||||||
}
|
}
|
||||||
if (kbLaunch) {
|
if (kbLaunch) {
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
quickreshape(
|
quickreshape(
|
||||||
c, ra.width / 6, GAPSZ, 2 * ra.width / 3, ra.height - 2 * GAPSZ);
|
c,
|
||||||
|
ra.width / 6,
|
||||||
|
GAPSZ,
|
||||||
|
2 * ra.width / 3,
|
||||||
|
ra.height - 2 * GAPSZ);
|
||||||
kbLaunch = 0;
|
kbLaunch = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void destroy(Window w) {
|
||||||
destroy(Window w) {
|
|
||||||
int i;
|
int i;
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
c = getclient(w, 0);
|
c = getclient(w, 0);
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (numvirtuals > 1)
|
if (numvirtuals > 1)
|
||||||
for (i = 0; i < numvirtuals; i++)
|
for (i = 0; i < numvirtuals; i++)
|
||||||
if (currents[i] == c) currents[i] = 0;
|
if (currents[i] == c)
|
||||||
|
currents[i] = 0;
|
||||||
|
|
||||||
rmclient(c);
|
rmclient(c);
|
||||||
|
|
||||||
|
@ -264,8 +312,7 @@ destroy(Window w) {
|
||||||
ignore_badwindow = 0;
|
ignore_badwindow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void clientmesg(XClientMessageEvent* e) {
|
||||||
clientmesg(XClientMessageEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
|
@ -280,11 +327,13 @@ clientmesg(XClientMessageEvent* e) {
|
||||||
perror("ryudo: exec failed");
|
perror("ryudo: exec failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (e->message_type == wm_protocols) return;
|
if (e->message_type == wm_protocols)
|
||||||
|
return;
|
||||||
if (e->message_type == wm_change_state) {
|
if (e->message_type == wm_change_state) {
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (e->format == 32 && e->data.l[0] == IconicState && c != 0) {
|
if (e->format == 32 && e->data.l[0] == IconicState && c != 0) {
|
||||||
if (normal(c)) hide(c);
|
if (normal(c))
|
||||||
|
hide(c);
|
||||||
} else
|
} else
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
|
@ -314,8 +363,7 @@ clientmesg(XClientMessageEvent* e) {
|
||||||
(int)e->window);
|
(int)e->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cmap(XColormapEvent* e) {
|
||||||
cmap(XColormapEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -324,21 +372,22 @@ cmap(XColormapEvent* e) {
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
c->cmap = e->colormap;
|
c->cmap = e->colormap;
|
||||||
if (c == current) cmapfocus(c);
|
if (c == current)
|
||||||
|
cmapfocus(c);
|
||||||
} else
|
} else
|
||||||
for (c = clients; c; c = c->next) {
|
for (c = clients; c; c = c->next) {
|
||||||
for (i = 0; i < c->ncmapwins; i++)
|
for (i = 0; i < c->ncmapwins; i++)
|
||||||
if (c->cmapwins[i] == e->window) {
|
if (c->cmapwins[i] == e->window) {
|
||||||
c->wmcmaps[i] = e->colormap;
|
c->wmcmaps[i] = e->colormap;
|
||||||
if (c == current) cmapfocus(c);
|
if (c == current)
|
||||||
|
cmapfocus(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void property(XPropertyEvent* e) {
|
||||||
property(XPropertyEvent* e) {
|
|
||||||
Atom a;
|
Atom a;
|
||||||
int delete;
|
int delete;
|
||||||
Client* c;
|
Client* c;
|
||||||
|
@ -348,22 +397,27 @@ property(XPropertyEvent* e) {
|
||||||
a = e->atom;
|
a = e->atom;
|
||||||
delete = (e->state == PropertyDelete);
|
delete = (e->state == PropertyDelete);
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case XA_WM_ICON_NAME:
|
case XA_WM_ICON_NAME:
|
||||||
if (c->iconname != 0) XFree((char*)c->iconname);
|
if (c->iconname != 0)
|
||||||
|
XFree((char*)c->iconname);
|
||||||
c->iconname = delete ? 0 : getprop(c->window, a);
|
c->iconname = delete ? 0 : getprop(c->window, a);
|
||||||
setlabel(c);
|
setlabel(c);
|
||||||
renamec(c, c->label);
|
renamec(c, c->label);
|
||||||
return;
|
return;
|
||||||
case XA_WM_NAME:
|
case XA_WM_NAME:
|
||||||
if (c->name != 0) XFree((char*)c->name);
|
if (c->name != 0)
|
||||||
|
XFree((char*)c->name);
|
||||||
c->name = delete ? 0 : getprop(c->window, a);
|
c->name = delete ? 0 : getprop(c->window, a);
|
||||||
setlabel(c);
|
setlabel(c);
|
||||||
renamec(c, c->label);
|
renamec(c, c->label);
|
||||||
return;
|
return;
|
||||||
case XA_WM_TRANSIENT_FOR: gettrans(c); return;
|
case XA_WM_TRANSIENT_FOR:
|
||||||
|
gettrans(c);
|
||||||
|
return;
|
||||||
case XA_WM_HINTS:
|
case XA_WM_HINTS:
|
||||||
case XA_WM_SIZE_HINTS:
|
case XA_WM_SIZE_HINTS:
|
||||||
case XA_WM_ZOOM_HINTS:
|
case XA_WM_ZOOM_HINTS:
|
||||||
|
@ -378,21 +432,23 @@ property(XPropertyEvent* e) {
|
||||||
}
|
}
|
||||||
if (a == _rio_hold_mode) {
|
if (a == _rio_hold_mode) {
|
||||||
c->hold = getiprop(c->window, _rio_hold_mode);
|
c->hold = getiprop(c->window, _rio_hold_mode);
|
||||||
if (c == current) draw_border(c, 1);
|
if (c == current)
|
||||||
|
draw_border(c, 1);
|
||||||
} else if (a == wm_colormaps) {
|
} else if (a == wm_colormaps) {
|
||||||
getcmaps(c);
|
getcmaps(c);
|
||||||
if (c == current) cmapfocus(c);
|
if (c == current)
|
||||||
|
cmapfocus(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void reparent(XReparentEvent* e) {
|
||||||
reparent(XReparentEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
|
|
||||||
/* we don't set curtime as nothing here uses it */
|
/* we don't set curtime as nothing here uses it */
|
||||||
if (!getscreen(e->event) || e->override_redirect) return;
|
if (!getscreen(e->event) || e->override_redirect)
|
||||||
|
return;
|
||||||
if ((s = getscreen(e->parent)) != 0) {
|
if ((s = getscreen(e->parent)) != 0) {
|
||||||
c = getclient(e->window, 1);
|
c = getclient(e->window, 1);
|
||||||
if (c != 0 && (c->dx == 0 || c->dy == 0)) {
|
if (c != 0 && (c->dx == 0 || c->dy == 0)) {
|
||||||
|
@ -408,58 +464,61 @@ reparent(XReparentEvent* e) {
|
||||||
c->dy = attr.height;
|
c->dy = attr.height;
|
||||||
c->border = attr.border_width;
|
c->border = attr.border_width;
|
||||||
c->screen = s;
|
c->screen = s;
|
||||||
if (c->parent == None) c->parent = c->screen->root;
|
if (c->parent == None)
|
||||||
|
c->parent = c->screen->root;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c != 0 && (c->parent == c->screen->root || withdrawn(c))) rmclient(c);
|
if (c != 0 && (c->parent == c->screen->root || withdrawn(c)))
|
||||||
|
rmclient(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
void
|
void shapenotify(XShapeEvent* e) {
|
||||||
shapenotify(XShapeEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
/* we don't set curtime as nothing here uses it */
|
/* we don't set curtime as nothing here uses it */
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
setshape(c);
|
setshape(c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void enter(XCrossingEvent* e) {
|
||||||
enter(XCrossingEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
curtime = e->time;
|
curtime = e->time;
|
||||||
if (!ffm)
|
if (!ffm)
|
||||||
if (e->mode != NotifyGrab || e->detail != NotifyNonlinearVirtual) return;
|
if (e->mode != NotifyGrab || e->detail != NotifyNonlinearVirtual)
|
||||||
|
return;
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c != 0 && c != current) {
|
if (c != 0 && c != current) {
|
||||||
/* someone grabbed the pointer; make them current */
|
/* someone grabbed the pointer; make them current */
|
||||||
if (!ffm) XMapRaised(dpy, c->parent);
|
if (!ffm)
|
||||||
|
XMapRaised(dpy, c->parent);
|
||||||
top(c);
|
top(c);
|
||||||
active(c);
|
active(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void leave(XCrossingEvent* e) {
|
||||||
leave(XCrossingEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c) XUndefineCursor(dpy, c->parent);
|
if (c)
|
||||||
|
XUndefineCursor(dpy, c->parent);
|
||||||
/* XDefineCursor(dpy, c->parent, c->screen->arrow); */
|
/* XDefineCursor(dpy, c->parent, c->screen->arrow); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void focusin(XFocusChangeEvent* e) {
|
||||||
focusin(XFocusChangeEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
|
|
||||||
curtime = CurrentTime;
|
curtime = CurrentTime;
|
||||||
if (e->detail != NotifyNonlinearVirtual) return;
|
if (e->detail != NotifyNonlinearVirtual)
|
||||||
|
return;
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c != 0 && c->window == e->window && c != current) {
|
if (c != 0 && c->window == e->window && c != current) {
|
||||||
#ifdef AUTOSTICK
|
#ifdef AUTOSTICK
|
||||||
|
@ -475,67 +534,77 @@ focusin(XFocusChangeEvent* e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BorderOrient
|
BorderOrient borderorient(Client* c, int x, int y) {
|
||||||
borderorient(Client* c, int x, int y) {
|
|
||||||
if (x <= BORDER) {
|
if (x <= BORDER) {
|
||||||
if (y <= CORNER) {
|
if (y <= CORNER) {
|
||||||
if (debug) fprintf(stderr, "topleft\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "topleft\n");
|
||||||
return BorderWNW;
|
return BorderWNW;
|
||||||
}
|
}
|
||||||
if (y >= (c->dy + 2 * BORDER) - CORNER) {
|
if (y >= (c->dy + 2 * BORDER) - CORNER) {
|
||||||
if (debug) fprintf(stderr, "botleft\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "botleft\n");
|
||||||
return BorderWSW;
|
return BorderWSW;
|
||||||
}
|
}
|
||||||
if (y > CORNER && y < (c->dy + 2 * BORDER) - CORNER) {
|
if (y > CORNER && y < (c->dy + 2 * BORDER) - CORNER) {
|
||||||
if (debug) fprintf(stderr, "left\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "left\n");
|
||||||
return BorderW;
|
return BorderW;
|
||||||
}
|
}
|
||||||
} else if (x <= CORNER) {
|
} else if (x <= CORNER) {
|
||||||
if (y <= BORDER) {
|
if (y <= BORDER) {
|
||||||
if (debug) fprintf(stderr, "topleft\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "topleft\n");
|
||||||
return BorderNNW;
|
return BorderNNW;
|
||||||
}
|
}
|
||||||
if (y >= (c->dy + BORDER)) {
|
if (y >= (c->dy + BORDER)) {
|
||||||
if (debug) fprintf(stderr, "botleft\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "botleft\n");
|
||||||
return BorderSSW;
|
return BorderSSW;
|
||||||
}
|
}
|
||||||
} else if (x >= (c->dx + BORDER)) {
|
} else if (x >= (c->dx + BORDER)) {
|
||||||
if (y <= CORNER) {
|
if (y <= CORNER) {
|
||||||
if (debug) fprintf(stderr, "topright\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "topright\n");
|
||||||
return BorderENE;
|
return BorderENE;
|
||||||
}
|
}
|
||||||
if (y >= (c->dy + 2 * BORDER) - CORNER) {
|
if (y >= (c->dy + 2 * BORDER) - CORNER) {
|
||||||
if (debug) fprintf(stderr, "botright\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "botright\n");
|
||||||
return BorderESE;
|
return BorderESE;
|
||||||
}
|
}
|
||||||
if (y > CORNER && y < (c->dy + 2 * BORDER) - CORNER) {
|
if (y > CORNER && y < (c->dy + 2 * BORDER) - CORNER) {
|
||||||
if (debug) fprintf(stderr, "right\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "right\n");
|
||||||
return BorderE;
|
return BorderE;
|
||||||
}
|
}
|
||||||
} else if (x >= (c->dx + 2 * BORDER) - CORNER) {
|
} else if (x >= (c->dx + 2 * BORDER) - CORNER) {
|
||||||
if (y <= BORDER) {
|
if (y <= BORDER) {
|
||||||
if (debug) fprintf(stderr, "topright\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "topright\n");
|
||||||
return BorderNNE;
|
return BorderNNE;
|
||||||
}
|
}
|
||||||
if (y >= (c->dy + BORDER)) {
|
if (y >= (c->dy + BORDER)) {
|
||||||
if (debug) fprintf(stderr, "botright\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "botright\n");
|
||||||
return BorderSSE;
|
return BorderSSE;
|
||||||
}
|
}
|
||||||
} else if (x > CORNER && x < (c->dx + 2 * BORDER) - CORNER) {
|
} else if (x > CORNER && x < (c->dx + 2 * BORDER) - CORNER) {
|
||||||
if (y <= BORDER) {
|
if (y <= BORDER) {
|
||||||
if (debug) fprintf(stderr, "top\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "top\n");
|
||||||
return BorderN;
|
return BorderN;
|
||||||
}
|
}
|
||||||
if (y >= (c->dy + BORDER)) {
|
if (y >= (c->dy + BORDER)) {
|
||||||
if (debug) fprintf(stderr, "bot\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "bot\n");
|
||||||
return BorderS;
|
return BorderS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BorderUnknown;
|
return BorderUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void motionnotify(XMotionEvent* e) {
|
||||||
motionnotify(XMotionEvent* e) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
BorderOrient bl;
|
BorderOrient bl;
|
||||||
|
|
||||||
|
|
189
grab.c
189
grab.c
|
@ -7,8 +7,7 @@
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
int
|
int nobuttons(XButtonEvent* e) /* Einstuerzende */
|
||||||
nobuttons(XButtonEvent* e) /* Einstuerzende */
|
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
|
@ -16,33 +15,41 @@ nobuttons(XButtonEvent* e) /* Einstuerzende */
|
||||||
return (e->type == ButtonRelease) && (state & (state - 1)) == 0;
|
return (e->type == ButtonRelease) && (state & (state - 1)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int grab(Window w, Window constrain, int mask, Cursor curs, int t) {
|
||||||
grab(Window w, Window constrain, int mask, Cursor curs, int t) {
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
if (t == 0) t = timestamp();
|
if (t == 0)
|
||||||
|
t = timestamp();
|
||||||
status = XGrabPointer(
|
status = XGrabPointer(
|
||||||
dpy, w, False, mask, GrabModeAsync, GrabModeAsync, constrain, curs, t);
|
dpy,
|
||||||
|
w,
|
||||||
|
False,
|
||||||
|
mask,
|
||||||
|
GrabModeAsync,
|
||||||
|
GrabModeAsync,
|
||||||
|
constrain,
|
||||||
|
curs,
|
||||||
|
t);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ungrab(XButtonEvent* e) {
|
||||||
ungrab(XButtonEvent* e) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
if (!nobuttons(e))
|
if (!nobuttons(e))
|
||||||
for (;;) {
|
for (;;) {
|
||||||
XMaskEvent(dpy, ButtonMask | ButtonMotionMask, &ev);
|
XMaskEvent(dpy, ButtonMask | ButtonMotionMask, &ev);
|
||||||
if (ev.type == MotionNotify) continue;
|
if (ev.type == MotionNotify)
|
||||||
|
continue;
|
||||||
e = &ev.xbutton;
|
e = &ev.xbutton;
|
||||||
if (nobuttons(e)) break;
|
if (nobuttons(e))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
XUngrabPointer(dpy, e->time);
|
XUngrabPointer(dpy, e->time);
|
||||||
curtime = e->time;
|
curtime = e->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void drawstring(
|
||||||
drawstring(
|
|
||||||
Display* dpy, ScreenInfo* s, Menu* m, int wide, int high, int i,
|
Display* dpy, ScreenInfo* s, Menu* m, int wide, int high, int i,
|
||||||
int selected) {
|
int selected) {
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
|
@ -67,14 +74,14 @@ drawstring(
|
||||||
strlen(m->item[i]));
|
strlen(m->item[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int menuhit(XButtonEvent* e, Menu* m) {
|
||||||
menuhit(XButtonEvent* e, Menu* m) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int i, n, cur, old, wide, high, status, drawn, warp;
|
int i, n, cur, old, wide, high, status, drawn, warp;
|
||||||
int x, y, dx, dy, xmax, ymax;
|
int x, y, dx, dy, xmax, ymax;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
|
|
||||||
if (font == 0) return -1;
|
if (font == 0)
|
||||||
|
return -1;
|
||||||
s = getscreen(e->root);
|
s = getscreen(e->root);
|
||||||
if (s == 0 || e->window == s->menuwin) /* ugly event mangling */
|
if (s == 0 || e->window == s->menuwin) /* ugly event mangling */
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -82,11 +89,13 @@ menuhit(XButtonEvent* e, Menu* m) {
|
||||||
dx = 0;
|
dx = 0;
|
||||||
for (n = 0; m->item[n]; n++) {
|
for (n = 0; m->item[n]; n++) {
|
||||||
wide = XTextWidth(font, m->item[n], strlen(m->item[n])) + 4;
|
wide = XTextWidth(font, m->item[n], strlen(m->item[n])) + 4;
|
||||||
if (wide > dx) dx = wide;
|
if (wide > dx)
|
||||||
|
dx = wide;
|
||||||
}
|
}
|
||||||
wide = dx;
|
wide = dx;
|
||||||
cur = m->lasthit;
|
cur = m->lasthit;
|
||||||
if (cur >= n) cur = n - 1;
|
if (cur >= n)
|
||||||
|
cur = n - 1;
|
||||||
|
|
||||||
high = font->ascent + font->descent + 1;
|
high = font->ascent + font->descent + 1;
|
||||||
dy = n * high;
|
dy = n * high;
|
||||||
|
@ -115,7 +124,8 @@ menuhit(XButtonEvent* e, Menu* m) {
|
||||||
y = ymax - dy;
|
y = ymax - dy;
|
||||||
warp++;
|
warp++;
|
||||||
}
|
}
|
||||||
if (warp) setmouse(e->x, e->y, s);
|
if (warp)
|
||||||
|
setmouse(e->x, e->y, s);
|
||||||
XMoveResizeWindow(dpy, s->menuwin, x, y, dx, dy);
|
XMoveResizeWindow(dpy, s->menuwin, x, y, dx, dy);
|
||||||
XSelectInput(dpy, s->menuwin, MenuMask);
|
XSelectInput(dpy, s->menuwin, MenuMask);
|
||||||
XMapRaised(dpy, s->menuwin);
|
XMapRaised(dpy, s->menuwin);
|
||||||
|
@ -132,9 +142,11 @@ menuhit(XButtonEvent* e, Menu* m) {
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "ryudo: menuhit: unknown ev.type %d\n", ev.type);
|
fprintf(stderr, "ryudo: menuhit: unknown ev.type %d\n", ev.type);
|
||||||
break;
|
break;
|
||||||
case ButtonPress: break;
|
case ButtonPress:
|
||||||
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
if (ev.xbutton.button != e->button) break;
|
if (ev.xbutton.button != e->button)
|
||||||
|
break;
|
||||||
x = ev.xbutton.x;
|
x = ev.xbutton.x;
|
||||||
y = ev.xbutton.y;
|
y = ev.xbutton.y;
|
||||||
i = y / high;
|
i = y / high;
|
||||||
|
@ -146,12 +158,14 @@ menuhit(XButtonEvent* e, Menu* m) {
|
||||||
i = -1;
|
i = -1;
|
||||||
else
|
else
|
||||||
m->lasthit = i;
|
m->lasthit = i;
|
||||||
if (!nobuttons(&ev.xbutton)) i = -1;
|
if (!nobuttons(&ev.xbutton))
|
||||||
|
i = -1;
|
||||||
ungrab(&ev.xbutton);
|
ungrab(&ev.xbutton);
|
||||||
XUnmapWindow(dpy, s->menuwin);
|
XUnmapWindow(dpy, s->menuwin);
|
||||||
return i;
|
return i;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if (!drawn) break;
|
if (!drawn)
|
||||||
|
break;
|
||||||
x = ev.xbutton.x;
|
x = ev.xbutton.x;
|
||||||
y = ev.xbutton.y;
|
y = ev.xbutton.y;
|
||||||
old = cur;
|
old = cur;
|
||||||
|
@ -162,20 +176,23 @@ menuhit(XButtonEvent* e, Menu* m) {
|
||||||
cur = -1;
|
cur = -1;
|
||||||
else if (cur < 0 || cur >= n)
|
else if (cur < 0 || cur >= n)
|
||||||
cur = -1;
|
cur = -1;
|
||||||
if (cur == old) break;
|
if (cur == old)
|
||||||
if (old >= 0 && old < n) drawstring(dpy, s, m, wide, high, old, 0);
|
break;
|
||||||
if (cur >= 0 && cur < n) drawstring(dpy, s, m, wide, high, cur, 1);
|
if (old >= 0 && old < n)
|
||||||
|
drawstring(dpy, s, m, wide, high, old, 0);
|
||||||
|
if (cur >= 0 && cur < n)
|
||||||
|
drawstring(dpy, s, m, wide, high, cur, 1);
|
||||||
break;
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
XClearWindow(dpy, s->menuwin);
|
XClearWindow(dpy, s->menuwin);
|
||||||
for (i = 0; i < n; i++) drawstring(dpy, s, m, wide, high, i, cur == i);
|
for (i = 0; i < n; i++)
|
||||||
|
drawstring(dpy, s, m, wide, high, i, cur == i);
|
||||||
drawn = 1;
|
drawn = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Client*
|
Client* selectwin(int release, int* shift, ScreenInfo* s) {
|
||||||
selectwin(int release, int* shift, ScreenInfo* s) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
XButtonEvent* e;
|
XButtonEvent* e;
|
||||||
int status;
|
int status;
|
||||||
|
@ -200,22 +217,25 @@ selectwin(int release, int* shift, ScreenInfo* s) {
|
||||||
w = e->subwindow;
|
w = e->subwindow;
|
||||||
if (!release) {
|
if (!release) {
|
||||||
c = getclient(w, 0);
|
c = getclient(w, 0);
|
||||||
if (c == 0) ungrab(e);
|
if (c == 0)
|
||||||
if (shift != 0) *shift = (e->state & ShiftMask) != 0;
|
ungrab(e);
|
||||||
|
if (shift != 0)
|
||||||
|
*shift = (e->state & ShiftMask) != 0;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
ungrab(e);
|
ungrab(e);
|
||||||
if (e->button != Button3 || e->subwindow != w) return 0;
|
if (e->button != Button3 || e->subwindow != w)
|
||||||
if (shift != 0) *shift = (e->state & ShiftMask) != 0;
|
return 0;
|
||||||
|
if (shift != 0)
|
||||||
|
*shift = (e->state & ShiftMask) != 0;
|
||||||
return getclient(w, 0);
|
return getclient(w, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sweepcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
||||||
sweepcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
|
||||||
int dx, dy, sx, sy;
|
int dx, dy, sx, sy;
|
||||||
|
|
||||||
dx = x - c->x;
|
dx = x - c->x;
|
||||||
|
@ -236,8 +256,10 @@ sweepcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
||||||
dy -= 2 * BORDER;
|
dy -= 2 * BORDER;
|
||||||
|
|
||||||
if (!c->is9term) {
|
if (!c->is9term) {
|
||||||
if (dx < c->min_dx) dx = c->min_dx;
|
if (dx < c->min_dx)
|
||||||
if (dy < c->min_dy) dy = c->min_dy;
|
dx = c->min_dx;
|
||||||
|
if (dy < c->min_dy)
|
||||||
|
dy = c->min_dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->size.flags & PResizeInc) {
|
if (c->size.flags & PResizeInc) {
|
||||||
|
@ -246,8 +268,10 @@ sweepcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->size.flags & PMaxSize) {
|
if (c->size.flags & PMaxSize) {
|
||||||
if (dx > c->size.max_width) dx = c->size.max_width;
|
if (dx > c->size.max_width)
|
||||||
if (dy > c->size.max_height) dy = c->size.max_height;
|
dx = c->size.max_width;
|
||||||
|
if (dy > c->size.max_height)
|
||||||
|
dy = c->size.max_height;
|
||||||
}
|
}
|
||||||
c->dx = sx * (dx + 2 * BORDER);
|
c->dx = sx * (dx + 2 * BORDER);
|
||||||
c->dy = sy * (dy + 2 * BORDER);
|
c->dy = sy * (dy + 2 * BORDER);
|
||||||
|
@ -255,16 +279,14 @@ sweepcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
||||||
return ignored;
|
return ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int dragcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
||||||
dragcalc(Client* c, int x, int y, BorderOrient bl, int ignored) {
|
|
||||||
c->x += x;
|
c->x += x;
|
||||||
c->y += y;
|
c->y += y;
|
||||||
|
|
||||||
return ignored;
|
return ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
||||||
pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
|
||||||
int dx, dy, sx, sy, px, py, spx, spy, rdx, rdy, xoff, yoff, xcorn, ycorn;
|
int dx, dy, sx, sy, px, py, spx, spy, rdx, rdy, xoff, yoff, xcorn, ycorn;
|
||||||
|
|
||||||
px = c->x;
|
px = c->x;
|
||||||
|
@ -333,17 +355,22 @@ pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
||||||
xoff = x - c->x;
|
xoff = x - c->x;
|
||||||
yoff = (c->y + c->dy) - y;
|
yoff = (c->y + c->dy) - y;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
switch (bl) {
|
switch (bl) {
|
||||||
case BorderNNW:
|
case BorderNNW:
|
||||||
case BorderNNE:
|
case BorderNNE:
|
||||||
case BorderSSW:
|
case BorderSSW:
|
||||||
case BorderSSE: xcorn = 1; break;
|
case BorderSSE:
|
||||||
|
xcorn = 1;
|
||||||
|
break;
|
||||||
case BorderWNW:
|
case BorderWNW:
|
||||||
case BorderENE:
|
case BorderENE:
|
||||||
case BorderWSW:
|
case BorderWSW:
|
||||||
case BorderESE: ycorn = 1; break;
|
case BorderESE:
|
||||||
|
ycorn = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!init || xoff < 0 || (xcorn && xoff > CORNER) ||
|
!init || xoff < 0 || (xcorn && xoff > CORNER) ||
|
||||||
|
@ -391,8 +418,10 @@ pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
||||||
dy -= (2 * BORDER - yoff);
|
dy -= (2 * BORDER - yoff);
|
||||||
|
|
||||||
if (!c->is9term) {
|
if (!c->is9term) {
|
||||||
if (dx < c->min_dx) dx = c->min_dx;
|
if (dx < c->min_dx)
|
||||||
if (dy < c->min_dy) dy = c->min_dy;
|
dx = c->min_dx;
|
||||||
|
if (dy < c->min_dy)
|
||||||
|
dy = c->min_dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->size.flags & PResizeInc) {
|
if (c->size.flags & PResizeInc) {
|
||||||
|
@ -401,8 +430,10 @@ pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->size.flags & PMaxSize) {
|
if (c->size.flags & PMaxSize) {
|
||||||
if (dx > c->size.max_width) dx = c->size.max_width;
|
if (dx > c->size.max_width)
|
||||||
if (dy > c->size.max_height) dy = c->size.max_height;
|
dx = c->size.max_width;
|
||||||
|
if (dy > c->size.max_height)
|
||||||
|
dy = c->size.max_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set size and position */
|
/* set size and position */
|
||||||
|
@ -412,14 +443,15 @@ pullcalc(Client* c, int x, int y, BorderOrient bl, int init) {
|
||||||
c->y = py;
|
c->y = py;
|
||||||
|
|
||||||
/* compensate position for size changed due to size hints */
|
/* compensate position for size changed due to size hints */
|
||||||
if (spx) c->x -= c->dx - rdx;
|
if (spx)
|
||||||
if (spy) c->y -= c->dy - rdy;
|
c->x -= c->dx - rdx;
|
||||||
|
if (spy)
|
||||||
|
c->y -= c->dy - rdy;
|
||||||
|
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void xcopy(
|
||||||
xcopy(
|
|
||||||
int fwd, Display* dpy, Drawable src, Drawable dst, GC gc, int x, int y,
|
int fwd, Display* dpy, Drawable src, Drawable dst, GC gc, int x, int y,
|
||||||
int dx, int dy, int x1, int y1) {
|
int dx, int dy, int x1, int y1) {
|
||||||
if (fwd)
|
if (fwd)
|
||||||
|
@ -428,14 +460,19 @@ xcopy(
|
||||||
XCopyArea(dpy, dst, src, gc, x1, y1, dx, dy, x, y);
|
XCopyArea(dpy, dst, src, gc, x1, y1, dx, dy, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void drawbound(Client* c, int drawing) {
|
||||||
drawbound(Client* c, int drawing) {
|
|
||||||
int x, y, dx, dy;
|
int x, y, dx, dy;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "drawbound %d %dx%d+%d+%d\n", drawing, c->dx, c->dy, c->x, c->y);
|
stderr,
|
||||||
|
"drawbound %d %dx%d+%d+%d\n",
|
||||||
|
drawing,
|
||||||
|
c->dx,
|
||||||
|
c->dy,
|
||||||
|
c->x,
|
||||||
|
c->y);
|
||||||
|
|
||||||
s = c->screen;
|
s = c->screen;
|
||||||
x = c->x;
|
x = c->x;
|
||||||
|
@ -450,7 +487,8 @@ drawbound(Client* c, int drawing) {
|
||||||
y += dy;
|
y += dy;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
}
|
}
|
||||||
if (dx <= 2 || dy <= 2) return;
|
if (dx <= 2 || dy <= 2)
|
||||||
|
return;
|
||||||
|
|
||||||
if (solidsweep) {
|
if (solidsweep) {
|
||||||
if (drawing == -1) {
|
if (drawing == -1) {
|
||||||
|
@ -471,7 +509,8 @@ drawbound(Client* c, int drawing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drawing == -1) return;
|
if (drawing == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
xcopy(drawing, dpy, s->root, s->bkup[0], s->gccopy, x, y, dx, BORDER, 0, 0);
|
xcopy(drawing, dpy, s->root, s->bkup[0], s->gccopy, x, y, dx, BORDER, 0, 0);
|
||||||
xcopy(
|
xcopy(
|
||||||
|
@ -508,8 +547,7 @@ drawbound(Client* c, int drawing) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void misleep(int msec) {
|
||||||
misleep(int msec) {
|
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
|
|
||||||
t.tv_sec = msec / 1000;
|
t.tv_sec = msec / 1000;
|
||||||
|
@ -517,8 +555,7 @@ misleep(int msec) {
|
||||||
select(0, 0, 0, 0, &t);
|
select(0, 0, 0, 0, &t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sweepdrag(
|
||||||
sweepdrag(
|
|
||||||
Client* c, int but, XButtonEvent* e0, BorderOrient bl,
|
Client* c, int but, XButtonEvent* e0, BorderOrient bl,
|
||||||
int (*recalc)(Client*, int, int, BorderOrient, int)) {
|
int (*recalc)(Client*, int, int, BorderOrient, int)) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
@ -542,7 +579,9 @@ sweepdrag(
|
||||||
else
|
else
|
||||||
getmouse(&c->x, &c->y, c->screen);
|
getmouse(&c->x, &c->y, c->screen);
|
||||||
XGrabServer(dpy);
|
XGrabServer(dpy);
|
||||||
if (bl != BorderUnknown) { notmoved = recalc(c, cx, cy, bl, notmoved); }
|
if (bl != BorderUnknown) {
|
||||||
|
notmoved = recalc(c, cx, cy, bl, notmoved);
|
||||||
|
}
|
||||||
drawbound(c, 1);
|
drawbound(c, 1);
|
||||||
idle = 0;
|
idle = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -576,7 +615,8 @@ sweepdrag(
|
||||||
drawbound(c, 0);
|
drawbound(c, 0);
|
||||||
ungrab(e);
|
ungrab(e);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
if (e->button != but && c->init) goto bad;
|
if (e->button != but && c->init)
|
||||||
|
goto bad;
|
||||||
if (c->dx < 0) {
|
if (c->dx < 0) {
|
||||||
c->x += c->dx;
|
c->x += c->dx;
|
||||||
c->dx = -c->dx;
|
c->dx = -c->dx;
|
||||||
|
@ -595,7 +635,8 @@ sweepdrag(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bad:
|
bad:
|
||||||
if (debug) fprintf(stderr, "sweepdrag bad\n");
|
if (debug)
|
||||||
|
fprintf(stderr, "sweepdrag bad\n");
|
||||||
c->x = ox;
|
c->x = ox;
|
||||||
c->y = oy;
|
c->y = oy;
|
||||||
c->dx = odx;
|
c->dx = odx;
|
||||||
|
@ -604,8 +645,7 @@ bad:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int sweep(Client* c, int but, XButtonEvent* ignored) {
|
||||||
sweep(Client* c, int but, XButtonEvent* ignored) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int status;
|
int status;
|
||||||
XButtonEvent* e;
|
XButtonEvent* e;
|
||||||
|
@ -630,8 +670,7 @@ sweep(Client* c, int but, XButtonEvent* ignored) {
|
||||||
return sweepdrag(c, but, e, BorderUnknown, sweepcalc);
|
return sweepdrag(c, but, e, BorderUnknown, sweepcalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int pull(Client* c, int but, XButtonEvent* e) {
|
||||||
pull(Client* c, int but, XButtonEvent* e) {
|
|
||||||
int status;
|
int status;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
BorderOrient bl;
|
BorderOrient bl;
|
||||||
|
@ -649,8 +688,7 @@ pull(Client* c, int but, XButtonEvent* e) {
|
||||||
return sweepdrag(c, but, 0, bl, pullcalc);
|
return sweepdrag(c, but, 0, bl, pullcalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int drag(Client* c, int but) {
|
||||||
drag(Client* c, int but) {
|
|
||||||
int status;
|
int status;
|
||||||
ScreenInfo* s;
|
ScreenInfo* s;
|
||||||
|
|
||||||
|
@ -663,17 +701,16 @@ drag(Client* c, int but) {
|
||||||
return sweepdrag(c, but, 0, BorderUnknown, dragcalc);
|
return sweepdrag(c, but, 0, BorderUnknown, dragcalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void getmouse(int* x, int* y, ScreenInfo* s) {
|
||||||
getmouse(int* x, int* y, ScreenInfo* s) {
|
|
||||||
Window dw1, dw2;
|
Window dw1, dw2;
|
||||||
int t1, t2;
|
int t1, t2;
|
||||||
unsigned int t3;
|
unsigned int t3;
|
||||||
|
|
||||||
XQueryPointer(dpy, s->root, &dw1, &dw2, x, y, &t1, &t2, &t3);
|
XQueryPointer(dpy, s->root, &dw1, &dw2, x, y, &t1, &t2, &t3);
|
||||||
if (debug) fprintf(stderr, "getmouse: %d %d\n", *x, *y);
|
if (debug)
|
||||||
|
fprintf(stderr, "getmouse: %d %d\n", *x, *y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setmouse(int x, int y, ScreenInfo* s) {
|
||||||
setmouse(int x, int y, ScreenInfo* s) {
|
|
||||||
XWarpPointer(dpy, None, s->root, None, None, None, None, x, y);
|
XWarpPointer(dpy, None, s->root, None, None, None, None, x, y);
|
||||||
}
|
}
|
||||||
|
|
205
key.c
205
key.c
|
@ -27,8 +27,7 @@ enum { GrabAltTab, GrabAltAny };
|
||||||
|
|
||||||
static void alttab(int shift);
|
static void alttab(int shift);
|
||||||
|
|
||||||
void
|
void keysetup(void) {
|
||||||
keysetup(void) {
|
|
||||||
int i;
|
int i;
|
||||||
int tabcode = XKeysymToKeycode(dpy, XK_Tab);
|
int tabcode = XKeysymToKeycode(dpy, XK_Tab);
|
||||||
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
|
int dcode = XKeysymToKeycode(dpy, DESTROY_KEY);
|
||||||
|
@ -57,39 +56,141 @@ keysetup(void) {
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i++) {
|
for (i = 0; i < num_screens; i++) {
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
tabcode,
|
||||||
|
Mod1Mask,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, dcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
dcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, icode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
icode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, ucode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
ucode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, rcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
rcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, vcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
vcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, mcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
mcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, scode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
scode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, hcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
hcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, lcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
lcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, jcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
jcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, kcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
kcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, qcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
qcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, wcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
wcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, ocode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
ocode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, pcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
pcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, ccode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
ccode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy,
|
dpy,
|
||||||
leftcode,
|
leftcode,
|
||||||
|
@ -124,9 +225,21 @@ keysetup(void) {
|
||||||
GrabModeAsync);
|
GrabModeAsync);
|
||||||
#ifdef DEVEL
|
#ifdef DEVEL
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, tcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
tcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
XGrabKey(
|
XGrabKey(
|
||||||
dpy, bcode, SHORTCUTMOD, screens[i].root, 0, GrabModeSync, GrabModeAsync);
|
dpy,
|
||||||
|
bcode,
|
||||||
|
SHORTCUTMOD,
|
||||||
|
screens[i].root,
|
||||||
|
0,
|
||||||
|
GrabModeSync,
|
||||||
|
GrabModeAsync);
|
||||||
#endif
|
#endif
|
||||||
/* XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync,
|
/* XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync,
|
||||||
* GrabModeAsync); */
|
* GrabModeAsync); */
|
||||||
|
@ -137,8 +250,7 @@ keysetup(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void keypress(XKeyEvent* e) {
|
||||||
keypress(XKeyEvent* e) {
|
|
||||||
/*
|
/*
|
||||||
* process key press here
|
* process key press here
|
||||||
*/
|
*/
|
||||||
|
@ -185,14 +297,22 @@ keypress(XKeyEvent* e) {
|
||||||
reshape(current, Button3, sweep, 0);
|
reshape(current, Button3, sweep, 0);
|
||||||
else if (e->keycode == mcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == mcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
quickreshape(
|
quickreshape(
|
||||||
current, -BORDER, -BORDER, ra.width + 2 * BORDER, ra.height + 2 * BORDER);
|
current,
|
||||||
|
-BORDER,
|
||||||
|
-BORDER,
|
||||||
|
ra.width + 2 * BORDER,
|
||||||
|
ra.height + 2 * BORDER);
|
||||||
else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == scode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
stick(current);
|
stick(current);
|
||||||
|
|
||||||
/* half snap */
|
/* half snap */
|
||||||
else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == hcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
quickreshape(
|
quickreshape(
|
||||||
current, GAPSZ, GAPSZ, ra.width / 2 - 1.5 * GAPSZ, ra.height - 2 * GAPSZ);
|
current,
|
||||||
|
GAPSZ,
|
||||||
|
GAPSZ,
|
||||||
|
ra.width / 2 - 1.5 * GAPSZ,
|
||||||
|
ra.height - 2 * GAPSZ);
|
||||||
else if (e->keycode == lcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == lcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
quickreshape(
|
quickreshape(
|
||||||
current,
|
current,
|
||||||
|
@ -209,7 +329,11 @@ keypress(XKeyEvent* e) {
|
||||||
ra.height / 2 - 1.5 * GAPSZ);
|
ra.height / 2 - 1.5 * GAPSZ);
|
||||||
else if (e->keycode == kcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == kcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
quickreshape(
|
quickreshape(
|
||||||
current, GAPSZ, GAPSZ, ra.width - 2 * GAPSZ, ra.height / 2 - 1.5 * GAPSZ);
|
current,
|
||||||
|
GAPSZ,
|
||||||
|
GAPSZ,
|
||||||
|
ra.width - 2 * GAPSZ,
|
||||||
|
ra.height / 2 - 1.5 * GAPSZ);
|
||||||
|
|
||||||
/* quarter snap */
|
/* quarter snap */
|
||||||
else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
else if (e->keycode == qcode && (e->state & SHORTCUTMOD) == (MODBITS))
|
||||||
|
@ -259,7 +383,8 @@ keypress(XKeyEvent* e) {
|
||||||
kbLaunch = 1;
|
kbLaunch = 1;
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
if (dpy != '\0') putenv(dpy);
|
if (dpy != '\0')
|
||||||
|
putenv(dpy);
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
|
@ -293,14 +418,11 @@ keypress(XKeyEvent* e) {
|
||||||
XAllowEvents(dpy, SyncKeyboard, e->time);
|
XAllowEvents(dpy, SyncKeyboard, e->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void keyrelease(XKeyEvent* e) { XAllowEvents(dpy, SyncKeyboard, e->time); }
|
||||||
keyrelease(XKeyEvent* e) {
|
|
||||||
XAllowEvents(dpy, SyncKeyboard, e->time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void quickreshape(Client* c, int x, int y, int dx, int dy) {
|
||||||
quickreshape(Client* c, int x, int y, int dx, int dy) {
|
if (c == 0)
|
||||||
if (c == 0) return;
|
return;
|
||||||
XMoveResizeWindow(dpy, c->parent, x, y, dx, dy);
|
XMoveResizeWindow(dpy, c->parent, x, y, dx, dy);
|
||||||
c->x = x + BORDER;
|
c->x = x + BORDER;
|
||||||
c->y = y + BORDER;
|
c->y = y + BORDER;
|
||||||
|
@ -310,8 +432,7 @@ quickreshape(Client* c, int x, int y, int dx, int dy) {
|
||||||
sendconfig(c);
|
sendconfig(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void centercurrent(XWindowAttributes ra) {
|
||||||
centercurrent(XWindowAttributes ra) {
|
|
||||||
static int centeroffsetnum =
|
static int centeroffsetnum =
|
||||||
CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2;
|
CENTERNUM % 2 == 0 ? CENTERDEN - CENTERNUM : (CENTERDEN - CENTERNUM) / 2;
|
||||||
|
|
||||||
|
@ -334,23 +455,23 @@ centercurrent(XWindowAttributes ra) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void alttab(int shift) {
|
||||||
alttab(int shift) {
|
|
||||||
shuffle(shift);
|
shuffle(shift);
|
||||||
/* fprintf(stderr, "%sTab\n", shift ? "Back" : ""); */
|
/* fprintf(stderr, "%sTab\n", shift ? "Back" : ""); */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEVEL
|
#ifdef DEVEL
|
||||||
void
|
void stickystack(int toTop) {
|
||||||
stickystack(int toTop) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
if (toTop) {
|
if (toTop) {
|
||||||
for (c = clients; c->next; c = c->next) {
|
for (c = clients; c->next; c = c->next) {
|
||||||
if (c && isautostick(c)) top(c);
|
if (c && isautostick(c))
|
||||||
|
top(c);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (c = clients; c->next; c = c->next) {
|
for (c = clients; c->next; c = c->next) {
|
||||||
if (c && !isautostick(c)) top(c);
|
if (c && !isautostick(c))
|
||||||
|
top(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
84
main.c
84
main.c
|
@ -60,8 +60,7 @@ Atom wm_state;
|
||||||
|
|
||||||
char* fontlist[] = FONTLIST;
|
char* fontlist[] = FONTLIST;
|
||||||
|
|
||||||
void
|
void usage(void) {
|
||||||
usage(void) {
|
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
"usage: ryudo [-ffm] [-font fname] [-s] [-term prog] [-version] [-virtuals "
|
"usage: ryudo [-ffm] [-font fname] [-s] [-term prog] [-version] [-virtuals "
|
||||||
|
@ -69,8 +68,7 @@ usage(void) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main(int argc, char* argv[]) {
|
||||||
main(int argc, char* argv[]) {
|
|
||||||
int i, do_exit, do_restart;
|
int i, do_exit, do_restart;
|
||||||
char* fname;
|
char* fname;
|
||||||
int shape_event;
|
int shape_event;
|
||||||
|
@ -102,12 +100,14 @@ main(int argc, char* argv[]) {
|
||||||
numvirtuals = atoi(argv[++i]);
|
numvirtuals = atoi(argv[++i]);
|
||||||
if (numvirtuals < 0 || numvirtuals > 12) {
|
if (numvirtuals < 0 || numvirtuals > 12) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "ryudo: wrong number of virtual displays, defaulting to 4\n");
|
stderr,
|
||||||
|
"ryudo: wrong number of virtual displays, defaulting to 4\n");
|
||||||
numvirtuals = 4;
|
numvirtuals = 4;
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[i], "-version") == 0) {
|
} else if (strcmp(argv[i], "-version") == 0) {
|
||||||
fprintf(stderr, "%s", version[0]);
|
fprintf(stderr, "%s", version[0]);
|
||||||
if (PATCHLEVEL > 0) fprintf(stderr, "; patch level %d", PATCHLEVEL);
|
if (PATCHLEVEL > 0)
|
||||||
|
fprintf(stderr, "; patch level %d", PATCHLEVEL);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (strcmp(argv[i], "-s") == 0) {
|
} else if (strcmp(argv[i], "-s") == 0) {
|
||||||
|
@ -124,19 +124,25 @@ main(int argc, char* argv[]) {
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (do_exit && do_restart) usage();
|
if (do_exit && do_restart)
|
||||||
|
usage();
|
||||||
|
|
||||||
shell = (char*)getenv("SHELL");
|
shell = (char*)getenv("SHELL");
|
||||||
if (shell == NULL) shell = DEFSHELL;
|
if (shell == NULL)
|
||||||
|
shell = DEFSHELL;
|
||||||
|
|
||||||
dpy = XOpenDisplay("");
|
dpy = XOpenDisplay("");
|
||||||
if (dpy == 0) fatal("can't open display");
|
if (dpy == 0)
|
||||||
|
fatal("can't open display");
|
||||||
|
|
||||||
initting = 1;
|
initting = 1;
|
||||||
XSetErrorHandler(handler);
|
XSetErrorHandler(handler);
|
||||||
if (signal(SIGTERM, sighandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
|
if (signal(SIGTERM, sighandler) == SIG_IGN)
|
||||||
if (signal(SIGINT, sighandler) == SIG_IGN) signal(SIGINT, SIG_IGN);
|
signal(SIGTERM, SIG_IGN);
|
||||||
if (signal(SIGHUP, sighandler) == SIG_IGN) signal(SIGHUP, SIG_IGN);
|
if (signal(SIGINT, sighandler) == SIG_IGN)
|
||||||
|
signal(SIGINT, SIG_IGN);
|
||||||
|
if (signal(SIGHUP, sighandler) == SIG_IGN)
|
||||||
|
signal(SIGHUP, SIG_IGN);
|
||||||
|
|
||||||
exit_rio = XInternAtom(dpy, "9WM_EXIT", False);
|
exit_rio = XInternAtom(dpy, "9WM_EXIT", False);
|
||||||
restart_rio = XInternAtom(dpy, "9WM_RESTART", False);
|
restart_rio = XInternAtom(dpy, "9WM_RESTART", False);
|
||||||
|
@ -153,7 +159,8 @@ main(int argc, char* argv[]) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0) XSynchronize(dpy, True);
|
if (0)
|
||||||
|
XSynchronize(dpy, True);
|
||||||
|
|
||||||
wm_state = XInternAtom(dpy, "WM_STATE", False);
|
wm_state = XInternAtom(dpy, "WM_STATE", False);
|
||||||
wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);
|
wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);
|
||||||
|
@ -180,7 +187,8 @@ main(int argc, char* argv[]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
font = XLoadQueryFont(dpy, fname);
|
font = XLoadQueryFont(dpy, fname);
|
||||||
if (font != 0) break;
|
if (font != 0)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nostalgia) {
|
if (nostalgia) {
|
||||||
|
@ -195,7 +203,8 @@ main(int argc, char* argv[]) {
|
||||||
num_screens = ScreenCount(dpy);
|
num_screens = ScreenCount(dpy);
|
||||||
screens = (ScreenInfo*)malloc(sizeof(ScreenInfo) * num_screens);
|
screens = (ScreenInfo*)malloc(sizeof(ScreenInfo) * num_screens);
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i++) initscreen(&screens[i], i, 0);
|
for (i = 0; i < num_screens; i++)
|
||||||
|
initscreen(&screens[i], i, 0);
|
||||||
|
|
||||||
initb2menu(numvirtuals);
|
initb2menu(numvirtuals);
|
||||||
|
|
||||||
|
@ -208,15 +217,15 @@ main(int argc, char* argv[]) {
|
||||||
|
|
||||||
nofocus();
|
nofocus();
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i++) scanwins(&screens[i]);
|
for (i = 0; i < num_screens; i++)
|
||||||
|
scanwins(&screens[i]);
|
||||||
|
|
||||||
keysetup();
|
keysetup();
|
||||||
mainloop(shape_event);
|
mainloop(shape_event);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void initscreen(ScreenInfo* s, int i, int background) {
|
||||||
initscreen(ScreenInfo* s, int i, int background) {
|
|
||||||
char *ds, *colon, *dot1;
|
char *ds, *colon, *dot1;
|
||||||
unsigned long mask;
|
unsigned long mask;
|
||||||
unsigned long gmask;
|
unsigned long gmask;
|
||||||
|
@ -271,9 +280,10 @@ initscreen(ScreenInfo* s, int i, int background) {
|
||||||
if (colon && num_screens > 1) {
|
if (colon && num_screens > 1) {
|
||||||
strcpy(s->display, "DISPLAY=");
|
strcpy(s->display, "DISPLAY=");
|
||||||
strcat(s->display, ds);
|
strcat(s->display, ds);
|
||||||
colon = s->display + 8 + (colon - ds); /* use version in buf */
|
colon = s->display + 8 + (colon - ds); /* use version in buf */
|
||||||
dot1 = index(colon, '.'); /* first period after colon */
|
dot1 = index(colon, '.'); /* first period after colon */
|
||||||
if (!dot1) dot1 = colon + strlen(colon); /* if not there, append */
|
if (!dot1)
|
||||||
|
dot1 = colon + strlen(colon); /* if not there, append */
|
||||||
sprintf(dot1, ".%d", i);
|
sprintf(dot1, ".%d", i);
|
||||||
} else
|
} else
|
||||||
s->display[0] = '\0';
|
s->display[0] = '\0';
|
||||||
|
@ -374,18 +384,17 @@ initscreen(ScreenInfo* s, int i, int background) {
|
||||||
&attrs);
|
&attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenInfo*
|
ScreenInfo* getscreen(Window w) {
|
||||||
getscreen(Window w) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_screens; i++)
|
for (i = 0; i < num_screens; i++)
|
||||||
if (screens[i].root == w) return &screens[i];
|
if (screens[i].root == w)
|
||||||
|
return &screens[i];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Time
|
Time timestamp(void) {
|
||||||
timestamp(void) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
if (curtime == CurrentTime) {
|
if (curtime == CurrentTime) {
|
||||||
|
@ -404,8 +413,7 @@ timestamp(void) {
|
||||||
return curtime;
|
return curtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void sendcmessage(Window w, Atom a, long x, int isroot, int usemask) {
|
||||||
sendcmessage(Window w, Atom a, long x, int isroot, int usemask) {
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int status;
|
int status;
|
||||||
long mask;
|
long mask;
|
||||||
|
@ -426,11 +434,11 @@ sendcmessage(Window w, Atom a, long x, int isroot, int usemask) {
|
||||||
mask |= ExposureMask; /* not really correct but so be it */
|
mask |= ExposureMask; /* not really correct but so be it */
|
||||||
}
|
}
|
||||||
status = XSendEvent(dpy, w, False, mask, &ev);
|
status = XSendEvent(dpy, w, False, mask, &ev);
|
||||||
if (status == 0) fprintf(stderr, "ryudo: sendcmessage failed\n");
|
if (status == 0)
|
||||||
|
fprintf(stderr, "ryudo: sendcmessage failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void sendconfig(Client* c) {
|
||||||
sendconfig(Client* c) {
|
|
||||||
XConfigureEvent ce;
|
XConfigureEvent ce;
|
||||||
|
|
||||||
ce.type = ConfigureNotify;
|
ce.type = ConfigureNotify;
|
||||||
|
@ -446,13 +454,9 @@ sendconfig(Client* c) {
|
||||||
XSendEvent(dpy, c->window, False, StructureNotifyMask, (XEvent*)&ce);
|
XSendEvent(dpy, c->window, False, StructureNotifyMask, (XEvent*)&ce);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void sighandler(void) { signalled = 1; }
|
||||||
sighandler(void) {
|
|
||||||
signalled = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void getevent(XEvent* e) {
|
||||||
getevent(XEvent* e) {
|
|
||||||
int fd;
|
int fd;
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
|
@ -486,8 +490,7 @@ getevent(XEvent* e) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cleanup(void) {
|
||||||
cleanup(void) {
|
|
||||||
Client *c, *cc[2], *next;
|
Client *c, *cc[2], *next;
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
int i;
|
int i;
|
||||||
|
@ -512,6 +515,7 @@ cleanup(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, timestamp());
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, timestamp());
|
||||||
for (i = 0; i < num_screens; i++) cmapnofocus(&screens[i]);
|
for (i = 0; i < num_screens; i++)
|
||||||
|
cmapnofocus(&screens[i]);
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
|
|
161
manage.c
161
manage.c
|
@ -22,8 +22,7 @@
|
||||||
|
|
||||||
int isNew;
|
int isNew;
|
||||||
|
|
||||||
int
|
int manage(Client* c, int mapped) {
|
||||||
manage(Client* c, int mapped) {
|
|
||||||
int fixsize, dohide, doreshape, state;
|
int fixsize, dohide, doreshape, state;
|
||||||
long msize;
|
long msize;
|
||||||
XClassHint class;
|
XClassHint class;
|
||||||
|
@ -71,7 +70,8 @@ manage(Client* c, int mapped) {
|
||||||
getcmaps(c);
|
getcmaps(c);
|
||||||
getproto(c);
|
getproto(c);
|
||||||
gettrans(c);
|
gettrans(c);
|
||||||
if (c->is9term) c->hold = getiprop(c->window, _rio_hold_mode);
|
if (c->is9term)
|
||||||
|
c->hold = getiprop(c->window, _rio_hold_mode);
|
||||||
|
|
||||||
/* Figure out what to do with the window from hints */
|
/* Figure out what to do with the window from hints */
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ manage(Client* c, int mapped) {
|
||||||
dohide = (state == IconicState);
|
dohide = (state == IconicState);
|
||||||
|
|
||||||
fixsize = 0;
|
fixsize = 0;
|
||||||
if ((c->size.flags & (USSize | PSize))) fixsize = 1;
|
if ((c->size.flags & (USSize | PSize)))
|
||||||
|
fixsize = 1;
|
||||||
if (
|
if (
|
||||||
(c->size.flags & (PMinSize | PMaxSize)) == (PMinSize | PMaxSize) &&
|
(c->size.flags & (PMinSize | PMaxSize)) == (PMinSize | PMaxSize) &&
|
||||||
c->size.min_width == c->size.max_width &&
|
c->size.min_width == c->size.max_width &&
|
||||||
|
@ -88,11 +89,15 @@ manage(Client* c, int mapped) {
|
||||||
fixsize = 1;
|
fixsize = 1;
|
||||||
doreshape = !mapped;
|
doreshape = !mapped;
|
||||||
if (fixsize) {
|
if (fixsize) {
|
||||||
if (c->size.flags & USPosition) doreshape = 0;
|
if (c->size.flags & USPosition)
|
||||||
if (dohide && (c->size.flags & PPosition)) doreshape = 0;
|
doreshape = 0;
|
||||||
if (c->trans != None) doreshape = 0;
|
if (dohide && (c->size.flags & PPosition))
|
||||||
|
doreshape = 0;
|
||||||
|
if (c->trans != None)
|
||||||
|
doreshape = 0;
|
||||||
}
|
}
|
||||||
if (c->is9term) fixsize = 0;
|
if (c->is9term)
|
||||||
|
fixsize = 0;
|
||||||
if (c->size.flags & PBaseSize) {
|
if (c->size.flags & PBaseSize) {
|
||||||
c->min_dx = c->size.base_width;
|
c->min_dx = c->size.base_width;
|
||||||
c->min_dy = c->size.base_height;
|
c->min_dy = c->size.base_height;
|
||||||
|
@ -105,7 +110,8 @@ manage(Client* c, int mapped) {
|
||||||
} else
|
} else
|
||||||
c->min_dx = c->min_dy = 0;
|
c->min_dx = c->min_dy = 0;
|
||||||
|
|
||||||
if (hints) XFree(hints);
|
if (hints)
|
||||||
|
XFree(hints);
|
||||||
|
|
||||||
/* Now do it!!! */
|
/* Now do it!!! */
|
||||||
|
|
||||||
|
@ -123,7 +129,8 @@ manage(Client* c, int mapped) {
|
||||||
c->min_dy,
|
c->min_dy,
|
||||||
c->dx,
|
c->dx,
|
||||||
c->dy);
|
c->dy);
|
||||||
if (current && current->screen == c->screen) cmapnofocus(c->screen);
|
if (current && current->screen == c->screen)
|
||||||
|
cmapnofocus(c->screen);
|
||||||
if (!c->is9term && c->x == 0 && c->y == 0) {
|
if (!c->is9term && c->x == 0 && c->y == 0) {
|
||||||
static int nwin;
|
static int nwin;
|
||||||
|
|
||||||
|
@ -136,7 +143,8 @@ manage(Client* c, int mapped) {
|
||||||
if (c->is9term && !(fixsize ? drag(c, Button3) : sweep(c, Button3))) {
|
if (c->is9term && !(fixsize ? drag(c, Button3) : sweep(c, Button3))) {
|
||||||
XKillClient(dpy, c->window);
|
XKillClient(dpy, c->window);
|
||||||
rmclient(c);
|
rmclient(c);
|
||||||
if (current && current->screen == c->screen) cmapfocus(current);
|
if (current && current->screen == c->screen)
|
||||||
|
cmapfocus(current);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +171,10 @@ manage(Client* c, int mapped) {
|
||||||
c->parent,
|
c->parent,
|
||||||
SubstructureRedirectMask | SubstructureNotifyMask | ButtonPressMask |
|
SubstructureRedirectMask | SubstructureNotifyMask | ButtonPressMask |
|
||||||
PointerMotionMask | LeaveWindowMask | KeyPressMask);
|
PointerMotionMask | LeaveWindowMask | KeyPressMask);
|
||||||
if (mapped) c->reparenting = 1;
|
if (mapped)
|
||||||
if (doreshape && !fixsize) XResizeWindow(dpy, c->window, c->dx, c->dy);
|
c->reparenting = 1;
|
||||||
|
if (doreshape && !fixsize)
|
||||||
|
XResizeWindow(dpy, c->window, c->dx, c->dy);
|
||||||
XSetWindowBorderWidth(dpy, c->window, 0);
|
XSetWindowBorderWidth(dpy, c->window, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -175,7 +185,9 @@ manage(Client* c, int mapped) {
|
||||||
* (black (or white) border around black (or white) window
|
* (black (or white) border around black (or white) window
|
||||||
* is not very helpful.
|
* is not very helpful.
|
||||||
*/
|
*/
|
||||||
if (c->screen->depth <= 8) { XSetWindowBorderWidth(dpy, c->parent, 1); }
|
if (c->screen->depth <= 8) {
|
||||||
|
XSetWindowBorderWidth(dpy, c->parent, 1);
|
||||||
|
}
|
||||||
|
|
||||||
XReparentWindow(dpy, c->window, c->parent, BORDER, BORDER);
|
XReparentWindow(dpy, c->window, c->parent, BORDER, BORDER);
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
|
@ -203,7 +215,8 @@ manage(Client* c, int mapped) {
|
||||||
setactive(c, 0);
|
setactive(c, 0);
|
||||||
setstate(c, NormalState);
|
setstate(c, NormalState);
|
||||||
}
|
}
|
||||||
if (current && (current != c)) cmapfocus(current);
|
if (current && (current != c))
|
||||||
|
cmapfocus(current);
|
||||||
c->init = 1;
|
c->init = 1;
|
||||||
|
|
||||||
/* If the window is out of bounds of the screen, try to wrangle it */
|
/* If the window is out of bounds of the screen, try to wrangle it */
|
||||||
|
@ -212,10 +225,18 @@ manage(Client* c, int mapped) {
|
||||||
if (c->dx >= ra.width || c->dy >= ra.width) {
|
if (c->dx >= ra.width || c->dy >= ra.width) {
|
||||||
if (c->dx >= ra.width)
|
if (c->dx >= ra.width)
|
||||||
quickreshape(
|
quickreshape(
|
||||||
c, -BORDER, c->y - BORDER, ra.width + 2 * BORDER, c->dy + 2 * BORDER);
|
c,
|
||||||
|
-BORDER,
|
||||||
|
c->y - BORDER,
|
||||||
|
ra.width + 2 * BORDER,
|
||||||
|
c->dy + 2 * BORDER);
|
||||||
if (c->dy >= ra.height)
|
if (c->dy >= ra.height)
|
||||||
quickreshape(
|
quickreshape(
|
||||||
c, c->x - BORDER, -BORDER, c->dx + 2 * BORDER, ra.height + 2 * BORDER);
|
c,
|
||||||
|
c->x - BORDER,
|
||||||
|
-BORDER,
|
||||||
|
c->dx + 2 * BORDER,
|
||||||
|
ra.height + 2 * BORDER);
|
||||||
|
|
||||||
/* and if it's got an edge out of bounds, nudge it into bounds */
|
/* and if it's got an edge out of bounds, nudge it into bounds */
|
||||||
} else {
|
} else {
|
||||||
|
@ -250,12 +271,12 @@ manage(Client* c, int mapped) {
|
||||||
* I can't find a way to have them notice during initdraw, so
|
* I can't find a way to have them notice during initdraw, so
|
||||||
* I solve the problem this way instead. -rsc
|
* I solve the problem this way instead. -rsc
|
||||||
*/
|
*/
|
||||||
if (c->is9term) sendconfig(c);
|
if (c->is9term)
|
||||||
|
sendconfig(c);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void scanwins(ScreenInfo* s) {
|
||||||
scanwins(ScreenInfo* s) {
|
|
||||||
unsigned int i, nwins;
|
unsigned int i, nwins;
|
||||||
Client* c;
|
Client* c;
|
||||||
Window dw1, dw2, *wins;
|
Window dw1, dw2, *wins;
|
||||||
|
@ -264,7 +285,8 @@ scanwins(ScreenInfo* s) {
|
||||||
XQueryTree(dpy, s->root, &dw1, &dw2, &wins, &nwins);
|
XQueryTree(dpy, s->root, &dw1, &dw2, &wins, &nwins);
|
||||||
for (i = 0; i < nwins; i++) {
|
for (i = 0; i < nwins; i++) {
|
||||||
XGetWindowAttributes(dpy, wins[i], &attr);
|
XGetWindowAttributes(dpy, wins[i], &attr);
|
||||||
if (attr.override_redirect || wins[i] == s->menuwin) continue;
|
if (attr.override_redirect || wins[i] == s->menuwin)
|
||||||
|
continue;
|
||||||
c = getclient(wins[i], 1);
|
c = getclient(wins[i], 1);
|
||||||
if (c != 0 && c->window == wins[i] && !c->init) {
|
if (c != 0 && c->window == wins[i] && !c->init) {
|
||||||
c->x = attr.x;
|
c->x = attr.x;
|
||||||
|
@ -274,14 +296,14 @@ scanwins(ScreenInfo* s) {
|
||||||
c->border = attr.border_width;
|
c->border = attr.border_width;
|
||||||
c->screen = s;
|
c->screen = s;
|
||||||
c->parent = s->root;
|
c->parent = s->root;
|
||||||
if (attr.map_state == IsViewable) manage(c, 1);
|
if (attr.map_state == IsViewable)
|
||||||
|
manage(c, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XFree((void*)wins); /* cast is to shut stoopid compiler up */
|
XFree((void*)wins); /* cast is to shut stoopid compiler up */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void gettrans(Client* c) {
|
||||||
gettrans(Client* c) {
|
|
||||||
Window trans;
|
Window trans;
|
||||||
|
|
||||||
trans = None;
|
trans = None;
|
||||||
|
@ -291,8 +313,7 @@ gettrans(Client* c) {
|
||||||
c->trans = None;
|
c->trans = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void withdraw(Client* c) {
|
||||||
withdraw(Client* c) {
|
|
||||||
XUnmapWindow(dpy, c->parent);
|
XUnmapWindow(dpy, c->parent);
|
||||||
XReparentWindow(dpy, c->window, c->screen->root, c->x, c->y);
|
XReparentWindow(dpy, c->window, c->screen->root, c->x, c->y);
|
||||||
XRemoveFromSaveSet(dpy, c->window);
|
XRemoveFromSaveSet(dpy, c->window);
|
||||||
|
@ -304,16 +325,14 @@ withdraw(Client* c) {
|
||||||
ignore_badwindow = 0;
|
ignore_badwindow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void installcmap(ScreenInfo* s, Colormap cmap) {
|
||||||
installcmap(ScreenInfo* s, Colormap cmap) {
|
|
||||||
if (cmap == None)
|
if (cmap == None)
|
||||||
XInstallColormap(dpy, s->def_cmap);
|
XInstallColormap(dpy, s->def_cmap);
|
||||||
else
|
else
|
||||||
XInstallColormap(dpy, cmap);
|
XInstallColormap(dpy, cmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cmapfocus(Client* c) {
|
||||||
cmapfocus(Client* c) {
|
|
||||||
int i, found;
|
int i, found;
|
||||||
Client* cc;
|
Client* cc;
|
||||||
|
|
||||||
|
@ -323,9 +342,11 @@ cmapfocus(Client* c) {
|
||||||
found = 0;
|
found = 0;
|
||||||
for (i = c->ncmapwins - 1; i >= 0; i--) {
|
for (i = c->ncmapwins - 1; i >= 0; i--) {
|
||||||
installcmap(c->screen, c->wmcmaps[i]);
|
installcmap(c->screen, c->wmcmaps[i]);
|
||||||
if (c->cmapwins[i] == c->window) found++;
|
if (c->cmapwins[i] == c->window)
|
||||||
|
found++;
|
||||||
}
|
}
|
||||||
if (!found) installcmap(c->screen, c->cmap);
|
if (!found)
|
||||||
|
installcmap(c->screen, c->cmap);
|
||||||
} else if (
|
} else if (
|
||||||
c->trans != None && (cc = getclient(c->trans, 0)) != 0 &&
|
c->trans != None && (cc = getclient(c->trans, 0)) != 0 &&
|
||||||
cc->ncmapwins != 0)
|
cc->ncmapwins != 0)
|
||||||
|
@ -334,13 +355,9 @@ cmapfocus(Client* c) {
|
||||||
installcmap(c->screen, c->cmap);
|
installcmap(c->screen, c->cmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void cmapnofocus(ScreenInfo* s) { installcmap(s, None); }
|
||||||
cmapnofocus(ScreenInfo* s) {
|
|
||||||
installcmap(s, None);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void getcmaps(Client* c) {
|
||||||
getcmaps(Client* c) {
|
|
||||||
int n, i;
|
int n, i;
|
||||||
Window* cw;
|
Window* cw;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
@ -382,8 +399,7 @@ getcmaps(Client* c) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setlabel(Client* c) {
|
||||||
setlabel(Client* c) {
|
|
||||||
char *label, *p, *lc;
|
char *label, *p, *lc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -397,7 +413,8 @@ setlabel(Client* c) {
|
||||||
label = c->class;
|
label = c->class;
|
||||||
else
|
else
|
||||||
label = "no label";
|
label = "no label";
|
||||||
if ((p = index(label, ':')) != 0) *p = '\0';
|
if ((p = index(label, ':')) != 0)
|
||||||
|
*p = '\0';
|
||||||
for (i = 0, lc = label; *lc != '\0'; lc++, i++) {
|
for (i = 0, lc = label; *lc != '\0'; lc++, i++) {
|
||||||
if (i >= 23) {
|
if (i >= 23) {
|
||||||
label[22] = '~';
|
label[22] = '~';
|
||||||
|
@ -409,8 +426,7 @@ setlabel(Client* c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
void
|
void setshape(Client* c) {
|
||||||
setshape(Client* c) {
|
|
||||||
int n, order;
|
int n, order;
|
||||||
XRectangle* rect;
|
XRectangle* rect;
|
||||||
|
|
||||||
|
@ -430,51 +446,56 @@ setshape(Client* c) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int _getprop(Window w, Atom a, Atom type, long len, unsigned char** p) {
|
||||||
_getprop(Window w, Atom a, Atom type, long len, unsigned char** p) {
|
|
||||||
Atom real_type;
|
Atom real_type;
|
||||||
int format;
|
int format;
|
||||||
unsigned long n, extra;
|
unsigned long n, extra;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = XGetWindowProperty(
|
status = XGetWindowProperty(
|
||||||
dpy, w, a, 0L, len, False, type, &real_type, &format, &n, &extra, p);
|
dpy,
|
||||||
if (status != Success || *p == 0) return -1;
|
w,
|
||||||
if (n == 0) XFree((void*)*p);
|
a,
|
||||||
|
0L,
|
||||||
|
len,
|
||||||
|
False,
|
||||||
|
type,
|
||||||
|
&real_type,
|
||||||
|
&format,
|
||||||
|
&n,
|
||||||
|
&extra,
|
||||||
|
p);
|
||||||
|
if (status != Success || *p == 0)
|
||||||
|
return -1;
|
||||||
|
if (n == 0)
|
||||||
|
XFree((void*)*p);
|
||||||
/* could check real_type, format, extra here... */
|
/* could check real_type, format, extra here... */
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char* getprop(Window w, Atom a) {
|
||||||
getprop(Window w, Atom a) {
|
|
||||||
unsigned char* p;
|
unsigned char* p;
|
||||||
|
|
||||||
if (_getprop(w, a, XA_STRING, 100L, &p) <= 0) return 0;
|
if (_getprop(w, a, XA_STRING, 100L, &p) <= 0)
|
||||||
|
return 0;
|
||||||
return (char*)p;
|
return (char*)p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int get1prop(Window w, Atom a, Atom type) {
|
||||||
get1prop(Window w, Atom a, Atom type) {
|
|
||||||
char **p, *x;
|
char **p, *x;
|
||||||
|
|
||||||
if (_getprop(w, a, type, 1L, (void*)&p) <= 0) return 0;
|
if (_getprop(w, a, type, 1L, (void*)&p) <= 0)
|
||||||
|
return 0;
|
||||||
x = *p;
|
x = *p;
|
||||||
XFree((void*)p);
|
XFree((void*)p);
|
||||||
return (int)(uintptr_t)x;
|
return (int)(uintptr_t)x;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window
|
Window getwprop(Window w, Atom a) { return get1prop(w, a, XA_WINDOW); }
|
||||||
getwprop(Window w, Atom a) {
|
|
||||||
return get1prop(w, a, XA_WINDOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int getiprop(Window w, Atom a) { return get1prop(w, a, XA_INTEGER); }
|
||||||
getiprop(Window w, Atom a) {
|
|
||||||
return get1prop(w, a, XA_INTEGER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void setstate(Client* c, int state) {
|
||||||
setstate(Client* c, int state) {
|
|
||||||
long data[2];
|
long data[2];
|
||||||
|
|
||||||
data[0] = (long)state;
|
data[0] = (long)state;
|
||||||
|
@ -492,19 +513,18 @@ setstate(Client* c, int state) {
|
||||||
2);
|
2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int getstate(Window w, int* state) {
|
||||||
getstate(Window w, int* state) {
|
|
||||||
long* p = 0;
|
long* p = 0;
|
||||||
|
|
||||||
if (_getprop(w, wm_state, wm_state, 2L, (void*)&p) <= 0) return 0;
|
if (_getprop(w, wm_state, wm_state, 2L, (void*)&p) <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
*state = (int)*p;
|
*state = (int)*p;
|
||||||
XFree((char*)p);
|
XFree((char*)p);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void getproto(Client* c) {
|
||||||
getproto(Client* c) {
|
|
||||||
Atom* p;
|
Atom* p;
|
||||||
int i;
|
int i;
|
||||||
long n;
|
long n;
|
||||||
|
@ -512,7 +532,8 @@ getproto(Client* c) {
|
||||||
|
|
||||||
w = c->window;
|
w = c->window;
|
||||||
c->proto = 0;
|
c->proto = 0;
|
||||||
if ((n = _getprop(w, wm_protocols, XA_ATOM, 20L, (void*)&p)) <= 0) return;
|
if ((n = _getprop(w, wm_protocols, XA_ATOM, 20L, (void*)&p)) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
if (p[i] == wm_delete)
|
if (p[i] == wm_delete)
|
||||||
|
|
185
menu.c
185
menu.c
|
@ -72,8 +72,7 @@ Menu b3menu = {b3items};
|
||||||
|
|
||||||
Menu egg = {version};
|
Menu egg = {version};
|
||||||
|
|
||||||
void
|
void button(XButtonEvent* e) {
|
||||||
button(XButtonEvent* e) {
|
|
||||||
int n, shift;
|
int n, shift;
|
||||||
Client* c;
|
Client* c;
|
||||||
Window dw;
|
Window dw;
|
||||||
|
@ -81,7 +80,8 @@ button(XButtonEvent* e) {
|
||||||
|
|
||||||
curtime = e->time;
|
curtime = e->time;
|
||||||
s = getscreen(e->root);
|
s = getscreen(e->root);
|
||||||
if (s == 0) return;
|
if (s == 0)
|
||||||
|
return;
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -98,23 +98,37 @@ button(XButtonEvent* e) {
|
||||||
if (borderorient(c, e->x, e->y) != BorderUnknown) {
|
if (borderorient(c, e->x, e->y) != BorderUnknown) {
|
||||||
switch (e->button) {
|
switch (e->button) {
|
||||||
case Button1:
|
case Button1:
|
||||||
case Button2: reshape(c, e->button, pull, e); return;
|
case Button2:
|
||||||
case Button3: move(c, Button3); return;
|
reshape(c, e->button, pull, e);
|
||||||
default: return;
|
return;
|
||||||
|
case Button3:
|
||||||
|
move(c, Button3);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->x += c->x - BORDER;
|
e->x += c->x - BORDER;
|
||||||
e->y += c->y - BORDER;
|
e->y += c->y - BORDER;
|
||||||
} else if (e->window != e->root) {
|
} else if (e->window != e->root) {
|
||||||
if (debug) fprintf(stderr, "but no client: e x=%d y=%d\n", e->x, e->y);
|
if (debug)
|
||||||
|
fprintf(stderr, "but no client: e x=%d y=%d\n", e->x, e->y);
|
||||||
XTranslateCoordinates(
|
XTranslateCoordinates(
|
||||||
dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw);
|
dpy,
|
||||||
|
e->window,
|
||||||
|
s->root,
|
||||||
|
e->x,
|
||||||
|
e->y,
|
||||||
|
&e->x,
|
||||||
|
&e->y,
|
||||||
|
&dw);
|
||||||
}
|
}
|
||||||
switch (e->button) {
|
switch (e->button) {
|
||||||
case Button1:
|
case Button1:
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (c) {
|
if (c) {
|
||||||
if (ffm) XRaiseWindow(dpy, c->window);
|
if (ffm)
|
||||||
|
XRaiseWindow(dpy, c->window);
|
||||||
XMapRaised(dpy, c->parent);
|
XMapRaised(dpy, c->parent);
|
||||||
top(c);
|
top(c);
|
||||||
active(c);
|
active(c);
|
||||||
|
@ -131,42 +145,60 @@ button(XButtonEvent* e) {
|
||||||
} else if (numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1)
|
} else if (numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1)
|
||||||
button2(n);
|
button2(n);
|
||||||
return;
|
return;
|
||||||
case Button3: break;
|
case Button3:
|
||||||
|
break;
|
||||||
case Button4:
|
case Button4:
|
||||||
/* scroll up changes to previous virtual screen */
|
/* scroll up changes to previous virtual screen */
|
||||||
if (!c && e->type == ButtonPress)
|
if (!c && e->type == ButtonPress)
|
||||||
if (numvirtuals > 1 && virt > 0) switch_to(virt - 1);
|
if (numvirtuals > 1 && virt > 0)
|
||||||
|
switch_to(virt - 1);
|
||||||
return;
|
return;
|
||||||
case Button5:
|
case Button5:
|
||||||
/* scroll down changes to next virtual screen */
|
/* scroll down changes to next virtual screen */
|
||||||
if (!c && e->type == ButtonPress)
|
if (!c && e->type == ButtonPress)
|
||||||
if (numvirtuals > 1 && virt < numvirtuals - 1) switch_to(virt + 1);
|
if (numvirtuals > 1 && virt < numvirtuals - 1)
|
||||||
|
switch_to(virt + 1);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
return;
|
return;
|
||||||
default: return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current && current->screen == s) cmapnofocus(s);
|
if (current && current->screen == s)
|
||||||
|
cmapnofocus(s);
|
||||||
switch (n = menuhit(e, &b3menu)) {
|
switch (n = menuhit(e, &b3menu)) {
|
||||||
case New: spawn(s); break;
|
case New:
|
||||||
case Reshape: reshape(selectwin(1, 0, s), Button3, sweep, 0); break;
|
spawn(s);
|
||||||
case Move: move(selectwin(0, 0, s), Button3); break;
|
break;
|
||||||
|
case Reshape:
|
||||||
|
reshape(selectwin(1, 0, s), Button3, sweep, 0);
|
||||||
|
break;
|
||||||
|
case Move:
|
||||||
|
move(selectwin(0, 0, s), Button3);
|
||||||
|
break;
|
||||||
case Delete:
|
case Delete:
|
||||||
shift = 0;
|
shift = 0;
|
||||||
c = selectwin(1, &shift, s);
|
c = selectwin(1, &shift, s);
|
||||||
delete (c, shift);
|
delete (c, shift);
|
||||||
break;
|
break;
|
||||||
case Hide: hide(selectwin(1, 0, s)); break;
|
case Hide:
|
||||||
|
hide(selectwin(1, 0, s));
|
||||||
|
break;
|
||||||
#ifdef SHOWSTICK
|
#ifdef SHOWSTICK
|
||||||
case Stick: stick(selectwin(1, 0, s)); break;
|
case Stick:
|
||||||
|
stick(selectwin(1, 0, s));
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default: /* unhide window */ unhide(n - B3FIXED, 1); break;
|
default: /* unhide window */
|
||||||
case -1: /* nothing */ break;
|
unhide(n - B3FIXED, 1);
|
||||||
|
break;
|
||||||
|
case -1: /* nothing */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (current && current->screen == s) cmapfocus(current);
|
if (current && current->screen == s)
|
||||||
|
cmapfocus(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void spawn(ScreenInfo* s) {
|
||||||
spawn(ScreenInfo* s) {
|
|
||||||
/*
|
/*
|
||||||
* ugly dance to cause sweeping for terminals.
|
* ugly dance to cause sweeping for terminals.
|
||||||
* the very next window created will require sweeping.
|
* the very next window created will require sweeping.
|
||||||
|
@ -181,7 +213,8 @@ spawn(ScreenInfo* s) {
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
if (s->display[0] != '\0') putenv(s->display);
|
if (s->display[0] != '\0')
|
||||||
|
putenv(s->display);
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
|
@ -201,15 +234,16 @@ spawn(ScreenInfo* s) {
|
||||||
wait((int*)0);
|
wait((int*)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void reshape(
|
||||||
reshape(
|
|
||||||
Client* c, int but, int (*fn)(Client*, int, XButtonEvent*), XButtonEvent* e) {
|
Client* c, int but, int (*fn)(Client*, int, XButtonEvent*), XButtonEvent* e) {
|
||||||
int odx, ody;
|
int odx, ody;
|
||||||
|
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
odx = c->dx;
|
odx = c->dx;
|
||||||
ody = c->dy;
|
ody = c->dy;
|
||||||
if (fn(c, but, e) == 0) return;
|
if (fn(c, but, e) == 0)
|
||||||
|
return;
|
||||||
active(c);
|
active(c);
|
||||||
top(c);
|
top(c);
|
||||||
XRaiseWindow(dpy, c->parent);
|
XRaiseWindow(dpy, c->parent);
|
||||||
|
@ -226,10 +260,11 @@ reshape(
|
||||||
XMoveResizeWindow(dpy, c->window, BORDER, BORDER, c->dx, c->dy);
|
XMoveResizeWindow(dpy, c->window, BORDER, BORDER, c->dx, c->dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void move(Client* c, int but) {
|
||||||
move(Client* c, int but) {
|
if (c == 0)
|
||||||
if (c == 0) return;
|
return;
|
||||||
if (drag(c, but) == 0) return;
|
if (drag(c, but) == 0)
|
||||||
|
return;
|
||||||
active(c);
|
active(c);
|
||||||
top(c);
|
top(c);
|
||||||
XRaiseWindow(dpy, c->parent);
|
XRaiseWindow(dpy, c->parent);
|
||||||
|
@ -238,16 +273,17 @@ move(Client* c, int but) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void delete (Client* c, int shift) {
|
void delete (Client* c, int shift) {
|
||||||
if (c == 0) return;
|
if (c == 0)
|
||||||
|
return;
|
||||||
if ((c->proto & Pdelete) && !shift)
|
if ((c->proto & Pdelete) && !shift)
|
||||||
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
|
sendcmessage(c->window, wm_protocols, wm_delete, 0, 0);
|
||||||
else
|
else
|
||||||
XKillClient(dpy, c->window); /* let event clean up */
|
XKillClient(dpy, c->window); /* let event clean up */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void hide(Client* c) {
|
||||||
hide(Client* c) {
|
if (c == 0 || numhidden == MAXHIDDEN)
|
||||||
if (c == 0 || numhidden == MAXHIDDEN) return;
|
return;
|
||||||
if (hidden(c)) {
|
if (hidden(c)) {
|
||||||
fprintf(stderr, "ryudo: already hidden: %s\n", c->label);
|
fprintf(stderr, "ryudo: already hidden: %s\n", c->label);
|
||||||
return;
|
return;
|
||||||
|
@ -255,11 +291,14 @@ hide(Client* c) {
|
||||||
XUnmapWindow(dpy, c->parent);
|
XUnmapWindow(dpy, c->parent);
|
||||||
XUnmapWindow(dpy, c->window);
|
XUnmapWindow(dpy, c->window);
|
||||||
setstate(c, IconicState);
|
setstate(c, IconicState);
|
||||||
if (c == current) nofocus();
|
if (c == current)
|
||||||
|
nofocus();
|
||||||
if (reversehide) {
|
if (reversehide) {
|
||||||
memmove(hiddenc + 1, hiddenc, numhidden * sizeof hiddenc[0]);
|
memmove(hiddenc + 1, hiddenc, numhidden * sizeof hiddenc[0]);
|
||||||
memmove(
|
memmove(
|
||||||
b3items + B3FIXED + 1, b3items + B3FIXED, numhidden * sizeof b3items[0]);
|
b3items + B3FIXED + 1,
|
||||||
|
b3items + B3FIXED,
|
||||||
|
numhidden * sizeof b3items[0]);
|
||||||
hiddenc[0] = c;
|
hiddenc[0] = c;
|
||||||
b3items[B3FIXED] = c->label;
|
b3items[B3FIXED] = c->label;
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,8 +309,7 @@ hide(Client* c) {
|
||||||
b3items[B3FIXED + numhidden] = 0;
|
b3items[B3FIXED + numhidden] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unhide(int n, int map) {
|
||||||
unhide(int n, int map) {
|
|
||||||
Client* c;
|
Client* c;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -306,8 +344,7 @@ unhide(int n, int map) {
|
||||||
b3items[B3FIXED + numhidden] = 0;
|
b3items[B3FIXED + numhidden] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void unhidec(Client* c, int map) {
|
||||||
unhidec(Client* c, int map) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numhidden; i++)
|
for (i = 0; i < numhidden; i++)
|
||||||
|
@ -316,24 +353,27 @@ unhidec(Client* c, int map) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "ryudo: unhidec: not hidden: %s(0x%x)\n", c->label, (int)c->window);
|
stderr,
|
||||||
|
"ryudo: unhidec: not hidden: %s(0x%x)\n",
|
||||||
|
c->label,
|
||||||
|
(int)c->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void stick(Client* c) {
|
||||||
stick(Client* c) {
|
|
||||||
if (numvirtuals > 1 && c->virt >= 0)
|
if (numvirtuals > 1 && c->virt >= 0)
|
||||||
c->virt = -1;
|
c->virt = -1;
|
||||||
else
|
else
|
||||||
c->virt = virt;
|
c->virt = virt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void renamec(Client* c, char* name) {
|
||||||
renamec(Client* c, char* name) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (name == 0) name = "???";
|
if (name == 0)
|
||||||
|
name = "???";
|
||||||
c->label = name;
|
c->label = name;
|
||||||
if (!hidden(c)) return;
|
if (!hidden(c))
|
||||||
|
return;
|
||||||
for (i = 0; i < numhidden; i++)
|
for (i = 0; i < numhidden; i++)
|
||||||
if (c == hiddenc[i]) {
|
if (c == hiddenc[i]) {
|
||||||
b3items[B3FIXED + i] = name;
|
b3items[B3FIXED + i] = name;
|
||||||
|
@ -341,50 +381,57 @@ renamec(Client* c, char* name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void button2(int n) {
|
||||||
button2(int n) {
|
|
||||||
switch_to(n);
|
switch_to(n);
|
||||||
if (current) cmapfocus(current);
|
if (current)
|
||||||
|
cmapfocus(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void switch_to_c(int n, Client* c) {
|
||||||
switch_to_c(int n, Client* c) {
|
if (c == 0)
|
||||||
if (c == 0) return;
|
return;
|
||||||
|
|
||||||
if (c->next) switch_to_c(n, c->next);
|
if (c->next)
|
||||||
|
switch_to_c(n, c->next);
|
||||||
|
|
||||||
if (c->parent == DefaultRootWindow(dpy)) return;
|
if (c->parent == DefaultRootWindow(dpy))
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef AUTOSTICK
|
#ifdef AUTOSTICK
|
||||||
if (c->virt >= 0 && isautostick(c)) { stick(c); }
|
if (c->virt >= 0 && isautostick(c)) {
|
||||||
|
stick(c);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (c->virt != virt && c->state == NormalState && c->virt >= 0) {
|
if (c->virt != virt && c->state == NormalState && c->virt >= 0) {
|
||||||
XUnmapWindow(dpy, c->parent);
|
XUnmapWindow(dpy, c->parent);
|
||||||
XUnmapWindow(dpy, c->window);
|
XUnmapWindow(dpy, c->window);
|
||||||
setstate(c, IconicState);
|
setstate(c, IconicState);
|
||||||
if (c == current) nofocus();
|
if (c == current)
|
||||||
|
nofocus();
|
||||||
} else if (c->virt == virt && c->state == IconicState) {
|
} else if (c->virt == virt && c->state == IconicState) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < numhidden; i++)
|
for (i = 0; i < numhidden; i++)
|
||||||
if (c == hiddenc[i]) break;
|
if (c == hiddenc[i])
|
||||||
|
break;
|
||||||
|
|
||||||
if (i == numhidden) {
|
if (i == numhidden) {
|
||||||
XMapWindow(dpy, c->window);
|
XMapWindow(dpy, c->window);
|
||||||
XMapWindow(dpy, c->parent);
|
XMapWindow(dpy, c->parent);
|
||||||
setstate(c, NormalState);
|
setstate(c, NormalState);
|
||||||
if (currents[virt] == c) active(c);
|
if (currents[virt] == c)
|
||||||
|
active(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void switch_to(int n) {
|
||||||
switch_to(int n) {
|
|
||||||
#ifdef VIRTNOTIFY
|
#ifdef VIRTNOTIFY
|
||||||
static char virtmsg[32];
|
static char virtmsg[32];
|
||||||
#endif
|
#endif
|
||||||
if (n == virt) return;
|
if (n == virt)
|
||||||
|
return;
|
||||||
currents[virt] = current;
|
currents[virt] = current;
|
||||||
virt = n;
|
virt = n;
|
||||||
|
|
||||||
|
@ -398,7 +445,8 @@ switch_to(int n) {
|
||||||
top(current);
|
top(current);
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
if (dpy != '\0') putenv(dpy);
|
if (dpy != '\0')
|
||||||
|
putenv(dpy);
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
|
@ -416,7 +464,4 @@ switch_to(int n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void initb2menu(int n) { b2items[n] = 0; }
|
||||||
initb2menu(int n) {
|
|
||||||
b2items[n] = 0;
|
|
||||||
}
|
|
||||||
|
|
540
printevent.c
540
printevent.c
|
@ -55,46 +55,52 @@ static char* sep = " ";
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/* Returns the string equivalent of a boolean parameter */
|
/* Returns the string equivalent of a boolean parameter */
|
||||||
static char*
|
static char* TorF(int bool) {
|
||||||
TorF(int bool) {
|
|
||||||
switch (bool) {
|
switch (bool) {
|
||||||
case True: return ("True");
|
case True:
|
||||||
|
return ("True");
|
||||||
|
|
||||||
case False: return ("False");
|
case False:
|
||||||
|
return ("False");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a property notify state */
|
/* Returns the string equivalent of a property notify state */
|
||||||
static char*
|
static char* PropertyState(int state) {
|
||||||
PropertyState(int state) {
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PropertyNewValue: return ("PropertyNewValue");
|
case PropertyNewValue:
|
||||||
|
return ("PropertyNewValue");
|
||||||
|
|
||||||
case PropertyDelete: return ("PropertyDelete");
|
case PropertyDelete:
|
||||||
|
return ("PropertyDelete");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a visibility notify state */
|
/* Returns the string equivalent of a visibility notify state */
|
||||||
static char*
|
static char* VisibilityState(int state) {
|
||||||
VisibilityState(int state) {
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case VisibilityUnobscured: return ("VisibilityUnobscured");
|
case VisibilityUnobscured:
|
||||||
|
return ("VisibilityUnobscured");
|
||||||
|
|
||||||
case VisibilityPartiallyObscured: return ("VisibilityPartiallyObscured");
|
case VisibilityPartiallyObscured:
|
||||||
|
return ("VisibilityPartiallyObscured");
|
||||||
|
|
||||||
case VisibilityFullyObscured: return ("VisibilityFullyObscured");
|
case VisibilityFullyObscured:
|
||||||
|
return ("VisibilityFullyObscured");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a timestamp */
|
/* Returns the string equivalent of a timestamp */
|
||||||
static char*
|
static char* ServerTime(Time time) {
|
||||||
ServerTime(Time time) {
|
|
||||||
unsigned long msec;
|
unsigned long msec;
|
||||||
unsigned long sec;
|
unsigned long sec;
|
||||||
unsigned long min;
|
unsigned long min;
|
||||||
|
@ -135,8 +141,7 @@ struct MaskType {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Returns the string equivalent of a mask of buttons and/or modifier keys */
|
/* Returns the string equivalent of a mask of buttons and/or modifier keys */
|
||||||
static char*
|
static char* ButtonAndOrModifierState(unsigned int state) {
|
||||||
ButtonAndOrModifierState(unsigned int state) {
|
|
||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
static MaskType masks[] = {
|
static MaskType masks[] = {
|
||||||
{Button1Mask, "Button1Mask"},
|
{Button1Mask, "Button1Mask"},
|
||||||
|
@ -172,8 +177,7 @@ ButtonAndOrModifierState(unsigned int state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a mask of configure window values */
|
/* Returns the string equivalent of a mask of configure window values */
|
||||||
static char*
|
static char* ConfigureValueMask(unsigned int valuemask) {
|
||||||
ConfigureValueMask(unsigned int valuemask) {
|
|
||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
static MaskType masks[] = {
|
static MaskType masks[] = {
|
||||||
{CWX, "CWX"},
|
{CWX, "CWX"},
|
||||||
|
@ -204,20 +208,21 @@ ConfigureValueMask(unsigned int valuemask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a motion hint */
|
/* Returns the string equivalent of a motion hint */
|
||||||
static char*
|
static char* IsHint(char is_hint) {
|
||||||
IsHint(char is_hint) {
|
|
||||||
switch (is_hint) {
|
switch (is_hint) {
|
||||||
case NotifyNormal: return ("NotifyNormal");
|
case NotifyNormal:
|
||||||
|
return ("NotifyNormal");
|
||||||
|
|
||||||
case NotifyHint: return ("NotifyHint");
|
case NotifyHint:
|
||||||
|
return ("NotifyHint");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of an id or the value "None" */
|
/* Returns the string equivalent of an id or the value "None" */
|
||||||
static char*
|
static char* MaybeNone(int value) {
|
||||||
MaybeNone(int value) {
|
|
||||||
static char buffer[16];
|
static char buffer[16];
|
||||||
|
|
||||||
if (value == None)
|
if (value == None)
|
||||||
|
@ -229,136 +234,167 @@ MaybeNone(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a colormap state */
|
/* Returns the string equivalent of a colormap state */
|
||||||
static char*
|
static char* ColormapState(int state) {
|
||||||
ColormapState(int state) {
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ColormapInstalled: return ("ColormapInstalled");
|
case ColormapInstalled:
|
||||||
|
return ("ColormapInstalled");
|
||||||
|
|
||||||
case ColormapUninstalled: return ("ColormapUninstalled");
|
case ColormapUninstalled:
|
||||||
|
return ("ColormapUninstalled");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a crossing detail */
|
/* Returns the string equivalent of a crossing detail */
|
||||||
static char*
|
static char* CrossingDetail(int detail) {
|
||||||
CrossingDetail(int detail) {
|
|
||||||
switch (detail) {
|
switch (detail) {
|
||||||
case NotifyAncestor: return ("NotifyAncestor");
|
case NotifyAncestor:
|
||||||
|
return ("NotifyAncestor");
|
||||||
|
|
||||||
case NotifyInferior: return ("NotifyInferior");
|
case NotifyInferior:
|
||||||
|
return ("NotifyInferior");
|
||||||
|
|
||||||
case NotifyVirtual: return ("NotifyVirtual");
|
case NotifyVirtual:
|
||||||
|
return ("NotifyVirtual");
|
||||||
|
|
||||||
case NotifyNonlinear: return ("NotifyNonlinear");
|
case NotifyNonlinear:
|
||||||
|
return ("NotifyNonlinear");
|
||||||
|
|
||||||
case NotifyNonlinearVirtual: return ("NotifyNonlinearVirtual");
|
case NotifyNonlinearVirtual:
|
||||||
|
return ("NotifyNonlinearVirtual");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a focus change detail */
|
/* Returns the string equivalent of a focus change detail */
|
||||||
static char*
|
static char* FocusChangeDetail(int detail) {
|
||||||
FocusChangeDetail(int detail) {
|
|
||||||
switch (detail) {
|
switch (detail) {
|
||||||
case NotifyAncestor: return ("NotifyAncestor");
|
case NotifyAncestor:
|
||||||
|
return ("NotifyAncestor");
|
||||||
|
|
||||||
case NotifyInferior: return ("NotifyInferior");
|
case NotifyInferior:
|
||||||
|
return ("NotifyInferior");
|
||||||
|
|
||||||
case NotifyVirtual: return ("NotifyVirtual");
|
case NotifyVirtual:
|
||||||
|
return ("NotifyVirtual");
|
||||||
|
|
||||||
case NotifyNonlinear: return ("NotifyNonlinear");
|
case NotifyNonlinear:
|
||||||
|
return ("NotifyNonlinear");
|
||||||
|
|
||||||
case NotifyNonlinearVirtual: return ("NotifyNonlinearVirtual");
|
case NotifyNonlinearVirtual:
|
||||||
|
return ("NotifyNonlinearVirtual");
|
||||||
|
|
||||||
case NotifyPointer: return ("NotifyPointer");
|
case NotifyPointer:
|
||||||
|
return ("NotifyPointer");
|
||||||
|
|
||||||
case NotifyPointerRoot: return ("NotifyPointerRoot");
|
case NotifyPointerRoot:
|
||||||
|
return ("NotifyPointerRoot");
|
||||||
|
|
||||||
case NotifyDetailNone: return ("NotifyDetailNone");
|
case NotifyDetailNone:
|
||||||
|
return ("NotifyDetailNone");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a configure detail */
|
/* Returns the string equivalent of a configure detail */
|
||||||
static char*
|
static char* ConfigureDetail(int detail) {
|
||||||
ConfigureDetail(int detail) {
|
|
||||||
switch (detail) {
|
switch (detail) {
|
||||||
case Above: return ("Above");
|
case Above:
|
||||||
|
return ("Above");
|
||||||
|
|
||||||
case Below: return ("Below");
|
case Below:
|
||||||
|
return ("Below");
|
||||||
|
|
||||||
case TopIf: return ("TopIf");
|
case TopIf:
|
||||||
|
return ("TopIf");
|
||||||
|
|
||||||
case BottomIf: return ("BottomIf");
|
case BottomIf:
|
||||||
|
return ("BottomIf");
|
||||||
|
|
||||||
case Opposite: return ("Opposite");
|
case Opposite:
|
||||||
|
return ("Opposite");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a grab mode */
|
/* Returns the string equivalent of a grab mode */
|
||||||
static char*
|
static char* GrabMode(int mode) {
|
||||||
GrabMode(int mode) {
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case NotifyNormal: return ("NotifyNormal");
|
case NotifyNormal:
|
||||||
|
return ("NotifyNormal");
|
||||||
|
|
||||||
case NotifyGrab: return ("NotifyGrab");
|
case NotifyGrab:
|
||||||
|
return ("NotifyGrab");
|
||||||
|
|
||||||
case NotifyUngrab: return ("NotifyUngrab");
|
case NotifyUngrab:
|
||||||
|
return ("NotifyUngrab");
|
||||||
|
|
||||||
case NotifyWhileGrabbed: return ("NotifyWhileGrabbed");
|
case NotifyWhileGrabbed:
|
||||||
|
return ("NotifyWhileGrabbed");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a mapping request */
|
/* Returns the string equivalent of a mapping request */
|
||||||
static char*
|
static char* MappingRequest(int request) {
|
||||||
MappingRequest(int request) {
|
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case MappingModifier: return ("MappingModifier");
|
case MappingModifier:
|
||||||
|
return ("MappingModifier");
|
||||||
|
|
||||||
case MappingKeyboard: return ("MappingKeyboard");
|
case MappingKeyboard:
|
||||||
|
return ("MappingKeyboard");
|
||||||
|
|
||||||
case MappingPointer: return ("MappingPointer");
|
case MappingPointer:
|
||||||
|
return ("MappingPointer");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a stacking order place */
|
/* Returns the string equivalent of a stacking order place */
|
||||||
static char*
|
static char* Place(int place) {
|
||||||
Place(int place) {
|
|
||||||
switch (place) {
|
switch (place) {
|
||||||
case PlaceOnTop: return ("PlaceOnTop");
|
case PlaceOnTop:
|
||||||
|
return ("PlaceOnTop");
|
||||||
|
|
||||||
case PlaceOnBottom: return ("PlaceOnBottom");
|
case PlaceOnBottom:
|
||||||
|
return ("PlaceOnBottom");
|
||||||
|
|
||||||
default: return ("?");
|
default:
|
||||||
|
return ("?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of a major code */
|
/* Returns the string equivalent of a major code */
|
||||||
static char*
|
static char* MajorCode(int code) {
|
||||||
MajorCode(int code) {
|
|
||||||
static char buffer[32];
|
static char buffer[32];
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case X_CopyArea: return ("X_CopyArea");
|
case X_CopyArea:
|
||||||
|
return ("X_CopyArea");
|
||||||
|
|
||||||
case X_CopyPlane: return ("X_CopyPlane");
|
case X_CopyPlane:
|
||||||
|
return ("X_CopyPlane");
|
||||||
|
|
||||||
default: sprintf(buffer, "0x%x", code); return (buffer);
|
default:
|
||||||
|
sprintf(buffer, "0x%x", code);
|
||||||
|
return (buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent the keycode contained in the key event */
|
/* Returns the string equivalent the keycode contained in the key event */
|
||||||
static char*
|
static char* Keycode(XKeyEvent* ev) {
|
||||||
Keycode(XKeyEvent* ev) {
|
|
||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
KeySym keysym_str;
|
KeySym keysym_str;
|
||||||
char* keysym_name;
|
char* keysym_name;
|
||||||
|
@ -380,12 +416,12 @@ Keycode(XKeyEvent* ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the string equivalent of an atom or "None"*/
|
/* Returns the string equivalent of an atom or "None"*/
|
||||||
static char*
|
static char* AtomName(Display* dpy, Atom atom) {
|
||||||
AtomName(Display* dpy, Atom atom) {
|
|
||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
char* atom_name;
|
char* atom_name;
|
||||||
|
|
||||||
if (atom == None) return ("None");
|
if (atom == None)
|
||||||
|
return ("None");
|
||||||
|
|
||||||
atom_name = XGetAtomName(dpy, atom);
|
atom_name = XGetAtomName(dpy, atom);
|
||||||
strncpy(buffer, atom_name, 256);
|
strncpy(buffer, atom_name, 256);
|
||||||
|
@ -397,8 +433,7 @@ AtomName(Display* dpy, Atom atom) {
|
||||||
/**** Routines to print out readable values for the field of various events ***/
|
/**** Routines to print out readable values for the field of various events ***/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
static void
|
static void VerbMotion(XMotionEvent* ev) {
|
||||||
VerbMotion(XMotionEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("root=0x%x%s", (int)ev->root, sep);
|
printf("root=0x%x%s", (int)ev->root, sep);
|
||||||
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
||||||
|
@ -410,8 +445,7 @@ VerbMotion(XMotionEvent* ev) {
|
||||||
printf("same_screen=%s\n", TorF(ev->same_screen));
|
printf("same_screen=%s\n", TorF(ev->same_screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbButton(XButtonEvent* ev) {
|
||||||
VerbButton(XButtonEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("root=0x%x%s", (int)ev->root, sep);
|
printf("root=0x%x%s", (int)ev->root, sep);
|
||||||
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
||||||
|
@ -423,16 +457,14 @@ VerbButton(XButtonEvent* ev) {
|
||||||
printf("same_screen=%s\n", TorF(ev->same_screen));
|
printf("same_screen=%s\n", TorF(ev->same_screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbColormap(XColormapEvent* ev) {
|
||||||
VerbColormap(XColormapEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
|
printf("colormap=%s%s", MaybeNone(ev->colormap), sep);
|
||||||
printf("new=%s%s", TorF(ev->new), sep);
|
printf("new=%s%s", TorF(ev->new), sep);
|
||||||
printf("state=%s\n", ColormapState(ev->state));
|
printf("state=%s\n", ColormapState(ev->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbCrossing(XCrossingEvent* ev) {
|
||||||
VerbCrossing(XCrossingEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("root=0x%x%s", (int)ev->root, sep);
|
printf("root=0x%x%s", (int)ev->root, sep);
|
||||||
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
||||||
|
@ -446,16 +478,14 @@ VerbCrossing(XCrossingEvent* ev) {
|
||||||
printf("state=%s\n", ButtonAndOrModifierState(ev->state));
|
printf("state=%s\n", ButtonAndOrModifierState(ev->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbExpose(XExposeEvent* ev) {
|
||||||
VerbExpose(XExposeEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
||||||
printf("width=%d height=%d%s", ev->width, ev->height, sep);
|
printf("width=%d height=%d%s", ev->width, ev->height, sep);
|
||||||
printf("count=%d\n", ev->count);
|
printf("count=%d\n", ev->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
|
||||||
VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
|
|
||||||
printf("drawable=0x%x%s", (int)ev->drawable, sep);
|
printf("drawable=0x%x%s", (int)ev->drawable, sep);
|
||||||
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
||||||
printf("width=%d height=%d%s", ev->width, ev->height, sep);
|
printf("width=%d height=%d%s", ev->width, ev->height, sep);
|
||||||
|
@ -463,41 +493,41 @@ VerbGraphicsExpose(XGraphicsExposeEvent* ev) {
|
||||||
printf("minor_code=%d\n", ev->minor_code);
|
printf("minor_code=%d\n", ev->minor_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbNoExpose(XNoExposeEvent* ev) {
|
||||||
VerbNoExpose(XNoExposeEvent* ev) {
|
|
||||||
printf("drawable=0x%x%s", (int)ev->drawable, sep);
|
printf("drawable=0x%x%s", (int)ev->drawable, sep);
|
||||||
printf("major_code=%s%s", MajorCode(ev->major_code), sep);
|
printf("major_code=%s%s", MajorCode(ev->major_code), sep);
|
||||||
printf("minor_code=%d\n", ev->minor_code);
|
printf("minor_code=%d\n", ev->minor_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbFocus(XFocusChangeEvent* ev) {
|
||||||
VerbFocus(XFocusChangeEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("mode=%s%s", GrabMode(ev->mode), sep);
|
printf("mode=%s%s", GrabMode(ev->mode), sep);
|
||||||
printf("detail=%s\n", FocusChangeDetail(ev->detail));
|
printf("detail=%s\n", FocusChangeDetail(ev->detail));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbKeymap(XKeymapEvent* ev) {
|
||||||
VerbKeymap(XKeymapEvent* ev) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("key_vector=");
|
printf("key_vector=");
|
||||||
for (i = 0; i < 32; i++) printf("%02x", ev->key_vector[i]);
|
for (i = 0; i < 32; i++)
|
||||||
|
printf("%02x", ev->key_vector[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbKey(XKeyEvent* ev) {
|
||||||
VerbKey(XKeyEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("root=0x%x%s", (int)ev->root, sep);
|
printf("root=0x%x%s", (int)ev->root, sep);
|
||||||
if (ev->subwindow) printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
if (ev->subwindow)
|
||||||
|
printf("subwindow=0x%x%s", (int)ev->subwindow, sep);
|
||||||
printf("time=%s%s", ServerTime(ev->time), sep);
|
printf("time=%s%s", ServerTime(ev->time), sep);
|
||||||
printf("[%d,%d]%s", ev->x, ev->y, sep);
|
printf("[%d,%d]%s", ev->x, ev->y, sep);
|
||||||
printf("root=[%d,%d]%s", ev->x_root, ev->y_root, sep);
|
printf("root=[%d,%d]%s", ev->x_root, ev->y_root, sep);
|
||||||
if (ev->state) printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
|
if (ev->state)
|
||||||
|
printf("state=%s%s", ButtonAndOrModifierState(ev->state), sep);
|
||||||
printf("keycode=%s%s", Keycode(ev), sep);
|
printf("keycode=%s%s", Keycode(ev), sep);
|
||||||
if (!ev->same_screen) printf("!same_screen", TorF(ev->same_screen));
|
if (!ev->same_screen)
|
||||||
|
printf("!same_screen", TorF(ev->same_screen));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -512,29 +542,25 @@ VerbKey(XKeyEvent* ev) {
|
||||||
printf("same_screen=%s\n", TorF(ev->same_screen));
|
printf("same_screen=%s\n", TorF(ev->same_screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbProperty(XPropertyEvent* ev) {
|
||||||
VerbProperty(XPropertyEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
|
printf("atom=%s%s", AtomName(ev->display, ev->atom), sep);
|
||||||
printf("time=%s%s", ServerTime(ev->time), sep);
|
printf("time=%s%s", ServerTime(ev->time), sep);
|
||||||
printf("state=%s\n", PropertyState(ev->state));
|
printf("state=%s\n", PropertyState(ev->state));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbResizeRequest(XResizeRequestEvent* ev) {
|
||||||
VerbResizeRequest(XResizeRequestEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("width=%d height=%d\n", ev->width, ev->height);
|
printf("width=%d height=%d\n", ev->width, ev->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbCirculate(XCirculateEvent* ev) {
|
||||||
VerbCirculate(XCirculateEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("place=%s\n", Place(ev->place));
|
printf("place=%s\n", Place(ev->place));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbConfigure(XConfigureEvent* ev) {
|
||||||
VerbConfigure(XConfigureEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
||||||
|
@ -544,8 +570,7 @@ VerbConfigure(XConfigureEvent* ev) {
|
||||||
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbCreateWindow(XCreateWindowEvent* ev) {
|
||||||
VerbCreateWindow(XCreateWindowEvent* ev) {
|
|
||||||
printf("parent=0x%x%s", (int)ev->parent, sep);
|
printf("parent=0x%x%s", (int)ev->parent, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
||||||
|
@ -554,28 +579,24 @@ VerbCreateWindow(XCreateWindowEvent* ev) {
|
||||||
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbDestroyWindow(XDestroyWindowEvent* ev) {
|
||||||
VerbDestroyWindow(XDestroyWindowEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x\n", (int)ev->window);
|
printf("window=0x%x\n", (int)ev->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbGravity(XGravityEvent* ev) {
|
||||||
VerbGravity(XGravityEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("x=%d y=%d\n", ev->x, ev->y);
|
printf("x=%d y=%d\n", ev->x, ev->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbMap(XMapEvent* ev) {
|
||||||
VerbMap(XMapEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbReparent(XReparentEvent* ev) {
|
||||||
VerbReparent(XReparentEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("parent=0x%x%s", (int)ev->parent, sep);
|
printf("parent=0x%x%s", (int)ev->parent, sep);
|
||||||
|
@ -583,22 +604,19 @@ VerbReparent(XReparentEvent* ev) {
|
||||||
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
printf("override_redirect=%s\n", TorF(ev->override_redirect));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbUnmap(XUnmapEvent* ev) {
|
||||||
VerbUnmap(XUnmapEvent* ev) {
|
|
||||||
printf("event=0x%x%s", (int)ev->event, sep);
|
printf("event=0x%x%s", (int)ev->event, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("from_configure=%s\n", TorF(ev->from_configure));
|
printf("from_configure=%s\n", TorF(ev->from_configure));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbCirculateRequest(XCirculateRequestEvent* ev) {
|
||||||
VerbCirculateRequest(XCirculateRequestEvent* ev) {
|
|
||||||
printf("parent=0x%x%s", (int)ev->parent, sep);
|
printf("parent=0x%x%s", (int)ev->parent, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("place=%s\n", Place(ev->place));
|
printf("place=%s\n", Place(ev->place));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbConfigureRequest(XConfigureRequestEvent* ev) {
|
||||||
VerbConfigureRequest(XConfigureRequestEvent* ev) {
|
|
||||||
printf("parent=0x%x%s", (int)ev->parent, sep);
|
printf("parent=0x%x%s", (int)ev->parent, sep);
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
printf("x=%d y=%d%s", ev->x, ev->y, sep);
|
||||||
|
@ -609,41 +627,37 @@ VerbConfigureRequest(XConfigureRequestEvent* ev) {
|
||||||
printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
|
printf("value_mask=%s\n", ConfigureValueMask(ev->value_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbMapRequest(XMapRequestEvent* ev) {
|
||||||
VerbMapRequest(XMapRequestEvent* ev) {
|
|
||||||
printf("parent=0x%x%s", (int)ev->parent, sep);
|
printf("parent=0x%x%s", (int)ev->parent, sep);
|
||||||
printf("window=0x%x\n", (int)ev->window);
|
printf("window=0x%x\n", (int)ev->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbClient(XClientMessageEvent* ev) {
|
||||||
VerbClient(XClientMessageEvent* ev) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
|
printf("message_type=%s%s", AtomName(ev->display, ev->message_type), sep);
|
||||||
printf("format=%d\n", ev->format);
|
printf("format=%d\n", ev->format);
|
||||||
printf("data (shown as longs)=");
|
printf("data (shown as longs)=");
|
||||||
for (i = 0; i < 5; i++) printf(" 0x%08lx", ev->data.l[i]);
|
for (i = 0; i < 5; i++)
|
||||||
|
printf(" 0x%08lx", ev->data.l[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbMapping(XMappingEvent* ev) {
|
||||||
VerbMapping(XMappingEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("request=%s%s", MappingRequest(ev->request), sep);
|
printf("request=%s%s", MappingRequest(ev->request), sep);
|
||||||
printf("first_keycode=0x%x%s", ev->first_keycode, sep);
|
printf("first_keycode=0x%x%s", ev->first_keycode, sep);
|
||||||
printf("count=0x%x\n", ev->count);
|
printf("count=0x%x\n", ev->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbSelectionClear(XSelectionClearEvent* ev) {
|
||||||
VerbSelectionClear(XSelectionClearEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
||||||
printf("time=%s\n", ServerTime(ev->time));
|
printf("time=%s\n", ServerTime(ev->time));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbSelection(XSelectionEvent* ev) {
|
||||||
VerbSelection(XSelectionEvent* ev) {
|
|
||||||
printf("requestor=0x%x%s", (int)ev->requestor, sep);
|
printf("requestor=0x%x%s", (int)ev->requestor, sep);
|
||||||
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
||||||
printf("target=%s%s", AtomName(ev->display, ev->target), sep);
|
printf("target=%s%s", AtomName(ev->display, ev->target), sep);
|
||||||
|
@ -651,8 +665,7 @@ VerbSelection(XSelectionEvent* ev) {
|
||||||
printf("time=%s\n", ServerTime(ev->time));
|
printf("time=%s\n", ServerTime(ev->time));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbSelectionRequest(XSelectionRequestEvent* ev) {
|
||||||
VerbSelectionRequest(XSelectionRequestEvent* ev) {
|
|
||||||
printf("owner=0x%x%s", (int)ev->owner, sep);
|
printf("owner=0x%x%s", (int)ev->owner, sep);
|
||||||
printf("requestor=0x%x%s", (int)ev->requestor, sep);
|
printf("requestor=0x%x%s", (int)ev->requestor, sep);
|
||||||
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
printf("selection=%s%s", AtomName(ev->display, ev->selection), sep);
|
||||||
|
@ -661,8 +674,7 @@ VerbSelectionRequest(XSelectionRequestEvent* ev) {
|
||||||
printf("time=%s\n", ServerTime(ev->time));
|
printf("time=%s\n", ServerTime(ev->time));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void VerbVisibility(XVisibilityEvent* ev) {
|
||||||
VerbVisibility(XVisibilityEvent* ev) {
|
|
||||||
printf("window=0x%x%s", (int)ev->window, sep);
|
printf("window=0x%x%s", (int)ev->window, sep);
|
||||||
printf("state=%s\n", VisibilityState(ev->state));
|
printf("state=%s\n", VisibilityState(ev->state));
|
||||||
}
|
}
|
||||||
|
@ -671,44 +683,76 @@ VerbVisibility(XVisibilityEvent* ev) {
|
||||||
/************ Return the string representation for type of an event ***********/
|
/************ Return the string representation for type of an event ***********/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
char*
|
char* eventtype(XEvent* ev) {
|
||||||
eventtype(XEvent* ev) {
|
|
||||||
static char buffer[20];
|
static char buffer[20];
|
||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case KeyPress: return ("KeyPress");
|
case KeyPress:
|
||||||
case KeyRelease: return ("KeyRelease");
|
return ("KeyPress");
|
||||||
case ButtonPress: return ("ButtonPress");
|
case KeyRelease:
|
||||||
case ButtonRelease: return ("ButtonRelease");
|
return ("KeyRelease");
|
||||||
case MotionNotify: return ("MotionNotify");
|
case ButtonPress:
|
||||||
case EnterNotify: return ("EnterNotify");
|
return ("ButtonPress");
|
||||||
case LeaveNotify: return ("LeaveNotify");
|
case ButtonRelease:
|
||||||
case FocusIn: return ("FocusIn");
|
return ("ButtonRelease");
|
||||||
case FocusOut: return ("FocusOut");
|
case MotionNotify:
|
||||||
case KeymapNotify: return ("KeymapNotify");
|
return ("MotionNotify");
|
||||||
case Expose: return ("Expose");
|
case EnterNotify:
|
||||||
case GraphicsExpose: return ("GraphicsExpose");
|
return ("EnterNotify");
|
||||||
case NoExpose: return ("NoExpose");
|
case LeaveNotify:
|
||||||
case VisibilityNotify: return ("VisibilityNotify");
|
return ("LeaveNotify");
|
||||||
case CreateNotify: return ("CreateNotify");
|
case FocusIn:
|
||||||
case DestroyNotify: return ("DestroyNotify");
|
return ("FocusIn");
|
||||||
case UnmapNotify: return ("UnmapNotify");
|
case FocusOut:
|
||||||
case MapNotify: return ("MapNotify");
|
return ("FocusOut");
|
||||||
case MapRequest: return ("MapRequest");
|
case KeymapNotify:
|
||||||
case ReparentNotify: return ("ReparentNotify");
|
return ("KeymapNotify");
|
||||||
case ConfigureNotify: return ("ConfigureNotify");
|
case Expose:
|
||||||
case ConfigureRequest: return ("ConfigureRequest");
|
return ("Expose");
|
||||||
case GravityNotify: return ("GravityNotify");
|
case GraphicsExpose:
|
||||||
case ResizeRequest: return ("ResizeRequest");
|
return ("GraphicsExpose");
|
||||||
case CirculateNotify: return ("CirculateNotify");
|
case NoExpose:
|
||||||
case CirculateRequest: return ("CirculateRequest");
|
return ("NoExpose");
|
||||||
case PropertyNotify: return ("PropertyNotify");
|
case VisibilityNotify:
|
||||||
case SelectionClear: return ("SelectionClear");
|
return ("VisibilityNotify");
|
||||||
case SelectionRequest: return ("SelectionRequest");
|
case CreateNotify:
|
||||||
case SelectionNotify: return ("SelectionNotify");
|
return ("CreateNotify");
|
||||||
case ColormapNotify: return ("ColormapNotify");
|
case DestroyNotify:
|
||||||
case ClientMessage: return ("ClientMessage");
|
return ("DestroyNotify");
|
||||||
case MappingNotify: return ("MappingNotify");
|
case UnmapNotify:
|
||||||
|
return ("UnmapNotify");
|
||||||
|
case MapNotify:
|
||||||
|
return ("MapNotify");
|
||||||
|
case MapRequest:
|
||||||
|
return ("MapRequest");
|
||||||
|
case ReparentNotify:
|
||||||
|
return ("ReparentNotify");
|
||||||
|
case ConfigureNotify:
|
||||||
|
return ("ConfigureNotify");
|
||||||
|
case ConfigureRequest:
|
||||||
|
return ("ConfigureRequest");
|
||||||
|
case GravityNotify:
|
||||||
|
return ("GravityNotify");
|
||||||
|
case ResizeRequest:
|
||||||
|
return ("ResizeRequest");
|
||||||
|
case CirculateNotify:
|
||||||
|
return ("CirculateNotify");
|
||||||
|
case CirculateRequest:
|
||||||
|
return ("CirculateRequest");
|
||||||
|
case PropertyNotify:
|
||||||
|
return ("PropertyNotify");
|
||||||
|
case SelectionClear:
|
||||||
|
return ("SelectionClear");
|
||||||
|
case SelectionRequest:
|
||||||
|
return ("SelectionRequest");
|
||||||
|
case SelectionNotify:
|
||||||
|
return ("SelectionNotify");
|
||||||
|
case ColormapNotify:
|
||||||
|
return ("ColormapNotify");
|
||||||
|
case ClientMessage:
|
||||||
|
return ("ClientMessage");
|
||||||
|
case MappingNotify:
|
||||||
|
return ("MappingNotify");
|
||||||
}
|
}
|
||||||
sprintf(buffer, "%d", ev->type);
|
sprintf(buffer, "%d", ev->type);
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -718,12 +762,12 @@ eventtype(XEvent* ev) {
|
||||||
/**************** Print the values of all fields for any event ****************/
|
/**************** Print the values of all fields for any event ****************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
void
|
void printevent(XEvent* e) {
|
||||||
printevent(XEvent* e) {
|
|
||||||
XAnyEvent* ev = (void*)e;
|
XAnyEvent* ev = (void*)e;
|
||||||
|
|
||||||
printf("%3ld %-20s ", ev->serial, eventtype(e));
|
printf("%3ld %-20s ", ev->serial, eventtype(e));
|
||||||
if (ev->send_event) printf("(sendevent) ");
|
if (ev->send_event)
|
||||||
|
printf("(sendevent) ");
|
||||||
if (0) {
|
if (0) {
|
||||||
printf("type=%s%s", eventtype(e), sep);
|
printf("type=%s%s", eventtype(e), sep);
|
||||||
printf("serial=%lu%s", ev->serial, sep);
|
printf("serial=%lu%s", ev->serial, sep);
|
||||||
|
@ -732,66 +776,124 @@ printevent(XEvent* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case MotionNotify: VerbMotion((void*)ev); break;
|
case MotionNotify:
|
||||||
|
VerbMotion((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
case ButtonRelease: VerbButton((void*)ev); break;
|
case ButtonRelease:
|
||||||
|
VerbButton((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ColormapNotify: VerbColormap((void*)ev); break;
|
case ColormapNotify:
|
||||||
|
VerbColormap((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case EnterNotify:
|
case EnterNotify:
|
||||||
case LeaveNotify: VerbCrossing((void*)ev); break;
|
case LeaveNotify:
|
||||||
|
VerbCrossing((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case Expose: VerbExpose((void*)ev); break;
|
case Expose:
|
||||||
|
VerbExpose((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case GraphicsExpose: VerbGraphicsExpose((void*)ev); break;
|
case GraphicsExpose:
|
||||||
|
VerbGraphicsExpose((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case NoExpose: VerbNoExpose((void*)ev); break;
|
case NoExpose:
|
||||||
|
VerbNoExpose((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
case FocusOut: VerbFocus((void*)ev); break;
|
case FocusOut:
|
||||||
|
VerbFocus((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case KeymapNotify: VerbKeymap((void*)ev); break;
|
case KeymapNotify:
|
||||||
|
VerbKeymap((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease: VerbKey((void*)ev); break;
|
case KeyRelease:
|
||||||
|
VerbKey((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case PropertyNotify: VerbProperty((void*)ev); break;
|
case PropertyNotify:
|
||||||
|
VerbProperty((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ResizeRequest: VerbResizeRequest((void*)ev); break;
|
case ResizeRequest:
|
||||||
|
VerbResizeRequest((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case CirculateNotify: VerbCirculate((void*)ev); break;
|
case CirculateNotify:
|
||||||
|
VerbCirculate((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ConfigureNotify: VerbConfigure((void*)ev); break;
|
case ConfigureNotify:
|
||||||
|
VerbConfigure((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case CreateNotify: VerbCreateWindow((void*)ev); break;
|
case CreateNotify:
|
||||||
|
VerbCreateWindow((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case DestroyNotify: VerbDestroyWindow((void*)ev); break;
|
case DestroyNotify:
|
||||||
|
VerbDestroyWindow((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case GravityNotify: VerbGravity((void*)ev); break;
|
case GravityNotify:
|
||||||
|
VerbGravity((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case MapNotify: VerbMap((void*)ev); break;
|
case MapNotify:
|
||||||
|
VerbMap((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ReparentNotify: VerbReparent((void*)ev); break;
|
case ReparentNotify:
|
||||||
|
VerbReparent((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case UnmapNotify: VerbUnmap((void*)ev); break;
|
case UnmapNotify:
|
||||||
|
VerbUnmap((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case CirculateRequest: VerbCirculateRequest((void*)ev); break;
|
case CirculateRequest:
|
||||||
|
VerbCirculateRequest((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ConfigureRequest: VerbConfigureRequest((void*)ev); break;
|
case ConfigureRequest:
|
||||||
|
VerbConfigureRequest((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case MapRequest: VerbMapRequest((void*)ev); break;
|
case MapRequest:
|
||||||
|
VerbMapRequest((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case ClientMessage: VerbClient((void*)ev); break;
|
case ClientMessage:
|
||||||
|
VerbClient((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case MappingNotify: VerbMapping((void*)ev); break;
|
case MappingNotify:
|
||||||
|
VerbMapping((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case SelectionClear: VerbSelectionClear((void*)ev); break;
|
case SelectionClear:
|
||||||
|
VerbSelectionClear((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case SelectionNotify: VerbSelection((void*)ev); break;
|
case SelectionNotify:
|
||||||
|
VerbSelection((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case SelectionRequest: VerbSelectionRequest((void*)ev); break;
|
case SelectionRequest:
|
||||||
|
VerbSelectionRequest((void*)ev);
|
||||||
|
break;
|
||||||
|
|
||||||
case VisibilityNotify: VerbVisibility((void*)ev); break;
|
case VisibilityNotify:
|
||||||
|
VerbVisibility((void*)ev);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
#include <X11/Intrinsic.h>
|
#include <X11/Intrinsic.h>
|
||||||
#include "printevent.h"
|
#include "printevent.h"
|
||||||
|
|
||||||
int
|
int main(int argc, char** argv) {
|
||||||
main(int argc, char** argv) {
|
|
||||||
int screen;
|
int screen;
|
||||||
Display* dpy;
|
Display* dpy;
|
||||||
Window window;
|
Window window;
|
||||||
|
|
118
xshove.c
118
xshove.c
|
@ -42,25 +42,28 @@ void listwindows(void);
|
||||||
int parsewinsize(char*, Rectangle*, int*, int*, int*);
|
int parsewinsize(char*, Rectangle*, int*, int*, int*);
|
||||||
void shove(char*, char*);
|
void shove(char*, char*);
|
||||||
|
|
||||||
void
|
void usage(void) {
|
||||||
usage(void) {
|
|
||||||
fprint(2, "usage: xshove [window rectangle]\n");
|
fprint(2, "usage: xshove [window rectangle]\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void main(int argc, char** argv) {
|
||||||
main(int argc, char** argv) {
|
|
||||||
int screen;
|
int screen;
|
||||||
|
|
||||||
screen = 0;
|
screen = 0;
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 's': screen = atoi(EARGF(usage())); break;
|
case 's':
|
||||||
default: usage(); break;
|
screen = atoi(EARGF(usage()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ARGEND
|
ARGEND
|
||||||
|
|
||||||
dpy = XOpenDisplay("");
|
dpy = XOpenDisplay("");
|
||||||
if (dpy == nil) sysfatal("open display: %r");
|
if (dpy == nil)
|
||||||
|
sysfatal("open display: %r");
|
||||||
|
|
||||||
root = RootWindow(dpy, screen);
|
root = RootWindow(dpy, screen);
|
||||||
getinfo();
|
getinfo();
|
||||||
|
@ -69,13 +72,13 @@ main(int argc, char** argv) {
|
||||||
listwindows();
|
listwindows();
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
if (argc != 2) usage();
|
if (argc != 2)
|
||||||
|
usage();
|
||||||
shove(argv[0], argv[1]);
|
shove(argv[0], argv[1]);
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char* getproperty(Window w, Atom a) {
|
||||||
getproperty(Window w, Atom a) {
|
|
||||||
uchar* p;
|
uchar* p;
|
||||||
int fmt;
|
int fmt;
|
||||||
Atom type;
|
Atom type;
|
||||||
|
@ -84,41 +87,57 @@ getproperty(Window w, Atom a) {
|
||||||
n = 100;
|
n = 100;
|
||||||
p = nil;
|
p = nil;
|
||||||
XGetWindowProperty(
|
XGetWindowProperty(
|
||||||
dpy, w, a, 0, 100L, 0, AnyPropertyType, &type, &fmt, &n, &dummy, &p);
|
dpy,
|
||||||
if (p == nil || *p == 0) return nil;
|
w,
|
||||||
|
a,
|
||||||
|
0,
|
||||||
|
100L,
|
||||||
|
0,
|
||||||
|
AnyPropertyType,
|
||||||
|
&type,
|
||||||
|
&fmt,
|
||||||
|
&n,
|
||||||
|
&dummy,
|
||||||
|
&p);
|
||||||
|
if (p == nil || *p == 0)
|
||||||
|
return nil;
|
||||||
return strdup((char*)p);
|
return strdup((char*)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
Window
|
Window findname(Window w) {
|
||||||
findname(Window w) {
|
|
||||||
int i;
|
int i;
|
||||||
uint nxwin;
|
uint nxwin;
|
||||||
Window dw1, dw2, *xwin;
|
Window dw1, dw2, *xwin;
|
||||||
|
|
||||||
if (getproperty(w, XA_WM_NAME)) return w;
|
if (getproperty(w, XA_WM_NAME))
|
||||||
if (!XQueryTree(dpy, w, &dw1, &dw2, &xwin, &nxwin)) return 0;
|
return w;
|
||||||
|
if (!XQueryTree(dpy, w, &dw1, &dw2, &xwin, &nxwin))
|
||||||
|
return 0;
|
||||||
for (i = 0; i < nxwin; i++)
|
for (i = 0; i < nxwin; i++)
|
||||||
if ((w = findname(xwin[i])) != 0) return w;
|
if ((w = findname(xwin[i])) != 0)
|
||||||
|
return w;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void getinfo(void) {
|
||||||
getinfo(void) {
|
|
||||||
int i;
|
int i;
|
||||||
uint nxwin;
|
uint nxwin;
|
||||||
Window dw1, dw2, *xwin;
|
Window dw1, dw2, *xwin;
|
||||||
XClassHint class;
|
XClassHint class;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
|
||||||
if (!XQueryTree(dpy, root, &dw1, &dw2, &xwin, &nxwin)) return;
|
if (!XQueryTree(dpy, root, &dw1, &dw2, &xwin, &nxwin))
|
||||||
|
return;
|
||||||
w = mallocz(nxwin * sizeof w[0], 1);
|
w = mallocz(nxwin * sizeof w[0], 1);
|
||||||
if (w == 0) sysfatal("malloc: %r");
|
if (w == 0)
|
||||||
|
sysfatal("malloc: %r");
|
||||||
|
|
||||||
Win* ww = w;
|
Win* ww = w;
|
||||||
for (i = 0; i < nxwin; i++) {
|
for (i = 0; i < nxwin; i++) {
|
||||||
memset(&attr, 0, sizeof attr);
|
memset(&attr, 0, sizeof attr);
|
||||||
xwin[i] = findname(xwin[i]);
|
xwin[i] = findname(xwin[i]);
|
||||||
if (xwin[i] == 0) continue;
|
if (xwin[i] == 0)
|
||||||
|
continue;
|
||||||
XGetWindowAttributes(dpy, xwin[i], &attr);
|
XGetWindowAttributes(dpy, xwin[i], &attr);
|
||||||
if (
|
if (
|
||||||
attr.width <= 0 || attr.override_redirect || attr.map_state != IsViewable)
|
attr.width <= 0 || attr.override_redirect || attr.map_state != IsViewable)
|
||||||
|
@ -140,8 +159,7 @@ getinfo(void) {
|
||||||
nw = ww - w;
|
nw = ww - w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void listwindows(void) {
|
||||||
listwindows(void) {
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nw; i++) {
|
for (i = 0; i < nw; i++) {
|
||||||
|
@ -159,8 +177,7 @@ listwindows(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void shove(char* name, char* geom) {
|
||||||
shove(char* name, char* geom) {
|
|
||||||
int i;
|
int i;
|
||||||
int isdelta, havemin, havesize;
|
int isdelta, havemin, havesize;
|
||||||
int old, new;
|
int old, new;
|
||||||
|
@ -205,8 +222,8 @@ shove(char* name, char* geom) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int parsewinsize(
|
||||||
parsewinsize(char* s, Rectangle* r, int* isdelta, int* havemin, int* havesize) {
|
char* s, Rectangle* r, int* isdelta, int* havemin, int* havesize) {
|
||||||
char c, *os;
|
char c, *os;
|
||||||
int i, j, k, l;
|
int i, j, k, l;
|
||||||
|
|
||||||
|
@ -222,26 +239,34 @@ parsewinsize(char* s, Rectangle* r, int* isdelta, int* havemin, int* havesize) {
|
||||||
*havemin = 0;
|
*havemin = 0;
|
||||||
*havesize = 0;
|
*havesize = 0;
|
||||||
memset(r, 0, sizeof *r);
|
memset(r, 0, sizeof *r);
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
i = strtol(s, &s, 0);
|
i = strtol(s, &s, 0);
|
||||||
if (*s == 'x') {
|
if (*s == 'x') {
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
j = strtol(s, &s, 0);
|
j = strtol(s, &s, 0);
|
||||||
r->max.x = i;
|
r->max.x = i;
|
||||||
r->max.y = j;
|
r->max.y = j;
|
||||||
*havesize = 1;
|
*havesize = 1;
|
||||||
if (*s == 0) return 0;
|
if (*s == 0)
|
||||||
if (*s != '@') goto oops;
|
return 0;
|
||||||
|
if (*s != '@')
|
||||||
|
goto oops;
|
||||||
|
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
i = strtol(s, &s, 0);
|
i = strtol(s, &s, 0);
|
||||||
if (*s != ',' && *s != ' ') goto oops;
|
if (*s != ',' && *s != ' ')
|
||||||
|
goto oops;
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
j = strtol(s, &s, 0);
|
j = strtol(s, &s, 0);
|
||||||
if (*s != 0) goto oops;
|
if (*s != 0)
|
||||||
|
goto oops;
|
||||||
r->min.x += i;
|
r->min.x += i;
|
||||||
r->max.x += i;
|
r->max.x += i;
|
||||||
r->min.y += j;
|
r->min.y += j;
|
||||||
|
@ -252,9 +277,11 @@ parsewinsize(char* s, Rectangle* r, int* isdelta, int* havemin, int* havesize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *s;
|
c = *s;
|
||||||
if (c != ' ' && c != ',') goto oops;
|
if (c != ' ' && c != ',')
|
||||||
|
goto oops;
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
j = strtol(s, &s, 0);
|
j = strtol(s, &s, 0);
|
||||||
if (*s == 0) {
|
if (*s == 0) {
|
||||||
r->min.x = i;
|
r->min.x = i;
|
||||||
|
@ -262,15 +289,20 @@ parsewinsize(char* s, Rectangle* r, int* isdelta, int* havemin, int* havesize) {
|
||||||
*havemin = 1;
|
*havemin = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (*s != c) goto oops;
|
if (*s != c)
|
||||||
|
goto oops;
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
k = strtol(s, &s, 0);
|
k = strtol(s, &s, 0);
|
||||||
if (*s != c) goto oops;
|
if (*s != c)
|
||||||
|
goto oops;
|
||||||
s++;
|
s++;
|
||||||
if (!isdigit((uchar)*s)) goto oops;
|
if (!isdigit((uchar)*s))
|
||||||
|
goto oops;
|
||||||
l = strtol(s, &s, 0);
|
l = strtol(s, &s, 0);
|
||||||
if (*s != 0) goto oops;
|
if (*s != 0)
|
||||||
|
goto oops;
|
||||||
r->min.x = i;
|
r->min.x = i;
|
||||||
r->min.y = j;
|
r->min.y = j;
|
||||||
r->max.x = k;
|
r->max.x = k;
|
||||||
|
|
Loading…
Reference in a new issue