[hackers] [dwm] setfullscreen: don't process the property twice

From: Quentin Rameau <quinq+hackers_AT_fifth.space>
Date: Mon, 2 Nov 2015 19:32:24 +0100

Some clients try to set _NET_WM_STATE_FULLSCREEN even when the window is
already in fullscreen.
We must check that it's not the case before processing it.
---
 dwm.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/dwm.c b/dwm.c
index 96b43f7..2bb654b 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -1442,17 +1442,19 @@ setfocus(Client *c) {
 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);
+		if(!c->isfullscreen) {
+			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 {
+	else if(c->isfullscreen) {
 		XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
 		                PropModeReplace, (unsigned char*)0, 0);
 		c->isfullscreen = False;
-- 
2.6.2
Received on Mon Nov 02 2015 - 19:32:24 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 02 2015 - 19:36:11 CET