301 buttonpress(XEvent *e) { |
301 buttonpress(XEvent *e) { |
302 unsigned int i, x; |
302 unsigned int i, x; |
303 Client *c; |
303 Client *c; |
304 XButtonPressedEvent *ev = &e->xbutton; |
304 XButtonPressedEvent *ev = &e->xbutton; |
305 |
305 |
306 if(barwin == ev->window) { |
306 if(ev->window == barwin) { |
307 x = 0; |
307 x = 0; |
308 for(i = 0; i < LENGTH(tags); i++) { |
308 for(i = 0; i < LENGTH(tags); i++) { |
309 x += textw(tags[i]); |
309 x += textw(tags[i]); |
310 if(ev->x < x) { |
310 if(ev->x < x) { |
311 if(ev->button == Button1) { |
311 if(ev->button == Button1) { |
329 else if((c = getclient(ev->window))) { |
329 else if((c = getclient(ev->window))) { |
330 focus(c); |
330 focus(c); |
331 if(CLEANMASK(ev->state) != MODKEY) |
331 if(CLEANMASK(ev->state) != MODKEY) |
332 return; |
332 return; |
333 if(ev->button == Button1) { |
333 if(ev->button == Button1) { |
334 if((floating == layout->arrange) || c->isfloating) |
334 if((layout->arrange == floating) || c->isfloating) |
335 restack(); |
335 restack(); |
336 else |
336 else |
337 togglefloating(NULL); |
337 togglefloating(NULL); |
338 movemouse(c); |
338 movemouse(c); |
339 } |
339 } |
775 gettextprop(Window w, Atom atom, char *text, unsigned int size) { |
775 gettextprop(Window w, Atom atom, char *text, unsigned int size) { |
776 char **list = NULL; |
776 char **list = NULL; |
777 int n; |
777 int n; |
778 XTextProperty name; |
778 XTextProperty name; |
779 |
779 |
780 if(!text || 0 == size) |
780 if(!text || size == 0) |
781 return False; |
781 return False; |
782 text[0] = '\0'; |
782 text[0] = '\0'; |
783 XGetTextProperty(dpy, w, &name, atom); |
783 XGetTextProperty(dpy, w, &name, atom); |
784 if(!name.nitems) |
784 if(!name.nitems) |
785 return False; |
785 return False; |
786 if(name.encoding == XA_STRING) |
786 if(name.encoding == XA_STRING) |
787 strncpy(text, (char *)name.value, size - 1); |
787 strncpy(text, (char *)name.value, size - 1); |
788 else { |
788 else { |
789 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success |
789 if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success |
790 && n > 0 && *list) |
790 && n > 0 && *list) { |
791 { |
|
792 strncpy(text, *list, size - 1); |
791 strncpy(text, *list, size - 1); |
793 XFreeStringList(list); |
792 XFreeStringList(list); |
794 } |
793 } |
795 } |
794 } |
796 text[size - 1] = '\0'; |
795 text[size - 1] = '\0'; |
1121 if((c = getclient(ev->window))) { |
1120 if((c = getclient(ev->window))) { |
1122 switch (ev->atom) { |
1121 switch (ev->atom) { |
1123 default: break; |
1122 default: break; |
1124 case XA_WM_TRANSIENT_FOR: |
1123 case XA_WM_TRANSIENT_FOR: |
1125 XGetTransientForHint(dpy, c->win, &trans); |
1124 XGetTransientForHint(dpy, c->win, &trans); |
1126 if(!c->isfloating && (c->isfloating = (NULL != getclient(trans)))) |
1125 if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL))) |
1127 arrange(); |
1126 arrange(); |
1128 break; |
1127 break; |
1129 case XA_WM_NORMAL_HINTS: |
1128 case XA_WM_NORMAL_HINTS: |
1130 updatesizehints(c); |
1129 updatesizehints(c); |
1131 break; |
1130 break; |
1255 XWindowChanges wc; |
1254 XWindowChanges wc; |
1256 |
1255 |
1257 drawbar(); |
1256 drawbar(); |
1258 if(!sel) |
1257 if(!sel) |
1259 return; |
1258 return; |
1260 if(sel->isfloating || (floating == layout->arrange)) |
1259 if(sel->isfloating || (layout->arrange == floating)) |
1261 XRaiseWindow(dpy, sel->win); |
1260 XRaiseWindow(dpy, sel->win); |
1262 if(floating != layout->arrange) { |
1261 if(layout->arrange != floating) { |
1263 wc.stack_mode = Below; |
1262 wc.stack_mode = Below; |
1264 wc.sibling = barwin; |
1263 wc.sibling = barwin; |
1265 if(!sel->isfloating) { |
1264 if(!sel->isfloating) { |
1266 XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc); |
1265 XConfigureWindow(dpy, sel->win, CWSibling | CWStackMode, &wc); |
1267 wc.sibling = sel->win; |
1266 wc.sibling = sel->win; |
1511 shell = "/bin/sh"; |
1510 shell = "/bin/sh"; |
1512 if(!arg) |
1511 if(!arg) |
1513 return; |
1512 return; |
1514 /* The double-fork construct avoids zombie processes and keeps the code |
1513 /* The double-fork construct avoids zombie processes and keeps the code |
1515 * clean from stupid signal handlers. */ |
1514 * clean from stupid signal handlers. */ |
1516 if(0 == fork()) { |
1515 if(fork() == 0) { |
1517 if(0 == fork()) { |
1516 if(fork() == 0) { |
1518 if(dpy) |
1517 if(dpy) |
1519 close(ConnectionNumber(dpy)); |
1518 close(ConnectionNumber(dpy)); |
1520 setsid(); |
1519 setsid(); |
1521 execl(shell, shell, "-c", arg, (char *)NULL); |
1520 execl(shell, shell, "-c", arg, (char *)NULL); |
1522 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg); |
1521 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg); |
1573 nx = wax; |
1572 nx = wax; |
1574 ny = way; |
1573 ny = way; |
1575 nw = 0; /* gcc stupidity requires this */ |
1574 nw = 0; /* gcc stupidity requires this */ |
1576 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) { |
1575 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) { |
1577 c->ismax = False; |
1576 c->ismax = False; |
1578 if(0 == i) { /* master */ |
1577 if(i == 0) { /* master */ |
1579 nw = mw - 2 * c->border; |
1578 nw = mw - 2 * c->border; |
1580 nh = wah - 2 * c->border; |
1579 nh = wah - 2 * c->border; |
1581 } |
1580 } |
1582 else { /* tile window */ |
1581 else { /* tile window */ |
1583 if(i == 1) { |
1582 if(i == 1) { |
1624 XEvent ev; |
1623 XEvent ev; |
1625 |
1624 |
1626 if(!sel || sel->isfixed) |
1625 if(!sel || sel->isfixed) |
1627 return; |
1626 return; |
1628 if((sel->ismax = !sel->ismax)) { |
1627 if((sel->ismax = !sel->ismax)) { |
1629 if((floating == layout->arrange) || sel->isfloating) |
1628 if((layout->arrange == floating) || sel->isfloating) |
1630 sel->wasfloating = True; |
1629 sel->wasfloating = True; |
1631 else { |
1630 else { |
1632 togglefloating(NULL); |
1631 togglefloating(NULL); |
1633 sel->wasfloating = False; |
1632 sel->wasfloating = False; |
1634 } |
1633 } |