honour fullscreen hint on map
d21026f0
1 file(s) · +66 −56
| 215 | 215 | static void sendmon(Client *c, Monitor *m); |
|
| 216 | 216 | static void setclientstate(Client *c, long state); |
|
| 217 | 217 | static void setfocus(Client *c); |
|
| 218 | + | static void setfullscreen(Client *c, Bool fullscreen); |
|
| 218 | 219 | static void setlayout(const Arg *arg); |
|
| 219 | 220 | static void setmfact(const Arg *arg); |
|
| 220 | 221 | static void setup(void); |
|
| 531 | 532 | ||
| 532 | 533 | if(!c) |
|
| 533 | 534 | return; |
|
| 534 | - | if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { |
|
| 535 | - | if(cme->data.l[0] && !c->isfullscreen) { |
|
| 536 | - | XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, |
|
| 537 | - | PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); |
|
| 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 | - | } |
|
| 535 | + | if(cme->message_type == netatom[NetWMState]) { |
|
| 536 | + | if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) |
|
| 537 | + | setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ |
|
| 538 | + | || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); |
|
| 559 | 539 | } |
|
| 560 | 540 | else if(cme->message_type == netatom[NetActiveWindow]) { |
|
| 561 | 541 | if(!ISVISIBLE(c)) { |
|
| 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 | 926 | unsigned long |
|
| 932 | 927 | getcolor(const char *colstr) { |
|
| 933 | 928 | Colormap cmap = DefaultColormap(dpy, screen); |
|
| 1133 | 1128 | c->w = c->oldw = wa->width; |
|
| 1134 | 1129 | c->h = c->oldh = wa->height; |
|
| 1135 | 1130 | c->oldbw = wa->border_width; |
|
| 1136 | - | if(c->w == c->mon->mw && c->h == c->mon->mh) { |
|
| 1137 | - | c->isfloating = True; // regression with flash, XXXX |
|
| 1138 | - | c->x = c->mon->mx; |
|
| 1139 | - | c->y = c->mon->my; |
|
| 1140 | - | c->bw = 0; |
|
| 1141 | - | } |
|
| 1142 | - | else { |
|
| 1143 | - | if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) |
|
| 1144 | - | c->x = c->mon->mx + c->mon->mw - WIDTH(c); |
|
| 1145 | - | if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) |
|
| 1146 | - | c->y = c->mon->my + c->mon->mh - HEIGHT(c); |
|
| 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 | - | } |
|
| 1131 | + | ||
| 1132 | + | if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) |
|
| 1133 | + | c->x = c->mon->mx + c->mon->mw - WIDTH(c); |
|
| 1134 | + | if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) |
|
| 1135 | + | c->y = c->mon->my + c->mon->mh - HEIGHT(c); |
|
| 1136 | + | c->x = MAX(c->x, c->mon->mx); |
|
| 1137 | + | /* only fix client y-offset, if the client center might cover the bar */ |
|
| 1138 | + | c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) |
|
| 1139 | + | && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); |
|
| 1140 | + | c->bw = borderpx; |
|
| 1141 | + | ||
| 1153 | 1142 | wc.border_width = c->bw; |
|
| 1154 | 1143 | XConfigureWindow(dpy, w, CWBorderWidth, &wc); |
|
| 1155 | 1144 | XSetWindowBorder(dpy, w, dc.norm[ColBorder]); |
|
| 1513 | 1502 | if(!c->neverfocus) |
|
| 1514 | 1503 | XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); |
|
| 1515 | 1504 | sendevent(c, wmatom[WMTakeFocus]); |
|
| 1505 | + | } |
|
| 1506 | + | ||
| 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 | + | } |
|
| 1516 | 1533 | } |
|
| 1517 | 1534 | ||
| 1518 | 1535 | void |
|
| 1974 | 1991 | } |
|
| 1975 | 1992 | ||
| 1976 | 1993 | void |
|
| 1977 | - | updatewindowtype(Client *c) |
|
| 1978 | - | { |
|
| 1979 | - | Atom wtype, real; |
|
| 1980 | - | int format; |
|
| 1981 | - | unsigned long n, extra; |
|
| 1982 | - | unsigned char *p = NULL; |
|
| 1994 | + | updatewindowtype(Client *c) { |
|
| 1995 | + | Atom state = getatomprop(c, netatom[NetWMState]); |
|
| 1996 | + | Atom wtype = getatomprop(c, netatom[NetWMWindowType]); |
|
| 1983 | 1997 | ||
| 1984 | - | if(XGetWindowProperty(dpy, c->win, netatom[NetWMWindowType], 0L, |
|
| 1985 | - | sizeof(Atom), False, XA_ATOM, &real, &format, |
|
| 1986 | - | &n, &extra, (unsigned char **)&p) == Success && p) { |
|
| 1987 | - | wtype = *(Atom *)p; |
|
| 1988 | - | XFree(p); |
|
| 1998 | + | if(state == netatom[NetWMFullscreen]) |
|
| 1999 | + | setfullscreen(c, True); |
|
| 1989 | 2000 | ||
| 1990 | - | if(wtype == netatom[NetWMWindowTypeDialog]) |
|
| 1991 | - | c->isfloating = True; |
|
| 1992 | - | } |
|
| 2001 | + | if(wtype == netatom[NetWMWindowTypeDialog]) |
|
| 2002 | + | c->isfloating = True; |
|
| 1993 | 2003 | } |
|
| 1994 | 2004 | ||
| 1995 | 2005 | void |
|