From 87d87cc4041a997d00ebf234ca5118b9248a3b95 Mon Sep 17 00:00:00 2001
From: krypek <115574014+krypciak@users.noreply.github.com>
Date: Wed, 23 Nov 2022 22:56:52 +0100
Subject: Fix comparison between signed and unsigned int

When c->bw is 0, the right side of the MAX functions gets turned into an unsigned integer and that results in -1 being the outcome.
This causes big issues in xwayland clients.
---
 dwl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dwl.c b/dwl.c
index b884d06..fc6c4da 100644
--- a/dwl.c
+++ b/dwl.c
@@ -389,8 +389,8 @@ applybounds(Client *c, struct wlr_box *bbox)
 		struct wlr_box min = {0}, max = {0};
 		client_get_size_hints(c, &max, &min);
 		/* try to set size hints */
-		c->geom.width = MAX(min.width + (2 * c->bw), c->geom.width);
-		c->geom.height = MAX(min.height + (2 * c->bw), c->geom.height);
+		c->geom.width = MAX(min.width + (2 * (int)c->bw), c->geom.width);
+		c->geom.height = MAX(min.height + (2 * (int)c->bw), c->geom.height);
 		/* Some clients set them max size to INT_MAX, which does not violates
 		 * the protocol but its innecesary, they can set them max size to zero. */
 		if (max.width > 0 && !(2 * c->bw > INT_MAX - max.width)) /* Checks for overflow */
-- 
cgit v1.2.3


From 3213088aa23e1f6cad1a5ba506dfb7318e1011c9 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Wed, 30 Nov 2022 17:42:58 -0600
Subject: do not try to set the parent's same tags and monitor for xwayland
 clients

References: https://github.com/djpohly/dwl/pull/334#issuecomment-1330166324
---
 dwl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dwl.c b/dwl.c
index c1ff934..fd22c8f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1381,7 +1381,8 @@ mapnotify(struct wl_listener *listener, void *data)
 	 * we always consider floating, clients that have parent and thus
 	 * we set the same tags and monitor than its parent, if not
 	 * try to apply rules for them */
