sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-selectivefakefullscreen-20201130-97099e7.diff (5346B)


      1 From 7b7230cba4a3b886aa4239edecb86665dffcd9d8 Mon Sep 17 00:00:00 2001
      2 From: Francisco Tapia <link_1232@yahoo.com.mx>
      3 Date: Mon, 30 Nov 2020 12:43:18 -0600
      4 Subject: [PATCH] Fix for selectivefakefullscreen resize issue
      5 
      6 Fixed a problem where entering a fake full screen caused the client
      7 to resize incorrectly, resulting in a truncated window, and
      8 requiring the user to force a whole screen update, e.g. toggling
      9 on and off the bar, to correctly draw the whole window.
     10 ---
     11  config.def.h |  6 +++---
     12  dwm.c        | 30 +++++++++++++++++++++++-------
     13  2 files changed, 26 insertions(+), 10 deletions(-)
     14 
     15 diff --git a/config.def.h b/config.def.h
     16 index 1c0b587..b7a445b 100644
     17 --- a/config.def.h
     18 +++ b/config.def.h
     19 @@ -26,9 +26,9 @@ static const Rule rules[] = {
     20  	 *	WM_CLASS(STRING) = instance, class
     21  	 *	WM_NAME(STRING) = title
     22  	 */
     23 -	/* class      instance    title       tags mask     isfloating   monitor */
     24 -	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     25 -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     26 +	/* class      instance    title       tags mask     isfloating   isfakefullscreen monitor */
     27 +	{ "Gimp",     NULL,       NULL,       0,            1,           0,               -1 },
     28 +	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           1,               -1 },
     29  };
     30  
     31  /* layout(s) */
     32 diff --git a/dwm.c b/dwm.c
     33 index 664c527..a7418aa 100644
     34 --- a/dwm.c
     35 +++ b/dwm.c
     36 @@ -92,7 +92,7 @@ struct Client {
     37  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     38  	int bw, oldbw;
     39  	unsigned int tags;
     40 -	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     41 +	int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isfakefullscreen;
     42  	Client *next;
     43  	Client *snext;
     44  	Monitor *mon;
     45 @@ -138,6 +138,7 @@ typedef struct {
     46  	const char *title;
     47  	unsigned int tags;
     48  	int isfloating;
     49 +	int isfakefullscreen;
     50  	int monitor;
     51  } Rule;
     52  
     53 @@ -299,6 +300,7 @@ applyrules(Client *c)
     54  		&& (!r->instance || strstr(instance, r->instance)))
     55  		{
     56  			c->isfloating = r->isfloating;
     57 +			c->isfakefullscreen = r->isfakefullscreen;
     58  			c->tags |= r->tags;
     59  			for (m = mons; m && m->num != r->monitor; m = m->next);
     60  			if (m)
     61 @@ -522,7 +524,8 @@ clientmessage(XEvent *e)
     62  		if (cme->data.l[1] == netatom[NetWMFullscreen]
     63  		|| cme->data.l[2] == netatom[NetWMFullscreen])
     64  			setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD    */
     65 -				|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
     66 +				      || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */
     67 +                                      && (!c->isfullscreen || c->isfakefullscreen))));
     68  	} else if (cme->message_type == netatom[NetActiveWindow]) {
     69  		if (c != selmon->sel && !c->isurgent)
     70  			seturgent(c, 1);
     71 @@ -566,7 +569,8 @@ configurenotify(XEvent *e)
     72  			updatebars();
     73  			for (m = mons; m; m = m->next) {
     74  				for (c = m->clients; c; c = c->next)
     75 -					if (c->isfullscreen)
     76 +					if (c->isfullscreen
     77 +                                        &&  !c->isfakefullscreen)
     78  						resizeclient(c, m->mx, m->my, m->mw, m->mh);
     79  				XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
     80  			}
     81 @@ -1144,7 +1148,8 @@ movemouse(const Arg *arg)
     82  
     83  	if (!(c = selmon->sel))
     84  		return;
     85 -	if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
     86 +	if (c->isfullscreen
     87 +	&&  !c->isfakefullscreen) /* no support moving fullscreen windows by mouse */
     88  		return;
     89  	restack(selmon);
     90  	ocx = c->x;
     91 @@ -1299,7 +1304,8 @@ resizemouse(const Arg *arg)
     92  
     93  	if (!(c = selmon->sel))
     94  		return;
     95 -	if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
     96 +	if (c->isfullscreen
     97 +	&&  !c->isfakefullscreen) /* no support resizing fullscreen windows by mouse */
     98  		return;
     99  	restack(selmon);
    100  	ocx = c->x;
    101 @@ -1477,6 +1483,10 @@ setfullscreen(Client *c, int fullscreen)
    102  		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
    103  			PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
    104  		c->isfullscreen = 1;
    105 +		if (c->isfakefullscreen) {
    106 +			resizeclient(c, c->x, c->y, c->w, c->h);
    107 +			return;
    108 +		}
    109  		c->oldstate = c->isfloating;
    110  		c->oldbw = c->bw;
    111  		c->bw = 0;
    112 @@ -1487,6 +1497,10 @@ setfullscreen(Client *c, int fullscreen)
    113  		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
    114  			PropModeReplace, (unsigned char*)0, 0);
    115  		c->isfullscreen = 0;
    116 +		if (c->isfakefullscreen) {
    117 +			resizeclient(c, c->x, c->y, c->w, c->h);
    118 +			return;
    119 +		}
    120  		c->isfloating = c->oldstate;
    121  		c->bw = c->oldbw;
    122  		c->x = c->oldx;
    123 @@ -1619,7 +1633,8 @@ showhide(Client *c)
    124  	if (ISVISIBLE(c)) {
    125  		/* show clients top down */
    126  		XMoveWindow(dpy, c->win, c->x, c->y);
    127 -		if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
    128 +		if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
    129 +                &&  (!c->isfullscreen || c->isfakefullscreen))
    130  			resize(c, c->x, c->y, c->w, c->h, 0);
    131  		showhide(c->snext);
    132  	} else {
    133 @@ -1713,7 +1728,8 @@ togglefloating(const Arg *arg)
    134  {
    135  	if (!selmon->sel)
    136  		return;
    137 -	if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
    138 +	if (selmon->sel->isfullscreen
    139 +	&&  !selmon->sel->isfakefullscreen) /* no support for fullscreen windows */
    140  		return;
    141  	selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
    142  	if (selmon->sel->isfloating)
    143 -- 
    144 2.20.1
    145