aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/monsterwm.c b/monsterwm.c
index 359d8e7..e586d6d 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -664,34 +664,32 @@ void killclient(void) {
void maprequest(XEvent *e) {
Desktop *d = NULL;
Client *c = NULL;
- XWindowAttributes wa; Window w;
-
- if (XGetWindowAttributes(dis, e->xmaprequest.window, &wa) && wa.override_redirect) return;
- if (wintoclient(e->xmaprequest.window, &c, &d)) return;
-
+ Window w = e->xmaprequest.window;
+ XWindowAttributes wa = {0};
+ XClassHint ch = {0};
Bool follow = False, floating = False;
int newdsk = currdeskidx;
- XClassHint ch = {0, 0};
- if (XGetClassHint(dis, e->xmaprequest.window, &ch))
- for (unsigned int i = 0; i < LENGTH(rules); i++)
- if (strstr(ch.res_class, rules[i].class) || strstr(ch.res_name, rules[i].class)) {
- if (rules[i].desktop >= 0) newdsk = rules[i].desktop;
- follow = rules[i].follow;
- floating = rules[i].floating;
- break;
- }
+ if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return;
+
+ if (XGetClassHint(dis, w, &ch)) for (unsigned int i = 0; i < LENGTH(rules); i++)
+ if (strstr(ch.res_class, rules[i].class) || strstr(ch.res_name, rules[i].class)) {
+ if (rules[i].desktop >= 0) newdsk = rules[i].desktop;
+ follow = rules[i].follow;
+ floating = rules[i].floating;
+ break;
+ }
if (ch.res_class) XFree(ch.res_class);
if (ch.res_name) XFree(ch.res_name);
- c = addwindow(e->xmaprequest.window, (d = &desktops[newdsk]));
+ c = addwindow(w, (d = &desktops[newdsk])); /* from now on, use c->win */
c->istrans = XGetTransientForHint(dis, c->win, &w);
if ((c->isfloat = (floating || d->mode == FLOAT)) && !c->istrans)
XMoveWindow(dis, c->win, (ww - wa.width)/2, (wh - wa.height)/2);
- int di; unsigned long dl; unsigned char *state = NULL; Atom da;
- if (XGetWindowProperty(dis, c->win, netatoms[NET_WM_STATE], 0L, sizeof da,
- False, XA_ATOM, &da, &di, &dl, &dl, &state) == Success && state)
+ int i; unsigned long l; unsigned char *state = NULL; Atom a;
+ if (XGetWindowProperty(dis, c->win, netatoms[NET_WM_STATE], 0L, sizeof a,
+ False, XA_ATOM, &a, &i, &l, &l, &state) == Success && state)
setfullscreen(c, d, (*(Atom *)state == netatoms[NET_FULLSCREEN]));
if (state) XFree(state);