From: Daniel Liu Date: Sun, 4 Oct 2020 16:24:47 +0000 (-0400) Subject: fakefullscreen X-Git-Url: https://git.danieliu.xyz/?p=dwm.git;a=commitdiff_plain;h=3b2a636ee4293351041fd5772ac85b1337e2bc0d;hp=-c fakefullscreen --- 3b2a636ee4293351041fd5772ac85b1337e2bc0d diff --combined dwm.c index 04742a3,32ce5e4..c497f8c --- a/dwm.c +++ b/dwm.c @@@ -113,7 -113,6 +113,7 @@@ typedef struct void (*arrange)(Monitor *); } Layout; +typedef struct Pertag Pertag; struct Monitor { char ltsymbol[16]; float mfact; @@@ -134,7 -133,6 +134,7 @@@ Monitor *next; Window barwin; const Layout *lt[2]; + Pertag *pertag; }; typedef struct { @@@ -300,15 -298,6 +300,15 @@@ static Window root, wmcheckwin /* configuration, allows nested code to access above variables */ #include "config.h" +struct Pertag { + unsigned int curtag, prevtag; /* current and previous tag */ + int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */ + float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ + unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ + const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ + int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ +}; + /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@@ -559,7 -548,7 +559,7 @@@ clientmessage(XEvent *e if (cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ - || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); + || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */)); } else if (cme->message_type == netatom[NetActiveWindow]) { if (c != selmon->sel && !c->isurgent) seturgent(c, 1); @@@ -589,7 -578,6 +589,6 @@@ voi configurenotify(XEvent *e) { Monitor *m; - Client *c; XConfigureEvent *ev = &e->xconfigure; int dirty; @@@ -602,9 -590,6 +601,6 @@@ drw_resize(drw, sw, bh); updatebars(); for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) - if (c->isfullscreen) - resizeclient(c, m->mx, m->my, m->mw, m->mh); XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh); } focus(NULL); @@@ -669,7 -654,6 +665,7 @@@ Monitor createmon(void) { Monitor *m; + unsigned int i; m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; @@@ -681,20 -665,6 +677,20 @@@ m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + m->pertag = ecalloc(1, sizeof(Pertag)); + m->pertag->curtag = m->pertag->prevtag = 1; + + for (i = 0; i <= LENGTH(tags); i++) { + m->pertag->nmasters[i] = m->nmaster; + m->pertag->mfacts[i] = m->mfact; + + m->pertag->ltidxs[i][0] = m->lt[0]; + m->pertag->ltidxs[i][1] = m->lt[1]; + m->pertag->sellts[i] = m->sellt; + + m->pertag->showbars[i] = m->showbar; + } + return m; } @@@ -1020,16 -990,7 +1016,16 @@@ grabkeys(void void incnmaster(const Arg *arg) { + unsigned int i; selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); + for(i=0; itagset[selmon->seltags] & 1<pertag->nmasters[i+1] = selmon->nmaster; + + if(selmon->pertag->curtag == 0) + { + selmon->pertag->nmasters[0] = selmon->nmaster; + } arrange(selmon); } @@@ -1206,8 -1167,6 +1202,6 @@@ movemouse(const Arg *arg if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@@ -1361,8 -1320,6 +1355,6 @@@ resizemouse(const Arg *arg if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@@ -1616,24 -1573,10 +1608,10 @@@ setfullscreen(Client *c, int fullscreen XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); c->isfullscreen = 1; - c->oldstate = c->isfloating; - c->oldbw = c->bw; - c->bw = 0; - c->isfloating = 1; - resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); - XRaiseWindow(dpy, c->win); } else if (!fullscreen && c->isfullscreen){ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)0, 0); c->isfullscreen = 0; - 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); } } @@@ -1650,26 -1593,11 +1628,26 @@@ setgaps(const Arg *arg void setlayout(const Arg *arg) { + unsigned int i; if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) selmon->sellt ^= 1; if (arg && arg->v) selmon->lt[selmon->sellt] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); + + for(i=0; itagset[selmon->seltags] & 1<pertag->ltidxs[i+1][selmon->sellt] = selmon->lt[selmon->sellt]; + selmon->pertag->sellts[i+1] = selmon->sellt; + } + + if(selmon->pertag->curtag == 0) + { + selmon->pertag->ltidxs[0][selmon->sellt] = selmon->lt[selmon->sellt]; + selmon->pertag->sellts[0] = selmon->sellt; + } + if (selmon->sel) arrange(selmon); else @@@ -1681,24 -1609,13 +1659,24 @@@ voi setmfact(const Arg *arg) { float f; + unsigned int i; if (!arg || !selmon->lt[selmon->sellt]->arrange) return; f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; + if (arg->f == 0.0) + f = mfact; if (f < 0.05 || f > 0.95) return; selmon->mfact = f; + for(i=0; itagset[selmon->seltags] & 1<pertag->mfacts[i+1] = f; + + if(selmon->pertag->curtag == 0) + { + selmon->pertag->mfacts[0] = f; + } arrange(selmon); } @@@ -1798,7 -1715,7 +1776,7 @@@ showhide(Client *c if (ISVISIBLE(c)) { /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); - if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) + if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, 0); showhide(c->snext); } else { @@@ -1881,16 -1798,7 +1859,16 @@@ tile(Monitor *m void togglebar(const Arg *arg) { + unsigned int i; selmon->showbar = !selmon->showbar; + for(i=0; itagset[selmon->seltags] & 1<pertag->showbars[i+1] = selmon->showbar; + + if(selmon->pertag->curtag == 0) + { + selmon->pertag->showbars[0] = selmon->showbar; + } updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); arrange(selmon); @@@ -1901,8 -1809,6 +1879,6 @@@ togglefloating(const Arg *arg { if (!selmon->sel) return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ - return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, @@@ -1929,33 -1835,9 +1905,33 @@@ voi toggleview(const Arg *arg) { unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); + int i; if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; + + if (newtagset == ~0) { + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = 0; + } + + /* test if the user did not select the same tag */ + if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) { + selmon->pertag->prevtag = selmon->pertag->curtag; + for (i = 0; !(newtagset & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + + /* apply settings for this view */ + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); + focus(NULL); arrange(selmon); } @@@ -2250,37 -2132,11 +2226,37 @@@ updatewmhints(Client *c void view(const Arg *arg) { + int i; + unsigned int tmptag; + if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if (arg->ui & TAGMASK) + if (arg->ui & TAGMASK) { selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->pertag->prevtag = selmon->pertag->curtag; + + if (arg->ui == ~0) + selmon->pertag->curtag = 0; + else { + for (i = 0; !(arg->ui & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + } else { + tmptag = selmon->pertag->prevtag; + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = tmptag; + } + + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); + focus(NULL); arrange(selmon); }