265 [MapRequest] = maprequest, |
265 [MapRequest] = maprequest, |
266 [PropertyNotify] = propertynotify, |
266 [PropertyNotify] = propertynotify, |
267 [UnmapNotify] = unmapnotify |
267 [UnmapNotify] = unmapnotify |
268 }; |
268 }; |
269 static Atom wmatom[WMLast], netatom[NetLast]; |
269 static Atom wmatom[WMLast], netatom[NetLast]; |
270 static Bool otherwm; |
|
271 static Bool running = True; |
270 static Bool running = True; |
272 static Cursor cursor[CurLast]; |
271 static Cursor cursor[CurLast]; |
273 static Display *dpy; |
272 static Display *dpy; |
274 static DC dc; |
273 static DC dc; |
275 static Monitor *mons = NULL, *selmon = NULL; |
274 static Monitor *mons = NULL, *selmon = NULL; |
456 buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); |
455 buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); |
457 } |
456 } |
458 |
457 |
459 void |
458 void |
460 checkotherwm(void) { |
459 checkotherwm(void) { |
461 otherwm = False; |
|
462 xerrorxlib = XSetErrorHandler(xerrorstart); |
460 xerrorxlib = XSetErrorHandler(xerrorstart); |
463 /* this causes an error if some other window manager is running */ |
461 /* this causes an error if some other window manager is running */ |
464 XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); |
462 XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); |
465 XSync(dpy, False); |
463 XSync(dpy, False); |
466 if(otherwm) |
|
467 die("dwm: another window manager is already running\n"); |
|
468 XSetErrorHandler(xerror); |
464 XSetErrorHandler(xerror); |
469 XSync(dpy, False); |
465 XSync(dpy, False); |
470 } |
466 } |
471 |
467 |
472 void |
468 void |
992 while(n--) |
988 while(n--) |
993 fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); |
989 fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); |
994 XFreeStringList(missing); |
990 XFreeStringList(missing); |
995 } |
991 } |
996 if(dc.font.set) { |
992 if(dc.font.set) { |
997 XFontSetExtents *font_extents; |
|
998 XFontStruct **xfonts; |
993 XFontStruct **xfonts; |
999 char **font_names; |
994 char **font_names; |
1000 |
995 |
1001 dc.font.ascent = dc.font.descent = 0; |
996 dc.font.ascent = dc.font.descent = 0; |
1002 font_extents = XExtentsOfFontSet(dc.font.set); |
997 XExtentsOfFontSet(dc.font.set); |
1003 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); |
998 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); |
1004 for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { |
999 for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) { |
1005 dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); |
1000 dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); |
1006 dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); |
1001 dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); |
1007 xfonts++; |
1002 xfonts++; |
1086 } |
1081 } |
1087 } |
1082 } |
1088 |
1083 |
1089 void |
1084 void |
1090 manage(Window w, XWindowAttributes *wa) { |
1085 manage(Window w, XWindowAttributes *wa) { |
1091 static Client cz; |
|
1092 Client *c, *t = NULL; |
1086 Client *c, *t = NULL; |
1093 Window trans = None; |
1087 Window trans = None; |
1094 XWindowChanges wc; |
1088 XWindowChanges wc; |
1095 |
1089 |
1096 if(!(c = malloc(sizeof(Client)))) |
1090 if(!(c = calloc(1, sizeof(Client)))) |
1097 die("fatal: could not malloc() %u bytes\n", sizeof(Client)); |
1091 die("fatal: could not malloc() %u bytes\n", sizeof(Client)); |
1098 *c = cz; |
|
1099 c->win = w; |
1092 c->win = w; |
1100 updatetitle(c); |
1093 updatetitle(c); |
1101 if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { |
1094 if(XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { |
1102 c->mon = t->mon; |
1095 c->mon = t->mon; |
1103 c->tags = t->tags; |
1096 c->tags = t->tags; |
1577 showhide(c->snext); |
1570 showhide(c->snext); |
1578 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
1571 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
1579 } |
1572 } |
1580 } |
1573 } |
1581 |
1574 |
1582 |
|
1583 void |
1575 void |
1584 sigchld(int unused) { |
1576 sigchld(int unused) { |
1585 if(signal(SIGCHLD, sigchld) == SIG_ERR) |
1577 if(signal(SIGCHLD, sigchld) == SIG_ERR) |
1586 die("Can't install SIGCHLD handler"); |
1578 die("Can't install SIGCHLD handler"); |
1587 while(0 < waitpid(-1, NULL, WNOHANG)); |
1579 while(0 < waitpid(-1, NULL, WNOHANG)); |
2013 |
2005 |
2014 /* Startup Error handler to check if another window manager |
2006 /* Startup Error handler to check if another window manager |
2015 * is already running. */ |
2007 * is already running. */ |
2016 int |
2008 int |
2017 xerrorstart(Display *dpy, XErrorEvent *ee) { |
2009 xerrorstart(Display *dpy, XErrorEvent *ee) { |
2018 otherwm = True; |
2010 die("dwm: another window manager is already running\n"); |
2019 return -1; |
2011 return -1; |
2020 } |
2012 } |
2021 |
2013 |
2022 void |
2014 void |
2023 zoom(const Arg *arg) { |
2015 zoom(const Arg *arg) { |