Mercurial > aewl
comparison client.c @ 18:1efa34c6e1b6
added mouse-based resizals
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 21:24:10 +0200 |
parents | 359b6e563b95 |
children | b5510d0c6d43 |
comparison
equal
deleted
inserted
replaced
17:aaf520f53110 | 18:1efa34c6e1b6 |
---|---|
7 #include <string.h> | 7 #include <string.h> |
8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
9 | 9 |
10 #include "util.h" | 10 #include "util.h" |
11 #include "wm.h" | 11 #include "wm.h" |
12 | |
13 #define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask) | |
12 | 14 |
13 void | 15 void |
14 update_name(Client *c) | 16 update_name(Client *c) |
15 { | 17 { |
16 XTextProperty name; | 18 XTextProperty name; |
68 c->r[RFloat].y = wa->y; | 70 c->r[RFloat].y = wa->y; |
69 c->r[RFloat].width = wa->width; | 71 c->r[RFloat].width = wa->width; |
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; |
77 c->fixedsize = | 79 c->fixedsize = |
78 (c->size.flags & PMinSize && c->size.flags & PMaxSize | 80 (c->size.flags & PMinSize && c->size.flags & PMaxSize |
93 c->next = *l; /* *l == nil */ | 95 c->next = *l; /* *l == nil */ |
94 *l = c; | 96 *l = c; |
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); |
103 } | |
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); | |
99 } | 126 } |
100 | 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 { |
110 Client **l; | 137 Client **l; |
111 | 138 |
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 |
118 for(l=&clients; *l && *l != c; l=&(*l)->next); | 146 for(l=&clients; *l && *l != c; l=&(*l)->next); |
119 eassert(*l == c); | 147 eassert(*l == c); |
124 free(c); | 152 free(c); |
125 | 153 |
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 } |
133 | 161 |
134 | 162 |