Compare commits

...

2 Commits

Author SHA1 Message Date
Nikita Ivanov
667c0fbdbe
menu: use builtin fd_set_nonblock 2025-03-22 21:03:57 +01:00
Nikita Ivanov
4f98041841
Update swallow patch 2025-03-22 18:34:36 +01:00
4 changed files with 29 additions and 35 deletions

View File

@ -1,12 +1,12 @@
From 1ce61fea52891ed719898c05d616ec20d34f2c73 Mon Sep 17 00:00:00 2001
From 7cfdf80b9ca536c29e49165e00b0b913685e396d Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Fri, 21 Mar 2025 21:48:42 +0100
Subject: [PATCH] Add menu command
---
config.def.h | 8 +++
dwl.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 162 insertions(+)
dwl.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+)
diff --git a/config.def.h b/config.def.h
index 22d2171..a5914ca 100644
@ -35,18 +35,10 @@ index 22d2171..a5914ca 100644
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
diff --git a/dwl.c b/dwl.c
index def2562..04543a6 100644
index def2562..868d0d0 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1,6 +1,7 @@
/*
* See LICENSE file for copyright and license details.
*/
+#include <fcntl.h>
#include <getopt.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
@@ -242,6 +243,12 @@ typedef struct {
@@ -242,6 +242,12 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
@ -59,7 +51,7 @@ index def2562..04543a6 100644
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -302,6 +309,12 @@ static void killclient(const Arg *arg);
@@ -302,6 +308,12 @@ static void killclient(const Arg *arg);
static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
@ -72,7 +64,7 @@ index def2562..04543a6 100644
static void monocle(Monitor *m);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
@@ -413,6 +426,11 @@ static struct wlr_box sgeom;
@@ -413,6 +425,11 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
@ -84,7 +76,7 @@ index def2562..04543a6 100644
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -1768,6 +1786,142 @@ maximizenotify(struct wl_listener *listener, void *data)
@@ -1768,6 +1785,142 @@ maximizenotify(struct wl_listener *listener, void *data)
wlr_xdg_surface_schedule_configure(c->surface.xdg);
}
@ -121,7 +113,7 @@ index def2562..04543a6 100644
+ close(fd_right[0]);
+ close(fd_left[1]);
+ menu_fd = fd_left[0];
+ if (fcntl(menu_fd, F_SETFL, fcntl(menu_fd, F_GETFL) | O_NONBLOCK) == -1)
+ if (fd_set_nonblock(menu_fd) == -1)
+ return;
+ if (!(f = fdopen(fd_right[1], "w")))
+ return;

View File

