changeset 1071 | 3303e2643918 |
parent 1070 | dc37f0e022f7 |
child 1072 | 5a06b4b69479 |
1070:dc37f0e022f7 | 1071:3303e2643918 |
---|---|
59 /* typedefs */ |
59 /* typedefs */ |
60 typedef struct Client Client; |
60 typedef struct Client Client; |
61 struct Client { |
61 struct Client { |
62 char name[256]; |
62 char name[256]; |
63 int x, y, w, h; |
63 int x, y, w, h; |
64 int rx, ry, rw, rh; /* revert geometry */ |
|
65 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
64 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
66 int minax, maxax, minay, maxay; |
65 int minax, maxax, minay, maxay; |
67 long flags; |
66 long flags; |
68 unsigned int border, oldborder; |
67 unsigned int border, oldborder; |
69 Bool isbanned, isfixed, ismax, isfloating, wasfloating; |
68 Bool isbanned, isfixed, isfloating; |
70 Bool *tags; |
69 Bool *tags; |
71 Client *next; |
70 Client *next; |
72 Client *prev; |
71 Client *prev; |
73 Client *snext; |
72 Client *snext; |
74 Window win; |
73 Window win; |
155 void killclient(const char *arg); |
154 void killclient(const char *arg); |
156 void leavenotify(XEvent *e); |
155 void leavenotify(XEvent *e); |
157 void manage(Window w, XWindowAttributes *wa); |
156 void manage(Window w, XWindowAttributes *wa); |
158 void mappingnotify(XEvent *e); |
157 void mappingnotify(XEvent *e); |
159 void maprequest(XEvent *e); |
158 void maprequest(XEvent *e); |
159 void maximize(const char *arg); |
|
160 void movemouse(Client *c); |
160 void movemouse(Client *c); |
161 Client *nexttiled(Client *c); |
161 Client *nexttiled(Client *c); |
162 void propertynotify(XEvent *e); |
162 void propertynotify(XEvent *e); |
163 void quit(const char *arg); |
163 void quit(const char *arg); |
164 void reapply(const char *arg); |
164 void reapply(const char *arg); |
176 unsigned int textnw(const char *text, unsigned int len); |
176 unsigned int textnw(const char *text, unsigned int len); |
177 unsigned int textw(const char *text); |
177 unsigned int textw(const char *text); |
178 void tile(void); |
178 void tile(void); |
179 void togglebar(const char *arg); |
179 void togglebar(const char *arg); |
180 void togglefloating(const char *arg); |
180 void togglefloating(const char *arg); |
181 void togglemax(const char *arg); |
|
182 void toggletag(const char *arg); |
181 void toggletag(const char *arg); |
183 void toggleview(const char *arg); |
182 void toggleview(const char *arg); |
184 void unban(Client *c); |
183 void unban(Client *c); |
185 void unmanage(Client *c); |
184 void unmanage(Client *c); |
186 void unmapnotify(XEvent *e); |
185 void unmapnotify(XEvent *e); |
464 Client *c; |
463 Client *c; |
465 XConfigureRequestEvent *ev = &e->xconfigurerequest; |
464 XConfigureRequestEvent *ev = &e->xconfigurerequest; |
466 XWindowChanges wc; |
465 XWindowChanges wc; |
467 |
466 |
468 if((c = getclient(ev->window))) { |
467 if((c = getclient(ev->window))) { |
469 c->ismax = False; |
|
470 if(ev->value_mask & CWBorderWidth) |
468 if(ev->value_mask & CWBorderWidth) |
471 c->border = ev->border_width; |
469 c->border = ev->border_width; |
472 if(c->isfixed || c->isfloating || (floating == layout->arrange)) { |
470 if(c->isfixed || c->isfloating || (floating == layout->arrange)) { |
473 if(ev->value_mask & CWX) |
471 if(ev->value_mask & CWX) |
474 c->x = ev->x; |
472 c->x = ev->x; |
561 drawtext(stext, dc.norm); |
559 drawtext(stext, dc.norm); |
562 if((dc.w = dc.x - x) > bh) { |
560 if((dc.w = dc.x - x) > bh) { |
563 dc.x = x; |
561 dc.x = x; |
564 if(sel) { |
562 if(sel) { |
565 drawtext(sel->name, dc.sel); |
563 drawtext(sel->name, dc.sel); |
566 drawsquare(sel->ismax, sel->isfloating, dc.sel); |
564 drawsquare(False, sel->isfloating, dc.sel); |
567 } |
565 } |
568 else |
566 else |
569 drawtext(NULL, dc.norm); |
567 drawtext(NULL, dc.norm); |
570 } |
568 } |
571 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); |
569 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); |
1077 if(!getclient(ev->window)) |
1075 if(!getclient(ev->window)) |
1078 manage(ev->window, &wa); |
1076 manage(ev->window, &wa); |
1079 } |
1077 } |
1080 |
1078 |
1081 void |
1079 void |
1080 maximize(const char *arg) { |
|
1081 if(!sel || (!sel->isfloating && layout->arrange != floating)) |
|
1082 return; |
|
1083 resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True); |
|
1084 } |
|
1085 |
|
1086 void |
|
1082 movemouse(Client *c) { |
1087 movemouse(Client *c) { |
1083 int x1, y1, ocx, ocy, di, nx, ny; |
1088 int x1, y1, ocx, ocy, di, nx, ny; |
1084 unsigned int dui; |
1089 unsigned int dui; |
1085 Window dummy; |
1090 Window dummy; |
1086 XEvent ev; |
1091 XEvent ev; |
1088 ocx = nx = c->x; |
1093 ocx = nx = c->x; |
1089 ocy = ny = c->y; |
1094 ocy = ny = c->y; |
1090 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
1095 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
1091 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
1096 None, cursor[CurMove], CurrentTime) != GrabSuccess) |
1092 return; |
1097 return; |
1093 c->ismax = False; |
|
1094 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
1098 XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui); |
1095 for(;;) { |
1099 for(;;) { |
1096 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); |
1100 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); |
1097 switch (ev.type) { |
1101 switch (ev.type) { |
1098 case ButtonRelease: |
1102 case ButtonRelease: |
1246 ocx = c->x; |
1250 ocx = c->x; |
1247 ocy = c->y; |
1251 ocy = c->y; |
1248 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
1252 if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync, |
1249 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
1253 None, cursor[CurResize], CurrentTime) != GrabSuccess) |
1250 return; |
1254 return; |
1251 c->ismax = False; |
|
1252 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); |
1255 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); |
1253 for(;;) { |
1256 for(;;) { |
1254 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev); |
1257 XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev); |
1255 switch(ev.type) { |
1258 switch(ev.type) { |
1256 case ButtonRelease: |
1259 case ButtonRelease: |
1607 |
1610 |
1608 nx = wax; |
1611 nx = wax; |
1609 ny = way; |
1612 ny = way; |
1610 nw = 0; /* gcc stupidity requires this */ |
1613 nw = 0; /* gcc stupidity requires this */ |
1611 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) { |
1614 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next), i++) { |
1612 c->ismax = False; |
|
1613 if(i == 0) { /* master */ |
1615 if(i == 0) { /* master */ |
1614 nw = mw - 2 * c->border; |
1616 nw = mw - 2 * c->border; |
1615 nh = wah - 2 * c->border; |
1617 nh = wah - 2 * c->border; |
1616 } |
1618 } |
1617 else { /* tile window */ |
1619 else { /* tile window */ |
1650 return; |
1652 return; |
1651 sel->isfloating = !sel->isfloating; |
1653 sel->isfloating = !sel->isfloating; |
1652 if(sel->isfloating) |
1654 if(sel->isfloating) |
1653 resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
1655 resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
1654 arrange(); |
1656 arrange(); |
1655 } |
|
1656 |
|
1657 void |
|
1658 togglemax(const char *arg) { |
|
1659 XEvent ev; |
|
1660 |
|
1661 if(!sel || sel->isfixed) |
|
1662 return; |
|
1663 if((sel->ismax = !sel->ismax)) { |
|
1664 if((layout->arrange == floating) || sel->isfloating) |
|
1665 sel->wasfloating = True; |
|
1666 else { |
|
1667 togglefloating(NULL); |
|
1668 sel->wasfloating = False; |
|
1669 } |
|
1670 sel->rx = sel->x; |
|
1671 sel->ry = sel->y; |
|
1672 sel->rw = sel->w; |
|
1673 sel->rh = sel->h; |
|
1674 resize(sel, wax, way, waw - 2 * sel->border, wah - 2 * sel->border, True); |
|
1675 } |
|
1676 else { |
|
1677 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True); |
|
1678 if(!sel->wasfloating) |
|
1679 togglefloating(NULL); |
|
1680 } |
|
1681 drawbar(); |
|
1682 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
|
1683 } |
1657 } |
1684 |
1658 |
1685 void |
1659 void |
1686 toggletag(const char *arg) { |
1660 toggletag(const char *arg) { |
1687 unsigned int i, j; |
1661 unsigned int i, j; |