44 else |
44 else |
45 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, |
45 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, |
46 GrabModeAsync, GrabModeSync, None, None); |
46 GrabModeAsync, GrabModeSync, None, None); |
47 } |
47 } |
48 |
48 |
|
49 static Bool |
|
50 isprotodel(Client *c) { |
|
51 int i, n; |
|
52 Atom *protocols; |
|
53 Bool ret = False; |
|
54 |
|
55 if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { |
|
56 for(i = 0; !ret && i < n; i++) |
|
57 if(protocols[i] == wmatom[WMDelete]) |
|
58 ret = True; |
|
59 XFree(protocols); |
|
60 } |
|
61 return ret; |
|
62 } |
|
63 |
49 static void |
64 static void |
50 setclientstate(Client *c, long state) { |
65 setclientstate(Client *c, long state) { |
51 long data[] = {state, None}; |
66 long data[] = {state, None}; |
52 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
67 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
53 PropModeReplace, (unsigned char *)data, 2); |
68 PropModeReplace, (unsigned char *)data, 2); |
77 ce.override_redirect = False; |
106 ce.override_redirect = False; |
78 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); |
107 XSendEvent(dpy, c->win, False, StructureNotifyMask, (XEvent *)&ce); |
79 } |
108 } |
80 |
109 |
81 void |
110 void |
|
111 detach(Client *c) { |
|
112 if(c->prev) |
|
113 c->prev->next = c->next; |
|
114 if(c->next) |
|
115 c->next->prev = c->prev; |
|
116 if(c == clients) |
|
117 clients = c->next; |
|
118 c->next = c->prev = NULL; |
|
119 } |
|
120 |
|
121 void |
|
122 detachstack(Client *c) { |
|
123 Client **tc; |
|
124 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); |
|
125 *tc = c->snext; |
|
126 } |
|
127 |
|
128 void |
82 focus(Client *c) { |
129 focus(Client *c) { |
83 if(c && !isvisible(c)) |
130 if(c && !isvisible(c)) |
84 return; |
131 return; |
85 if(sel && sel != c) { |
132 if(sel && sel != c) { |
86 grabbuttons(sel, False); |
133 grabbuttons(sel, False); |
101 } |
148 } |
102 else |
149 else |
103 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
150 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); |
104 } |
151 } |
105 |
152 |
106 Bool |
153 void |
107 isprotodel(Client *c) { |
154 focusnext(Arg *arg) { |
108 int i, n; |
155 Client *c; |
109 Atom *protocols; |
156 |
110 Bool ret = False; |
157 if(!sel) |
111 |
158 return; |
112 if(XGetWMProtocols(dpy, c->win, &protocols, &n)) { |
159 for(c = sel->next; c && !isvisible(c); c = c->next); |
113 for(i = 0; !ret && i < n; i++) |
160 if(!c) |
114 if(protocols[i] == wmatom[WMDelete]) |
161 for(c = clients; c && !isvisible(c); c = c->next); |
115 ret = True; |
162 if(c) { |
116 XFree(protocols); |
163 focus(c); |
117 } |
164 restack(); |
118 return ret; |
165 } |
|
166 } |
|
167 |
|
168 void |
|
169 focusprev(Arg *arg) { |
|
170 Client *c; |
|
171 |
|
172 if(!sel) |
|
173 return; |
|
174 for(c = sel->prev; c && !isvisible(c); c = c->prev); |
|
175 if(!c) { |
|
176 for(c = clients; c && c->next; c = c->next); |
|
177 for(; c && !isvisible(c); c = c->prev); |
|
178 } |
|
179 if(c) { |
|
180 focus(c); |
|
181 restack(); |
|
182 } |
|
183 } |
|
184 |
|
185 Client * |
|
186 getclient(Window w) { |
|
187 Client *c; |
|
188 |
|
189 for(c = clients; c; c = c->next) |
|
190 if(c->win == w) |
|
191 return c; |
|
192 return NULL; |
119 } |
193 } |
120 |
194 |
121 void |
195 void |
122 killclient(Arg *arg) { |
196 killclient(Arg *arg) { |
123 if(!sel) |
197 if(!sel) |