aboutsummaryrefslogtreecommitdiff
path: root/xfce-plugins.diff
blob: c789dafa29ae5fb7e66488059b592c595bc1f3cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
From 4e33fe0d465fb24f6b42d4a1fb63d4d7902f1986 Mon Sep 17 00:00:00 2001
From: Gunther Klessinger <gunther.klessinger@axiros.com>
Date: Thu, 1 Jul 2021 09:19:07 +0200
Subject: [PATCH] Supporting xfce4-panel in dwm

We treat the panel as special window which
- never has borders
- never has focus
- always has y=0
- is never shown as active window in the indicators
- is shown on all tags (via config rule)
- is ignored on focusstack (MOD+j, MOD+k)

Which window? "xfce4-panel" - configurable in config.h
---
 config.def.h |  2 ++
 dwm.c        | 28 +++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/config.def.h b/config.def.h
index 1c0b587..3b9e7d6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,6 +3,7 @@
 /* appearance */
 static const unsigned int borderpx  = 1;        /* border pixel of windows */
 static const unsigned int snap      = 32;       /* snap pixel */
+static const char panel[][20]       = { "xfce4-panel", "Xfce4-panel" }; /* name & cls of panel win */
 static const int showbar            = 1;        /* 0 means no bar */
 static const int topbar             = 1;        /* 0 means bottom bar */
 static const char *fonts[]          = { "monospace:size=10" };


 /* layout(s) */
diff --git a/dwm.c b/dwm.c
index b0b3466..956d402 100644
--- a/dwm.c
+++ b/dwm.c
@@ -175,6 +175,7 @@ static long getstate(Window w);
 static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
 static void grabbuttons(Client *c, int focused);
 static void grabkeys(void);
+static int ispanel(Client *c);
 static void incnmaster(const Arg *arg);
 static void keypress(XEvent *e);
 static void killclient(const Arg *arg);
@@ -710,6 +711,8 @@ drawbar(Monitor *m)
	}
 
	for (c = m->clients; c; c = c->next) {
+        // prevent showing the panel as active application:
+        if (ispanel(c)) continue;
		occ |= c->tags;
		if (c->isurgent)
			urg |= c->tags;
@@ -793,11 +796,14 @@ focus(Client *c)
			selmon = c->mon;
		if (c->isurgent)
			seturgent(c, 0);
-		detachstack(c);
-		attachstack(c);
-		grabbuttons(c, 1);
-		XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
-		setfocus(c);
+        // prevents the panel getting focus when tag switching:
+		if (!ispanel(c)) {
+            detachstack(c);
+            attachstack(c);
+            grabbuttons(c, 1);
+            XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+            setfocus(c);
+        }
	} else {
		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
@@ -853,6 +859,7 @@ focusstack(const Arg *arg)
	if (c) {
		focus(c);
		restack(selmon);
+        if (ispanel(c)) focusstack(arg);
	}
 }

@@ -964,6 +971,11 @@ grabkeys(void)
	}
 }

+int
+ispanel(Client *c) {
+    return !strcmp(c->name, panel[0]);
+}
+
 void
 incnmaster(const Arg *arg)
 {
@@ -1049,7 +1061,8 @@ manage(Window w, XWindowAttributes *wa)
	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;
-
+    // no border - even when active
+    if (ispanel(c)) c->bw = c->oldbw = 0;
	wc.border_width = c->bw;
	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
	XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);
@@ -1283,6 +1296,7 @@ resizeclient(Client *c, int x, int y, int w, int h)
	c->oldw = c->w; c->w = wc.width = w;
	c->oldh = c->h; c->h = wc.height = h;
	wc.border_width = c->bw;
+    if (ispanel(c)) c->y = c->oldy = c->bw = wc.y = wc.border_width = 0;
	XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
	configure(c);
	XSync(dpy, False);
@@ -1991,7 +2005,7 @@ void
 updatestatus(void)
 {
	if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
-		strcpy(stext, "dwm-"VERSION);
+		strcpy(stext, " "); // no shining of dwm version thru panel, when transparent
	drawbar(selmon);
 }

--
2.31.1