diff options
Diffstat (limited to '')
| -rw-r--r-- | client.c | 32 |
1 files changed, 30 insertions, 2 deletions
| @@ -10,6 +10,8 @@ | |||
| 10 | #include "util.h" | 10 | #include "util.h" |
| 11 | #include "wm.h" | 11 | #include "wm.h" |
| 12 | 12 | ||
| 13 | #define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask) | ||
| 14 | |||
| 13 | void | 15 | void |
| 14 | update_name(Client *c) | 16 | update_name(Client *c) |
| 15 | { | 17 | { |
| @@ -70,7 +72,7 @@ manage(Window w, XWindowAttributes *wa) | |||
| 70 | c->r[RFloat].height = wa->height; | 72 | c->r[RFloat].height = wa->height; |
| 71 | c->border = wa->border_width; | 73 | c->border = wa->border_width; |
| 72 | XSetWindowBorderWidth(dpy, c->win, 0); | 74 | XSetWindowBorderWidth(dpy, c->win, 0); |
| 73 | XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); | 75 | XSelectInput(dpy, c->win, CLIENT_MASK); |
| 74 | XGetTransientForHint(dpy, c->win, &c->trans); | 76 | XGetTransientForHint(dpy, c->win, &c->trans); |
| 75 | if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) | 77 | if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) |
| 76 | c->size.flags = PSize; | 78 | c->size.flags = PSize; |
| @@ -95,9 +97,34 @@ manage(Window w, XWindowAttributes *wa) | |||
| 95 | c->snext = stack; | 97 | c->snext = stack; |
| 96 | stack = c; | 98 | stack = c; |
| 97 | XMapWindow(dpy, c->win); | 99 | XMapWindow(dpy, c->win); |
| 100 | XGrabButton(dpy, AnyButton, Mod1Mask, c->win, False, ButtonPressMask, | ||
| 101 | GrabModeAsync, GrabModeSync, None, None); | ||
| 98 | focus(c); | 102 | focus(c); |
| 99 | } | 103 | } |
| 100 | 104 | ||
| 105 | void | ||
| 106 | resize(Client *c) | ||
| 107 | { | ||
| 108 | XConfigureEvent e; | ||
| 109 | |||
| 110 | XMoveResizeWindow(dpy, c->win, c->r[RFloat].x, c->r[RFloat].y, | ||
| 111 | c->r[RFloat].width, c->r[RFloat].height); | ||
| 112 | e.type = ConfigureNotify; | ||
| 113 | e.event = c->win; | ||
| 114 | e.window = c->win; | ||
| 115 | e.x = c->r[RFloat].x; | ||
| 116 | e.y = c->r[RFloat].y; | ||
| 117 | e.width = c->r[RFloat].width; | ||
| 118 | e.height = c->r[RFloat].height; | ||
| 119 | e.border_width = c->border; | ||
| 120 | e.above = None; | ||
| 121 | e.override_redirect = False; | ||
| 122 | XSelectInput(dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); | ||
| 123 | XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&e); | ||
| 124 | XSelectInput(dpy, c->win, CLIENT_MASK); | ||
| 125 | XFlush(dpy); | ||
| 126 | } | ||
| 127 | |||
| 101 | static int | 128 | static int |
| 102 | dummy_error_handler(Display *dpy, XErrorEvent *error) | 129 | dummy_error_handler(Display *dpy, XErrorEvent *error) |
| 103 | { | 130 | { |
| @@ -112,6 +139,7 @@ unmanage(Client *c) | |||
| 112 | XGrabServer(dpy); | 139 | XGrabServer(dpy); |
| 113 | XSetErrorHandler(dummy_error_handler); | 140 | XSetErrorHandler(dummy_error_handler); |
| 114 | 141 | ||
| 142 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | ||
| 115 | XUnmapWindow(dpy, c->win); | 143 | XUnmapWindow(dpy, c->win); |
| 116 | XDestroyWindow(dpy, c->title); | 144 | XDestroyWindow(dpy, c->title); |
| 117 | 145 | ||
| @@ -126,7 +154,7 @@ unmanage(Client *c) | |||
| 126 | XFlush(dpy); | 154 | XFlush(dpy); |
| 127 | XSetErrorHandler(error_handler); | 155 | XSetErrorHandler(error_handler); |
| 128 | XUngrabServer(dpy); | 156 | XUngrabServer(dpy); |
| 129 | flush_events(EnterWindowMask); | 157 | discard_events(EnterWindowMask); |
| 130 | if(stack) | 158 | if(stack) |
| 131 | focus(stack); | 159 | focus(stack); |
| 132 | } | 160 | } |
