diff options
| -rw-r--r-- | dwm.c | 122 |
1 files changed, 66 insertions, 56 deletions
| @@ -215,6 +215,7 @@ static Bool sendevent(Client *c, Atom proto); | |||
| 215 | static void sendmon(Client *c, Monitor *m); | 215 | static void sendmon(Client *c, Monitor *m); |
| 216 | static void setclientstate(Client *c, long state); | 216 | static void setclientstate(Client *c, long state); |
| 217 | static void setfocus(Client *c); | 217 | static void setfocus(Client *c); |
| 218 | static void setfullscreen(Client *c, Bool fullscreen); | ||
| 218 | static void setlayout(const Arg *arg); | 219 | static void setlayout(const Arg *arg); |
| 219 | static void setmfact(const Arg *arg); | 220 | static void setmfact(const Arg *arg); |
| 220 | static void setup(void); | 221 | static void setup(void); |
| @@ -531,31 +532,10 @@ clientmessage(XEvent *e) { | |||
| 531 | 532 | ||
| 532 | if(!c) | 533 | if(!c) |
| 533 | return; | 534 | return; |
| 534 | if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { | 535 | if(cme->message_type == netatom[NetWMState]) { |
| 535 | if(cme->data.l[0] && !c->isfullscreen) { | 536 | if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) |
| 536 | XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, | 537 | setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ |
| 537 | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); | 538 | || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); |
| 538 | c->isfullscreen = True; | ||
| 539 | c->oldstate = c->isfloating; | ||
| 540 | c->oldbw = c->bw; | ||
| 541 | c->bw = 0; | ||
| 542 | c->isfloating = True; | ||
| 543 | resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); | ||
| 544 | XRaiseWindow(dpy, c->win); | ||
| 545 | } | ||
| 546 | else { | ||
| 547 | XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, | ||
| 548 | PropModeReplace, (unsigned char*)0, 0); | ||
| 549 | c->isfullscreen = False; | ||
| 550 | c->isfloating = c->oldstate; | ||
| 551 | c->bw = c->oldbw; | ||
| 552 | c->x = c->oldx; | ||
| 553 | c->y = c->oldy; | ||
| 554 | c->w = c->oldw; | ||
| 555 | c->h = c->oldh; | ||
| 556 | resizeclient(c, c->x, c->y, c->w, c->h); | ||
| 557 | arrange(c->mon); | ||
| 558 | } | ||
| 559 | } | 539 | } |
| 560 | else if(cme->message_type == netatom[NetActiveWindow]) { | 540 | else if(cme->message_type == netatom[NetActiveWindow]) { |
| 561 | if(!ISVISIBLE(c)) { | 541 | if(!ISVISIBLE(c)) { |
| @@ -928,6 +908,21 @@ focusstack(const Arg *arg) { | |||
| 928 | } | 908 | } |
| 929 | } | 909 | } |
| 930 | 910 | ||
| 911 | Atom | ||
| 912 | getatomprop(Client *c, Atom prop) { | ||
| 913 | int di; | ||
| 914 | unsigned long dl; | ||
| 915 | unsigned char *p = NULL; | ||
| 916 | Atom da, atom = None; | ||
| 917 | |||
| 918 | if(XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM, | ||
| 919 | &da, &di, &dl, &dl, &p) == Success && p) { | ||
| 920 | atom = *(Atom *)p; | ||
| 921 | XFree(p); | ||
| 922 | } | ||
| 923 | return atom; | ||
| 924 | } | ||
| 925 | |||
| 931 | unsigned long | 926 | unsigned long |
| 932 | getcolor(const char *colstr) { | 927 | getcolor(const char *colstr) { |
| 933 | Colormap cmap = DefaultColormap(dpy, screen); | 928 | Colormap cmap = DefaultColormap(dpy, screen); |
| @@ -1133,23 +1128,17 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1133 | c->w = c->oldw = wa->width; | 1128 | c->w = c->oldw = wa->width; |
| 1134 | c->h = c->oldh = wa->height; | 1129 | c->h = c->oldh = wa->height; |
| 1135 | c->oldbw = wa->border_width; | 1130 | c->oldbw = wa->border_width; |
| 1136 | if(c->w == c->mon->mw && c->h == c->mon->mh) { | 1131 | |
| 1137 | c->isfloating = True; // regression with flash, XXXX | 1132 | if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) |
| 1138 | c->x = c->mon->mx; | 1133 | c->x = c->mon->mx + c->mon->mw - WIDTH(c); |
| 1139 | c->y = c->mon->my; | 1134 | if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) |
| 1140 | c->bw = 0; | 1135 | c->y = c->mon->my + c->mon->mh - HEIGHT(c); |
| 1141 | } | 1136 | c->x = MAX(c->x, c->mon->mx); |
| 1142 | else { | 1137 | /* only fix client y-offset, if the client center might cover the bar */ |
| 1143 | if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) | 1138 | c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) |
| 1144 | c->x = c->mon->mx + c->mon->mw - WIDTH(c); | 1139 | && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); |
| 1145 | if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) | 1140 | c->bw = borderpx; |
| 1146 | c->y = c->mon->my + c->mon->mh - HEIGHT(c); | 1141 | |
| 1147 | c->x = MAX(c->x, c->mon->mx); | ||
| 1148 | /* only fix client y-offset, if the client center might cover the bar */ | ||
| 1149 | c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) | ||
| 1150 | && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); | ||
| 1151 | c->bw = borderpx; | ||
| 1152 | } | ||
| 1153 | wc.border_width = c->bw; | 1142 | wc.border_width = c->bw; |
| 1154 | XConfigureWindow(dpy, w, CWBorderWidth, &wc); | 1143 | XConfigureWindow(dpy, w, CWBorderWidth, &wc); |
| 1155 | XSetWindowBorder(dpy, w, dc.norm[ColBorder]); | 1144 | XSetWindowBorder(dpy, w, dc.norm[ColBorder]); |
| @@ -1516,6 +1505,34 @@ setfocus(Client *c) { | |||
| 1516 | } | 1505 | } |
| 1517 | 1506 | ||
| 1518 | void | 1507 | void |
| 1508 | setfullscreen(Client *c, Bool fullscreen) { | ||
| 1509 | if(fullscreen) { | ||
| 1510 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, | ||
| 1511 | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); | ||
| 1512 | c->isfullscreen = True; | ||
| 1513 | c->oldstate = c->isfloating; | ||
| 1514 | c->oldbw = c->bw; | ||
| 1515 | c->bw = 0; | ||
| 1516 | c->isfloating = True; | ||
| 1517 | resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); | ||
| 1518 | XRaiseWindow(dpy, c->win); | ||
| 1519 | } | ||
| 1520 | else { | ||
| 1521 | XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, | ||
| 1522 | PropModeReplace, (unsigned char*)0, 0); | ||
| 1523 | c->isfullscreen = False; | ||
| 1524 | c->isfloating = c->oldstate; | ||
| 1525 | c->bw = c->oldbw; | ||
| 1526 | c->x = c->oldx; | ||
| 1527 | c->y = c->oldy; | ||
| 1528 | c->w = c->oldw; | ||
| 1529 | c->h = c->oldh; | ||
| 1530 | resizeclient(c, c->x, c->y, c->w, c->h); | ||
| 1531 | arrange(c->mon); | ||
| 1532 | } | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | void | ||
| 1519 | setlayout(const Arg *arg) { | 1536 | setlayout(const Arg *arg) { |
| 1520 | if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) | 1537 | if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) |
| 1521 | selmon->sellt ^= 1; | 1538 | selmon->sellt ^= 1; |
| @@ -1974,22 +1991,15 @@ updatestatus(void) { | |||
| 1974 | } | 1991 | } |
| 1975 | 1992 | ||
| 1976 | void | 1993 | void |
| 1977 | updatewindowtype(Client *c) | 1994 | updatewindowtype(Client *c) { |
| 1978 | { | 1995 | Atom state = getatomprop(c, netatom[NetWMState]); |
| 1979 | Atom wtype, real; | 1996 | Atom wtype = getatomprop(c, netatom[NetWMWindowType]); |
| 1980 | int format; | ||
| 1981 | unsigned long n, extra; | ||
| 1982 | unsigned char *p = NULL; | ||
| 1983 | 1997 | ||
| 1984 | if(XGetWindowProperty(dpy, c->win, netatom[NetWMWindowType], 0L, | 1998 | if(state == netatom[NetWMFullscreen]) |
| 1985 | sizeof(Atom), False, XA_ATOM, &real, &format, | 1999 | setfullscreen(c, True); |
| 1986 | &n, &extra, (unsigned char **)&p) == Success && p) { | ||
| 1987 | wtype = *(Atom *)p; | ||
| 1988 | XFree(p); | ||
| 1989 | 2000 | ||
| 1990 | if(wtype == netatom[NetWMWindowTypeDialog]) | 2001 | if(wtype == netatom[NetWMWindowTypeDialog]) |
| 1991 | c->isfloating = True; | 2002 | c->isfloating = True; |
| 1992 | } | ||
| 1993 | } | 2003 | } |
| 1994 | 2004 | ||
| 1995 | void | 2005 | void |
