diff options
Diffstat (limited to '')
| -rw-r--r-- | main.c | 43 |
1 files changed, 16 insertions, 27 deletions
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | /* static */ | 18 | /* static */ |
| 19 | 19 | ||
| 20 | static Bool otherwm; | ||
| 21 | static int (*xerrorxlib)(Display *, XErrorEvent *); | 20 | static int (*xerrorxlib)(Display *, XErrorEvent *); |
| 21 | static Bool otherwm; | ||
| 22 | 22 | ||
| 23 | static void | 23 | static void |
| 24 | cleanup() | 24 | cleanup() |
| @@ -34,9 +34,8 @@ static void | |||
| 34 | scan() | 34 | scan() |
| 35 | { | 35 | { |
| 36 | unsigned int i, num; | 36 | unsigned int i, num; |
| 37 | Window *wins; | 37 | Window *wins, d1, d2; |
| 38 | XWindowAttributes wa; | 38 | XWindowAttributes wa; |
| 39 | Window d1, d2; | ||
| 40 | 39 | ||
| 41 | if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { | 40 | if(XQueryTree(dpy, root, &d1, &d2, &wins, &num)) { |
| 42 | for(i = 0; i < num; i++) { | 41 | for(i = 0; i < num; i++) { |
| @@ -55,10 +54,9 @@ scan() | |||
| 55 | static int | 54 | static int |
| 56 | win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) | 55 | win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) |
| 57 | { | 56 | { |
| 58 | Atom real; | 57 | int status, format; |
| 59 | int format; | ||
| 60 | unsigned long res, extra; | 58 | unsigned long res, extra; |
| 61 | int status; | 59 | Atom real; |
| 62 | 60 | ||
| 63 | status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, | 61 | status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format, |
| 64 | &res, &extra, prop); | 62 | &res, &extra, prop); |
| @@ -101,10 +99,10 @@ Window root, barwin; | |||
| 101 | int | 99 | int |
| 102 | getproto(Window w) | 100 | getproto(Window w) |
| 103 | { | 101 | { |
| 104 | unsigned char *protocols; | ||
| 105 | long res; | ||
| 106 | int protos = 0; | 102 | int protos = 0; |
| 107 | int i; | 103 | int i; |
| 104 | long res; | ||
| 105 | unsigned char *protocols; | ||
| 108 | 106 | ||
| 109 | res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols); | 107 | res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols); |
| 110 | if(res <= 0) { | 108 | if(res <= 0) { |
| @@ -148,21 +146,15 @@ int | |||
| 148 | xerror(Display *dpy, XErrorEvent *ee) | 146 | xerror(Display *dpy, XErrorEvent *ee) |
| 149 | { | 147 | { |
| 150 | if(ee->error_code == BadWindow | 148 | if(ee->error_code == BadWindow |
| 151 | || (ee->request_code == X_SetInputFocus | 149 | || (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch) |
| 152 | && ee->error_code == BadMatch) | 150 | || (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable) |
| 153 | || (ee->request_code == X_PolyText8 | 151 | || (ee->request_code == X_PolyFillRectangle && ee->error_code == BadDrawable) |
| 154 | && ee->error_code == BadDrawable) | 152 | || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) |
| 155 | || (ee->request_code == X_PolyFillRectangle | 153 | || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) |
| 156 | && ee->error_code == BadDrawable) | 154 | || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)) |
| 157 | || (ee->request_code == X_PolySegment | ||
| 158 | && ee->error_code == BadDrawable) | ||
| 159 | || (ee->request_code == X_ConfigureWindow | ||
| 160 | && ee->error_code == BadMatch) | ||
| 161 | || (ee->request_code == X_GrabKey | ||
| 162 | && ee->error_code == BadAccess)) | ||
| 163 | return 0; | 155 | return 0; |
| 164 | fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", | 156 | fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", |
| 165 | ee->request_code, ee->error_code); | 157 | ee->request_code, ee->error_code); |
| 166 | return xerrorxlib(dpy, ee); /* may call exit() */ | 158 | return xerrorxlib(dpy, ee); /* may call exit() */ |
| 167 | } | 159 | } |
| 168 | 160 | ||
| @@ -170,12 +162,12 @@ int | |||
| 170 | main(int argc, char *argv[]) | 162 | main(int argc, char *argv[]) |
| 171 | { | 163 | { |
| 172 | int i, n; | 164 | int i, n; |
| 173 | fd_set rd; | ||
| 174 | XSetWindowAttributes wa; | ||
| 175 | unsigned int mask; | 165 | unsigned int mask; |
| 166 | fd_set rd; | ||
| 176 | Bool readstdin = True; | 167 | Bool readstdin = True; |
| 177 | Window w; | 168 | Window w; |
| 178 | XEvent ev; | 169 | XEvent ev; |
| 170 | XSetWindowAttributes wa; | ||
| 179 | 171 | ||
| 180 | for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { | 172 | for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { |
| 181 | switch (argv[i][1]) { | 173 | switch (argv[i][1]) { |
| @@ -254,14 +246,11 @@ main(int argc, char *argv[]) | |||
| 254 | 246 | ||
| 255 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | 247 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
| 256 | 248 | ||
| 257 | wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ | 249 | wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask; |
| 258 | | LeaveWindowMask; | ||
| 259 | wa.cursor = cursor[CurNormal]; | 250 | wa.cursor = cursor[CurNormal]; |
| 260 | |||
| 261 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 251 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
| 262 | 252 | ||
| 263 | strcpy(stext, "dwm-"VERSION); | 253 | strcpy(stext, "dwm-"VERSION); |
| 264 | |||
| 265 | scan(); | 254 | scan(); |
| 266 | 255 | ||
| 267 | /* main event loop, reads status text from stdin as well */ | 256 | /* main event loop, reads status text from stdin as well */ |