-	if ((p = client_get_parent(c))) {
+	 /* TODO: https://github.com/djpohly/dwl/pull/334#issuecomment-1330166324 */
+	if (c->type == XDGShell && (p = client_get_parent(c))) {
 		c->isfloating = 1;
 		wlr_scene_node_reparent(&c->scene->node, layers[LyrFloat]);
 		setmon(c, p->mon, p->tags);
-- 
cgit v1.2.3


From c91d21b68f436bc61dfce8b3f47beb5855bdd1a2 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Fri, 25 Nov 2022 12:15:55 -0600
Subject: do not move/resize if grabbed client is fullscreen

---
 dwl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dwl.c b/dwl.c
index fd22c8f..4648890 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1510,7 +1510,7 @@ moveresize(const Arg *arg)
 	if (cursor_mode != CurNormal && cursor_mode != CurPressed)
 		return;
 	xytonode(cursor->x, cursor->y, NULL, &grabc, NULL, NULL, NULL);
-	if (!grabc || client_is_unmanaged(grabc))
+	if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
 		return;
 
 	/* Float the window and tell motionnotify to grab it */
-- 
cgit v1.2.3


From 10c56d63489506ee852f3ec18f078e60ba1885f0 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Wed, 30 Nov 2022 18:51:35 -0600
Subject: add option to allow invisible surfaces to disable idle tracking

---
 config.def.h | 13 +++++++------
 dwl.c        |  5 +++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/config.def.h b/config.def.h
index 0473b40..8f01192 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,11 +1,12 @@
 /* appearance */
-static const int sloppyfocus        = 1;  /* focus follows mouse */
-static const unsigned int borderpx  = 1;  /* border pixel of windows */
-static const float rootcolor[]      = {0.3, 0.3, 0.3, 1.0};
-static const float bordercolor[]    = {0.5, 0.5, 0.5, 1.0};
-static const float focuscolor[]     = {1.0, 0.0, 0.0, 1.0};
+static const int sloppyfocus               = 1;  /* focus follows mouse */
+static const int bypass_surface_visibility = 0;  /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible  */
+static const unsigned int borderpx         = 1;  /* border pixel of windows */
+static const float rootcolor[]             = {0.3, 0.3, 0.3, 1.0};
+static const float bordercolor[]           = {0.5, 0.5, 0.5, 1.0};
+static const float focuscolor[]            = {1.0, 0.0, 0.0, 1.0};
 /* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
-static const float fullscreen_bg[]  = {0.1, 0.1, 0.1, 1.0};
+static const float fullscreen_bg[]         = {0.1, 0.1, 0.1, 1.0};
 
 /* tagging */
 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
diff --git a/dwl.c b/dwl.c
index 4648890..f07a867 100644
--- a/dwl.c
+++ b/dwl.c
@@ -597,8 +597,9 @@ checkidleinhibitor(struct wlr_surface *exclude)
 	struct wlr_scene_tree *tree;
 	struct wlr_idle_inhibitor_v1 *inhibitor;
 	wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
-		if (exclude != inhibitor->surface && (tree = inhibitor->surface->data)
-				&& tree->node.enabled) {
+		if (bypass_surface_visibility || (exclude != inhibitor->surface
+				&& (tree = inhibitor->surface->data)
+				&& tree->node.enabled)) {
 			inhibited = 1;
 			break;
 		}
-- 
cgit v1.2.3


From 6df6781b437937e835d8caca14024829747bd2ab Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Wed, 30 Nov 2022 18:54:54 -0600
Subject: simplify check for surface's node state

all `struct wlr_surface` should have a `wlr_scene_tree *` as data
---
 dwl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/dwl.c b/dwl.c
index f07a867..3f6db50 100644
--- a/dwl.c
+++ b/dwl.c
@@ -594,11 +594,10 @@ void
 checkidleinhibitor(struct wlr_surface *exclude)
 {
 	int inhibited = 0;
-	struct wlr_scene_tree *tree;
 	struct wlr_idle_inhibitor_v1 *inhibitor;
 	wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
+		struct wlr_scene_tree *tree = inhibitor->surface->data;
 		if (bypass_surface_visibility || (exclude != inhibitor->surface
-				&& (tree = inhibitor->surface->data)
 				&& tree->node.enabled)) {
 			inhibited = 1;
 			break;
-- 
cgit v1.2.3


From b4fb1f77c768fb7bd568d3cc67c59dcfdb7cae28 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Thu, 1 Dec 2022 20:49:49 -0600
Subject: fix xwayland clients being floating by default

Fix 3213088aa23e1f6cad1a5ba506dfb7318e1011c9
References: https://github.com/djpohly/dwl/pull/334#issuecomment-1333147730
---
 client.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/client.h b/client.h
index 3c81135..c18d01a 100644
--- a/client.h
+++ b/client.h
@@ -184,8 +184,7 @@ client_is_float_type(Client *c)
 	}
 #endif
 	return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
-		&& (min.width == max.width || min.height == max.height))
-		|| client_get_parent(c);
+		&& (min.width == max.width || min.height == max.height));
 }
 
 static inline int
-- 
cgit v1.2.3


From f929eaef1e15c2624de20cdcb0e348e6cab21152 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Fri, 2 Dec 2022 10:07:24 -0600
Subject: ask for version instead of commit in bug reports

---
 .github/ISSUE_TEMPLATE/bug_report.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 64e2054..6b60803 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -8,7 +8,7 @@ assignees: ''
 ---
 
 ## Info
-dwl's commit:
+dwl version:
 wlroots version:
 ## Description
 <!--
-- 
cgit v1.2.3


From eaf8a216037e6eb60170a24fe7c02b615a20aa72 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Fri, 11 Nov 2022 23:27:58 -0600
Subject: unset fullscreen when mapping a client in the same monitor

Fixes: https://github.com/djpohly/dwl/issues/327
---
 dwl.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/dwl.c b/dwl.c
index 179c1b6..5f6d061 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1329,7 +1329,8 @@ void
 mapnotify(struct wl_listener *listener, void *data)
 {
 	/* Called when the surface is mapped, or ready to display on-screen. */
-	Client *p, *c = wl_container_of(listener, c, map);
+	Client *p, *w, *c = wl_container_of(listener, c, map);
+	Monitor *m;
 	int i;
 
 	/* Create scene tree for this client and its border */
@@ -1357,7 +1358,7 @@ mapnotify(struct wl_listener *listener, void *data)
 			focusclient(c, 1);
 			exclusive_focus = c;
 		}
-		return;
+		goto unset_fullscreen;
 	}
 #endif
 
@@ -1392,6 +1393,12 @@ mapnotify(struct wl_listener *listener, void *data)
 	printstatus();
 
 	c->mon->un_map = 1;
+
+unset_fullscreen:
+	m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
+	wl_list_for_each(w, &clients, link)
+		if (w != c && w->isfullscreen && VISIBLEON(w, m))
+			setfullscreen(w, 0);
 }
 
 void
@@ -2501,10 +2508,6 @@ createnotifyx11(struct wl_listener *listener, void *data)
 {
 	struct wlr_xwayland_surface *xsurface = data;
 	Client *c;
-	/* TODO: why we unset fullscreen when a xwayland client is created? */
-	wl_list_for_each(c, &clients, link)
-		if (c->isfullscreen && VISIBLEON(c, c->mon))
-			setfullscreen(c, 0);
 
 	/* Allocate a Client for this surface */
 	c = xsurface->data = ecalloc(1, sizeof(*c));
-- 
cgit v1.2.3


From 4c6050331e4e9e03a43afb365263e3c48b50b294 Mon Sep 17 00:00:00 2001
From: Leonardo Hernández Hernández <leohdz172@protonmail.com>
Date: Fri, 2 Dec 2022 10:12:16 -0600
Subject: bump version to 0.4-rc1

---
 config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config.mk b/config.mk
index 3e21cc1..c2dd026 100644
--- a/config.mk
+++ b/config.mk
@@ -1,4 +1,4 @@
-_VERSION = 0.3.1-dev
+_VERSION = 0.4-rc1
 VERSION  = `git describe --long --tags --dirty 2>/dev/null || echo $(_VERSION)`
 
 PKG_CONFIG = pkg-config
-- 
cgit v1.2.3