@ -10,8 +10,8 @@ line by avoiding cluttering the screen with many unusable terminals.
`foot` is the terminal by default, you can change it in client rules in config.h.
In `2025-03-03 v0.7` version, the patch had been rewritten from scratch to make
it more robust and add a few more features:
In `2025-03-03 v0.7` version and above, the patch had been rewritten from
scratch to make it more robust and add a few more features:
- "dynamically swallow" windows by pressing `Alt+a` (a focused window will
swallow/unswallow the previously focused one)
@ -22,8 +22,8 @@ it more robust and add a few more features:
#### swallow.patch
- [git branch](https://codeberg.org/nikitaivanov/dwl/src/branch/swallow)
- [2025-03-03 v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swallow/swallow.patch) (added "dynamic swallowing support")
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swallow/swallow.patch)
- [2025-03-03 v0.7](https://codeberg.org/dwl/dwl-patches/raw/commit/2e5748edfe1129f95c7bb1bf9dd590a897f55f57/patches/swallow/swallow.patch) (added "dynamic swallowing" support)
- [2024-07-13](https://codeberg.org/dwl/dwl-patches/raw/commit/f1ed83eaeba46108f4ee8164094cb431d64a3e68/patches/swallow/swallow.patch)
- [2024-07-13](https://codeberg.org/dwl/dwl-patches/raw/commit/f64d701bab2f9f52d3637edd091684f920407d87/patches/swallow/swallow.patch)
- [2024-05-02](https://codeberg.org/dwl/dwl-patches/raw/commit/9c5d5d85f3ac780e7a14d5d0535e3349ce8b8f53/patches/swallow/swallow.patch)
@ -39,7 +39,8 @@ it more robust and add a few more features:
Apply this patch on top of the swallow.patch if you use FreeBSD.
- [2025-03-03 v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swallow/swallow-freebsd.patch)
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/swallow/swallow-freebsd.patch)
- [2025-03-03 v0.7](https://codeberg.org/dwl/dwl-patches/raw/commit/2e5748edfe1129f95c7bb1bf9dd590a897f55f57/patches/swallow/swallow-freebsd.patch) (added "dynamic swallowing" support)
- [2024-07-13](https://codeberg.org/dwl/dwl-patches/raw/commit/f1ed83eaeba46108f4ee8164094cb431d64a3e68/patches/swallow/swallow-freebsd.patch)
### Authors

View File

@ -1,4 +1,4 @@
From 002e11e197cd254f06b65681ffd5bcf617d830b9 Mon Sep 17 00:00:00 2001
From 301e1b368d92a32a7bdcd4bd1f0ede0295977e3e Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Mon, 3 Mar 2025 19:49:07 +0100
Subject: [PATCH] swallow: add FreeBSD support
@ -8,7 +8,7 @@ Subject: [PATCH] swallow: add FreeBSD support
1 file changed, 17 insertions(+)
diff --git a/dwl.c b/dwl.c
index bbbbe6f..dc55319 100644
index 71d500a..52fdd9c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -67,6 +67,14 @@
@ -50,5 +50,5 @@ index bbbbe6f..dc55319 100644
void
--
2.48.1
2.49.0

View File

@ -1,13 +1,13 @@
From 7255d7e2e1b87c0583a202ea20c83fa75466c0fc Mon Sep 17 00:00:00 2001
From a220e1ed4b04a66c837dfc8e3363d3e696cbf541 Mon Sep 17 00:00:00 2001
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Wed, 5 Feb 2025 02:34:39 +0100
Subject: [PATCH] Swallow: hide the terminal when it spawns a client
---
client.h | 12 ++++
config.def.h | 10 +++-
config.def.h | 11 +++-
dwl.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 167 insertions(+), 7 deletions(-)
3 files changed, 168 insertions(+), 7 deletions(-)
diff --git a/client.h b/client.h
index 42f225f..bc9cad2 100644
@ -33,18 +33,19 @@ index 42f225f..bc9cad2 100644
client_get_clip(Client *c, struct wlr_box *clip)
{
diff --git a/config.def.h b/config.def.h
index 22d2171..fb5f8fb 100644
index 22d2171..42342f1 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
+static int enableautoswallow = 1; /* enables autoswallowing newly spawned clients */
+static float swallowborder = 1.0f; /* add this multiplied by borderpx to border when a client is swallowed */
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
@@ -22,10 +23,11 @@ static int log_level = WLR_ERROR;
@@ -22,10 +24,11 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
@ -59,7 +60,7 @@ index 22d2171..fb5f8fb 100644
};
/* layout(s) */
@@ -142,6 +144,8 @@ static const Key keys[] = {
@@ -142,6 +145,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
@ -69,7 +70,7 @@ index 22d2171..fb5f8fb 100644
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index def2562..bbbbe6f 100644
index def2562..71d500a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -73,12 +73,13 @@
@ -83,7 +84,7 @@ index def2562..bbbbe6f 100644
#define TAGMASK ((1u << TAGCOUNT) - 1)
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
#define LISTEN_STATIC(E, H) do { static struct wl_listener _l = {.notify = (H)}; wl_signal_add((E), &_l); } while (0)
+#define BORDERPX(C) (borderpx + ((C)->swallowing ? (C)->swallowing->bw : 0))
+#define BORDERPX(C) (borderpx + ((C)->swallowing ? (int)ceilf(swallowborder * (C)->swallowing->bw) : 0))
/* enums */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
@ -346,5 +347,5 @@ index def2562..bbbbe6f 100644
if (c == exclusive_focus) {
exclusive_focus = NULL;
--
2.48.1
2.49.0