honour fullscreen hint on map

master
Connor Lane Smith 2011-11-06 20:30:06 +01:00
parent e5a1e77351
commit d21026f0a1
1 changed files with 66 additions and 56 deletions

122
dwm.c
View File

@ -215,6 +215,7 @@ static Bool sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m); static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state); static void setclientstate(Client *c, long state);
static void setfocus(Client *c); static void setfocus(Client *c);
static void setfullscreen(Client *c, Bool fullscreen);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static void setup(void); static void setup(void);
@ -531,31 +532,10 @@ clientmessage(XEvent *e) {
if(!c) if(!c)
return; return;
if(cme->message_type == netatom[NetWMState] && cme->data.l[1] == netatom[NetWMFullscreen]) { if(cme->message_type == netatom[NetWMState]) {
if(cme->data.l[0] && !c->isfullscreen) { if(cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen])
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32, setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
c->isfullscreen = True;
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
c->isfloating = True;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
else {
XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfullscreen = False;
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
c->y = c->oldy;
c->w = c->oldw;
c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
}
} }
else if(cme->message_type == netatom[NetActiveWindow]) { else if(cme->message_type == netatom[NetActiveWindow]) {
if(!ISVISIBLE(c)) { if(!ISVISIBLE(c)) {
@ -928,6 +908,21 @@ focusstack(const Arg *arg) {
} }
} }
Atom
getatomprop(Client *c, Atom prop) {
int di;
unsigned long dl;
unsigned char *p = NULL;
Atom da, atom = None;
if(XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
&da, &di, &dl, &dl, &p) == Success && p) {
atom = *(Atom *)p;
XFree(p);
}
return atom;
}
unsigned long unsigned long
getcolor(const char *colstr) { getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen); Colormap cmap = DefaultColormap(dpy, screen);
@ -1133,23 +1128,17 @@ manage(Window w, XWindowAttributes *wa) {
c->w = c->oldw = wa->width; c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height; c->h = c->oldh = wa->height;
c->oldbw = wa->border_width; c->oldbw = wa->border_width;
if(c->w == c->mon->mw && c->h == c->mon->mh) {
c->isfloating = True; // regression with flash, XXXX if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
c->x = c->mon->mx; c->x = c->mon->mx + c->mon->mw - WIDTH(c);
c->y = c->mon->my; if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
c->bw = 0; c->y = c->mon->my + c->mon->mh - HEIGHT(c);
} c->x = MAX(c->x, c->mon->mx);
else { /* only fix client y-offset, if the client center might cover the bar */
if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw) c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
c->x = c->mon->mx + c->mon->mw - WIDTH(c); && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh) c->bw = borderpx;
c->y = c->mon->my + c->mon->mh - HEIGHT(c);
c->x = MAX(c->x, c->mon->mx);
/* only fix client y-offset, if the client center might cover the bar */
c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
&& (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
c->bw = borderpx;
}
wc.border_width = c->bw; wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc); XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, dc.norm[ColBorder]); XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
@ -1515,6 +1504,34 @@ setfocus(Client *c) {
sendevent(c, wmatom[WMTakeFocus]); sendevent(c, wmatom[WMTakeFocus]);
} }
void
setfullscreen(Client *c, Bool fullscreen) {
if(fullscreen) {
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
c->isfullscreen = True;
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
c->isfloating = True;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
else {
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfullscreen = False;
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
c->y = c->oldy;
c->w = c->oldw;
c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
}
}
void void
setlayout(const Arg *arg) { setlayout(const Arg *arg) {
if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
@ -1974,22 +1991,15 @@ updatestatus(void) {
} }
void void
updatewindowtype(Client *c) updatewindowtype(Client *c) {
{ Atom state = getatomprop(c, netatom[NetWMState]);
Atom wtype, real; Atom wtype = getatomprop(c, netatom[NetWMWindowType]);
int format;
unsigned long n, extra;
unsigned char *p = NULL;
if(XGetWindowProperty(dpy, c->win, netatom[NetWMWindowType], 0L, if(state == netatom[NetWMFullscreen])
sizeof(Atom), False, XA_ATOM, &real, &format, setfullscreen(c, True);
&n, &extra, (unsigned char **)&p) == Success && p) {
wtype = *(Atom *)p;
XFree(p);
if(wtype == netatom[NetWMWindowTypeDialog]) if(wtype == netatom[NetWMWindowTypeDialog])
c->isfloating = True; c->isfloating = True;
}
} }
void void