X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=c11d5d5b970f08602ef085c2b57648bf64d1d041;hb=48b6e9a3968e54a87f022c8e68b5bec5423cb75f;hp=f87fb80f5d09115e24942fa2d31c7a1196e43e07;hpb=586f66331d1105be03c42e6faeae1672b974a98a;p=dwm.git diff --git a/client.c b/client.c index f87fb80..c11d5d5 100644 --- a/client.c +++ b/client.c @@ -10,6 +10,8 @@ #include "util.h" #include "wm.h" +#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask) + void update_name(Client *c) { @@ -35,6 +37,10 @@ update_name(Client *c) } } XFree(name.value); + if(c == stack) + draw_bar(); + else + draw_client(c); } void @@ -64,8 +70,8 @@ manage(Window w, XWindowAttributes *wa) c->r[RFloat].y = wa->y; c->r[RFloat].width = wa->width; c->r[RFloat].height = wa->height; - c->border = wa->border_width; - XSetWindowBorderWidth(dpy, c->win, 0); + XSetWindowBorderWidth(dpy, c->win, 1); + XSelectInput(dpy, c->win, CLIENT_MASK); XGetTransientForHint(dpy, c->win, &c->trans); if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) c->size.flags = PSize; @@ -90,9 +96,38 @@ manage(Window w, XWindowAttributes *wa) c->snext = stack; stack = c; XMapWindow(dpy, c->win); + XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, + GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, + GrabModeAsync, GrabModeSync, None, None); + XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, + GrabModeAsync, GrabModeSync, None, None); focus(c); } +void +resize(Client *c) +{ + XConfigureEvent e; + + XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, + c->r[RFloat].width, c->r[RFloat].height); + e.type = ConfigureNotify; + e.event = c->win; + e.window = c->win; + e.x = c->r[RFloat].x; + e.y = c->r[RFloat].y; + e.width = c->r[RFloat].width; + e.height = c->r[RFloat].height; + e.border_width = 0; + e.above = None; + e.override_redirect = False; + XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); + XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e); + XSelectInput(dpy, c->win, CLIENT_MASK); + XFlush(dpy); +} + static int dummy_error_handler(Display *dpy, XErrorEvent *error) { @@ -107,6 +142,7 @@ unmanage(Client *c) XGrabServer(dpy); XSetErrorHandler(dummy_error_handler); + XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XUnmapWindow(dpy, c->win); XDestroyWindow(dpy, c->title); @@ -121,7 +157,7 @@ unmanage(Client *c) XFlush(dpy); XSetErrorHandler(error_handler); XUngrabServer(dpy); - flush_events(EnterWindowMask); + discard_events(EnterWindowMask); if(stack) focus(stack); }