nextlayout: new patch - 0.7

This commit is contained in:
sewn 2024-09-08 22:48:02 +03:00
parent b1a2620e28
commit 084b90b98e
No known key found for this signature in database
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,9 @@
### Description
Change the current layout to the next available one.
### Download
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/nextlayout/nextlayout.patch)
### Authors
- [sewn](/sewn)

View File

@ -0,0 +1,57 @@
From 2a3a1dbbc83160070296ae7b9f894649dcb284ef Mon Sep 17 00:00:00 2001
From: sewn <sewn@disroot.org>
Date: Sun, 8 Sep 2024 22:46:09 +0300
Subject: [PATCH] add feature to switch to next available layout
ported from suckless cyclelayouts to be slightly more useful
https://dwm.suckless.org/patches/cyclelayouts/
---
config.def.h | 1 +
dwl.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/config.def.h b/config.def.h
index 22d2171..2c8ff86 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { NULL, NULL }, /* terminate */
};
/* monitors */
diff --git a/dwl.c b/dwl.c
index a2711f6..a66d9d9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -308,6 +308,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
double sy, double sx_unaccel, double sy_unaccel);
static void motionrelative(struct wl_listener *listener, void *data);
static void moveresize(const Arg *arg);
+static void nextlayout(const Arg *arg);
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
@@ -1927,6 +1928,17 @@ moveresize(const Arg *arg)
}
}
+void
+nextlayout(const Arg *arg)
+{
+ Layout *l;
+ for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++);
+ if(l->symbol && (l + 1)->symbol)
+ setlayout(&((Arg) { .v = (l + 1) }));
+ else
+ setlayout(&((Arg) { .v = layouts }));
+}
+
void
outputmgrapply(struct wl_listener *listener, void *data)
{
--
2.46.0