mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
Minur cleanup.
This commit is contained in:
parent
29825ad4c6
commit
a1e41d15c1
@ -171,7 +171,6 @@ bar_draw(WMScreen *s) {
|
||||
border(screen->ibuf, b->r, 1, b->col.border);
|
||||
}
|
||||
copyimage(s->barwin, r, screen->ibuf, ZP);
|
||||
sync();
|
||||
}
|
||||
|
||||
Bar*
|
||||
|
@ -262,27 +262,27 @@ client_destroy(Client *c) {
|
||||
hide = true;
|
||||
|
||||
XGrabServer(display);
|
||||
|
||||
/* In case the client is already unmapped */
|
||||
/* In case the client is already destroyed. */
|
||||
handler = XSetErrorHandler(ignoreerrors);
|
||||
|
||||
none = nil;
|
||||
client_setviews(c, &none);
|
||||
sethandler(&c->w, nil);
|
||||
refree(&c->tagre);
|
||||
refree(&c->tagvre);
|
||||
free(c->retags);
|
||||
|
||||
if(hide)
|
||||
reparentwindow(&c->w, &scr.root, screen->r.max);
|
||||
else
|
||||
reparentwindow(&c->w, &scr.root, r.min);
|
||||
destroywindow(c->framewin);
|
||||
|
||||
sync();
|
||||
XSetErrorHandler(handler);
|
||||
XUngrabServer(display);
|
||||
|
||||
none = nil;
|
||||
client_setviews(c, &none);
|
||||
refree(&c->tagre);
|
||||
refree(&c->tagvre);
|
||||
free(c->retags);
|
||||
|
||||
destroywindow(c->framewin);
|
||||
|
||||
ewmh_destroyclient(c);
|
||||
group_remove(c);
|
||||
event("DestroyClient %C\n", c);
|
||||
@ -472,11 +472,9 @@ focus(Client *c, bool user) {
|
||||
|
||||
void
|
||||
client_focus(Client *c) {
|
||||
/* Round trip. */
|
||||
static long id;
|
||||
long _id;
|
||||
flushevents(FocusChangeMask, true);
|
||||
|
||||
_id = id++ % 99;
|
||||
|
||||
if(c && c->group)
|
||||
c->group->client = c;
|
||||
@ -484,9 +482,9 @@ client_focus(Client *c) {
|
||||
sync();
|
||||
flushevents(FocusChangeMask, true);
|
||||
|
||||
_id = id++ % 99;
|
||||
Dprint(DFocus, "client_focus([%C]%s) %ld\n", c, clientname(c), _id);
|
||||
Dprint(DFocus, "\t%02d [%C]%s\n\t=> [%C]%s\n",
|
||||
_id,
|
||||
Dprint(DFocus, "\t%02d [%C]%s\n\t=> [%C]%s\n", _id,
|
||||
screen->focus, clientname(screen->focus),
|
||||
c, clientname(c));
|
||||
if(screen->focus != c) {
|
||||
@ -513,7 +511,7 @@ client_resize(Client *c, Rectangle r) {
|
||||
f = c->sel;
|
||||
frame_resize(f, r);
|
||||
|
||||
if(f->area->view != screen->sel) {
|
||||
if(f->view != screen->sel) {
|
||||
client_unmap(c, IconicState);
|
||||
unmap_frame(c);
|
||||
return;
|
||||
|
@ -133,6 +133,7 @@ struct Area {
|
||||
bool floating;
|
||||
ushort id;
|
||||
int mode;
|
||||
bool max;
|
||||
Rectangle r;
|
||||
Rectangle r_old;
|
||||
};
|
||||
@ -237,13 +238,6 @@ struct Map {
|
||||
uint nhash;
|
||||
};
|
||||
|
||||
struct MapEnt {
|
||||
ulong hash;
|
||||
const char* key;
|
||||
void* val;
|
||||
MapEnt* next;
|
||||
};
|
||||
|
||||
struct Rule {
|
||||
Rule* next;
|
||||
Reprog* regex;
|
||||
|
@ -32,19 +32,19 @@ findtime(Display *d, XEvent *e, XPointer v) {
|
||||
|
||||
void
|
||||
xtime_kludge(void) {
|
||||
Window *w;
|
||||
/* Round trip. */
|
||||
static Window *w;
|
||||
WinAttr wa;
|
||||
XEvent e;
|
||||
long l;
|
||||
|
||||
w = createwindow(&scr.root, Rect(0, 0, 1, 1), 0, InputOnly, &wa, 0);
|
||||
|
||||
XSelectInput(display, w->w, PropertyChangeMask);
|
||||
if(w == nil) {
|
||||
w = createwindow(&scr.root, Rect(0, 0, 1, 1), 0, InputOnly, &wa, 0);
|
||||
selectinput(w, PropertyChangeMask);
|
||||
}
|
||||
changeprop_long(w, "ATOM", "ATOM", &l, 0);
|
||||
sync();
|
||||
XIfEvent(display, &e, findtime, (void*)w);
|
||||
|
||||
destroywindow(w);
|
||||
}
|
||||
|
||||
|
||||
@ -368,6 +368,7 @@ unmapnotify(XEvent *e) {
|
||||
|
||||
ev = &e->xunmap;
|
||||
if((w = findwin(ev->window)) && (ev->event == w->parent->w)) {
|
||||
w->mapped = false;
|
||||
if(ev->send_event || w->unmapped-- == 0)
|
||||
handle(w, unmap, ev);
|
||||
}
|
||||
|
@ -175,9 +175,9 @@ void update_keys(void);
|
||||
void init_screen(WMScreen*);
|
||||
|
||||
/* map.c */
|
||||
MapEnt* hash_get(Map*, const char*, int create);
|
||||
void** hash_get(Map*, const char*, bool create);
|
||||
void* hash_rm(Map*, const char*);
|
||||
MapEnt* map_get(Map*, ulong, int create);
|
||||
void** map_get(Map*, ulong, bool create);
|
||||
void* map_rm(Map*, ulong);
|
||||
|
||||
/* message.c */
|
||||
|
@ -513,7 +513,6 @@ frame_draw(Frame *f) {
|
||||
XSetWindowBackgroundPixmap(display, c->framewin->w, None);
|
||||
|
||||
copyimage(c->framewin, fr, img, ZP);
|
||||
sync();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7,7 +7,7 @@
|
||||
bool
|
||||
rect_haspoint_p(Point pt, Rectangle r) {
|
||||
return (pt.x >= r.min.x) && (pt.x < r.max.x)
|
||||
&& (pt.y >= r.min.y) && (pt.y < r.max.y);
|
||||
&& (pt.y >= r.min.y) && (pt.y < r.max.y);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -22,7 +22,7 @@ Rectangle
|
||||
rect_intersection(Rectangle r, Rectangle r2) {
|
||||
Rectangle ret;
|
||||
|
||||
/* canonrect(ret) != ret if not intersection */
|
||||
/* ret != canonrect(ret) ≡ no intersection. */
|
||||
ret.min.x = max(r.min.x, r2.min.x);
|
||||
ret.max.x = min(r.max.x, r2.max.x);
|
||||
ret.min.y = max(r.min.y, r2.min.y);
|
||||
@ -60,32 +60,35 @@ quadrant(Rectangle r, Point pt) {
|
||||
Cursor
|
||||
quad_cursor(Align align) {
|
||||
switch(align) {
|
||||
case NEast:
|
||||
return cursor[CurNECorner];
|
||||
case NWest:
|
||||
return cursor[CurNWCorner];
|
||||
case SEast:
|
||||
return cursor[CurSECorner];
|
||||
case SWest:
|
||||
return cursor[CurSWCorner];
|
||||
default:
|
||||
return cursor[CurMove];
|
||||
case NEast: return cursor[CurNECorner];
|
||||
case NWest: return cursor[CurNWCorner];
|
||||
case SEast: return cursor[CurSECorner];
|
||||
case SWest: return cursor[CurSWCorner];
|
||||
case South:
|
||||
case North: return cursor[CurDVArrow];
|
||||
case East:
|
||||
case West: return cursor[CurDHArrow];
|
||||
default: return cursor[CurMove];
|
||||
}
|
||||
}
|
||||
|
||||
Align
|
||||
get_sticky(Rectangle src, Rectangle dst) {
|
||||
Align stickycorner = 0;
|
||||
Align corner;
|
||||
|
||||
if(src.min.x != dst.min.x && src.max.x == dst.max.x)
|
||||
stickycorner |= East;
|
||||
corner = 0;
|
||||
if(src.min.x != dst.min.x
|
||||
&& src.max.x == dst.max.x)
|
||||
corner |= East;
|
||||
else
|
||||
stickycorner |= West;
|
||||
if(src.min.y != dst.min.y && src.max.y == dst.max.y)
|
||||
stickycorner |= South;
|
||||
else
|
||||
stickycorner |= North;
|
||||
corner |= West;
|
||||
|
||||
return stickycorner;
|
||||
if(src.min.y != dst.min.y
|
||||
&& src.max.y == dst.max.y)
|
||||
corner |= South;
|
||||
else
|
||||
corner |= North;
|
||||
|
||||
return corner;
|
||||
}
|
||||
|
||||
|
@ -54,16 +54,20 @@ str2modmask(const char *val) {
|
||||
}
|
||||
|
||||
static void
|
||||
grabkey(Key *k) {
|
||||
XGrabKey(display, k->key, k->mod, scr.root.w,
|
||||
_grab(XWindow w, int keycode, uint mod) {
|
||||
XGrabKey(display, keycode, mod, w,
|
||||
true, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
|
||||
static void
|
||||
grabkey(Key *k) {
|
||||
/* Round trip. */
|
||||
_grab(scr.root.w, k->key, k->mod);
|
||||
if(numlock_mask) {
|
||||
XGrabKey(display, k->key, k->mod | numlock_mask, scr.root.w,
|
||||
true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(display, k->key, k->mod | numlock_mask | LockMask, scr.root.w,
|
||||
true, GrabModeAsync, GrabModeAsync);
|
||||
_grab(scr.root.w, k->key, k->mod | numlock_mask);
|
||||
_grab(scr.root.w, k->key, k->mod | numlock_mask | LockMask);
|
||||
}
|
||||
sync();
|
||||
/* sync(); */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -73,7 +77,9 @@ ungrabkey(Key *k) {
|
||||
XUngrabKey(display, k->key, k->mod | numlock_mask, scr.root.w);
|
||||
XUngrabKey(display, k->key, k->mod | numlock_mask | LockMask, scr.root.w);
|
||||
}
|
||||
/*
|
||||
sync();
|
||||
*/
|
||||
}
|
||||
|
||||
static Key *
|
||||
@ -253,3 +259,4 @@ update_keys(void) {
|
||||
}
|
||||
sync();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,13 @@
|
||||
|
||||
/* Edit s/^([a-zA-Z].*)\n([a-z].*) {/\1 \2;/g x/^([^a-zA-Z]|static|$)/-+d s/ (\*map|val|*str)//g */
|
||||
|
||||
struct MapEnt {
|
||||
ulong hash;
|
||||
const char* key;
|
||||
void* val;
|
||||
MapEnt* next;
|
||||
};
|
||||
|
||||
MapEnt *NM;
|
||||
|
||||
/* By Dan Bernstein. Public domain. */
|
||||
@ -69,20 +76,20 @@ hash_getp(Map *map, const char *str, int create) {
|
||||
return e;
|
||||
}
|
||||
|
||||
MapEnt*
|
||||
map_get(Map *map, ulong val, int create) {
|
||||
MapEnt **e;
|
||||
void**
|
||||
map_get(Map *map, ulong val, bool create) {
|
||||
MapEnt *e;
|
||||
|
||||
e = map_getp(map, val, create);
|
||||
return *e;
|
||||
e = *map_getp(map, val, create);
|
||||
return e ? &e->val : nil;
|
||||
}
|
||||
|
||||
MapEnt*
|
||||
hash_get(Map *map, const char *str, int create) {
|
||||
MapEnt **e;
|
||||
void**
|
||||
hash_get(Map *map, const char *str, bool create) {
|
||||
MapEnt *e;
|
||||
|
||||
e = hash_getp(map, str, create);
|
||||
return *e;
|
||||
e = *hash_getp(map, str, create);
|
||||
return e ? &e->val : nil;
|
||||
}
|
||||
|
||||
void*
|
||||
@ -116,3 +123,4 @@ hash_rm(Map *map, const char *str) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ view_destroy(View *v) {
|
||||
assert(v != v->next);
|
||||
|
||||
/* FIXME: Can do better */
|
||||
/* Detach frames held here by regex tags. */
|
||||
for(a=v->area; a; a=an) {
|
||||
an = a->next;
|
||||
for(f=a->frame; f; f=fn) {
|
||||
|
@ -366,7 +366,7 @@ lowerwin(Window *w) {
|
||||
Handlers*
|
||||
sethandler(Window *w, Handlers *new) {
|
||||
Handlers *old;
|
||||
MapEnt *e;
|
||||
void **e;
|
||||
|
||||
assert(w->type == WWindow);
|
||||
assert((w->prev != nil && w->next != nil) || w->next == w->prev);
|
||||
@ -374,8 +374,8 @@ sethandler(Window *w, Handlers *new) {
|
||||
if(new == nil)
|
||||
map_rm(&windowmap, (ulong)w->w);
|
||||
else {
|
||||
e = map_get(&windowmap, (ulong)w->w, 1);
|
||||
e->val = w;
|
||||
e = map_get(&windowmap, (ulong)w->w, true);
|
||||
*e = w;
|
||||
}
|
||||
old = w->handler;
|
||||
w->handler = new;
|
||||
@ -384,11 +384,11 @@ sethandler(Window *w, Handlers *new) {
|
||||
|
||||
Window*
|
||||
findwin(XWindow w) {
|
||||
MapEnt *e;
|
||||
void **e;
|
||||
|
||||
e = map_get(&windowmap, (ulong)w, 0);
|
||||
e = map_get(&windowmap, (ulong)w, false);
|
||||
if(e)
|
||||
return e->val;
|
||||
return *e;
|
||||
return nil;
|
||||
}
|
||||
|
||||
@ -651,12 +651,12 @@ labelh(Font *font) {
|
||||
/* Misc */
|
||||
Atom
|
||||
xatom(char *name) {
|
||||
MapEnt *e;
|
||||
void **e;
|
||||
|
||||
e = hash_get(&atommap, name, 1);
|
||||
if(e->val == nil)
|
||||
e->val = (void*)XInternAtom(display, name, false);
|
||||
return (Atom)e->val;
|
||||
e = hash_get(&atommap, name, true);
|
||||
if(*e == nil)
|
||||
*e = (void*)XInternAtom(display, name, false);
|
||||
return (Atom)*e;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user