about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2023-07-20 14:39:34 +0000
committerokan <okan>2023-07-20 14:39:34 +0000
commitd86d3aa419f331b7fb34f4592c23f3f93ebf223e (patch)
tree51ddd0967b6fdf65f695aee4b8aaca267d437450
parent9eb763ab8781610b67df44b9914a018d32dfe1fe (diff)
downloadcwm-d86d3aa419f331b7fb34f4592c23f3f93ebf223e.tar.gz
cwm-d86d3aa419f331b7fb34f4592c23f3f93ebf223e.tar.xz
cwm-d86d3aa419f331b7fb34f4592c23f3f93ebf223e.zip
Allow cwm(1) to cycle through windows of the same window class as the HEAD master
active window; default key binding to M-grave, respectively Alt-Tilde,
like other window managers have as well.

from Simon Dassow
-rw-r--r--calmwm.h1
-rw-r--r--conf.c6
-rw-r--r--cwm.14
-rw-r--r--cwmrc.54
-rw-r--r--kbfunc.c4
5 files changed, 18 insertions, 1 deletions
diff --git a/calmwm.h b/calmwm.h
index 7c428f6..60e59f6 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -67,6 +67,7 @@
 #define CWM_CYCLE_FORWARD	0x0001
 #define CWM_CYCLE_REVERSE	0x0002
 #define CWM_CYCLE_INGROUP	0x0004
+#define CWM_CYCLE_INCLASS	0x0008
 
 enum cwm_status {
 	CWM_QUIT,
diff --git a/conf.c b/conf.c
index 7610400..39f0406 100644
--- a/conf.c
+++ b/conf.c
@@ -136,6 +136,10 @@ static const struct {
 		(CWM_CYCLE_FORWARD | CWM_CYCLE_INGROUP)) },
 	{ FUNC_SC(window-rcycle-ingroup, client_cycle,
 		(CWM_CYCLE_REVERSE | CWM_CYCLE_INGROUP)) },
+	{ FUNC_SC(window-cycle-inclass, client_cycle,
+		(CWM_CYCLE_FORWARD | CWM_CYCLE_INCLASS)) },
+	{ FUNC_SC(window-rcycle-inclass, client_cycle,
+		(CWM_CYCLE_REVERSE | CWM_CYCLE_INCLASS)) },
 
 	{ FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) },
 	{ FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) },
@@ -220,6 +224,8 @@ static const struct {
 	{ "C-slash",	"menu-cmd" },
 	{ "M-Tab",	"window-cycle" },
 	{ "MS-Tab",	"window-rcycle" },
+	{ "M-grave",	"window-cycle-inclass" },
+	{ "MS-grave",	"window-rcycle-inclass" },
 	{ "CM-n",	"window-menu-label" },
 	{ "CM-x",	"window-close" },
 	{ "CM-a",	"group-toggle-all" },
diff --git a/cwm.1 b/cwm.1
index e0a892e..d70d856 100644
--- a/cwm.1
+++ b/cwm.1
@@ -102,6 +102,10 @@ Label current window.
 Cycle through currently visible windows.
 .It Ic MS-Tab
 Reverse cycle through currently visible windows.
+.It Ic M-grave
+Cycle through currently visible windows of the same window class.
+.It Ic MS-grave
+Reverse cycle through currently visible windows of the same window class.
 .It Ic CM-x
 Close current window.
 .It Ic CM-[n]
diff --git a/cwmrc.5 b/cwmrc.5
index 7075288..7d5f1f8 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -295,6 +295,10 @@ Reverse cycle through windows.
 Forward cycle through windows in current group.
 .It window-rcycle-ingroup
 Reverse cycle through windows in current group.
+.It window-cycle-inclass
+Forward cycle through windows of the current window class.
+.It window-rcycle-inclass
+Reverse cycle through windows of the current window class.
 .It window-close
 Close current window.
 .It window-hide
diff --git a/kbfunc.c b/kbfunc.c
index f805360..d858b7b 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -430,7 +430,9 @@ kbfunc_client_cycle(void *ctx, struct cargs *cargs)
 		/* Only cycle visible and non-ignored windows. */
 		if ((newcc->flags & (CLIENT_SKIP_CYCLE)) ||
 		    ((flags & CWM_CYCLE_INGROUP) &&
-		    (newcc->gc != oldcc->gc)))
+		    (newcc->gc != oldcc->gc)) ||
+		    ((flags & CWM_CYCLE_INCLASS) &&
+		    strcmp(newcc->res_class, oldcc->res_class) != 0))
 			again = 1;
 
 		/* Is oldcc the only non-hidden window? */