Some grabbox fixes, and, it seems, several changes I forgot to commit.

This commit is contained in:
Kris Maglione 2007-05-10 13:14:39 -04:00
parent fda2ca35cc
commit b645346147
13 changed files with 182 additions and 207 deletions

8
TODO
View File

@ -4,11 +4,9 @@
* Switch to mk for building * Switch to mk for building
4.0 4.0
* Get rid of col modes * Get rid of colmodes
* (Multi line) Tag bars * (Multi line) Tag bars
* Replace bar with master tag bar
* New event system
* Resizable managed area * Resizable managed area
* Sticky clients * Regex-based tag strings
* New dmenu(with real cursor and using Bio) * New dmenu(with real cursor and using Bio)
* Depend on plan9-corelibs * Use libbio, libfmt, libregex9

View File

@ -296,7 +296,7 @@ place_frame(Frame *f) {
if(c->trans) if(c->trans)
return; return;
if(c->fullscreen || c->w.hints->position) if(c->fullscreen || c->w.hints->position || starting)
return; return;
if(!field) { if(!field) {
mx = Dx(screen->r) / dx; mx = Dx(screen->r) / dx;

View File

@ -104,14 +104,14 @@ manage_client(Client *c) {
r = c->w.r; r = c->w.r;
p.x = def.border; p.x = def.border;
p.y = labelh(def.font); p.y = labelh(def.font);
reparent_client(c, c->framewin, ZP); reparentwindow(&c->w, c->framewin, p);
if(!strlen(c->tags)) if(!strlen(c->tags))
apply_rules(c); apply_rules(c);
else else
apply_tags(c, c->tags); apply_tags(c, c->tags);
if(c->w.hints->position) { if(c->w.hints->position || starting) {
r = gravclient(c, r); r = gravclient(c, r);
if(c->sel->area->floating) if(c->sel->area->floating)
resize_client(c, &r); resize_client(c, &r);
@ -138,7 +138,7 @@ destroy_client(Client *c) {
Rectangle r; Rectangle r;
char *dummy; char *dummy;
Client **tc; Client **tc;
XEvent ev; Bool hide;
Debug fprintf(stderr, "client.c:destroy_client(%p) %s\n", c, c->name); Debug fprintf(stderr, "client.c:destroy_client(%p) %s\n", c, c->name);
@ -148,37 +148,39 @@ destroy_client(Client *c) {
break; break;
} }
r = c->w.r;
if(c->sel) {
r = gravclient(c, ZR);
r = frame2client(c->sel, r);
}
hide = False;
if(!c->sel || c->sel->view != screen->sel)
hide = True;
XGrabServer(display); XGrabServer(display);
/* In case the client is already unmapped */ /* In case the client is already unmapped */
handler = XSetErrorHandler(ignoreerrors); handler = XSetErrorHandler(ignoreerrors);
if(c->sel) {
r = gravclient(c, ZR);
r = frame2client(nil, r);
}
dummy = nil; dummy = nil;
update_client_views(c, &dummy); update_client_views(c, &dummy);
unmap_client(c, IconicState);
unmap_client(c, WithdrawnState);
reparent_client(c, &scr.root, r.min);
write_event("DestroyClient 0x%x\n", (uint)c->w.w);
destroywindow(c->framewin);
sethandler(&c->w, nil); sethandler(&c->w, nil);
if(hide)
reparentwindow(&c->w, &scr.root, screen->r.max);
else
reparentwindow(&c->w, &scr.root, r.min);
destroywindow(c->framewin);
XSync(display, False); XSync(display, False);
XSetErrorHandler(handler); XSetErrorHandler(handler);
XUngrabServer(display); XUngrabServer(display);
write_event("DestroyClient 0x%x\n", clientwin(c));
flushevents(EnterWindowMask, False); flushevents(EnterWindowMask, False);
while(XCheckMaskEvent(display, StructureNotifyMask, &ev))
if(ev.type != UnmapNotify || ev.xunmap.window != c->w.w)
dispatch_event(&ev);
free(c); free(c);
} }
@ -325,14 +327,15 @@ focus_client(Client *c) {
if(screen->focus != c) { if(screen->focus != c) {
Debug fprintf(stderr, "\t%s => %s\n", clientname(screen->focus), clientname(c)); Debug fprintf(stderr, "\t%s => %s\n", clientname(screen->focus), clientname(c));
if(c) if(c)
setfocus(&c->w, RevertToParent); setfocus(&c->w, RevertToParent);
else else
setfocus(screen->barwin, RevertToParent); setfocus(screen->barwin, RevertToParent);
XSync(display, False);
}
flushevents(FocusChangeMask, True); XSync(display, False);
flushevents(FocusChangeMask, True);
}
} }
void void
@ -364,13 +367,8 @@ resize_client(Client *c, Rectangle *r) {
map_frame(c); map_frame(c);
configure_client(c); configure_client(c);
} }
flushevents(FocusChangeMask|ExposureMask, True);
}
void flushevents(FocusChangeMask|ExposureMask, True);
reparent_client(Client *c, Window *w, Point pt) {
reparentwindow(&c->w, w, pt);
} }
void void
@ -500,6 +498,8 @@ update_client_name(Client *c) {
free(str); free(str);
update_class(c); update_class(c);
if(c->sel)
draw_frame(c->sel);
} }
static void static void
@ -546,13 +546,15 @@ prop_client(Client *c, Atom a) {
char **class; char **class;
int n; int n;
if(a == xatom("WM_PROTOCOLS")) if(a == xatom("WM_PROTOCOLS")) {
c->proto = winprotocols(&c->w); c->proto = winprotocols(&c->w);
else if(a == xatom("_NET_WM_NAME")) }
else if(a == xatom("_NET_WM_NAME")) {
goto wmname; goto wmname;
else if(a == xatom("_MOTIF_WM_HINTS")) }
else if(a == xatom("_MOTIF_WM_HINTS")) {
updatemwm(c); updatemwm(c);
else switch (a) { }else switch (a) {
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(display, c->w.w, &c->trans); XGetTransientForHint(display, c->w.w, &c->trans);
break; break;
@ -579,8 +581,6 @@ prop_client(Client *c, Atom a) {
case XA_WM_NAME: case XA_WM_NAME:
wmname: wmname:
update_client_name(c); update_client_name(c);
if(c->frame)
draw_frame(c->sel);
break; break;
} }
} }
@ -611,7 +611,8 @@ configreq_event(Window *w, XConfigureRequestEvent *e) {
r = rectaddpt(r, p); r = rectaddpt(r, p);
r = gravclient(c, r); r = gravclient(c, r);
if((Dx(r) == Dx(screen->r)) && (Dy(r) == Dy(screen->r))) { if((Dx(r) == Dx(screen->r))
&& (Dy(r) == Dy(screen->r))) {
c->fullscreen = True; c->fullscreen = True;
if(f) { if(f) {
if(!f->area->floating) if(!f->area->floating)
@ -666,27 +667,22 @@ focusin_event(Window *w, XFocusChangeEvent *e) {
if(c != old) { if(c != old) {
if(c->sel) if(c->sel)
draw_frame(c->sel); draw_frame(c->sel);
if(old && old->sel)
draw_frame(old->sel);
} }
} }
static void static void
focusout_event(Window *w, XFocusChangeEvent *e) { focusout_event(Window *w, XFocusChangeEvent *e) {
Client *c; Client *c;
c = w->aux;
c = w->aux;
if((e->mode == NotifyWhileGrabbed) && (screen->hasgrab != &c_root)) { if((e->mode == NotifyWhileGrabbed) && (screen->hasgrab != &c_root)) {
if((screen->focus) && (screen->hasgrab != screen->focus)) if((screen->focus) && (screen->hasgrab != screen->focus))
screen->hasgrab = screen->focus; screen->hasgrab = screen->focus;
if(screen->hasgrab == c) if(screen->hasgrab == c)
return; return;
}else if(e->mode != NotifyGrab) { }else if(screen->focus == c) {
if(screen->focus == c) { print_focus(&c_magic, "<magic>");
print_focus(&c_magic, "<magic>"); screen->focus = &c_magic;
screen->focus = &c_magic;
}
if(c->sel) if(c->sel)
draw_frame(c->sel); draw_frame(c->sel);
} }

View File

@ -204,13 +204,6 @@ scale_column(Area *a) {
if(!a->frame) if(!a->frame)
return; return;
/* This works by comparing heights based on a surplus of their
* minimum size. We start by subtracting the minimum size, then
* scale the surplus, and add back the minimum size later. This
* is based on the size of the client, rather than the frame, so
* increment gaps can be equalized later */
/* Frames that can't be accomodated are pushed to the floating layer */
minh = labelh(def.font); minh = labelh(def.font);
colh = labelh(def.font); colh = labelh(def.font);
uncolh = minh + colh +1; uncolh = minh + colh +1;
@ -253,11 +246,6 @@ scale_column(Area *a) {
f = *fp; f = *fp;
if(f == a->sel) if(f == a->sel)
i++, j++; i++, j++;
if(!f->collapsed) {
if(j < 0 && (f != a->sel))
f->collapsed = True;
j--;
}
if(f->collapsed) { if(f->collapsed) {
if(i < 0 && (f != a->sel)) { if(i < 0 && (f != a->sel)) {
f->collapsed = False; f->collapsed = False;
@ -265,6 +253,10 @@ scale_column(Area *a) {
continue; continue;
} }
i--; i--;
}else {
if(j < 0 && (f != a->sel))
f->collapsed = True;
j--;
} }
/* Doesn't change if we 'continue' */ /* Doesn't change if we 'continue' */
fp=&f->anext; fp=&f->anext;
@ -281,8 +273,8 @@ scale_column(Area *a) {
}else { }else {
f->r.max.y = uncolh; f->r.max.y = uncolh;
dy += Dy(f->crect); dy += Dy(f->crect);
surplus += Dy(f->r);
} }
surplus += Dy(f->r);
} }
for(f = a->frame; f; f = f->anext) for(f = a->frame; f; f = f->anext)
f->ratio = (float)Dy(f->crect)/dy; f->ratio = (float)Dy(f->crect)/dy;
@ -293,11 +285,9 @@ scale_column(Area *a) {
j = surplus; j = surplus;
dy = 0; dy = 0;
for(f=a->frame; f; f=f->anext) { for(f=a->frame; f; f=f->anext) {
if(!f->collapsed) { if(!f->collapsed)
f->r.max.y += f->ratio * surplus; f->r.max.y += f->ratio * surplus;
resize_frame(f, f->r); resize_frame(f, f->r);
f->r.max.y = Dy(f->crect) + labelh(def.font) + 1;
}
dy += Dy(f->r); dy += Dy(f->r);
} }
surplus = Dy(a->r) - dy; surplus = Dy(a->r) - dy;
@ -336,11 +326,9 @@ arrange_column(Area *a, Bool dirty) {
switch(a->mode) { switch(a->mode) {
case Coldefault: case Coldefault:
for(f=a->frame; f; f=f->anext) { if(dirty)
f->collapsed = False; for(f=a->frame; f; f=f->anext)
if(dirty)
f->r = Rect(0, 0, 100, 100); f->r = Rect(0, 0, 100, 100);
}
break; break;
case Colstack: case Colstack:
for(f=a->frame; f; f=f->anext) for(f=a->frame; f; f=f->anext)

View File

@ -15,6 +15,8 @@ dispatch_event(XEvent *e) {
handler[e->type](e); handler[e->type](e);
} }
#define handle(w, fn, ev) ((w)->handler->fn ? (w)->handler->fn((w), ev) : (void)0)
uint uint
flushevents(long event_mask, Bool dispatch) { flushevents(long event_mask, Bool dispatch) {
XEvent ev; XEvent ev;
@ -35,8 +37,7 @@ buttonrelease(XEvent *e) {
ev = &e->xbutton; ev = &e->xbutton;
if((w = findwin(ev->window))) if((w = findwin(ev->window)))
if(w->handler->bup) handle(w, bup, ev);
w->handler->bup(w, ev);
} }
static void static void
@ -45,10 +46,8 @@ buttonpress(XEvent *e) {
Window *w; Window *w;
ev = &e->xbutton; ev = &e->xbutton;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->bdown) handle(w, bdown, ev);
w->handler->bdown(w, ev);
}
else else
XAllowEvents(display, ReplayPointer, ev->time); XAllowEvents(display, ReplayPointer, ev->time);
} }
@ -60,10 +59,9 @@ configurerequest(XEvent *e) {
Window *w; Window *w;
ev = &e->xconfigurerequest; ev = &e->xconfigurerequest;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->configreq) handle(w, configreq, ev);
w->handler->configreq(w, ev); else{
}else{
wc.x = ev->x; wc.x = ev->x;
wc.y = ev->y; wc.y = ev->y;
wc.width = ev->width; wc.width = ev->width;
@ -71,7 +69,6 @@ configurerequest(XEvent *e) {
wc.border_width = ev->border_width; wc.border_width = ev->border_width;
wc.sibling = ev->above; wc.sibling = ev->above;
wc.stack_mode = ev->detail; wc.stack_mode = ev->detail;
//ev->value_mask &= ~(CWStackMode|CWSibling);
XConfigureWindow(display, ev->window, ev->value_mask, &wc); XConfigureWindow(display, ev->window, ev->value_mask, &wc);
} }
} }
@ -83,10 +80,9 @@ destroynotify(XEvent *e) {
Client *c; Client *c;
ev = &e->xdestroywindow; ev = &e->xdestroywindow;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->destroy) handle(w, destroy, ev);
w->handler->destroy(w, ev); else {
}else {
Debug fprintf(stderr, "DestroyWindow(%x) (no handler)\n", (uint)ev->window); Debug fprintf(stderr, "DestroyWindow(%x) (no handler)\n", (uint)ev->window);
if((c = win2client(ev->window))) if((c = win2client(ev->window)))
fprintf(stderr, "Badness: Unhandled DestroyNotify: " fprintf(stderr, "Badness: Unhandled DestroyNotify: "
@ -103,10 +99,8 @@ enternotify(XEvent *e) {
if(ev->mode != NotifyNormal) if(ev->mode != NotifyNormal)
return; return;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->enter) handle(w, enter, ev);
w->handler->enter(w, ev);
}
else if(ev->window == scr.root.w) { else if(ev->window == scr.root.w) {
sel_screen = True; sel_screen = True;
draw_frames(); draw_frames();
@ -164,21 +158,15 @@ focusin(XEvent *e) {
print_focus(nil, "<nil>"); print_focus(nil, "<nil>");
screen->focus = nil; screen->focus = nil;
} }
else if((w = findwin(ev->window))) { else if((w = findwin(ev->window)))
if(w->handler->focusin) handle(w, focusin, ev);
w->handler->focusin(w, ev);
}
else if(ev->mode == NotifyGrab) { else if(ev->mode == NotifyGrab) {
if(ev->window == scr.root.w) if(ev->window == scr.root.w)
if(XCheckMaskEvent(display, KeyPressMask, &me)) { if(XCheckMaskEvent(display, KeyPressMask, &me)) {
/* wmii has grabbed focus */ /* wmii has grabbed focus */
c = screen->focus;
screen->hasgrab = &c_root; screen->hasgrab = &c_root;
screen->focus = &c_magic; flushevents(FocusChangeMask, True);
if(c)
draw_frame(c->sel);
dispatch_event(&me); dispatch_event(&me);
return;
} }
/* Some unmanaged window has grabbed focus */ /* Some unmanaged window has grabbed focus */
if((c = screen->focus)) { if((c = screen->focus)) {
@ -197,15 +185,16 @@ focusout(XEvent *e) {
ev = &e->xfocus; ev = &e->xfocus;
if(!((ev->detail == NotifyNonlinear) if(!((ev->detail == NotifyNonlinear)
||(ev->detail == NotifyNonlinearVirtual))) ||(ev->detail == NotifyNonlinearVirtual)
||(ev->detail == NotifyVirtual)
||(ev->detail == NotifyInferior)
||(ev->detail == NotifyAncestor)))
return; return;
if(ev->mode == NotifyUngrab) if(ev->mode == NotifyUngrab)
screen->hasgrab = nil; screen->hasgrab = nil;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->focusout) handle(w, focusout, ev);
w->handler->focusout(w, ev);
}
} }
static void static void
@ -215,10 +204,8 @@ expose(XEvent *e) {
ev = &e->xexpose; ev = &e->xexpose;
if(ev->count == 0) { if(ev->count == 0) {
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->expose) handle(w, expose, ev);
w->handler->expose(w, ev);
}
} }
} }
@ -271,10 +258,8 @@ motionnotify(XEvent *e) {
Window *w; Window *w;
ev = &e->xmotion; ev = &e->xmotion;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->motion) handle(w, motion, ev);
w->handler->motion(w, ev);
}
} }
static void static void
@ -283,10 +268,8 @@ propertynotify(XEvent *e) {
Window *w; Window *w;
ev = &e->xproperty; ev = &e->xproperty;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->property) handle(w, property, ev);
w->handler->property(w, ev);
}
} }
static void static void
@ -295,10 +278,8 @@ mapnotify(XEvent *e) {
Window *w; Window *w;
ev = &e->xmap; ev = &e->xmap;
if((w = findwin(ev->window))) { if((w = findwin(ev->window)))
if(w->handler->map) handle(w, map, ev);
w->handler->map(w, ev);
}
} }
static void static void
@ -309,28 +290,27 @@ unmapnotify(XEvent *e) {
ev = &e->xunmap; ev = &e->xunmap;
if((w = findwin(ev->window)) && (ev->event == w->parent->w)) { if((w = findwin(ev->window)) && (ev->event == w->parent->w)) {
if(ev->send_event || w->unmapped-- == 0) if(ev->send_event || w->unmapped-- == 0)
if(w->handler->unmap) handle(w, unmap, ev);
w->handler->unmap(w, ev);
} }
} }
void (*handler[LASTEvent]) (XEvent *) = { void (*handler[LASTEvent]) (XEvent *) = {
[ButtonPress] = buttonpress, [ButtonPress] = buttonpress,
[ButtonRelease] = buttonrelease, [ButtonRelease] = buttonrelease,
[ConfigureRequest]=configurerequest, [ConfigureRequest] = configurerequest,
[DestroyNotify] = destroynotify, [DestroyNotify] = destroynotify,
[EnterNotify] = enternotify, [EnterNotify] = enternotify,
[Expose] = expose, [Expose] = expose,
[FocusIn] = focusin, [FocusIn] = focusin,
[FocusOut] = focusout, [FocusOut] = focusout,
[KeyPress] = keypress, [KeyPress] = keypress,
[LeaveNotify] = leavenotify, [LeaveNotify] = leavenotify,
[MapNotify] = mapnotify, [MapNotify] = mapnotify,
[MapRequest] = maprequest, [MapRequest] = maprequest,
[MappingNotify] = mappingnotify, [MappingNotify] = mappingnotify,
[MotionNotify] = motionnotify, [MotionNotify] = motionnotify,
[PropertyNotify]= propertynotify, [PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify, [UnmapNotify] = unmapnotify,
}; };
void void

View File

@ -133,7 +133,7 @@ bdown_event(Window *w, XButtonEvent *e) {
XAllowEvents(display, ReplayPointer, e->time); XAllowEvents(display, ReplayPointer, e->time);
break; break;
} }
XAllowEvents(display, AsyncPointer, e->time); XUngrabPointer(display, e->time);
}else{ }else{
if(e->button == Button1) { if(e->button == Button1) {
if(frame_to_top(f)) if(frame_to_top(f))
@ -267,6 +267,13 @@ resize_frame(Frame *f, Rectangle r) {
f->crect = frame2client(f, f->crect); f->crect = frame2client(f, f->crect);
f->crect = rectsubpt(f->crect, f->crect.min); f->crect = rectsubpt(f->crect, f->crect.min);
if(!f->area->floating && f->area->mode == Coldefault) {
if(Dy(f->r) < 2 * labelh(def.font))
f->collapsed = True;
else
f->collapsed = False;
}
if(Dx(f->crect) < labelh(def.font)) { if(Dx(f->crect) < labelh(def.font)) {
f->r.max.x = f->r.min.x + frame_delta_h(); f->r.max.x = f->r.min.x + frame_delta_h();
f->collapsed = True; f->collapsed = True;
@ -313,34 +320,29 @@ set_frame_cursor(Frame *f, Point pt) {
void void
swap_frames(Frame *fa, Frame *fb) { swap_frames(Frame *fa, Frame *fb) {
Rectangle trect; Frame **fp;
Area *a; Client *c;
Frame *an, *ap, *bn, *bp;
if(fa == fb) return; if(fa == fb) return;
an = fa->anext;
ap = fa->aprev;
bn = fb->anext;
bp = fb->aprev;
fb->anext = an; for(fp = &fa->client->frame; *fp; fp = &(*fp)->cnext)
fb->aprev = ap; if(*fp == fa) break;
fa->anext = bn; *fp = (*fp)->cnext;
fa->aprev = bp;
if(fb->area->sel == fb) for(fp = &fb->client->frame; *fp; fp = &(*fp)->cnext)
fb->area->sel = fa; if(*fp == fb) break;
if(fa->area->sel == fa) *fp = (*fp)->cnext;
fa->area->sel = fb;
c = fa->client;
fa->client = fb->client;
fb->client = c;
a = fb->area; fb->cnext = c->frame;
fb->area = fa->area; c->frame = fb;
fa->area = a;
trect = fa->r; c = fa->client;
fa->r = fb->r; fa->cnext = c->frame;
fb->r = trect; c->frame = fa;
} }
void void

View File

@ -664,7 +664,7 @@ fs_read(Ixp9Req *r) {
respond(r, nil); respond(r, nil);
return; return;
case FsFTindex: case FsFTindex:
buf = (char *)view_index(f->p.view); buf = (char*)view_index(f->p.view);
n = strlen(buf); n = strlen(buf);
write_buf(r, buf, n); write_buf(r, buf, n);
respond(r, nil); respond(r, nil);

View File

@ -219,19 +219,8 @@ init_screen(WMScreen *screen) {
static void static void
cleanup() { cleanup() {
Point p; while(client)
Client *c; destroy_client(client);
for(c=client; c; c=c->next) {
p = ZP;
if(c->sel)
p = c->sel->r.min;
reparent_client(c, &scr.root, p);
if(c->sel && c->sel->view != screen->sel)
unmap_client(c, IconicState);
}
XSync(display, False);
XCloseDisplay(display);
ixp_server_close(&srv); ixp_server_close(&srv);
close(sleeperfd); close(sleeperfd);
} }
@ -250,7 +239,7 @@ struct {
/* /*
* There's no way to check accesses to destroyed windows, thus * There's no way to check accesses to destroyed windows, thus
* those cases are ignored (especially on UnmapNotify's). * those cases are ignored (especially on UnmapNotifys).
* Other types of errors call Xlib's default error handler, which * Other types of errors call Xlib's default error handler, which
* calls exit(). * calls exit().
*/ */
@ -269,6 +258,8 @@ errorhandler(Display *dpy, XErrorEvent *error) {
fprintf(stderr, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n", fprintf(stderr, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n",
argv0, error->request_code, error->error_code); argv0, error->request_code, error->error_code);
/* Try to cleanup, but only try once, in case we're called again */
if(!dead++) if(!dead++)
cleanup(); cleanup();
return xlib_errorhandler(display, error); /* calls exit() */ return xlib_errorhandler(display, error); /* calls exit() */
@ -377,12 +368,17 @@ spawn_command(const char *cmd) {
} }
} }
void static void
check_9pcon(IxpConn *c) { check_9pcon(IxpConn *c) {
serve_9pcon(c); serve_9pcon(c);
check_x_event(nil); check_x_event(nil);
} }
static void
closedisplay(IxpConn *c) {
XCloseDisplay(display);
}
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
char *wmiirc, *str; char *wmiirc, *str;
@ -447,7 +443,7 @@ main(int argc, char *argv[]) {
init_lock_keys(); init_lock_keys();
ixp_listen(&srv, sock, &p9srv, check_9pcon, nil); ixp_listen(&srv, sock, &p9srv, check_9pcon, nil);
ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, nil); ixp_listen(&srv, ConnectionNumber(display), nil, check_x_event, closedisplay);
def.font = loadfont(FONT); def.font = loadfont(FONT);
def.border = 1; def.border = 1;
@ -508,7 +504,6 @@ main(int argc, char *argv[]) {
if(exitsignal) if(exitsignal)
raise(exitsignal); raise(exitsignal);
fprintf(stderr, "execstr: %s\n", execstr);
if(execstr) if(execstr)
execl("/bin/sh", "sh", "-c", execstr, nil); execl("/bin/sh", "sh", "-c", execstr, nil);
if(errstr) if(errstr)

View File

@ -107,6 +107,7 @@ hashrm(Map *map, char *str) {
MapEnt **e, *te; MapEnt **e, *te;
void *ret; void *ret;
ret = nil;
e = hashgetp(map, str, 0); e = hashgetp(map, str, 0);
if(*e) { if(*e) {
te = *e; te = *e;

View File

@ -9,10 +9,11 @@
#include "dat.h" #include "dat.h"
#include "fns.h" #include "fns.h"
static char Ebadcmd[] = "bad command", static char
Ebadcmd[] = "bad command",
Ebadvalue[] = "bad value"; Ebadvalue[] = "bad value";
/* Edit s/"([^"]+)"/L\1/g Edit |tr 'a-z' 'A-Z' */ /* Edit |sort Edit s/"([^"]+)"/L\1/g Edit |tr 'a-z' 'A-Z' */
enum { enum {
LNOTURGENT, LNOTURGENT,
LURGENT, LURGENT,
@ -388,7 +389,7 @@ send_frame(Frame *f, int sym, Bool swap) {
insert_frame(fp, f); insert_frame(fp, f);
} }
arrange_column(a, False); arrange_view(f->view);
flushevents(EnterWindowMask, False); flushevents(EnterWindowMask, False);
focus_frame(f, True); focus_frame(f, True);
@ -471,6 +472,7 @@ send_client(View *v, Message *m, Bool swap) {
flushevents(EnterWindowMask, False); flushevents(EnterWindowMask, False);
focus_frame(f, True); focus_frame(f, True);
arrange_view(v);
update_views(); update_views();
return nil; return nil;
} }
@ -494,6 +496,8 @@ select_frame(Frame *f, int sym) {
if(fp == nil) if(fp == nil)
fp = a->frame; fp = a->frame;
break; break;
default:
assert(!"can't get here");
} }
focus_frame(fp, False); focus_frame(fp, False);

View File

@ -30,7 +30,6 @@ struct Framewin {
Point pt; Point pt;
int or; int or;
int n; int n;
int before;
}; };
static Rectangle static Rectangle
@ -63,7 +62,6 @@ frameadjust(Framewin *f, Point pt, int or, int n) {
f->or = or; f->or = or;
f->n = n; f->n = n;
f->pt = pt; f->pt = pt;
reshapewin(f->w, framerect(f));
} }
static Framewin* static Framewin*
@ -81,6 +79,7 @@ framewin(Frame *f, Point pt, int or, int n) {
fw->f = f; fw->f = f;
fw->gb = f->grabbox; fw->gb = f->grabbox;
frameadjust(fw, pt, or, n); frameadjust(fw, pt, or, n);
reshapewin(fw->w, framerect(fw));
mapwin(fw->w); mapwin(fw->w);
raisewin(fw->w); raisewin(fw->w);
@ -136,33 +135,34 @@ vplace(Framewin *fw, Point pt) {
int hr; int hr;
v = screen->sel; v = screen->sel;
r = fw->w->r;
hr = Dy(r)/2;
fw->n = pt.y;
fw->before = 1;
for(a = v->area->next; a->next; a = a->next) for(a = v->area->next; a->next; a = a->next)
if(pt.x < a->r.max.x) if(pt.x < a->r.max.x)
break; break;
fw->ra = a; fw->ra = a;
for(f = a->frame; f->anext; f = f->anext) { pt.x = a->r.min.x;
if(f == fw->f) frameadjust(fw, pt, OHoriz, Dx(a->r));
fw->before = 0;
r = fw->w->r;
hr = Dy(r)/2;
fw->n = pt.y;
for(f = a->frame; f->anext; f = f->anext)
if(pt.y < f->r.max.y) if(pt.y < f->r.max.y)
break; break;
}
if(!f->collapsed) { if(!f->collapsed) {
fw->fp = f; fw->fp = f;
fw->fr = fw->fp->r; fw->fr = fw->fp->r;
if(f == fw->f) { if(f == fw->f) {
fw->fp = f->aprev; fw->fp = f->aprev;
fw->fr.max = f->r.max; fw->fr.max = f->r.max;
if(_vsnap(fw, f->r.min.y+hr)) if(_vsnap(fw, f->r.min.y+hr))
goto done; goto done;
} }
if(_vsnap(fw, f->r.max.y - hr)) { if(_vsnap(fw, f->r.max.y - hr)) {
fw->fr.min.y = f->r.max.y - labelh(def.font); fw->fr.min.y = f->r.max.y - labelh(def.font);
goto done; goto done;
@ -175,26 +175,27 @@ vplace(Framewin *fw, Point pt) {
_vsnap(fw, f->r.min.y); _vsnap(fw, f->r.min.y);
else if(_vsnap(fw, f->r.min.y-hr)) else if(_vsnap(fw, f->r.min.y-hr))
fw->fp = f->aprev; fw->fp = f->aprev;
fw->fr.min.y = fw->n - hr; fw->fr.min.y = pt.y - hr;
if(fw->fp && fw->fp->anext == fw->f) if(fw->fp && fw->fp->anext == fw->f)
fw->fr.max = fw->f->r.max; fw->fr.max = fw->f->r.max;
goto done; goto done;
} }
if(pt.y < f->r.min.y + hr) { if(pt.y < f->r.min.y + hr) {
fw->n = f->r.min.y; pt.y = f->r.min.y;
if(f->aprev && !f->aprev->collapsed) if(f->aprev && !f->aprev->collapsed)
fw->n -= hr; pt.y -= hr;
}else { }else {
fw->n = f->r.max.y; pt.y = f->r.max.y;
if(f->anext == fw->f) if(f->anext == fw->f)
fw->n += hr; pt.y += hr;
} }
done: done:
pt.x = a->r.min.x; pt.x = a->r.min.x;
pt.y = fw->n; pt.y = fw->n;
frameadjust(fw, pt, OHoriz, Dx(a->r)); frameadjust(fw, pt, OHoriz, Dx(a->r));
reshapewin(fw->w, framerect(fw));
} }
static void static void
@ -221,7 +222,8 @@ hplace(Framewin *fw, Point pt) {
} }
pt.y = a->r.min.y; pt.y = a->r.min.y;
frameadjust(fw, pt, OVert, Dy(a->r)); frameadjust(fw, pt, OVert, Dy(a->r));
reshapewin(fw->w, framerect(fw));
} }
static void static void
@ -232,7 +234,7 @@ do_managed_move(Client *c) {
Framewin *fw; Framewin *fw;
Window *cwin; Window *cwin;
Frame *f; Frame *f;
Point pt; Point pt, pt2;
int y; int y;
focus(c, False); focus(c, False);
@ -240,8 +242,9 @@ do_managed_move(Client *c) {
pt = querypointer(&scr.root); pt = querypointer(&scr.root);
pt.x = f->area->r.min.x; pt2.x = f->area->r.min.x;
fw = framewin(f, pt, OHoriz, Dx(f->area->r)); pt2.y = pt.y;
fw = framewin(f, pt2, OHoriz, Dx(f->area->r));
r = screen->r; r = screen->r;
r.min.y += fw->gb.min.y + Dy(fw->gb)/2; r.min.y += fw->gb.min.y + Dy(fw->gb)/2;
@ -272,7 +275,7 @@ horiz:
case ButtonRelease: case ButtonRelease:
switch(ev.xbutton.button) { switch(ev.xbutton.button) {
case 1: case 1:
if(f->anext && (!f->aprev || (fw->fp != f->aprev && fw->fp != f->aprev->aprev))) { if((f->anext) && (!f->aprev || (fw->fp != f->aprev && fw->fp != f->aprev->aprev))) {
f->anext->r.min.y = f->r.min.y; f->anext->r.min.y = f->r.min.y;
resize_frame(f->anext, f->anext->r); resize_frame(f->anext, f->anext->r);
} }
@ -352,6 +355,11 @@ done:
XUngrabPointer(display, CurrentTime); XUngrabPointer(display, CurrentTime);
framedestroy(fw); framedestroy(fw);
destroywindow(cwin); destroywindow(cwin);
pt = addpt(f->r.min, f->grabbox.min);
pt.x += Dx(f->grabbox)/2;
pt.y += Dy(f->grabbox)/2;
warppointer(pt);
} }
static Window * static Window *

View File

@ -171,6 +171,8 @@ void
reparentwindow(Window *w, Window *par, Point p) { reparentwindow(Window *w, Window *par, Point p) {
XReparentWindow(display, w->w, par->w, p.x, p.y); XReparentWindow(display, w->w, par->w, p.x, p.y);
w->parent = par; w->parent = par;
w->r = rectsubpt(w->r, w->r.min);
w->r = rectaddpt(w->r, p);
} }
void void

View File

@ -13,7 +13,8 @@ INCPATH = .:${ROOT}/include:${INCLUDE}:/usr/include
LIBS = -L/usr/lib -lc LIBS = -L/usr/lib -lc
# Flags # Flags
CFLAGS += -g -O0 -Wall include ${ROOT}/mk/gcc.mk
CFLAGS += -g -O0
LDFLAGS += -g ${LIBS} LDFLAGS += -g ${LIBS}
STATIC = -static STATIC = -static
MKDEP = cpp -M MKDEP = cpp -M