mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-11-06 13:13:25 +00:00
Compare commits
5
Commits
main
..
c5d5f9fed4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5d5f9fed4 | ||
|
|
85427bdb01 | ||
|
|
80c0d175a3 | ||
|
|
447397a44c | ||
|
|
675fa1815e |
@@ -1,9 +0,0 @@
|
||||
## Description
|
||||
Choose multiple/one floating window to be always-on-top - this prevents other floating windows from being raised above it. Useful for playing films, etc.
|
||||
this builds against tag 0.9 and also against commit 1dae5ba3ed.
|
||||
### Download
|
||||
- [2026-09-17](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/ontop/ontop.patch)
|
||||
### Author
|
||||
- [killertofus](https://codeberg.org/killertofus)
|
||||
killertofus irc/matrix
|
||||
with help from kana
|
||||
@@ -1,99 +0,0 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..0af77b2 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -137,6 +137,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_space, togglealwaysontop, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index c51e0d5..a6c9a05 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -88,7 +88,7 @@
|
||||
/* enums */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
+enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrAlwaysTop, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
|
||||
|
||||
@@ -158,7 +158,7 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, isalwaysontop;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -355,6 +355,7 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void togglealwaysontop(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -565,7 +566,7 @@ arrange(Monitor *m)
|
||||
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
|
||||
* in floating layout to avoid "real" floating clients be always on top */
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
- if (c->mon != m || c->scene->node.parent == layers[LyrFS])
|
||||
+ if (c->mon != m || c->scene->node.parent == layers[LyrFS] || c->isalwaysontop)
|
||||
continue;
|
||||
|
||||
wlr_scene_node_reparent(&c->scene->node,
|
||||
@@ -2487,7 +2488,8 @@ setfloating(Client *c, int floating)
|
||||
return;
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
|
||||
(p && p->isfullscreen) ? LyrFS
|
||||
- : c->isfloating ? LyrFloat : LyrTile]);
|
||||
+ : c->isfloating ? (c->isalwaysontop ? LyrAlwaysTop : LyrFloat) : LyrTile]);
|
||||
+
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2501,7 +2503,8 @@ setfullscreen(Client *c, int fullscreen)
|
||||
c->bw = fullscreen ? 0 : borderpx;
|
||||
client_set_fullscreen(c, fullscreen);
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
|
||||
- ? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
|
||||
+ ? LyrFS : c->isfloating ? (c->isalwaysontop ? LyrAlwaysTop : LyrFloat) : LyrTile]);
|
||||
+
|
||||
|
||||
if (fullscreen) {
|
||||
c->prev = c->geom;
|
||||
@@ -2515,6 +2518,27 @@ setfullscreen(Client *c, int fullscreen)
|
||||
printstatus();
|
||||
}
|
||||
|
||||
+void
|
||||
+togglealwaysontop(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ if (!sel)
|
||||
+ return;
|
||||
+
|
||||
+ if (sel->isfullscreen)
|
||||
+ return;
|
||||
+
|
||||
+ if (sel->isalwaysontop) {
|
||||
+ wlr_scene_node_reparent(&sel->scene->node, layers[sel->isalwaysontop]);
|
||||
+ sel->isalwaysontop = 0;
|
||||
+ } else {
|
||||
+ sel->isalwaysontop = sel->isfullscreen ? LyrFS : LyrTile;
|
||||
+ wlr_scene_node_reparent(&sel->scene->node, layers[LyrAlwaysTop]);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
+
|
||||
void
|
||||
setlayout(const Arg *arg)
|
||||
{
|
||||
@@ -1,10 +0,0 @@
|
||||
### Description
|
||||
Add simple animation support with a [cubic-bezier](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) curve.
|
||||
|
||||
### Download
|
||||
- [git branch](/pi66/dwl-patches/src/branch/animation)
|
||||
- [animation-0.9.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-0.9.patch)
|
||||
- [animation-e203845.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-e203845.patch)
|
||||
|
||||
### Authors
|
||||
- [Pi66](https://codeberg.org/pi66)
|
||||
@@ -1,307 +0,0 @@
|
||||
From 302ace232def0685dfccefe5d48570996263619d Mon Sep 17 00:00:00 2001
|
||||
From: pi66 <pixel2176@proton.me>
|
||||
Date: Wed, 30 Sep 2026 00:05:37 +0100
|
||||
Subject: [PATCH] fix: animation glitches and zoom logic
|
||||
|
||||
---
|
||||
client.h | 9 +--
|
||||
config.def.h | 4 ++
|
||||
dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-------
|
||||
3 files changed, 144 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/client.h b/client.h
|
||||
index dc0615e..9300417 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -365,7 +365,7 @@ client_set_scale(struct wlr_surface *s, float scale)
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
-static inline void
|
||||
+static inline uint32_t
|
||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
@@ -375,9 +375,10 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
- if ((int32_t)width != c->surface.xdg->toplevel->current.width
|
||||
- || (int32_t)height != c->surface.xdg->toplevel->current.height)
|
||||
- wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
+ if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
||||
+ && (int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
+ return 0;
|
||||
+ return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
}
|
||||
|
||||
static inline void
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..b0c17e8 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -15,6 +15,10 @@ 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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
|
||||
+/* animation */
|
||||
+static const unsigned int animation_duration = 300; /* ms */
|
||||
+static const float animation_curve[4] = {0.0f, 0.85f, 0.2f, 1.0f}; /* cubic-bezier x1, y1, x2, y2 */
|
||||
+
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4cfd0fd..81f157d 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -86,6 +86,7 @@
|
||||
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
|
||||
|
||||
/* enums */
|
||||
+enum { CliNormal, CliClosing, CliOpening }; /* client events */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
@@ -159,6 +160,11 @@ typedef struct {
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
+
|
||||
+ /* Animation */
|
||||
+ struct wlr_box anim_from, anim_to, anim_cur;
|
||||
+ uint32_t anim_start, serial;
|
||||
+ int animating, status;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -260,6 +266,10 @@ typedef struct {
|
||||
} SessionLock;
|
||||
|
||||
/* function declarations */
|
||||
+static uint32_t animation_now_ms(void);
|
||||
+static float animation_bezier(float t);
|
||||
+static int animation_tick(void *data);
|
||||
+static void animation_apply(Client *c, struct wlr_box g);
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
static void arrange(Monitor *m);
|
||||
@@ -374,6 +384,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
+static struct wl_event_source *animation_timer;
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
static void *exclusive_focus;
|
||||
@@ -485,6 +496,86 @@ static struct wlr_xwayland *xwayland;
|
||||
#include "ime.h"
|
||||
|
||||
/* function implementations */
|
||||
+uint32_t
|
||||
+animation_now_ms(void)
|
||||
+{
|
||||
+ struct timespec t;
|
||||
+
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
+ return t.tv_sec * 1000 + t.tv_nsec / 1000000;
|
||||
+}
|
||||
+
|
||||
+float
|
||||
+animation_bezier(float t)
|
||||
+{
|
||||
+ float x1 = animation_curve[0], y1 = animation_curve[1];
|
||||
+ float x2 = animation_curve[2], y2 = animation_curve[3];
|
||||
+ float lo = 0, hi = 1, s = t, x;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < 20; i++) {
|
||||
+ x = 3*(1-s)*(1-s)*s*x1 + 3*(1-s)*s*s*x2 + s*s*s;
|
||||
+ if (x < t)
|
||||
+ lo = s;
|
||||
+ else
|
||||
+ hi = s;
|
||||
+ s = (lo + hi) / 2;
|
||||
+ }
|
||||
+ return 3*(1-s)*(1-s)*s*y1 + 3*(1-s)*s*s*y2 + s*s*s;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+animation_tick(void *data)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ float t, p;
|
||||
+ int more = 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!c->animating)
|
||||
+ continue;
|
||||
+ t = (animation_now_ms() - c->anim_start) / (float)animation_duration;
|
||||
+ if (t >= 1) {
|
||||
+ t = 1;
|
||||
+ c->animating = 0;
|
||||
+ }
|
||||
+ p = animation_bezier(t);
|
||||
+ c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p);
|
||||
+ c->anim_cur.y = (int)(c->anim_from.y + (c->anim_to.y - c->anim_from.y) * p);
|
||||
+ c->anim_cur.width = (int)(c->anim_from.width + (c->anim_to.width - c->anim_from.width) * p);
|
||||
+ c->anim_cur.height = (int)(c->anim_from.height + (c->anim_to.height - c->anim_from.height) * p);
|
||||
+
|
||||
+ animation_apply(c, c->anim_cur);
|
||||
+ more |= c->animating;
|
||||
+ }
|
||||
+ if (more)
|
||||
+ wl_event_source_timer_update(animation_timer, 16);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+animation_apply(Client *c, struct wlr_box g)
|
||||
+{
|
||||
+ struct wlr_box clip, save = c->geom;
|
||||
+
|
||||
+ c->geom = g;
|
||||
+
|
||||
+ wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
+ wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[3], c->bw, c->geom.height - 2 * c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+
|
||||
+ client_get_clip(c, &clip);
|
||||
+ wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
+
|
||||
+ c->geom = save;
|
||||
+}
|
||||
+
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
{
|
||||
@@ -1873,6 +1964,7 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
.title = client_get_title(c),
|
||||
};
|
||||
|
||||
+ c->status = CliOpening;
|
||||
/* Create scene tree for this client and its border */
|
||||
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
|
||||
/* Enabled later by a call to arrange() */
|
||||
@@ -2322,12 +2414,17 @@ rendermon(struct wl_listener *listener, void *data)
|
||||
* generally at the output's refresh rate (e.g. 60Hz). */
|
||||
Monitor *m = wl_container_of(listener, m, frame);
|
||||
struct timespec now;
|
||||
+ Client *c;
|
||||
|
||||
if (!wlr_scene_output_needs_frame(m->scene_output)) {
|
||||
return;
|
||||
}
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
|
||||
+ goto skip;
|
||||
|
||||
wlr_scene_output_commit(m->scene_output, NULL);
|
||||
+skip:
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
wlr_scene_output_send_frame_done(m->scene_output, &now);
|
||||
}
|
||||
@@ -2365,7 +2462,6 @@ void
|
||||
resize(Client *c, struct wlr_box geo, int interact)
|
||||
{
|
||||
struct wlr_box *bbox;
|
||||
- struct wlr_box clip;
|
||||
|
||||
if (!c->mon || !client_surface(c)->mapped)
|
||||
return;
|
||||
@@ -2375,21 +2471,27 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
client_set_bounds(c, geo.width, geo.height);
|
||||
c->geom = geo;
|
||||
applybounds(c, bbox);
|
||||
+ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
|
||||
- /* Update scene-graph, including borders */
|
||||
- wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
- wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[3], c->bw, c->geom.height - 2 * c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+ if (interact) {
|
||||
+ c->animating = 0;
|
||||
+ c->anim_cur = c->geom;
|
||||
+ animation_apply(c, c->geom);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
- client_get_clip(c, &clip);
|
||||
- wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
+ if (!c->animating && c->anim_cur.width == 0) {
|
||||
+ c->anim_cur.width = c->geom.width / 2;
|
||||
+ c->anim_cur.height = c->geom.height / 2;
|
||||
+ c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2;
|
||||
+ c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2;
|
||||
+ }
|
||||
+
|
||||
+ c->anim_from = c->anim_cur;
|
||||
+ c->anim_to = c->geom;
|
||||
+ c->anim_start = animation_now_ms();
|
||||
+ c->animating = 1;
|
||||
+ wl_event_source_timer_update(animation_timer, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2615,6 +2717,7 @@ setup(void)
|
||||
* clients from the Unix socket, managing Wayland globals, and so on. */
|
||||
dpy = wl_display_create();
|
||||
event_loop = wl_display_get_event_loop(dpy);
|
||||
+ animation_timer = wl_event_loop_add_timer(event_loop, animation_tick, NULL);
|
||||
|
||||
/* The backend is a wlroots feature which abstracts the underlying input and
|
||||
* output hardware. The autocreate option will choose the most suitable
|
||||
@@ -2896,19 +2999,31 @@ tile(Monitor *m)
|
||||
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
else
|
||||
mw = m->w.width;
|
||||
+
|
||||
i = my = ty = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
+ struct wlr_box geo;
|
||||
+
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
+
|
||||
if (i < m->nmaster) {
|
||||
- resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
- .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
- my += c->geom.height;
|
||||
+ geo = (struct wlr_box){m->w.x, m->w.y + my, mw,
|
||||
+ (m->w.height - my) / (MIN(n, m->nmaster) - i)};
|
||||
+ my += geo.height;
|
||||
} else {
|
||||
- resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
|
||||
- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
|
||||
- ty += c->geom.height;
|
||||
+ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw,
|
||||
+ (m->w.height - ty) / (n - i)};
|
||||
+ ty += geo.height;
|
||||
+ }
|
||||
+
|
||||
+ if (c->status == CliOpening) {
|
||||
+ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4,
|
||||
+ geo.width / 2, geo.height / 2};
|
||||
+ c->anim_from = c->anim_cur;
|
||||
+ c->status = CliNormal;
|
||||
}
|
||||
+ resize(c, geo, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
From e8f65d36d788cfb0a02984ecaf979d639388913c Mon Sep 17 00:00:00 2001
|
||||
From: pi66 <pixel2176@proton.me>
|
||||
Date: Wed, 30 Sep 2026 00:03:31 +0100
|
||||
Subject: [PATCH] fix: animation glitches and zoom logic
|
||||
|
||||
---
|
||||
client.h | 9 +--
|
||||
config.def.h | 4 ++
|
||||
dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++-------
|
||||
3 files changed, 144 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/client.h b/client.h
|
||||
index eb1bb47..a271446 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -366,7 +366,7 @@ client_set_scale(struct wlr_surface *s, float scale)
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
-static inline void
|
||||
+static inline uint32_t
|
||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
@@ -376,9 +376,10 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
- if ((int32_t)width != c->surface.xdg->toplevel->current.width
|
||||
- || (int32_t)height != c->surface.xdg->toplevel->current.height)
|
||||
- wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
+ if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
||||
+ && (int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
+ return 0;
|
||||
+ return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
}
|
||||
|
||||
static inline void
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a4019d3..d37aa10 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -15,6 +15,10 @@ 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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
|
||||
+/* animation */
|
||||
+static const unsigned int animation_duration = 300; /* ms */
|
||||
+static const float animation_curve[4] = {0.0f, 0.85f, 0.2f, 1.0f}; /* cubic-bezier x1, y1, x2, y2 */
|
||||
+
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 216deb5..50e1687 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -86,6 +86,7 @@
|
||||
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
|
||||
|
||||
/* enums */
|
||||
+enum { CliNormal, CliClosing, CliOpening }; /* client events */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
@@ -159,6 +160,11 @@ typedef struct {
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
+
|
||||
+ /* Animation */
|
||||
+ struct wlr_box anim_from, anim_to, anim_cur;
|
||||
+ uint32_t anim_start, serial;
|
||||
+ int animating, status;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -261,6 +267,10 @@ typedef struct {
|
||||
} SessionLock;
|
||||
|
||||
/* function declarations */
|
||||
+static uint32_t animation_now_ms(void);
|
||||
+static float animation_bezier(float t);
|
||||
+static int animation_tick(void *data);
|
||||
+static void animation_apply(Client *c, struct wlr_box g);
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
static void arrange(Monitor *m);
|
||||
@@ -376,6 +386,7 @@ static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
+static struct wl_event_source *animation_timer;
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
static Client *focused_client;
|
||||
@@ -486,6 +497,86 @@ static struct wlr_xwayland *xwayland;
|
||||
#include "ime.h"
|
||||
|
||||
/* function implementations */
|
||||
+uint32_t
|
||||
+animation_now_ms(void)
|
||||
+{
|
||||
+ struct timespec t;
|
||||
+
|
||||
+ clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
+ return t.tv_sec * 1000 + t.tv_nsec / 1000000;
|
||||
+}
|
||||
+
|
||||
+float
|
||||
+animation_bezier(float t)
|
||||
+{
|
||||
+ float x1 = animation_curve[0], y1 = animation_curve[1];
|
||||
+ float x2 = animation_curve[2], y2 = animation_curve[3];
|
||||
+ float lo = 0, hi = 1, s = t, x;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < 20; i++) {
|
||||
+ x = 3*(1-s)*(1-s)*s*x1 + 3*(1-s)*s*s*x2 + s*s*s;
|
||||
+ if (x < t)
|
||||
+ lo = s;
|
||||
+ else
|
||||
+ hi = s;
|
||||
+ s = (lo + hi) / 2;
|
||||
+ }
|
||||
+ return 3*(1-s)*(1-s)*s*y1 + 3*(1-s)*s*s*y2 + s*s*s;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+animation_tick(void *data)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ float t, p;
|
||||
+ int more = 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!c->animating)
|
||||
+ continue;
|
||||
+ t = (animation_now_ms() - c->anim_start) / (float)animation_duration;
|
||||
+ if (t >= 1) {
|
||||
+ t = 1;
|
||||
+ c->animating = 0;
|
||||
+ }
|
||||
+ p = animation_bezier(t);
|
||||
+ c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p);
|
||||
+ c->anim_cur.y = (int)(c->anim_from.y + (c->anim_to.y - c->anim_from.y) * p);
|
||||
+ c->anim_cur.width = (int)(c->anim_from.width + (c->anim_to.width - c->anim_from.width) * p);
|
||||
+ c->anim_cur.height = (int)(c->anim_from.height + (c->anim_to.height - c->anim_from.height) * p);
|
||||
+
|
||||
+ animation_apply(c, c->anim_cur);
|
||||
+ more |= c->animating;
|
||||
+ }
|
||||
+ if (more)
|
||||
+ wl_event_source_timer_update(animation_timer, 16);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+animation_apply(Client *c, struct wlr_box g)
|
||||
+{
|
||||
+ struct wlr_box clip, save = c->geom;
|
||||
+
|
||||
+ c->geom = g;
|
||||
+
|
||||
+ wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
+ wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
|
||||
+ wlr_scene_rect_set_size(c->border[3], c->bw, c->geom.height - 2 * c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
+ wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+
|
||||
+ client_get_clip(c, &clip);
|
||||
+ wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
+
|
||||
+ c->geom = save;
|
||||
+}
|
||||
+
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
{
|
||||
@@ -1887,6 +1978,7 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
.title = client_get_title(c),
|
||||
};
|
||||
|
||||
+ c->status = CliOpening;
|
||||
/* Create scene tree for this client and its border */
|
||||
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
|
||||
/* Enabled later by a call to arrange() */
|
||||
@@ -2340,12 +2432,17 @@ rendermon(struct wl_listener *listener, void *data)
|
||||
* generally at the output's refresh rate (e.g. 60Hz). */
|
||||
Monitor *m = wl_container_of(listener, m, frame);
|
||||
struct timespec now;
|
||||
+ Client *c;
|
||||
|
||||
if (!wlr_scene_output_needs_frame(m->scene_output)) {
|
||||
return;
|
||||
}
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
|
||||
+ goto skip;
|
||||
|
||||
wlr_scene_output_commit(m->scene_output, NULL);
|
||||
+skip:
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
wlr_scene_output_send_frame_done(m->scene_output, &now);
|
||||
}
|
||||
@@ -2383,7 +2480,6 @@ void
|
||||
resize(Client *c, struct wlr_box geo, int interact)
|
||||
{
|
||||
struct wlr_box *bbox;
|
||||
- struct wlr_box clip;
|
||||
|
||||
if (!c->mon || !client_surface(c)->mapped)
|
||||
return;
|
||||
@@ -2393,21 +2489,27 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
client_set_bounds(c, geo.width, geo.height);
|
||||
c->geom = geo;
|
||||
applybounds(c, bbox);
|
||||
+ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
|
||||
- /* Update scene-graph, including borders */
|
||||
- wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
- wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[1], c->geom.width, c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[2], c->bw, c->geom.height - 2 * c->bw);
|
||||
- wlr_scene_rect_set_size(c->border[3], c->bw, c->geom.height - 2 * c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
- wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+ if (interact) {
|
||||
+ c->animating = 0;
|
||||
+ c->anim_cur = c->geom;
|
||||
+ animation_apply(c, c->geom);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
- client_get_clip(c, &clip);
|
||||
- wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
+ if (!c->animating && c->anim_cur.width == 0) {
|
||||
+ c->anim_cur.width = c->geom.width / 2;
|
||||
+ c->anim_cur.height = c->geom.height / 2;
|
||||
+ c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2;
|
||||
+ c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2;
|
||||
+ }
|
||||
+
|
||||
+ c->anim_from = c->anim_cur;
|
||||
+ c->anim_to = c->geom;
|
||||
+ c->anim_start = animation_now_ms();
|
||||
+ c->animating = 1;
|
||||
+ wl_event_source_timer_update(animation_timer, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2633,6 +2735,7 @@ setup(void)
|
||||
* clients from the Unix socket, managing Wayland globals, and so on. */
|
||||
dpy = wl_display_create();
|
||||
event_loop = wl_display_get_event_loop(dpy);
|
||||
+ animation_timer = wl_event_loop_add_timer(event_loop, animation_tick, NULL);
|
||||
|
||||
/* The backend is a wlroots feature which abstracts the underlying input and
|
||||
* output hardware. The autocreate option will choose the most suitable
|
||||
@@ -2914,19 +3017,31 @@ tile(Monitor *m)
|
||||
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
else
|
||||
mw = m->w.width;
|
||||
+
|
||||
i = my = ty = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
+ struct wlr_box geo;
|
||||
+
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
+
|
||||
if (i < m->nmaster) {
|
||||
- resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
- .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
- my += c->geom.height;
|
||||
+ geo = (struct wlr_box){m->w.x, m->w.y + my, mw,
|
||||
+ (m->w.height - my) / (MIN(n, m->nmaster) - i)};
|
||||
+ my += geo.height;
|
||||
} else {
|
||||
- resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
|
||||
- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
|
||||
- ty += c->geom.height;
|
||||
+ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw,
|
||||
+ (m->w.height - ty) / (n - i)};
|
||||
+ ty += geo.height;
|
||||
+ }
|
||||
+
|
||||
+ if (c->status == CliOpening) {
|
||||
+ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4,
|
||||
+ geo.width / 2, geo.height / 2};
|
||||
+ c->anim_from = c->anim_cur;
|
||||
+ c->status = CliNormal;
|
||||
}
|
||||
+ resize(c, geo, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -5,9 +5,8 @@ Note: Commands from array are executed using execvp(). So if you need to execute
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/sevz/dwl/src/branch/autostart)
|
||||
- [autostart_main-5fd19fe](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_main-5fd19fe.patch)
|
||||
- [autostart_wlroots-next-f4249db.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_wlroots-next-f4249db.patch)
|
||||
- [autostart_0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart_0.8.patch)
|
||||
- [autostart-wlroots-next-f4249db.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart-wlroots-next-f4249db.patch)
|
||||
- [autostart-0.8.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/autostart/autostart-0.8.patch)
|
||||
|
||||
### Authors
|
||||
- [fauxmight](https://codeberg.org/fauxmight)
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 572984b..0697b66 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
|
||||
/* logging */
|
||||
static int log_level = WLR_ERROR;
|
||||
|
||||
+/* Autostart */
|
||||
+static const char *const autostart[] = {
|
||||
+ "wbg", "/path/to/your/image", NULL,
|
||||
+ NULL /* terminate */
|
||||
+};
|
||||
+
|
||||
static const Rule rules[] = {
|
||||
/* app_id title tags mask isfloating monitor */
|
||||
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index f902ace..36496b3 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -263,6 +263,7 @@ static void arrange(Monitor *m);
|
||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
+static void autostartexec(void);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void capturerequest(struct wl_listener *listener, void *data);
|
||||
@@ -471,6 +472,9 @@ static struct wl_listener xwayland_ready = {.notify = xwaylandready};
|
||||
static struct wlr_xwayland *xwayland;
|
||||
#endif
|
||||
|
||||
+static pid_t *autostart_pids;
|
||||
+static size_t autostart_len;
|
||||
+
|
||||
/* configuration, allows nested code to access above variables */
|
||||
#include "config.h"
|
||||
|
||||
@@ -630,6 +634,27 @@ arrangelayers(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+autostartexec(void) {
|
||||
+ const char *const *p;
|
||||
+ size_t i = 0;
|
||||
+
|
||||
+ /* count entries */
|
||||
+ for (p = autostart; *p; autostart_len++, p++)
|
||||
+ while (*++p);
|
||||
+
|
||||
+ autostart_pids = calloc(autostart_len, sizeof(pid_t));
|
||||
+ for (p = autostart; *p; i++, p++) {
|
||||
+ if ((autostart_pids[i] = fork()) == 0) {
|
||||
+ setsid();
|
||||
+ execvp(*p, (char *const *)p);
|
||||
+ die("dwl: execvp %s:", *p);
|
||||
+ }
|
||||
+ /* skip arguments */
|
||||
+ while (*++p);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
axisnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -767,12 +792,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
||||
void
|
||||
cleanup(void)
|
||||
{
|
||||
+ size_t i;
|
||||
+
|
||||
cleanuplisteners();
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
xwayland = NULL;
|
||||
#endif
|
||||
wl_display_destroy_clients(dpy);
|
||||
+
|
||||
+ /* kill child processes */
|
||||
+ for (i = 0; i < autostart_len; i++) {
|
||||
+ if (0 < autostart_pids[i]) {
|
||||
+ kill(autostart_pids[i], SIGTERM);
|
||||
+ waitpid(autostart_pids[i], NULL, 0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (child_pid > 0) {
|
||||
kill(-child_pid, SIGTERM);
|
||||
waitpid(child_pid, NULL, 0);
|
||||
@@ -1646,10 +1682,25 @@ gpureset(struct wl_listener *listener, void *data)
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
- if (signo == SIGCHLD)
|
||||
- while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
- else if (signo == SIGINT || signo == SIGTERM)
|
||||
+ if (signo == SIGCHLD) {
|
||||
+ pid_t pid, *p, *lim;
|
||||
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
|
||||
+ if (pid == child_pid)
|
||||
+ child_pid = -1;
|
||||
+ if (!(p = autostart_pids))
|
||||
+ continue;
|
||||
+ lim = &p[autostart_len];
|
||||
+
|
||||
+ for (; p < lim; p++) {
|
||||
+ if (*p == pid) {
|
||||
+ *p = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (signo == SIGINT || signo == SIGTERM) {
|
||||
quit(NULL);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2365,6 +2416,7 @@ run(char *startup_cmd)
|
||||
die("startup: backend_start");
|
||||
|
||||
/* Now that the socket exists and the backend is started, run the startup command */
|
||||
+ autostartexec();
|
||||
if (startup_cmd) {
|
||||
int piperw[2];
|
||||
if (pipe(piperw) < 0)
|
||||
@@ -1,42 +0,0 @@
|
||||
### Description
|
||||
|
||||
Based on the corresponding `dwm` patch, this patch implements the AwesomeWM-style bar for `dwl`.
|
||||
|
||||
Clients are hidden using the logic already present in the `arrange` function.
|
||||
|
||||
#### Default key bindings
|
||||
|
||||
* `Mod + s` — Unhide the selected client.
|
||||
* `Mod + Shift + s` — Unhide all hidden clients on the current tag.
|
||||
* `Mod + Shift + h` — Hide the focused client.
|
||||
* `Mod + Shift + j` / `Mod + Shift + k` — Cycle through both visible and hidden clients.
|
||||
|
||||
#### Bar buttons
|
||||
|
||||
* Clicking the focused client hides it.
|
||||
* Clicking an unfocused visible client focuses it.
|
||||
* Clicking a hidden client unhides and focuses it.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* [bar](/dwl/dwl-patches/raw/branch/main/patches/bar/bar.patch)
|
||||
|
||||
### Download
|
||||
|
||||
* [main 2026-08-03](/dwl/dwl-patches/raw/branch/main/patches/bar-awesomebar/bar-awesomebar.patch)
|
||||
|
||||
### Authors
|
||||
|
||||
* [DanD](https://codeberg.org/DanD)
|
||||
|
||||
### Credits
|
||||
|
||||
This patch is based on the original `dwm` implementation by:
|
||||
|
||||
* ornx <ornx[at]protonmail.com>
|
||||
* Yegor Bayev [kodxpub@gmail.com](mailto:kodxpub@gmail.com)
|
||||
* Xac [jiangfengxi.c@gmail.com](mailto:jiangfengxi.c@gmail.com)
|
||||
* G-OD
|
||||
* mpetco https://codeberg.org/mpetco
|
||||
|
||||
|
||||
@@ -1,405 +0,0 @@
|
||||
From c712e2f23e9dbe28ee1e9ba461056f1533aabbaa Mon Sep 17 00:00:00 2001
|
||||
From: Ricardo <dandgg.ftw@gmail.com>
|
||||
Date: Mon, 3 Aug 2026 00:31:37 +0100
|
||||
Subject: [PATCH] awesomebar
|
||||
|
||||
---
|
||||
config.def.h | 12 +++-
|
||||
dwl.c | 195 ++++++++++++++++++++++++++++++++++++++++++++++-----
|
||||
2 files changed, 186 insertions(+), 21 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 7da50d2..1dca4a2 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -17,6 +17,7 @@ static uint32_t colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { 0xbbbbbbff, 0x222222ff, 0x444444ff },
|
||||
[SchemeSel] = { 0xeeeeeeff, 0x005577ff, 0x005577ff },
|
||||
+ [SchemeHid] = { 0x005577ff, 0x222222ff, 0x005577ff },
|
||||
[SchemeUrg] = { 0, 0, 0x770000ff },
|
||||
};
|
||||
|
||||
@@ -130,8 +131,13 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_b, togglebar, {0} },
|
||||
- { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
- { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY, XKB_KEY_j, focusstackvis, {.i = +1} },
|
||||
+ { MODKEY, XKB_KEY_k, focusstackvis, {.i = -1} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_j, focusstackhid, {.i = +1} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_k, focusstackhid, {.i = -1} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_h, hide, {0} },
|
||||
+ { MODKEY, XKB_KEY_s, show, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_s, showall, {0} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
@@ -175,7 +181,7 @@ static const Key keys[] = {
|
||||
static const Button buttons[] = {
|
||||
{ ClkLtSymbol, 0, BTN_LEFT, setlayout, {.v = &layouts[0]} },
|
||||
{ ClkLtSymbol, 0, BTN_RIGHT, setlayout, {.v = &layouts[2]} },
|
||||
- { ClkTitle, 0, BTN_MIDDLE, zoom, {0} },
|
||||
+ { ClkTitle, 0, BTN_LEFT, togglewin, {0} },
|
||||
{ ClkStatus, 0, BTN_MIDDLE, spawn, {.v = termcmd} },
|
||||
{ ClkClient, MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ ClkClient, MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 7fe9468..0d325b3 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -79,7 +79,8 @@
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
||||
-#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
+#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]) && !(C)->ishidden)
|
||||
+#define VISIBLE(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||
#define END(A) ((A) + LENGTH(A))
|
||||
#define TAGMASK ((1u << LENGTH(tags)) - 1)
|
||||
@@ -88,7 +89,7 @@
|
||||
#define TEXTW(mon, text) (drwl_font_getwidth(mon->drw, text) + mon->lrpad)
|
||||
|
||||
/* enums */
|
||||
-enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
|
||||
+enum { SchemeNorm, SchemeSel, SchemeHid, SchemeUrg }; /* color schemes */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
@@ -148,6 +149,7 @@ typedef struct {
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ int ishidden, tempshow;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -216,6 +218,7 @@ struct Monitor {
|
||||
int width, height;
|
||||
int real_width, real_height; /* non-scaled */
|
||||
float scale;
|
||||
+ int bt, btw; /* awesome bar */
|
||||
} b; /* bar area */
|
||||
struct wlr_box w; /* window area, layout-relative */
|
||||
struct wl_list layers[4]; /* LayerSurface.link */
|
||||
@@ -319,11 +322,14 @@ static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
-static void focusstack(const Arg *arg);
|
||||
+static void focusstack(const Arg *arg, int hid);
|
||||
+static void focusstackhid(const Arg *arg);
|
||||
+static void focusstackvis(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
+static void hide(const Arg *arg);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -363,6 +369,8 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
+static void show(const Arg *arg);
|
||||
+static void showall(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static int statusin(int fd, unsigned int mask, void *data);
|
||||
@@ -374,6 +382,7 @@ static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
+static void togglewin(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
static void unmaplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void unmapnotify(struct wl_listener *listener, void *data);
|
||||
@@ -786,8 +795,28 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
click = ClkLtSymbol;
|
||||
else if (cx > selmon->b.width - (TEXTW(selmon, stext) - selmon->lrpad + 2)) {
|
||||
click = ClkStatus;
|
||||
- } else
|
||||
- click = ClkTitle;
|
||||
+ } else {
|
||||
+ int nvis = selmon->b.bt;
|
||||
+ int base = nvis ? selmon->b.btw / nvis : 0;
|
||||
+ int remainder = nvis ? selmon->b.btw % nvis : 0;
|
||||
+ int idx = 0;
|
||||
+ int tabw = 0;
|
||||
+
|
||||
+ x += TEXTW(selmon, selmon->ltsymbol);
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLE(c, selmon))
|
||||
+ continue;
|
||||
+ tabw = base + (idx < remainder ? 1 : 0);
|
||||
+ idx++;
|
||||
+ x += tabw;
|
||||
+ if (cx < x) {
|
||||
+ arg.v = c;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (arg.v)
|
||||
+ click = ClkTitle;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Change focus if the button was _pressed_ over a client */
|
||||
@@ -799,7 +828,10 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) && event->button == b->button && click == b->click && b->func) {
|
||||
- b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg);
|
||||
+ if (click == ClkTitle && b->arg.i == 0)
|
||||
+ b->func(&arg);
|
||||
+ else
|
||||
+ b->func(click == ClkTagBar && b->arg.i == 0 ? &arg : &b->arg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1571,7 +1603,7 @@ dirtomon(enum wlr_direction dir)
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
- int x, w, tw = 0;
|
||||
+ int x, w, tw = 0, n = 0;
|
||||
int boxs = m->drw->font->height / 9;
|
||||
int boxw = m->drw->font->height / 6 + 2;
|
||||
uint32_t i, occ = 0, urg = 0;
|
||||
@@ -1593,6 +1625,8 @@ drawbar(Monitor *m)
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
+ if (VISIBLE(c, m))
|
||||
+ n++;
|
||||
occ |= c->tags;
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
@@ -1614,17 +1648,35 @@ drawbar(Monitor *m)
|
||||
x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
if ((w = m->b.width - tw - x) > m->b.height) {
|
||||
- if (c) {
|
||||
- drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
- drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
|
||||
- if (c && c->isfloating)
|
||||
- drwl_rect(m->drw, x + boxs, boxs, boxw, boxw, 0, 0);
|
||||
+ if (n > 0) {
|
||||
+ int base = w / n;
|
||||
+ int remainder = w % n;
|
||||
+ int tabw;
|
||||
+ int idx = 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLE(c, m))
|
||||
+ continue;
|
||||
+ if (c == focustop(m))
|
||||
+ drwl_setscheme(m->drw, colors[SchemeSel]);
|
||||
+ else if (c->ishidden)
|
||||
+ drwl_setscheme(m->drw, colors[SchemeHid]);
|
||||
+ else
|
||||
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
+ tabw = base + (idx < remainder ? 1 : 0);
|
||||
+ idx++;
|
||||
+ drwl_text(m->drw, x, 0, tabw, m->b.height, m->lrpad / 2, client_get_title(c), 0);
|
||||
+ x += tabw;
|
||||
+ }
|
||||
} else {
|
||||
drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
drwl_rect(m->drw, x, 0, w, m->b.height, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
+ m->b.bt = n;
|
||||
+ m->b.btw = w;
|
||||
+
|
||||
wlr_scene_buffer_set_dest_size(m->scene_buffer,
|
||||
m->b.real_width, m->b.real_height);
|
||||
wlr_scene_node_set_position(&m->scene_buffer->node, m->m.x,
|
||||
@@ -1677,7 +1729,12 @@ focusclient(Client *c, int lift)
|
||||
* handling a drag operation */
|
||||
if (!exclusive_focus && !seat->drag)
|
||||
client_set_border_color(c, (float[])COLOR(colors[SchemeSel][ColBorder]));
|
||||
- }
|
||||
+ if (c->ishidden) {
|
||||
+ c->tempshow = 1;
|
||||
+ c->ishidden = 0;
|
||||
+ arrange(c->mon);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/* Deactivate old client if focus is changing */
|
||||
if (old && (!c || client_surface(c) != old)) {
|
||||
@@ -1695,6 +1752,11 @@ focusclient(Client *c, int lift)
|
||||
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
|
||||
client_set_border_color(old_c, (float[])COLOR(colors[SchemeNorm][ColBorder]));
|
||||
client_activate_surface(old, 0);
|
||||
+ if (old_c->tempshow) {
|
||||
+ old_c->tempshow = 0;
|
||||
+ old_c->ishidden = 1;
|
||||
+ arrange(old_c->mon);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
drawbars();
|
||||
@@ -1728,24 +1790,37 @@ focusmon(const Arg *arg)
|
||||
}
|
||||
|
||||
void
|
||||
-focusstack(const Arg *arg)
|
||||
+focusstack(const Arg *arg, int hid)
|
||||
{
|
||||
/* Focus the next or previous client (in tiling order) on selmon */
|
||||
- Client *c, *sel = focustop(selmon);
|
||||
- if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
+ Client *c, *sel;
|
||||
+
|
||||
+ if (hid) {
|
||||
+ wl_list_for_each(sel, &fstack, flink)
|
||||
+ if (VISIBLE(sel, selmon))
|
||||
+ break;
|
||||
+ } else {
|
||||
+ sel = focustop(selmon);
|
||||
+ }
|
||||
+
|
||||
+ if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
wl_list_for_each(c, &sel->link, link) {
|
||||
if (&c->link == &clients)
|
||||
continue; /* wrap past the sentinel node */
|
||||
- if (VISIBLEON(c, selmon))
|
||||
+ if (!hid && VISIBLEON(c, selmon))
|
||||
+ break; /* found it */
|
||||
+ if (hid && VISIBLE(c, selmon))
|
||||
break; /* found it */
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each_reverse(c, &sel->link, link) {
|
||||
if (&c->link == &clients)
|
||||
continue; /* wrap past the sentinel node */
|
||||
- if (VISIBLEON(c, selmon))
|
||||
+ if (!hid && VISIBLEON(c, selmon))
|
||||
+ break; /* found it */
|
||||
+ if (hid && VISIBLE(c, selmon))
|
||||
break; /* found it */
|
||||
}
|
||||
}
|
||||
@@ -1753,6 +1828,18 @@ focusstack(const Arg *arg)
|
||||
focusclient(c, 1);
|
||||
}
|
||||
|
||||
+void
|
||||
+focusstackhid(const Arg *arg)
|
||||
+{
|
||||
+ focusstack(arg, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+focusstackvis(const Arg *arg)
|
||||
+{
|
||||
+ focusstack(arg, 0);
|
||||
+}
|
||||
+
|
||||
/* We probably should change the name of this: it sounds like it
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
@@ -1808,6 +1895,21 @@ handlesig(int signo)
|
||||
quit(NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+hide(const Arg *arg)
|
||||
+{
|
||||
+ Client *c = focustop(selmon);
|
||||
+
|
||||
+ if (!c || client_is_unmanaged(c) || c->isfullscreen)
|
||||
+ return;
|
||||
+
|
||||
+ if (!c->ishidden && !c->tempshow) {
|
||||
+ c->ishidden = 1;
|
||||
+ arrange(c->mon);
|
||||
+ focusclient(focustop(c->mon), 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -2869,6 +2971,38 @@ setup(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
+void
|
||||
+show(const Arg *arg)
|
||||
+{
|
||||
+ Client *c = focustop(selmon);
|
||||
+
|
||||
+ if (!c)
|
||||
+ return;
|
||||
+
|
||||
+ if (c->tempshow) {
|
||||
+ c->ishidden = 0;
|
||||
+ c->tempshow = 0;
|
||||
+ arrange(c->mon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+showall(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLE(c, selmon))
|
||||
+ if (c->ishidden) {
|
||||
+ c->ishidden = 0;
|
||||
+ if (c->tempshow)
|
||||
+ c->tempshow = 0;
|
||||
+ }
|
||||
+
|
||||
+ arrange(selmon);
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+}
|
||||
+
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
@@ -3025,6 +3159,31 @@ toggleview(const Arg *arg)
|
||||
drawbars();
|
||||
}
|
||||
|
||||
+void
|
||||
+togglewin(const Arg *arg)
|
||||
+{
|
||||
+ Client *c = (Client *)arg->v;
|
||||
+
|
||||
+ if (!c)
|
||||
+ return;
|
||||
+
|
||||
+ if (c == focustop(selmon)) {
|
||||
+ if (!c->ishidden && !client_is_unmanaged(c) && !c->isfullscreen) {
|
||||
+ c->ishidden = 1;
|
||||
+ c->tempshow = 0;
|
||||
+ arrange(c->mon);
|
||||
+ focusclient(focustop(c->mon), 1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (c->ishidden) {
|
||||
+ c->ishidden = 0;
|
||||
+ c->tempshow = 0;
|
||||
+ arrange(c->mon);
|
||||
+ }
|
||||
+ focusclient(c, 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
unlocksession(struct wl_listener *listener, void *data)
|
||||
{
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
### Description
|
||||
Add a `window_title` option to toggle showing window titles in the bar, similar to the DWM `notitle` patch.
|
||||
|
||||
### Dependencies
|
||||
this patch depends on [bar](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/bar/) patch
|
||||
|
||||
### Download
|
||||
- [git branch](/pi66/dwl-patches/src/branch/bar-notitle)
|
||||
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/bar-notitle/bar-notitle.patch)
|
||||
- [main 2026-02-28](/dwl/dwl-patches/raw/branch/main/patches/bar-notitle/bar-notitle.patch)
|
||||
|
||||
### Authors
|
||||
- [Pi66](https://codeberg.org/pi66)
|
||||
[website](https://pi66.xyz)
|
||||
@@ -1,38 +0,0 @@
|
||||
From 5dc83d75ff1b7dadf1fd1f96fe2303848e35d382 Mon Sep 17 00:00:00 2001
|
||||
From: pi66 <pixel2176@proton.me>
|
||||
Date: Sat, 28 Feb 2026 20:26:28 +0100
|
||||
Subject: [PATCH] add window_title option (like dwm notitle patch)
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 7da50d2..3d3dfe8 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -7,6 +7,7 @@
|
||||
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 int window_title = 0; /* 1 means showing window titles on the bar */
|
||||
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"};
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 7fe9468..0c7262a 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1614,7 +1614,7 @@ drawbar(Monitor *m)
|
||||
x = drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, m->ltsymbol, 0);
|
||||
|
||||
if ((w = m->b.width - tw - x) > m->b.height) {
|
||||
- if (c) {
|
||||
+ if (c && window_title) {
|
||||
drwl_setscheme(m->drw, colors[m == selmon ? SchemeSel : SchemeNorm]);
|
||||
drwl_text(m->drw, x, 0, w, m->b.height, m->lrpad / 2, client_get_title(c), 0);
|
||||
if (c && c->isfloating)
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
### Description
|
||||
|
||||
Blur implemented using scenefx
|
||||
|
||||
Implemented keybinds:
|
||||
- dynamically toggle blur globally:
|
||||
```c
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
|
||||
```
|
||||
- toggle blur for focused window:
|
||||
```c
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
|
||||
```
|
||||
|
||||
Options in config.def.h:
|
||||
```c
|
||||
#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
|
||||
static int blur_enabled = 1;
|
||||
```
|
||||
|
||||
Requires [scenefx](https://github.com/wlrfx/scenefx) version 0.5 (which is currently the latest version). Some information about installation instructions is provided at the bottom.
|
||||
|
||||
I have only implemented the xray version of blur, where blur skips past contents of other windows underneath a window and directly shows the background, because this way the background blur is cached, which helps to significantly reduce the gpu usage.
|
||||
|
||||
Tested blur.patch on main branch commit dwl/dwl@f1675a4800
|
||||
|
||||
As of commit fd5e06a50d the bar patch does not apply cleanly to dwl/dwl@f1675a4800, therefore the blur_bar.patch would also need to be manually applied. I will update it after the bar patch gets updated.
|
||||
|
||||
### Download
|
||||
|
||||
- [blur.patch](/dwl/dwl-patches/raw/branch/main/patches/blur/blur.patch) : for application to base dwl, does not apply blur to the bar
|
||||
|
||||
- [blur_bar.patch](/dwl/dwl-patches/raw/branch/main/patches/blur/blur_bar.patch) : for use with the bar patch, this version applies blur to the bar too, but to actually see the blur effect the bar background color would need to be changed to a transparent or translucent value, for example:
|
||||
```c
|
||||
static uint32_t colors[][3] = {
|
||||
/* fg bg border */
|
||||
[SchemeNorm] = { 0x777777ff, 0x00000000, 0x00000000 },
|
||||
[SchemeSel] = { 0x00ffffff, 0x00000000, 0x00ffffff },
|
||||
[SchemeUrg] = { 0xff00ffff, 0x00000000, 0xff00ffff },
|
||||
};
|
||||
```
|
||||
|
||||
### Authors
|
||||
|
||||
- [atourist](https://codeberg.org/atourist)
|
||||
|
||||
---
|
||||
|
||||
Installing [scenefx](https://github.com/wlrfx/scenefx) version 0.5
|
||||
|
||||
The recommended way to install scenefx is through your linux distro's package manager, if the scenefx version in your distro's official repositories is 0.5. The scenefx github page has a [list](https://github.com/wlrfx/scenefx#Installation) with the version info on some common distros. For vanilla Arch Linux users, scenefx is not available in the official repositories, but it can be installed via the AUR instead, either using yay or paru or some other AUR helper, or manually by following the steps listed on the [Arch wiki for AUR](https://wiki.archlinux.org/title/Arch_User_Repository). Some derivative Arch distros like CachyOS provide scenefx through their official repositories.
|
||||
|
||||
If you install scenefx via your package manager or through AUR, **no further steps are needed**.
|
||||
But if you compile from source using the instructions provided in the [scenefx github repository](https://github.com/wlrfx/scenefx), depending on where you install scenefx, you might need to ensure that the `PKG_CONFIG` specified in dwl's `config.mk` is able to locate the header files for scenefx. By default, it uses pkg-config, so to check, use the following terminal command:
|
||||
```sh
|
||||
pkg-config --cflags scenefx-0.5
|
||||
```
|
||||
If this returns a path to the scenefx header files, **no further steps are needed**.
|
||||
**Otherwise** the path to the header files needs to be manually provided following these steps:
|
||||
1. Apply the blur patch
|
||||
2. In `Makefile` in the dwl source code, remove `scenefx-0.5` from `PKGS = `
|
||||
3. In `Makefile` add `-I/path/to/scenefx_headers` with the correct path to `DWLCFLAGS =` such that it is placed before all other options, so it should look something like this:
|
||||
```Makefile
|
||||
DWLCFLAGS = -I/path/to/scenefx_headers `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
```
|
||||
4. In `Makefile` add `-lscenefx-0.5` to `LDLIBS =` such that it is placed before all other options, so it should look something like this:
|
||||
```Makefile
|
||||
LDLIBS = -lscenefx-0.5 `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
|
||||
```
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 8304245..f55e2f9 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wfloat-conversion
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
-PKGS = wayland-server xkbcommon libinput $(XLIBS)
|
||||
+PKGS = scenefx-0.5 wayland-server xkbcommon libinput $(XLIBS)
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a4019d3..88029d9 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -18,6 +18,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
+#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
|
||||
+static int blur_enabled = 1;
|
||||
+
|
||||
/* logging */
|
||||
static int log_level = WLR_ERROR;
|
||||
|
||||
@@ -123,6 +126,8 @@ static const Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index ca97c30..af50458 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
+#include <scenefx/render/fx_renderer/fx_renderer.h>
|
||||
+#include <scenefx/types/wlr_scene.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
@@ -51,7 +53,6 @@
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||
-#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
@@ -88,8 +89,7 @@
|
||||
/* enums */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
- LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
+enum { LyrBg, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
|
||||
|
||||
typedef union {
|
||||
@@ -159,6 +159,7 @@ typedef struct {
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
+ struct wlr_scene_blur *blur;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -226,6 +227,7 @@ struct Monitor {
|
||||
int nmaster;
|
||||
char ltsymbol[16];
|
||||
int asleep;
|
||||
+ struct wlr_scene_optimized_blur *blur;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -357,6 +359,8 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void toggleblur(const Arg *arg);
|
||||
+static void toggleblurfocused(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -841,6 +845,8 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
+ wlr_scene_node_destroy(&m->blur->node);
|
||||
+ m->blur = NULL;
|
||||
free(m);
|
||||
}
|
||||
|
||||
@@ -944,6 +950,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
arrangelayers(l->mon);
|
||||
+ if ((layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -990,6 +997,7 @@ commitnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
|
||||
+ wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1211,6 +1219,11 @@ createmon(struct wl_listener *listener, void *data)
|
||||
m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
|
||||
|
||||
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, m->m.width, m->m.height);
|
||||
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
||||
+ wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
|
||||
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
||||
+
|
||||
/* Adds this to the output layout in the order it was configured.
|
||||
*
|
||||
* The output layout utility automatically adds a wl_output global to the
|
||||
@@ -1955,6 +1968,11 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
printstatus();
|
||||
|
||||
+ c->blur = wlr_scene_blur_create(c->scene, c->geom.width, c->geom.height);
|
||||
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
|
||||
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
|
||||
+ wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
||||
+
|
||||
unset_fullscreen:
|
||||
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
|
||||
wl_list_for_each(w, &clients, link) {
|
||||
@@ -2651,11 +2669,13 @@ setup(void)
|
||||
drag_icon = wlr_scene_tree_create(&scene->tree);
|
||||
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
||||
|
||||
+ wlr_scene_set_blur_data(scene, blur_params);
|
||||
+
|
||||
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
|
||||
* can also specify a renderer using the WLR_RENDERER env var.
|
||||
* The renderer is responsible for defining the various pixel formats it
|
||||
* supports for shared memory, this configures that for clients. */
|
||||
- if (!(drw = wlr_renderer_autocreate(backend)))
|
||||
+ if (!(drw = fx_renderer_create(backend)))
|
||||
die("couldn't create renderer");
|
||||
wl_signal_add(&drw->events.lost, &gpu_reset);
|
||||
|
||||
@@ -2933,6 +2953,21 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void toggleblur(const Arg *arg) {
|
||||
+ Client *c;
|
||||
+ Monitor *m = NULL;
|
||||
+ blur_enabled = !blur_enabled;
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
||||
+ }
|
||||
+ wl_list_for_each(c, &clients, link) wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
||||
+}
|
||||
+
|
||||
+void toggleblurfocused(const Arg *arg) {
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ if (sel && sel->blur) wlr_scene_node_set_enabled(&sel->blur->node, !sel->blur->node.enabled);
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
@@ -2995,6 +3030,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
arrangelayers(l->mon);
|
||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
focusclient(focustop(selmon), NULL, 1);
|
||||
+ if ((l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -3098,6 +3134,9 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
|
||||
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
|
||||
|
||||
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
||||
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
|
||||
+
|
||||
if (m->lock_surface) {
|
||||
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
||||
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
||||
@@ -1,209 +0,0 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 09ae285..02e7e13 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wfloat-conversion
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
-PKGS = wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
||||
+PKGS = scenefx-0.5 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1c50fc5..90e17d6 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -20,6 +20,9 @@ static uint32_t colors[][3] = {
|
||||
[SchemeUrg] = { 0, 0, 0x770000ff },
|
||||
};
|
||||
|
||||
+#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
|
||||
+static int blur_enabled = 1;
|
||||
+
|
||||
/* tagging */
|
||||
static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
@@ -130,6 +133,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_b, togglebar, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 2afec86..9bec152 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
+#include <scenefx/render/fx_renderer/fx_renderer.h>
|
||||
+#include <scenefx/types/wlr_scene.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
@@ -50,7 +52,6 @@
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||
-#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
#include <wlr/types/wlr_server_decoration.h>
|
||||
@@ -91,7 +92,7 @@
|
||||
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
+enum { LyrBg, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
|
||||
enum { ClkTagBar, ClkLtSymbol, ClkStatus, ClkTitle, ClkClient, ClkRoot }; /* clicks */
|
||||
|
||||
@@ -163,6 +164,7 @@ typedef struct {
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ struct wlr_scene_blur *blur;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -221,6 +223,7 @@ struct Monitor {
|
||||
struct wlr_output *wlr_output;
|
||||
struct wlr_scene_output *scene_output;
|
||||
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
|
||||
+ struct wlr_scene_blur *bar_blur;
|
||||
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
|
||||
struct wl_listener frame;
|
||||
struct wl_listener destroy;
|
||||
@@ -247,6 +250,7 @@ struct Monitor {
|
||||
Drwl *drw;
|
||||
Buffer *pool[2];
|
||||
int lrpad;
|
||||
+ struct wlr_scene_optimized_blur *blur;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -387,6 +391,8 @@ static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglebar(const Arg *arg);
|
||||
+static void toggleblur(const Arg *arg);
|
||||
+static void toggleblurfocused(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -979,6 +985,8 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
wlr_scene_node_destroy(&m->scene_buffer->node);
|
||||
+ wlr_scene_node_destroy(&m->blur->node);
|
||||
+ m->blur = NULL;
|
||||
free(m);
|
||||
}
|
||||
|
||||
@@ -1087,6 +1095,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
arrangelayers(l->mon);
|
||||
+ if ((layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1120,6 +1129,7 @@ commitnotify(struct wl_listener *listener, void *data)
|
||||
/* mark a pending resize as completed */
|
||||
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
|
||||
c->resize = 0;
|
||||
+ wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1347,6 +1357,16 @@ createmon(struct wl_listener *listener, void *data)
|
||||
m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
|
||||
|
||||
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, m->m.width, m->m.height);
|
||||
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
||||
+ wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
|
||||
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
||||
+ m->bar_blur = wlr_scene_blur_create(layers[LyrBottom], m->b.real_width, m->b.real_height);
|
||||
+ wlr_scene_node_set_position(&m->bar_blur->node, m->m.x, m->m.y);
|
||||
+ wlr_scene_node_lower_to_bottom(&m->bar_blur->node);
|
||||
+ wlr_scene_blur_set_should_only_blur_bottom_layer(m->bar_blur, true);
|
||||
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
|
||||
+
|
||||
/* Adds this to the output layout in the order it was configured.
|
||||
*
|
||||
* The output layout utility automatically adds a wl_output global to the
|
||||
@@ -2154,6 +2174,11 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
drawbars();
|
||||
|
||||
+ c->blur = wlr_scene_blur_create(c->scene, c->geom.width, c->geom.height);
|
||||
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
|
||||
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
|
||||
+ wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
||||
+
|
||||
unset_fullscreen:
|
||||
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
|
||||
wl_list_for_each(w, &clients, link) {
|
||||
@@ -2785,11 +2810,13 @@ setup(void)
|
||||
drag_icon = wlr_scene_tree_create(&scene->tree);
|
||||
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
||||
|
||||
+ wlr_scene_set_blur_data(scene, blur_params);
|
||||
+
|
||||
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
|
||||
* can also specify a renderer using the WLR_RENDERER env var.
|
||||
* The renderer is responsible for defining the various pixel formats it
|
||||
* supports for shared memory, this configures that for clients. */
|
||||
- if (!(drw = wlr_renderer_autocreate(backend)))
|
||||
+ if (!(drw = fx_renderer_create(backend)))
|
||||
die("couldn't create renderer");
|
||||
wl_signal_add(&drw->events.lost, &gpu_reset);
|
||||
|
||||
@@ -3108,6 +3135,22 @@ togglebar(const Arg *arg)
|
||||
drawbars();
|
||||
}
|
||||
|
||||
+void toggleblur(const Arg *arg) {
|
||||
+ Client *c;
|
||||
+ Monitor *m = NULL;
|
||||
+ blur_enabled = !blur_enabled;
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
||||
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
|
||||
+ }
|
||||
+ wl_list_for_each(c, &clients, link) wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
||||
+}
|
||||
+
|
||||
+void toggleblurfocused(const Arg *arg) {
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ if (sel && sel->blur) wlr_scene_node_set_enabled(&sel->blur->node, !sel->blur->node.enabled);
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
@@ -3172,6 +3215,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
arrangelayers(l->mon);
|
||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
focusclient(focustop(selmon), 1);
|
||||
+ if ((l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -3274,6 +3318,9 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
|
||||
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
|
||||
|
||||
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
||||
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
|
||||
+
|
||||
if (m->lock_surface) {
|
||||
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
||||
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
||||
+50
-29
@@ -1,10 +1,10 @@
|
||||
### Description
|
||||
|
||||
# btrtile - A Focus-Driven Tiling Layout
|
||||
# btrtile — A Focus-Driven Tiling Layout
|
||||
|
||||
It provides a focus-driven, mouse- and keyboard-friendly tiling layout that grants you granular control over how clients are placed and resized.
|
||||
|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
@@ -14,34 +14,38 @@ While dwl’s patches folder is full of different layouts, I couldn't find suita
|
||||
|
||||
---
|
||||
|
||||
# How it works
|
||||
# Features
|
||||
|
||||
Clients live in a binary tree, every split has a ratio (50/50 by default).
|
||||
- **Combined Tiling and Management**
|
||||
Combines tiling layout and management of clients under one patchset.
|
||||
|
||||
When a new client opens, it splits the client you last focused. The pointer decides which side it lands on: left half of the client puts it on the left, and so on. If the area is wider than it is tall the split is vertical, otherwise horizontal. When several clients open at once, each one splits the previous one, so you get a nice spiral instead of a pile in one corner.
|
||||
- **Focus-Driven Splits**
|
||||
When you add a new client, btrtile checks where your pointer is relative to the focused client’s geometry.
|
||||
- If the pointer is on the left half (for a horizontally large client), the new client spawns on the left side, and vice versa.
|
||||
- By default, new splits are 50/50.
|
||||
|
||||
- **Mouse**
|
||||
Drag a tiled client with `MODKEY` + left button to float it, drop it on another tiled client to place it next to it.
|
||||
`MODKEY` + right button resizes the divider next to the client you grabbed, it follows the pointer 1:1.
|
||||
- **Keyboard**
|
||||
`setratio_h` / `setratio_v` move a divider, `swapclients` swaps a client with its neighbour in a direction,
|
||||
`togglesplit` flips the direction of the split you're in (and keeps it that way),
|
||||
`swapsplit` mirrors the split.
|
||||
- **Adaptive Splitting**
|
||||
- If the area to be split is wider than its height, btrtile does a vertical split.
|
||||
- Otherwise, it does a horizontal split.
|
||||
|
||||
**config.h:**
|
||||
```c
|
||||
use_active_for_splits = 1; /* 1: split the last focused client, 0: the one under the pointer */
|
||||
force_split = 0; /* 0: new client on the pointer's side, 1: always left/top, 2: always right/bottom */
|
||||
preserve_split = 0; /* 1: splits keep their direction, 0: direction follows the shape of the area */
|
||||
split_width_multiplier = 1.0f; /* split side by side when width >= height * this */
|
||||
resize_interval_ms = 16; /* limits mouse resize updates, 16ms is ~60 per second */
|
||||
```
|
||||
- **Keyboard and Mouse Driven**
|
||||
- Supports keyboard-based commands for quick ratio adjustments and client swapping.
|
||||
- Mouse-based resizing and moving are integrated for more intuitive manipulation.
|
||||
|
||||
`force_split = 2` gives you a predictable spiral if you don't want the pointer to matter.
|
||||
`split_width_multiplier` is handy on wide monitors, where windows tend to stay wider than tall for a long time.
|
||||
---
|
||||
|
||||
Smoother mouse resizing costs some cpu, so tune `resize_interval_ms` to your refresh rate.
|
||||
If resizing feels sluggish, try compiling dwl with -O2/-O3.
|
||||
# How It Works
|
||||
|
||||
btrtile organizes clients using a binary tree data structure that represents splits either vertically or horizontally.
|
||||
|
||||
When a new client appears:
|
||||
1. **Focused Client Detection**
|
||||
btrtile checks your pointer location to find which client (if any) you’re interacting with.
|
||||
2. **Split Creation**
|
||||
- If there’s a focused client, btrtile creates a split node around it, placing the new client on the side where your pointer is.
|
||||
|
||||
3. **Ratio Management**
|
||||
Each split node has a `split_ratio` (defaulting to 0.5). This ratio defines how much space is allocated to each child node. You can adjust this ratio using keyboard or mouse actions.
|
||||
|
||||
---
|
||||
|
||||
@@ -52,6 +56,23 @@ If resizing feels sluggish, try compiling dwl with -O2/-O3.
|
||||
|
||||
---
|
||||
|
||||
# Configuring btrtile
|
||||
|
||||
btrtile adds couple variables to config.h to fine tune the mouse resizing of tiled clients.
|
||||
|
||||
1. **resize_factor**
|
||||
- A multiplier to transfer pointer movement to client weight ratio. Depends heavily on mouse sensitivity.
|
||||
Defaults to 0.0002f.
|
||||
|
||||
2. **resize_interval_ms**
|
||||
- A time based resize call limiter. Depends on framerate and screen refresh rate.
|
||||
Defaults to 16ms. (~60 resize updates per second)
|
||||
|
||||
Fine tune these values to find the best values for your setup, smoother resizing can significally increase cpu overhead.
|
||||
If mouse resizing feels sluggish, you can try compiling dwl with more aggressive optimization flags like -O2/-O3.
|
||||
|
||||
---
|
||||
|
||||
# Patch recommendations
|
||||
|
||||
1. **Patches that I use with my btrtile**
|
||||
@@ -74,11 +95,11 @@ If resizing feels sluggish, try compiling dwl with -O2/-O3.
|
||||
---
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-0.9)
|
||||
- [btrtile-0.9](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.9.patch)
|
||||
- [btrtile-0.9 WITH gaps](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-gaps-v0.9.patch)
|
||||
- [btrtile-0.8](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8.patch)
|
||||
- [btrtile-0.8 WITH gaps](/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8-gaps.patch)
|
||||
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/btrtile-dev)
|
||||
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8.patch)
|
||||
- [0.8 WITH gaps](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-v0.8-gaps.patch)
|
||||
- [wlroots-next](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-wlroots-next-d41ecb7.patch)
|
||||
- [wlroots-next WITH gaps](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/btrtile/btrtile-wlroots-next-d41ecb7-gaps.patch)
|
||||
|
||||
### Authors
|
||||
- [julmajustus](https://codeberg.org/julmajustus)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,21 @@
|
||||
From 42e35a6a8a93f0e6d886ad69686c85c1d58536d6 Mon Sep 17 00:00:00 2001
|
||||
From f5d7fe287bd4405879a92d649243d3f646652617 Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Mon, 22 Jun 2026 22:54:11 +0300
|
||||
Subject: [PATCH] btrtile: bug fixes and readability improvement
|
||||
Date: Thu, 19 Mar 2026 00:08:10 +0200
|
||||
Subject: [PATCH] Refactor btrtile-gaps to v0.8
|
||||
|
||||
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
|
||||
- Improved readability of the client sanitization loop inside btrtile function
|
||||
- Removed fullscreened client's from the sanitization loop to retain their geometry
|
||||
---
|
||||
btrtile.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
btrtile.c | 584 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
config.def.h | 12 ++
|
||||
dwl.c | 151 +++++++++++---
|
||||
3 files changed, 711 insertions(+), 27 deletions(-)
|
||||
dwl.c | 148 ++++++++++---
|
||||
3 files changed, 717 insertions(+), 27 deletions(-)
|
||||
create mode 100644 btrtile.c
|
||||
|
||||
diff --git a/btrtile.c b/btrtile.c
|
||||
new file mode 100644
|
||||
index 0000000..24bf4d9
|
||||
index 0000000..afe3c8f
|
||||
--- /dev/null
|
||||
+++ b/btrtile.c
|
||||
@@ -0,0 +1,575 @@
|
||||
@@ -0,0 +1,584 @@
|
||||
+/* ************************************************************************** */
|
||||
+/* @@@ @@@@@@@@ */
|
||||
+/* @@@ @@@@@@@@@@ */
|
||||
@@ -29,7 +26,7 @@ index 0000000..24bf4d9
|
||||
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
|
||||
+/* ::! :!: !:! */
|
||||
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
|
||||
+/* Updated: 2026/06/22 22:54:06 by julmajustus : : : : : : */
|
||||
+/* Updated: 2026/03/19 00:07:19 by julmajustus : : : : : : */
|
||||
+/* */
|
||||
+/* ************************************************************************** */
|
||||
+
|
||||
@@ -52,8 +49,7 @@ index 0000000..24bf4d9
|
||||
+static void destroy_node(LayoutNode *node);
|
||||
+static void destroy_tree(Monitor *m);
|
||||
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
|
||||
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
|
||||
+ unsigned int need_vertical, int focused_on_left);
|
||||
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
|
||||
+static void init_tree(Monitor *m);
|
||||
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
|
||||
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
|
||||
@@ -64,6 +60,7 @@ index 0000000..24bf4d9
|
||||
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
|
||||
+static Client *xytoclient(double x, double y);
|
||||
+
|
||||
+static int resizing_from_mouse = 0;
|
||||
+static double resize_last_update_x, resize_last_update_y;
|
||||
+static uint32_t last_resize_time = 0;
|
||||
+
|
||||
@@ -79,7 +76,7 @@ index 0000000..24bf4d9
|
||||
+ if (!node)
|
||||
+ return;
|
||||
+
|
||||
+ if (is_root && e) {
|
||||
+ if (is_root && e) {
|
||||
+ area.x += gappx;
|
||||
+ area.y += gappx;
|
||||
+ area.width -= 2 * gappx;
|
||||
@@ -92,6 +89,7 @@ index 0000000..24bf4d9
|
||||
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ return;
|
||||
+ resize(c, area, 0);
|
||||
+ c->old_geom = area;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -131,7 +129,7 @@ index 0000000..24bf4d9
|
||||
+ right_area.width = area.width - mid;
|
||||
+ right_area.height = area.height;
|
||||
+
|
||||
+ if (e) {
|
||||
+ if (e) {
|
||||
+ left_area.width -= gappx / 2;
|
||||
+ right_area.x += gappx / 2;
|
||||
+ right_area.width -= gappx / 2;
|
||||
@@ -149,7 +147,7 @@ index 0000000..24bf4d9
|
||||
+ right_area.width = area.width;
|
||||
+ right_area.height= area.height - mid;
|
||||
+
|
||||
+ if (e) {
|
||||
+ if (e) {
|
||||
+ left_area.height -= gappx / 2;
|
||||
+ right_area.y += gappx / 2;
|
||||
+ right_area.height -= gappx / 2;
|
||||
@@ -168,13 +166,15 @@ index 0000000..24bf4d9
|
||||
+ LayoutNode *found;
|
||||
+ struct wlr_box full_area;
|
||||
+
|
||||
+ if (!m)
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+
|
||||
+ /* Remove floating and moved clients */
|
||||
+ /* Remove non tiled clients from tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon != m || c->isfloating)
|
||||
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
|
||||
+ } else {
|
||||
+ remove_client(m, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client is found under cursor, fallback to focustop(m) */
|
||||
@@ -268,37 +268,30 @@ index 0000000..24bf4d9
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_suitable_split(Monitor *m, LayoutNode *start_node,
|
||||
+ unsigned int need_vertical, int focused_on_left)
|
||||
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
|
||||
+{
|
||||
+ LayoutNode *n = start_node, *child = NULL;
|
||||
+
|
||||
+ if (!m)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (n && n->is_client_node) {
|
||||
+ child = n;
|
||||
+ LayoutNode *n = start_node;
|
||||
+ /* if we started from a client node, jump to its parent: */
|
||||
+ if (n && n->is_client_node)
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+
|
||||
+ while (n) {
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
|
||||
+ && visible_count(n->left, m) > 0
|
||||
+ && visible_count(n->right, m) > 0) {
|
||||
+ if ((focused_on_left && n->left == child) ||
|
||||
+ (!focused_on_left && n->right == child))
|
||||
+ return n;
|
||||
+ }
|
||||
+ child = n;
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
|
||||
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
|
||||
+ return n;
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+init_tree(Monitor *m)
|
||||
+{
|
||||
+ if (m)
|
||||
+ m->root = NULL;
|
||||
+ if (!m)
|
||||
+ return;
|
||||
+ m->root = calloc(1, sizeof(LayoutNode));
|
||||
+ if (!m->root)
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
@@ -422,31 +415,21 @@ index 0000000..24bf4d9
|
||||
+ m->root = remove_client_node(m->root, c);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setratio(unsigned int need_vertical, const Arg *arg)
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel;
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+ int focused_on_left;
|
||||
+
|
||||
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ sel = focustop(selmon);
|
||||
+ if (!sel)
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ focused_on_left = (arg->f >= 0.0f);
|
||||
+
|
||||
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
|
||||
+
|
||||
+ if (!split_node)
|
||||
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
|
||||
+ split_node = find_suitable_split(client_node, 1);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
@@ -457,85 +440,109 @@ index 0000000..24bf4d9
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ apply_layout(selmon, selmon->root, selmon->w, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ setratio(1, arg);
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_v(const Arg *arg)
|
||||
+{
|
||||
+ setratio(0, arg);
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 0);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void swapclients(const Arg *arg) {
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ LayoutNode *sel_node, *target_node;
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ cand_center_x, cand_center_y;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+unsigned int
|
||||
@@ -558,12 +565,11 @@ index 0000000..24bf4d9
|
||||
+
|
||||
+Client *
|
||||
+xytoclient(double x, double y) {
|
||||
+ Monitor *m = xytomon(x, y);
|
||||
+ Client *c, *closest = NULL;
|
||||
+ double dist, mindist = INT_MAX, dx, dy;
|
||||
+
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
|
||||
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
|
||||
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
|
||||
+ return c;
|
||||
@@ -572,7 +578,7 @@ index 0000000..24bf4d9
|
||||
+
|
||||
+ /* If no client was found at cursor position fallback to closest. */
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
|
||||
+ dx = 0, dy = 0;
|
||||
+
|
||||
+ if (x < c->geom.x)
|
||||
@@ -585,7 +591,7 @@ index 0000000..24bf4d9
|
||||
+ else if (y > (c->geom.y + c->geom.height))
|
||||
+ dy = y - (c->geom.y + c->geom.height);
|
||||
+
|
||||
+ dist = dx * dx + dy * dy;
|
||||
+ dist = sqrt(dx * dx + dy * dy);
|
||||
+ if (dist < mindist) {
|
||||
+ mindist = dist;
|
||||
+ closest = c;
|
||||
@@ -633,7 +639,7 @@ index 8a6eda0..bc04e3f 100644
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..2529e1f 100644
|
||||
index 44f3ad9..f74d9a1 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
@@ -652,16 +658,18 @@ index 44f3ad9..2529e1f 100644
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
@@ -137,7 +139,7 @@ typedef struct {
|
||||
@@ -137,8 +139,9 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, was_tiled;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ struct wlr_box old_geom;
|
||||
} Client;
|
||||
|
||||
@@ -205,6 +207,7 @@ struct Monitor {
|
||||
typedef struct {
|
||||
@@ -205,6 +208,7 @@ struct Monitor {
|
||||
int nmaster;
|
||||
char ltsymbol[16];
|
||||
int asleep;
|
||||
@@ -669,7 +677,7 @@ index 44f3ad9..2529e1f 100644
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -247,6 +250,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
@@ -247,6 +251,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
@@ -677,7 +685,7 @@ index 44f3ad9..2529e1f 100644
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
@@ -329,6 +333,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
@@ -329,6 +334,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
@@ -687,7 +695,7 @@ index 44f3ad9..2529e1f 100644
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -454,6 +461,7 @@ static struct wlr_xwayland *xwayland;
|
||||
@@ -454,6 +462,7 @@ static struct wlr_xwayland *xwayland;
|
||||
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
@@ -695,7 +703,7 @@ index 44f3ad9..2529e1f 100644
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
@@ -624,7 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -624,7 +633,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
struct wlr_pointer_button_event *event = data;
|
||||
struct wlr_keyboard *keyboard;
|
||||
uint32_t mods;
|
||||
@@ -704,7 +712,7 @@ index 44f3ad9..2529e1f 100644
|
||||
const Button *b;
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
@@ -645,7 +653,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -645,7 +654,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
|
||||
@@ -713,7 +721,7 @@ index 44f3ad9..2529e1f 100644
|
||||
b->func(&b->arg);
|
||||
return;
|
||||
}
|
||||
@@ -655,6 +663,21 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -655,6 +664,27 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||
/* TODO: should reset to the pointer focus's current setcursor */
|
||||
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
|
||||
@@ -728,14 +736,20 @@ index 44f3ad9..2529e1f 100644
|
||||
+ selmon->root = create_client_node(c);
|
||||
+
|
||||
+ setfloating(c, 0);
|
||||
+ apply_layout(selmon, selmon->root, selmon->w, 1);
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ } else if (cursor_mode == CurResize && !c->isfloating) {
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (cursor_mode == CurResize && resizing_from_mouse)
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ /* Default behaviour */
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
cursor_mode = CurNormal;
|
||||
/* Drop the window off on its new monitor */
|
||||
@@ -746,6 +769,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
@@ -746,6 +776,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
@@ -743,7 +757,7 @@ index 44f3ad9..2529e1f 100644
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -1090,6 +1114,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -1090,6 +1121,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
@@ -751,25 +765,18 @@ index 44f3ad9..2529e1f 100644
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
@@ -1329,9 +1354,17 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the xdg_toplevel is destroyed. */
|
||||
Client *c = wl_container_of(listener, c, destroy);
|
||||
+ Monitor *mon;
|
||||
@@ -1332,6 +1364,10 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->destroy.link);
|
||||
wl_list_remove(&c->set_title.link);
|
||||
wl_list_remove(&c->fullscreen.link);
|
||||
+ /* We check if the destroyed client was part of any tiled_list, to catch
|
||||
+ * client removals even if they would not be currently managed by btrtile */
|
||||
+ wl_list_for_each(mon, &mons, link) {
|
||||
+ if (mon->root) {
|
||||
+ remove_client(mon, c);
|
||||
+ }
|
||||
+ }
|
||||
+ if (selmon && selmon->root)
|
||||
+ remove_client(selmon, c);
|
||||
#ifdef XWAYLAND
|
||||
if (c->type != XDGShell) {
|
||||
wl_list_remove(&c->activate.link);
|
||||
@@ -1862,7 +1895,8 @@ void
|
||||
@@ -1862,7 +1898,8 @@ void
|
||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||
double dx_unaccel, double dy_unaccel)
|
||||
{
|
||||
@@ -779,13 +786,13 @@ index 44f3ad9..2529e1f 100644
|
||||
Client *c = NULL, *w = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@@ -1916,18 +1950,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
@@ -1916,18 +1953,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* Update drag icon's position */
|
||||
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
|
||||
|
||||
- /* If we are currently grabbing the mouse, handle and return */
|
||||
+ /* Skip if internal call */
|
||||
+ if (time == 0)
|
||||
+ /* Skip if internal call or already resizing */
|
||||
+ if (time == 0 && resizing_from_mouse)
|
||||
+ goto focus;
|
||||
+
|
||||
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
|
||||
@@ -807,7 +814,7 @@ index 44f3ad9..2529e1f 100644
|
||||
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
- return;
|
||||
+ if (tiled) {
|
||||
+ if (tiled && resizing_from_mouse) {
|
||||
+ dx_total = cursor->x - resize_last_update_x;
|
||||
+ dy_total = cursor->y - resize_last_update_y;
|
||||
+
|
||||
@@ -820,6 +827,7 @@ index 44f3ad9..2529e1f 100644
|
||||
+ a.f = (float)(dy_total * resize_factor);
|
||||
+ setratio_v(&a);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ last_resize_time = time;
|
||||
+ resize_last_update_x = cursor->x;
|
||||
@@ -842,7 +850,7 @@ index 44f3ad9..2529e1f 100644
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
* off of a client or over its border. */
|
||||
@@ -1961,22 +2032,40 @@ moveresize(const Arg *arg)
|
||||
@@ -1961,22 +2036,41 @@ moveresize(const Arg *arg)
|
||||
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
|
||||
return;
|
||||
|
||||
@@ -877,6 +885,7 @@ index 44f3ad9..2529e1f 100644
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ resizing_from_mouse = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
@@ -899,21 +908,6 @@ index 44f3ad9..2529e1f 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2826,6 +2915,14 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
} else {
|
||||
+ /* btrtile remove clients for each monitor */
|
||||
+ Monitor *mon;
|
||||
+ wl_list_for_each(mon, &mons, link) {
|
||||
+ if (mon->root) {
|
||||
+ remove_client(mon, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
wl_list_remove(&c->link);
|
||||
setmon(c, NULL, 0);
|
||||
wl_list_remove(&c->flink);
|
||||
--
|
||||
2.53.0
|
||||
2.52.0
|
||||
|
||||
|
||||
+155
-161
@@ -1,24 +1,21 @@
|
||||
From 04d7c04a0a88e381df788e1ec60398d956543f8b Mon Sep 17 00:00:00 2001
|
||||
From 1b75163aac16942a715c6fc0aaf5d508e778dd6a Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Mon, 22 Jun 2026 22:52:57 +0300
|
||||
Subject: [PATCH] btrtile: bug fixes and readability improvement
|
||||
Date: Wed, 18 Mar 2026 20:23:00 +0200
|
||||
Subject: [PATCH] Refactor btrtile for v0.8
|
||||
|
||||
- Removed client old_geom caching for simplicity fixes: https://codeberg.org/dwl/dwl-patches/issues/647
|
||||
- Improved readability of the client sanitization loop inside btrtile function
|
||||
- Removed fullscreened client's from the sanitization loop to retain their geometry
|
||||
---
|
||||
btrtile.c | 556 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
btrtile.c | 565 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
config.def.h | 12 ++
|
||||
dwl.c | 151 +++++++++++---
|
||||
3 files changed, 692 insertions(+), 27 deletions(-)
|
||||
dwl.c | 148 +++++++++++---
|
||||
3 files changed, 698 insertions(+), 27 deletions(-)
|
||||
create mode 100644 btrtile.c
|
||||
|
||||
diff --git a/btrtile.c b/btrtile.c
|
||||
new file mode 100644
|
||||
index 0000000..6055871
|
||||
index 0000000..d706c3b
|
||||
--- /dev/null
|
||||
+++ b/btrtile.c
|
||||
@@ -0,0 +1,556 @@
|
||||
@@ -0,0 +1,565 @@
|
||||
+/* ************************************************************************** */
|
||||
+/* @@@ @@@@@@@@ */
|
||||
+/* @@@ @@@@@@@@@@ */
|
||||
@@ -29,7 +26,7 @@ index 0000000..6055871
|
||||
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
|
||||
+/* ::! :!: !:! */
|
||||
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
|
||||
+/* Updated: 2026/06/22 22:52:52 by julmajustus : : : : : : */
|
||||
+/* Updated: 2026/03/18 20:26:17 by julmajustus : : : : : : */
|
||||
+/* */
|
||||
+/* ************************************************************************** */
|
||||
+
|
||||
@@ -52,8 +49,7 @@ index 0000000..6055871
|
||||
+static void destroy_node(LayoutNode *node);
|
||||
+static void destroy_tree(Monitor *m);
|
||||
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
|
||||
+static LayoutNode *find_suitable_split(Monitor *m, LayoutNode *start,
|
||||
+ unsigned int need_vertical, int focused_on_left);
|
||||
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
|
||||
+static void init_tree(Monitor *m);
|
||||
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
|
||||
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
|
||||
@@ -64,6 +60,7 @@ index 0000000..6055871
|
||||
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
|
||||
+static Client *xytoclient(double x, double y);
|
||||
+
|
||||
+static int resizing_from_mouse = 0;
|
||||
+static double resize_last_update_x, resize_last_update_y;
|
||||
+static uint32_t last_resize_time = 0;
|
||||
+
|
||||
@@ -85,6 +82,7 @@ index 0000000..6055871
|
||||
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ return;
|
||||
+ resize(c, area, 0);
|
||||
+ c->old_geom = area;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -149,13 +147,15 @@ index 0000000..6055871
|
||||
+ LayoutNode *found;
|
||||
+ struct wlr_box full_area;
|
||||
+
|
||||
+ if (!m)
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+
|
||||
+ /* Remove floating and moved clients */
|
||||
+ /* Remove non tiled clients from tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon != m || c->isfloating)
|
||||
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
|
||||
+ } else {
|
||||
+ remove_client(m, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client is found under cursor, fallback to focustop(m) */
|
||||
@@ -249,37 +249,30 @@ index 0000000..6055871
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_suitable_split(Monitor *m, LayoutNode *start_node,
|
||||
+ unsigned int need_vertical, int focused_on_left)
|
||||
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
|
||||
+{
|
||||
+ LayoutNode *n = start_node, *child = NULL;
|
||||
+
|
||||
+ if (!m)
|
||||
+ return NULL;
|
||||
+
|
||||
+ if (n && n->is_client_node) {
|
||||
+ child = n;
|
||||
+ LayoutNode *n = start_node;
|
||||
+ /* if we started from a client node, jump to its parent: */
|
||||
+ if (n && n->is_client_node)
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+
|
||||
+ while (n) {
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical
|
||||
+ && visible_count(n->left, m) > 0
|
||||
+ && visible_count(n->right, m) > 0) {
|
||||
+ if ((focused_on_left && n->left == child) ||
|
||||
+ (!focused_on_left && n->right == child))
|
||||
+ return n;
|
||||
+ }
|
||||
+ child = n;
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
|
||||
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
|
||||
+ return n;
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+init_tree(Monitor *m)
|
||||
+{
|
||||
+ if (m)
|
||||
+ m->root = NULL;
|
||||
+ if (!m)
|
||||
+ return;
|
||||
+ m->root = calloc(1, sizeof(LayoutNode));
|
||||
+ if (!m->root)
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
@@ -403,31 +396,21 @@ index 0000000..6055871
|
||||
+ m->root = remove_client_node(m->root, c);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setratio(unsigned int need_vertical, const Arg *arg)
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel;
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+ int focused_on_left;
|
||||
+
|
||||
+ if (!selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ sel = focustop(selmon);
|
||||
+ if (!sel)
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ focused_on_left = (arg->f >= 0.0f);
|
||||
+
|
||||
+ split_node = find_suitable_split(selmon, client_node, need_vertical, focused_on_left);
|
||||
+
|
||||
+ if (!split_node)
|
||||
+ split_node = find_suitable_split(selmon, client_node, need_vertical, !focused_on_left);
|
||||
+ split_node = find_suitable_split(client_node, 1);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
@@ -438,85 +421,109 @@ index 0000000..6055871
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ apply_layout(selmon, selmon->root, selmon->w, 1);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ setratio(1, arg);
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_v(const Arg *arg)
|
||||
+{
|
||||
+ setratio(0, arg);
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 0);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void swapclients(const Arg *arg) {
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ LayoutNode *sel_node, *target_node;
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ cand_center_x, cand_center_y;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+unsigned int
|
||||
@@ -539,12 +546,11 @@ index 0000000..6055871
|
||||
+
|
||||
+Client *
|
||||
+xytoclient(double x, double y) {
|
||||
+ Monitor *m = xytomon(x, y);
|
||||
+ Client *c, *closest = NULL;
|
||||
+ double dist, mindist = INT_MAX, dx, dy;
|
||||
+
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen &&
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
|
||||
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
|
||||
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
|
||||
+ return c;
|
||||
@@ -553,7 +559,7 @@ index 0000000..6055871
|
||||
+
|
||||
+ /* If no client was found at cursor position fallback to closest. */
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
|
||||
+ dx = 0, dy = 0;
|
||||
+
|
||||
+ if (x < c->geom.x)
|
||||
@@ -566,7 +572,7 @@ index 0000000..6055871
|
||||
+ else if (y > (c->geom.y + c->geom.height))
|
||||
+ dy = y - (c->geom.y + c->geom.height);
|
||||
+
|
||||
+ dist = dx * dx + dy * dy;
|
||||
+ dist = sqrt(dx * dx + dy * dy);
|
||||
+ if (dist < mindist) {
|
||||
+ mindist = dist;
|
||||
+ closest = c;
|
||||
@@ -614,7 +620,7 @@ index 8a6eda0..bc04e3f 100644
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..2529e1f 100644
|
||||
index 44f3ad9..f74d9a1 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
@@ -633,16 +639,18 @@ index 44f3ad9..2529e1f 100644
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
@@ -137,7 +139,7 @@ typedef struct {
|
||||
@@ -137,8 +139,9 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, was_tiled;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ struct wlr_box old_geom;
|
||||
} Client;
|
||||
|
||||
@@ -205,6 +207,7 @@ struct Monitor {
|
||||
typedef struct {
|
||||
@@ -205,6 +208,7 @@ struct Monitor {
|
||||
int nmaster;
|
||||
char ltsymbol[16];
|
||||
int asleep;
|
||||
@@ -650,7 +658,7 @@ index 44f3ad9..2529e1f 100644
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -247,6 +250,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
@@ -247,6 +251,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
@@ -658,7 +666,7 @@ index 44f3ad9..2529e1f 100644
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
@@ -329,6 +333,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
@@ -329,6 +334,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
@@ -668,7 +676,7 @@ index 44f3ad9..2529e1f 100644
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -454,6 +461,7 @@ static struct wlr_xwayland *xwayland;
|
||||
@@ -454,6 +462,7 @@ static struct wlr_xwayland *xwayland;
|
||||
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
@@ -676,7 +684,7 @@ index 44f3ad9..2529e1f 100644
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
@@ -624,7 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -624,7 +633,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
struct wlr_pointer_button_event *event = data;
|
||||
struct wlr_keyboard *keyboard;
|
||||
uint32_t mods;
|
||||
@@ -685,7 +693,7 @@ index 44f3ad9..2529e1f 100644
|
||||
const Button *b;
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
@@ -645,7 +653,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -645,7 +654,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
|
||||
@@ -694,7 +702,7 @@ index 44f3ad9..2529e1f 100644
|
||||
b->func(&b->arg);
|
||||
return;
|
||||
}
|
||||
@@ -655,6 +663,21 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -655,6 +664,27 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||
/* TODO: should reset to the pointer focus's current setcursor */
|
||||
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
|
||||
@@ -709,14 +717,20 @@ index 44f3ad9..2529e1f 100644
|
||||
+ selmon->root = create_client_node(c);
|
||||
+
|
||||
+ setfloating(c, 0);
|
||||
+ apply_layout(selmon, selmon->root, selmon->w, 1);
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ } else if (cursor_mode == CurResize && !c->isfloating) {
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (cursor_mode == CurResize && resizing_from_mouse)
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ /* Default behaviour */
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
cursor_mode = CurNormal;
|
||||
/* Drop the window off on its new monitor */
|
||||
@@ -746,6 +769,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
@@ -746,6 +776,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
@@ -724,7 +738,7 @@ index 44f3ad9..2529e1f 100644
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -1090,6 +1114,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -1090,6 +1121,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
@@ -732,25 +746,18 @@ index 44f3ad9..2529e1f 100644
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
@@ -1329,9 +1354,17 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the xdg_toplevel is destroyed. */
|
||||
Client *c = wl_container_of(listener, c, destroy);
|
||||
+ Monitor *mon;
|
||||
@@ -1332,6 +1364,10 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->destroy.link);
|
||||
wl_list_remove(&c->set_title.link);
|
||||
wl_list_remove(&c->fullscreen.link);
|
||||
+ /* We check if the destroyed client was part of any tiled_list, to catch
|
||||
+ * client removals even if they would not be currently managed by btrtile */
|
||||
+ wl_list_for_each(mon, &mons, link) {
|
||||
+ if (mon->root) {
|
||||
+ remove_client(mon, c);
|
||||
+ }
|
||||
+ }
|
||||
+ if (selmon && selmon->root)
|
||||
+ remove_client(selmon, c);
|
||||
#ifdef XWAYLAND
|
||||
if (c->type != XDGShell) {
|
||||
wl_list_remove(&c->activate.link);
|
||||
@@ -1862,7 +1895,8 @@ void
|
||||
@@ -1862,7 +1898,8 @@ void
|
||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||
double dx_unaccel, double dy_unaccel)
|
||||
{
|
||||
@@ -760,13 +767,13 @@ index 44f3ad9..2529e1f 100644
|
||||
Client *c = NULL, *w = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@@ -1916,18 +1950,55 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
@@ -1916,18 +1953,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* Update drag icon's position */
|
||||
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
|
||||
|
||||
- /* If we are currently grabbing the mouse, handle and return */
|
||||
+ /* Skip if internal call */
|
||||
+ if (time == 0)
|
||||
+ /* Skip if internal call or already resizing */
|
||||
+ if (time == 0 && resizing_from_mouse)
|
||||
+ goto focus;
|
||||
+
|
||||
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
|
||||
@@ -788,7 +795,7 @@ index 44f3ad9..2529e1f 100644
|
||||
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
- return;
|
||||
+ if (tiled) {
|
||||
+ if (tiled && resizing_from_mouse) {
|
||||
+ dx_total = cursor->x - resize_last_update_x;
|
||||
+ dy_total = cursor->y - resize_last_update_y;
|
||||
+
|
||||
@@ -801,6 +808,7 @@ index 44f3ad9..2529e1f 100644
|
||||
+ a.f = (float)(dy_total * resize_factor);
|
||||
+ setratio_v(&a);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ last_resize_time = time;
|
||||
+ resize_last_update_x = cursor->x;
|
||||
@@ -823,7 +831,7 @@ index 44f3ad9..2529e1f 100644
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
* off of a client or over its border. */
|
||||
@@ -1961,22 +2032,40 @@ moveresize(const Arg *arg)
|
||||
@@ -1961,22 +2036,41 @@ moveresize(const Arg *arg)
|
||||
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
|
||||
return;
|
||||
|
||||
@@ -858,6 +866,7 @@ index 44f3ad9..2529e1f 100644
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ resizing_from_mouse = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
@@ -880,21 +889,6 @@ index 44f3ad9..2529e1f 100644
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2826,6 +2915,14 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
} else {
|
||||
+ /* btrtile remove clients for each monitor */
|
||||
+ Monitor *mon;
|
||||
+ wl_list_for_each(mon, &mons, link) {
|
||||
+ if (mon->root) {
|
||||
+ remove_client(mon, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
wl_list_remove(&c->link);
|
||||
setmon(c, NULL, 0);
|
||||
wl_list_remove(&c->flink);
|
||||
--
|
||||
2.53.0
|
||||
2.52.0
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,913 @@
|
||||
From a9329abe48083a4c5b64eee726ceefdb4bf0bb9f Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Thu, 19 Mar 2026 22:59:49 +0200
|
||||
Subject: [PATCH] Refactor btrtile-gaps to wlroots-next
|
||||
|
||||
---
|
||||
btrtile.c | 584 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
config.def.h | 12 ++
|
||||
dwl.c | 148 ++++++++++---
|
||||
3 files changed, 717 insertions(+), 27 deletions(-)
|
||||
create mode 100644 btrtile.c
|
||||
|
||||
diff --git a/btrtile.c b/btrtile.c
|
||||
new file mode 100644
|
||||
index 0000000..8703617
|
||||
--- /dev/null
|
||||
+++ b/btrtile.c
|
||||
@@ -0,0 +1,584 @@
|
||||
+/* ************************************************************************** */
|
||||
+/* @@@ @@@@@@@@ */
|
||||
+/* @@@ @@@@@@@@@@ */
|
||||
+/* @@! @@! @@@@ */
|
||||
+/* !@! !@! @!@!@ */
|
||||
+/* btrtile.c @!! @!@ @! !@! */
|
||||
+/* !!! !@!!! !!! */
|
||||
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
|
||||
+/* ::! :!: !:! */
|
||||
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
|
||||
+/* Updated: 2026/03/19 22:59:12 by julmajustus : : : : : : */
|
||||
+/* */
|
||||
+/* ************************************************************************** */
|
||||
+
|
||||
+typedef struct LayoutNode {
|
||||
+ unsigned int is_client_node;
|
||||
+ unsigned int is_split_vertically;
|
||||
+ float split_ratio;
|
||||
+ struct LayoutNode *left;
|
||||
+ struct LayoutNode *right;
|
||||
+ struct LayoutNode *split_node;
|
||||
+ Client *client;
|
||||
+} LayoutNode;
|
||||
+
|
||||
+static void apply_layout(Monitor *m, LayoutNode *node,
|
||||
+ struct wlr_box area, unsigned int is_root);
|
||||
+static void btrtile(Monitor *m);
|
||||
+static LayoutNode *create_client_node(Client *c);
|
||||
+static LayoutNode *create_split_node(unsigned int is_split_vertically,
|
||||
+ LayoutNode *left, LayoutNode *right);
|
||||
+static void destroy_node(LayoutNode *node);
|
||||
+static void destroy_tree(Monitor *m);
|
||||
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
|
||||
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
|
||||
+static void init_tree(Monitor *m);
|
||||
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
|
||||
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
|
||||
+static void remove_client(Monitor *m, Client *c);
|
||||
+static void setratio_h(const Arg *arg);
|
||||
+static void setratio_v(const Arg *arg);
|
||||
+static void swapclients(const Arg *arg);
|
||||
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
|
||||
+static Client *xytoclient(double x, double y);
|
||||
+
|
||||
+static int resizing_from_mouse = 0;
|
||||
+static double resize_last_update_x, resize_last_update_y;
|
||||
+static uint32_t last_resize_time = 0;
|
||||
+
|
||||
+void
|
||||
+apply_layout(Monitor *m, LayoutNode *node,
|
||||
+ struct wlr_box area, unsigned int is_root)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ float ratio;
|
||||
+ unsigned int left_count, right_count, mid, e = m->gaps;
|
||||
+ struct wlr_box left_area, right_area;
|
||||
+
|
||||
+ if (!node)
|
||||
+ return;
|
||||
+
|
||||
+ if (is_root && e) {
|
||||
+ area.x += gappx;
|
||||
+ area.y += gappx;
|
||||
+ area.width -= 2 * gappx;
|
||||
+ area.height -= 2 * gappx;
|
||||
+ }
|
||||
+
|
||||
+ /* If this node is a client node, check if it is visible. */
|
||||
+ if (node->is_client_node) {
|
||||
+ c = node->client;
|
||||
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ return;
|
||||
+ resize(c, area, 0);
|
||||
+ c->old_geom = area;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* For a split node, we see how many visible children are on each side: */
|
||||
+ left_count = visible_count(node->left, m);
|
||||
+ right_count = visible_count(node->right, m);
|
||||
+
|
||||
+ if (left_count == 0 && right_count == 0) {
|
||||
+ return;
|
||||
+ } else if (left_count > 0 && right_count == 0) {
|
||||
+ apply_layout(m, node->left, area, 0);
|
||||
+ return;
|
||||
+ } else if (left_count == 0 && right_count > 0) {
|
||||
+ apply_layout(m, node->right, area, 0);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* If we’re here, we have visible clients in both subtrees. */
|
||||
+ ratio = node->split_ratio;
|
||||
+ if (ratio < 0.05f)
|
||||
+ ratio = 0.05f;
|
||||
+ if (ratio > 0.95f)
|
||||
+ ratio = 0.95f;
|
||||
+
|
||||
+ memset(&left_area, 0, sizeof(left_area));
|
||||
+ memset(&right_area, 0, sizeof(right_area));
|
||||
+
|
||||
+ if (node->is_split_vertically) {
|
||||
+ mid = (unsigned int)(area.width * ratio);
|
||||
+ left_area.x = area.x;
|
||||
+ left_area.y = area.y;
|
||||
+ left_area.width = mid;
|
||||
+ left_area.height = area.height;
|
||||
+
|
||||
+ right_area.x = area.x + mid;
|
||||
+ right_area.y = area.y;
|
||||
+ right_area.width = area.width - mid;
|
||||
+ right_area.height = area.height;
|
||||
+
|
||||
+ if (e) {
|
||||
+ left_area.width -= gappx / 2;
|
||||
+ right_area.x += gappx / 2;
|
||||
+ right_area.width -= gappx / 2;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* horizontal split */
|
||||
+ mid = (unsigned int)(area.height * ratio);
|
||||
+ left_area.x = area.x;
|
||||
+ left_area.y = area.y;
|
||||
+ left_area.width = area.width;
|
||||
+ left_area.height = mid;
|
||||
+
|
||||
+ right_area.x = area.x;
|
||||
+ right_area.y = area.y + mid;
|
||||
+ right_area.width = area.width;
|
||||
+ right_area.height= area.height - mid;
|
||||
+
|
||||
+ if (e) {
|
||||
+ left_area.height -= gappx / 2;
|
||||
+ right_area.y += gappx / 2;
|
||||
+ right_area.height -= gappx / 2;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ apply_layout(m, node->left, left_area, 0);
|
||||
+ apply_layout(m, node->right, right_area, 0);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+btrtile(Monitor *m)
|
||||
+{
|
||||
+ Client *c, *focused = NULL;
|
||||
+ int n = 0;
|
||||
+ LayoutNode *found;
|
||||
+ struct wlr_box full_area;
|
||||
+
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+
|
||||
+ /* Remove non tiled clients from tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
|
||||
+ } else {
|
||||
+ remove_client(m, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client is found under cursor, fallback to focustop(m) */
|
||||
+ if (!(focused = xytoclient(cursor->x, cursor->y)))
|
||||
+ focused = focustop(m);
|
||||
+
|
||||
+ /* Insert visible clients that are not part of the tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen && c->mon == m) {
|
||||
+ found = find_client_node(m->root, c);
|
||||
+ if (!found) {
|
||||
+ insert_client(m, focused, c);
|
||||
+ }
|
||||
+ n++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ full_area = m->w;
|
||||
+ apply_layout(m, m->root, full_area, 1);
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+create_client_node(Client *c)
|
||||
+{
|
||||
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
|
||||
+
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ node->is_client_node = 1;
|
||||
+ node->split_ratio = 0.5f;
|
||||
+ node->client = c;
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+create_split_node(unsigned int is_split_vertically,
|
||||
+ LayoutNode *left, LayoutNode *right)
|
||||
+{
|
||||
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
|
||||
+
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ node->is_client_node = 0;
|
||||
+ node->split_ratio = 0.5f;
|
||||
+ node->is_split_vertically = is_split_vertically;
|
||||
+ node->left = left;
|
||||
+ node->right = right;
|
||||
+ if (left)
|
||||
+ left->split_node = node;
|
||||
+ if (right)
|
||||
+ right->split_node = node;
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+destroy_node(LayoutNode *node)
|
||||
+{
|
||||
+ if (!node)
|
||||
+ return;
|
||||
+ if (!node->is_client_node) {
|
||||
+ destroy_node(node->left);
|
||||
+ destroy_node(node->right);
|
||||
+ }
|
||||
+ free(node);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+destroy_tree(Monitor *m)
|
||||
+{
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+ destroy_node(m->root);
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_client_node(LayoutNode *node, Client *c)
|
||||
+{
|
||||
+ LayoutNode *res;
|
||||
+
|
||||
+ if (!node || !c)
|
||||
+ return NULL;
|
||||
+ if (node->is_client_node) {
|
||||
+ return (node->client == c) ? node : NULL;
|
||||
+ }
|
||||
+ res = find_client_node(node->left, c);
|
||||
+ return res ? res : find_client_node(node->right, c);
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
|
||||
+{
|
||||
+ LayoutNode *n = start_node;
|
||||
+ /* if we started from a client node, jump to its parent: */
|
||||
+ if (n && n->is_client_node)
|
||||
+ n = n->split_node;
|
||||
+
|
||||
+ while (n) {
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
|
||||
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
|
||||
+ return n;
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+init_tree(Monitor *m)
|
||||
+{
|
||||
+ if (!m)
|
||||
+ return;
|
||||
+ m->root = calloc(1, sizeof(LayoutNode));
|
||||
+ if (!m->root)
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+insert_client(Monitor *m, Client *focused_client, Client *new_client)
|
||||
+{
|
||||
+ Client *old_client;
|
||||
+ LayoutNode **root = &m->root, *old_root,
|
||||
+ *focused_node, *new_client_node, *old_client_node;
|
||||
+ unsigned int wider, mid_x, mid_y;
|
||||
+
|
||||
+ /* If no root , new client becomes the root. */
|
||||
+ if (!*root) {
|
||||
+ *root = create_client_node(new_client);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Find the focused_client node,
|
||||
+ * if not found split the root. */
|
||||
+ focused_node = focused_client ?
|
||||
+ find_client_node(*root, focused_client) : NULL;
|
||||
+ if (!focused_node) {
|
||||
+ old_root = *root;
|
||||
+ new_client_node = create_client_node(new_client);
|
||||
+ *root = create_split_node(1, old_root, new_client_node);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Turn focused node from a client node into a split node,
|
||||
+ * and attach old_client + new_client. */
|
||||
+ old_client = focused_node->client;
|
||||
+ old_client_node = create_client_node(old_client);
|
||||
+ new_client_node = create_client_node(new_client);
|
||||
+
|
||||
+ /* Decide split direction. */
|
||||
+ wider = (focused_client->geom.width >= focused_client->geom.height);
|
||||
+ focused_node->is_client_node = 0;
|
||||
+ focused_node->client = NULL;
|
||||
+ focused_node->is_split_vertically = (wider ? 1 : 0);
|
||||
+
|
||||
+ /* Pick new_client side depending on the cursor position. */
|
||||
+ mid_x = focused_client->geom.x + focused_client->geom.width / 2;
|
||||
+ mid_y = focused_client->geom.y + focused_client->geom.height / 2;
|
||||
+
|
||||
+ if (wider) {
|
||||
+ /* vertical split => left vs right */
|
||||
+ if (cursor->x <= mid_x) {
|
||||
+ focused_node->left = new_client_node;
|
||||
+ focused_node->right = old_client_node;
|
||||
+ } else {
|
||||
+ focused_node->left = old_client_node;
|
||||
+ focused_node->right = new_client_node;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* horizontal split => top vs bottom */
|
||||
+ if (cursor->y <= mid_y) {
|
||||
+ focused_node->left = new_client_node;
|
||||
+ focused_node->right = old_client_node;
|
||||
+ } else {
|
||||
+ focused_node->left = old_client_node;
|
||||
+ focused_node->right = new_client_node;
|
||||
+ }
|
||||
+ }
|
||||
+ old_client_node->split_node = focused_node;
|
||||
+ new_client_node->split_node = focused_node;
|
||||
+ focused_node->split_ratio = 0.5f;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+remove_client_node(LayoutNode *node, Client *c)
|
||||
+{
|
||||
+ LayoutNode *tmp;
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ if (node->is_client_node) {
|
||||
+ /* If this client_node is the client we're removing,
|
||||
+ * return NULL to remove it */
|
||||
+ if (node->client == c) {
|
||||
+ free(node);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return node;
|
||||
+ }
|
||||
+
|
||||
+ node->left = remove_client_node(node->left, c);
|
||||
+ node->right = remove_client_node(node->right, c);
|
||||
+
|
||||
+ /* If one of the client node is NULL after removal and the other is not,
|
||||
+ * we "lift" the other client node up to replace this split node. */
|
||||
+ if (!node->left && node->right) {
|
||||
+ tmp = node->right;
|
||||
+
|
||||
+ /* Save pointer to split node */
|
||||
+ if (tmp)
|
||||
+ tmp->split_node = node->split_node;
|
||||
+
|
||||
+ free(node);
|
||||
+ return tmp;
|
||||
+ }
|
||||
+
|
||||
+ if (!node->right && node->left) {
|
||||
+ tmp = node->left;
|
||||
+
|
||||
+ /* Save pointer to split node */
|
||||
+ if (tmp)
|
||||
+ tmp->split_node = node->split_node;
|
||||
+
|
||||
+ free(node);
|
||||
+ return tmp;
|
||||
+ }
|
||||
+
|
||||
+ /* If both children exist or both are NULL (empty tree),
|
||||
+ * return node as is. */
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+remove_client(Monitor *m, Client *c)
|
||||
+{
|
||||
+ if (!m->root || !c)
|
||||
+ return;
|
||||
+ m->root = remove_client_node(m->root, c);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 1);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_v(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 0);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void swapclients(const Arg *arg) {
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ LayoutNode *sel_node, *target_node;
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ cand_center_x, cand_center_y;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+unsigned int
|
||||
+visible_count(LayoutNode *node, Monitor *m)
|
||||
+{
|
||||
+ Client *c;
|
||||
+
|
||||
+ if (!node)
|
||||
+ return 0;
|
||||
+ /* Check if this client is visible. */
|
||||
+ if (node->is_client_node) {
|
||||
+ c = node->client;
|
||||
+ if (c && VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* Else it’s a split node. */
|
||||
+ return visible_count(node->left, m) + visible_count(node->right, m);
|
||||
+}
|
||||
+
|
||||
+Client *
|
||||
+xytoclient(double x, double y) {
|
||||
+ Client *c, *closest = NULL;
|
||||
+ double dist, mindist = INT_MAX, dx, dy;
|
||||
+
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
|
||||
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
|
||||
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
|
||||
+ return c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client was found at cursor position fallback to closest. */
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
|
||||
+ dx = 0, dy = 0;
|
||||
+
|
||||
+ if (x < c->geom.x)
|
||||
+ dx = c->geom.x - x;
|
||||
+ else if (x > (c->geom.x + c->geom.width))
|
||||
+ dx = x - (c->geom.x + c->geom.width);
|
||||
+
|
||||
+ if (y < c->geom.y)
|
||||
+ dy = c->geom.y - y;
|
||||
+ else if (y > (c->geom.y + c->geom.height))
|
||||
+ dy = y - (c->geom.y + c->geom.height);
|
||||
+
|
||||
+ dist = sqrt(dx * dx + dy * dy);
|
||||
+ if (dist < mindist) {
|
||||
+ mindist = dist;
|
||||
+ closest = c;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return closest;
|
||||
+}
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..bc04e3f 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -13,7 +13,10 @@ 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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
|
||||
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
|
||||
|
||||
+enum Direction { DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN };
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
@@ -30,6 +33,7 @@ static const Rule rules[] = {
|
||||
/* layout(s) */
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
+ { "|w|", btrtile },
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
@@ -144,6 +148,14 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 8101ffa..e4e7074 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* See LICENSE file for copyright and license details.
|
||||
*/
|
||||
+#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <libinput.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
@@ -104,6 +105,7 @@ typedef struct {
|
||||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
+typedef struct LayoutNode LayoutNode;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
@@ -141,8 +143,9 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, was_tiled;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ struct wlr_box old_geom;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -209,6 +212,7 @@ struct Monitor {
|
||||
int nmaster;
|
||||
char ltsymbol[16];
|
||||
int asleep;
|
||||
+ LayoutNode *root;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -251,6 +255,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
+static void btrtile(Monitor *m);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
@@ -333,6 +338,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
+static void setratio_h(const Arg *arg);
|
||||
+static void setratio_v(const Arg *arg);
|
||||
+static void swapclients(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -458,6 +466,7 @@ static struct wlr_xwayland *xwayland;
|
||||
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
+#include "btrtile.c"
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
@@ -628,7 +637,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
struct wlr_pointer_button_event *event = data;
|
||||
struct wlr_keyboard *keyboard;
|
||||
uint32_t mods;
|
||||
- Client *c;
|
||||
+ Client *c, *target = NULL;
|
||||
const Button *b;
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
@@ -649,7 +658,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
|
||||
- event->button == b->button && b->func) {
|
||||
+ event->button == b->button && b->func) {
|
||||
b->func(&b->arg);
|
||||
return;
|
||||
}
|
||||
@@ -659,6 +668,27 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||
/* TODO: should reset to the pointer focus's current setcursor */
|
||||
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
|
||||
+ c = grabc;
|
||||
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
|
||||
+ if (cursor_mode == CurMove && c->isfloating) {
|
||||
+ target = xytoclient(cursor->x, cursor->y);
|
||||
+
|
||||
+ if (target && !target->isfloating && !target->isfullscreen)
|
||||
+ insert_client(selmon, target, c);
|
||||
+ else
|
||||
+ selmon->root = create_client_node(c);
|
||||
+
|
||||
+ setfloating(c, 0);
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ } else if (cursor_mode == CurResize && !c->isfloating) {
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (cursor_mode == CurResize && resizing_from_mouse)
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ /* Default behaviour */
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
cursor_mode = CurNormal;
|
||||
/* Drop the window off on its new monitor */
|
||||
@@ -750,6 +780,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
+ destroy_tree(m);
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -1094,6 +1125,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
+ init_tree(m);
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
@@ -1336,6 +1368,10 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->destroy.link);
|
||||
wl_list_remove(&c->set_title.link);
|
||||
wl_list_remove(&c->fullscreen.link);
|
||||
+ /* We check if the destroyed client was part of any tiled_list, to catch
|
||||
+ * client removals even if they would not be currently managed by btrtile */
|
||||
+ if (selmon && selmon->root)
|
||||
+ remove_client(selmon, c);
|
||||
#ifdef XWAYLAND
|
||||
if (c->type != XDGShell) {
|
||||
wl_list_remove(&c->activate.link);
|
||||
@@ -1866,7 +1902,8 @@ void
|
||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||
double dx_unaccel, double dy_unaccel)
|
||||
{
|
||||
- double sx = 0, sy = 0, sx_confined, sy_confined;
|
||||
+ int tiled = 0;
|
||||
+ double sx = 0, sy = 0, sx_confined, sy_confined, dx_total, dy_total;
|
||||
Client *c = NULL, *w = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@@ -1920,18 +1957,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* Update drag icon's position */
|
||||
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
|
||||
|
||||
- /* If we are currently grabbing the mouse, handle and return */
|
||||
+ /* Skip if internal call or already resizing */
|
||||
+ if (time == 0 && resizing_from_mouse)
|
||||
+ goto focus;
|
||||
+
|
||||
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
|
||||
if (cursor_mode == CurMove) {
|
||||
/* Move the grabbed client to the new position. */
|
||||
- resize(grabc, (struct wlr_box){.x = (int)round(cursor->x) - grabcx, .y = (int)round(cursor->y) - grabcy,
|
||||
- .width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
||||
- return;
|
||||
+ if (grabc && grabc->isfloating) {
|
||||
+ resize(grabc, (struct wlr_box){
|
||||
+ .x = (int)round(cursor->x) - grabcx,
|
||||
+ .y = (int)round(cursor->y) - grabcy,
|
||||
+ .width = grabc->geom.width,
|
||||
+ .height = grabc->geom.height
|
||||
+ }, 1);
|
||||
+ return;
|
||||
+ }
|
||||
} else if (cursor_mode == CurResize) {
|
||||
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
- return;
|
||||
+ if (tiled && resizing_from_mouse) {
|
||||
+ dx_total = cursor->x - resize_last_update_x;
|
||||
+ dy_total = cursor->y - resize_last_update_y;
|
||||
+
|
||||
+ if (time - last_resize_time >= resize_interval_ms) {
|
||||
+ Arg a = {0};
|
||||
+ if (fabs(dx_total) > fabs(dy_total)) {
|
||||
+ a.f = (float)(dx_total * resize_factor);
|
||||
+ setratio_h(&a);
|
||||
+ } else {
|
||||
+ a.f = (float)(dy_total * resize_factor);
|
||||
+ setratio_v(&a);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ last_resize_time = time;
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ }
|
||||
+
|
||||
+ } else if (grabc && grabc->isfloating) {
|
||||
+ /* Floating resize as original */
|
||||
+ resize(grabc, (struct wlr_box){
|
||||
+ .x = grabc->geom.x,
|
||||
+ .y = grabc->geom.y,
|
||||
+ .width = (int)round(cursor->x) - grabc->geom.x,
|
||||
+ .height = (int)round(cursor->y) - grabc->geom.y
|
||||
+ }, 1);
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
+focus:
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
* off of a client or over its border. */
|
||||
@@ -1965,22 +2040,41 @@ moveresize(const Arg *arg)
|
||||
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
|
||||
return;
|
||||
|
||||
- /* Float the window and tell motionnotify to grab it */
|
||||
- setfloating(grabc, 1);
|
||||
- switch (cursor_mode = arg->ui) {
|
||||
- case CurMove:
|
||||
- grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
- grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
|
||||
- break;
|
||||
- case CurResize:
|
||||
- /* Doesn't work for X11 output - the next absolute motion event
|
||||
- * returns the cursor to where it started */
|
||||
- wlr_cursor_warp_closest(cursor, NULL,
|
||||
- grabc->geom.x + grabc->geom.width,
|
||||
- grabc->geom.y + grabc->geom.height);
|
||||
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
- break;
|
||||
+ cursor_mode = arg->ui;
|
||||
+ grabc->was_tiled = (!grabc->isfloating && !grabc->isfullscreen);
|
||||
+
|
||||
+ if (grabc->was_tiled) {
|
||||
+ switch (cursor_mode) {
|
||||
+ case CurMove:
|
||||
+ setfloating(grabc, 1);
|
||||
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
|
||||
+ break;
|
||||
+ case CurResize:
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ resizing_from_mouse = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Default floating logic */
|
||||
+ /* Float the window and tell motionnotify to grab it */
|
||||
+ setfloating(grabc, 1);
|
||||
+ switch (cursor_mode) {
|
||||
+ case CurMove:
|
||||
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
|
||||
+ break;
|
||||
+ case CurResize:
|
||||
+ wlr_cursor_warp_closest(cursor, NULL,
|
||||
+ grabc->geom.x + grabc->geom.width,
|
||||
+ grabc->geom.y + grabc->geom.height);
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -0,0 +1,894 @@
|
||||
From 912701a41b19c013a9adcb176a7b6503aa1cf9c1 Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Thu, 19 Mar 2026 22:56:45 +0200
|
||||
Subject: [PATCH] Refactor btrtile to wlroots-next
|
||||
|
||||
---
|
||||
btrtile.c | 565 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
config.def.h | 12 ++
|
||||
dwl.c | 148 +++++++++++---
|
||||
3 files changed, 698 insertions(+), 27 deletions(-)
|
||||
create mode 100644 btrtile.c
|
||||
|
||||
diff --git a/btrtile.c b/btrtile.c
|
||||
new file mode 100644
|
||||
index 0000000..d706c3b
|
||||
--- /dev/null
|
||||
+++ b/btrtile.c
|
||||
@@ -0,0 +1,565 @@
|
||||
+/* ************************************************************************** */
|
||||
+/* @@@ @@@@@@@@ */
|
||||
+/* @@@ @@@@@@@@@@ */
|
||||
+/* @@! @@! @@@@ */
|
||||
+/* !@! !@! @!@!@ */
|
||||
+/* btrtile.c @!! @!@ @! !@! */
|
||||
+/* !!! !@!!! !!! */
|
||||
+/* By: julmajustus <julmajustus@tutanota.com> !!: !!:! !!! */
|
||||
+/* ::! :!: !:! */
|
||||
+/* Created: 2024/12/15 00:26:07 by julmajustus :: ::::::: :: */
|
||||
+/* Updated: 2026/03/18 20:26:17 by julmajustus : : : : : : */
|
||||
+/* */
|
||||
+/* ************************************************************************** */
|
||||
+
|
||||
+typedef struct LayoutNode {
|
||||
+ unsigned int is_client_node;
|
||||
+ unsigned int is_split_vertically;
|
||||
+ float split_ratio;
|
||||
+ struct LayoutNode *left;
|
||||
+ struct LayoutNode *right;
|
||||
+ struct LayoutNode *split_node;
|
||||
+ Client *client;
|
||||
+} LayoutNode;
|
||||
+
|
||||
+static void apply_layout(Monitor *m, LayoutNode *node,
|
||||
+ struct wlr_box area, unsigned int is_root);
|
||||
+static void btrtile(Monitor *m);
|
||||
+static LayoutNode *create_client_node(Client *c);
|
||||
+static LayoutNode *create_split_node(unsigned int is_split_vertically,
|
||||
+ LayoutNode *left, LayoutNode *right);
|
||||
+static void destroy_node(LayoutNode *node);
|
||||
+static void destroy_tree(Monitor *m);
|
||||
+static LayoutNode *find_client_node(LayoutNode *node, Client *c);
|
||||
+static LayoutNode *find_suitable_split(LayoutNode *start, unsigned int need_vert);
|
||||
+static void init_tree(Monitor *m);
|
||||
+static void insert_client(Monitor *m, Client *focused_client, Client *new_client);
|
||||
+static LayoutNode *remove_client_node(LayoutNode *node, Client *c);
|
||||
+static void remove_client(Monitor *m, Client *c);
|
||||
+static void setratio_h(const Arg *arg);
|
||||
+static void setratio_v(const Arg *arg);
|
||||
+static void swapclients(const Arg *arg);
|
||||
+static unsigned int visible_count(LayoutNode *node, Monitor *m);
|
||||
+static Client *xytoclient(double x, double y);
|
||||
+
|
||||
+static int resizing_from_mouse = 0;
|
||||
+static double resize_last_update_x, resize_last_update_y;
|
||||
+static uint32_t last_resize_time = 0;
|
||||
+
|
||||
+void
|
||||
+apply_layout(Monitor *m, LayoutNode *node,
|
||||
+ struct wlr_box area, unsigned int is_root)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ float ratio;
|
||||
+ unsigned int left_count, right_count, mid;
|
||||
+ struct wlr_box left_area, right_area;
|
||||
+
|
||||
+ if (!node)
|
||||
+ return;
|
||||
+
|
||||
+ /* If this node is a client node, check if it is visible. */
|
||||
+ if (node->is_client_node) {
|
||||
+ c = node->client;
|
||||
+ if (!c || !VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ return;
|
||||
+ resize(c, area, 0);
|
||||
+ c->old_geom = area;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* For a split node, we see how many visible children are on each side: */
|
||||
+ left_count = visible_count(node->left, m);
|
||||
+ right_count = visible_count(node->right, m);
|
||||
+
|
||||
+ if (left_count == 0 && right_count == 0) {
|
||||
+ return;
|
||||
+ } else if (left_count > 0 && right_count == 0) {
|
||||
+ apply_layout(m, node->left, area, 0);
|
||||
+ return;
|
||||
+ } else if (left_count == 0 && right_count > 0) {
|
||||
+ apply_layout(m, node->right, area, 0);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* If we’re here, we have visible clients in both subtrees. */
|
||||
+ ratio = node->split_ratio;
|
||||
+ if (ratio < 0.05f)
|
||||
+ ratio = 0.05f;
|
||||
+ if (ratio > 0.95f)
|
||||
+ ratio = 0.95f;
|
||||
+
|
||||
+ memset(&left_area, 0, sizeof(left_area));
|
||||
+ memset(&right_area, 0, sizeof(right_area));
|
||||
+
|
||||
+ if (node->is_split_vertically) {
|
||||
+ mid = (unsigned int)(area.width * ratio);
|
||||
+ left_area.x = area.x;
|
||||
+ left_area.y = area.y;
|
||||
+ left_area.width = mid;
|
||||
+ left_area.height = area.height;
|
||||
+
|
||||
+ right_area.x = area.x + mid;
|
||||
+ right_area.y = area.y;
|
||||
+ right_area.width = area.width - mid;
|
||||
+ right_area.height = area.height;
|
||||
+ } else {
|
||||
+ /* horizontal split */
|
||||
+ mid = (unsigned int)(area.height * ratio);
|
||||
+ left_area.x = area.x;
|
||||
+ left_area.y = area.y;
|
||||
+ left_area.width = area.width;
|
||||
+ left_area.height = mid;
|
||||
+
|
||||
+ right_area.x = area.x;
|
||||
+ right_area.y = area.y + mid;
|
||||
+ right_area.width = area.width;
|
||||
+ right_area.height= area.height - mid;
|
||||
+ }
|
||||
+
|
||||
+ apply_layout(m, node->left, left_area, 0);
|
||||
+ apply_layout(m, node->right, right_area, 0);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+btrtile(Monitor *m)
|
||||
+{
|
||||
+ Client *c, *focused = NULL;
|
||||
+ int n = 0;
|
||||
+ LayoutNode *found;
|
||||
+ struct wlr_box full_area;
|
||||
+
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+
|
||||
+ /* Remove non tiled clients from tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon == m && !c->isfloating && !c->isfullscreen) {
|
||||
+ } else {
|
||||
+ remove_client(m, c);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client is found under cursor, fallback to focustop(m) */
|
||||
+ if (!(focused = xytoclient(cursor->x, cursor->y)))
|
||||
+ focused = focustop(m);
|
||||
+
|
||||
+ /* Insert visible clients that are not part of the tree. */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen && c->mon == m) {
|
||||
+ found = find_client_node(m->root, c);
|
||||
+ if (!found) {
|
||||
+ insert_client(m, focused, c);
|
||||
+ }
|
||||
+ n++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ full_area = m->w;
|
||||
+ apply_layout(m, m->root, full_area, 1);
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+create_client_node(Client *c)
|
||||
+{
|
||||
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
|
||||
+
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ node->is_client_node = 1;
|
||||
+ node->split_ratio = 0.5f;
|
||||
+ node->client = c;
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+create_split_node(unsigned int is_split_vertically,
|
||||
+ LayoutNode *left, LayoutNode *right)
|
||||
+{
|
||||
+ LayoutNode *node = calloc(1, sizeof(LayoutNode));
|
||||
+
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ node->is_client_node = 0;
|
||||
+ node->split_ratio = 0.5f;
|
||||
+ node->is_split_vertically = is_split_vertically;
|
||||
+ node->left = left;
|
||||
+ node->right = right;
|
||||
+ if (left)
|
||||
+ left->split_node = node;
|
||||
+ if (right)
|
||||
+ right->split_node = node;
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+destroy_node(LayoutNode *node)
|
||||
+{
|
||||
+ if (!node)
|
||||
+ return;
|
||||
+ if (!node->is_client_node) {
|
||||
+ destroy_node(node->left);
|
||||
+ destroy_node(node->right);
|
||||
+ }
|
||||
+ free(node);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+destroy_tree(Monitor *m)
|
||||
+{
|
||||
+ if (!m || !m->root)
|
||||
+ return;
|
||||
+ destroy_node(m->root);
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_client_node(LayoutNode *node, Client *c)
|
||||
+{
|
||||
+ LayoutNode *res;
|
||||
+
|
||||
+ if (!node || !c)
|
||||
+ return NULL;
|
||||
+ if (node->is_client_node) {
|
||||
+ return (node->client == c) ? node : NULL;
|
||||
+ }
|
||||
+ res = find_client_node(node->left, c);
|
||||
+ return res ? res : find_client_node(node->right, c);
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+find_suitable_split(LayoutNode *start_node, unsigned int need_vertical)
|
||||
+{
|
||||
+ LayoutNode *n = start_node;
|
||||
+ /* if we started from a client node, jump to its parent: */
|
||||
+ if (n && n->is_client_node)
|
||||
+ n = n->split_node;
|
||||
+
|
||||
+ while (n) {
|
||||
+ if (!n->is_client_node && n->is_split_vertically == need_vertical &&
|
||||
+ visible_count(n->left, selmon) > 0 && visible_count(n->right, selmon) > 0)
|
||||
+ return n;
|
||||
+ n = n->split_node;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+init_tree(Monitor *m)
|
||||
+{
|
||||
+ if (!m)
|
||||
+ return;
|
||||
+ m->root = calloc(1, sizeof(LayoutNode));
|
||||
+ if (!m->root)
|
||||
+ m->root = NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+insert_client(Monitor *m, Client *focused_client, Client *new_client)
|
||||
+{
|
||||
+ Client *old_client;
|
||||
+ LayoutNode **root = &m->root, *old_root,
|
||||
+ *focused_node, *new_client_node, *old_client_node;
|
||||
+ unsigned int wider, mid_x, mid_y;
|
||||
+
|
||||
+ /* If no root , new client becomes the root. */
|
||||
+ if (!*root) {
|
||||
+ *root = create_client_node(new_client);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Find the focused_client node,
|
||||
+ * if not found split the root. */
|
||||
+ focused_node = focused_client ?
|
||||
+ find_client_node(*root, focused_client) : NULL;
|
||||
+ if (!focused_node) {
|
||||
+ old_root = *root;
|
||||
+ new_client_node = create_client_node(new_client);
|
||||
+ *root = create_split_node(1, old_root, new_client_node);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Turn focused node from a client node into a split node,
|
||||
+ * and attach old_client + new_client. */
|
||||
+ old_client = focused_node->client;
|
||||
+ old_client_node = create_client_node(old_client);
|
||||
+ new_client_node = create_client_node(new_client);
|
||||
+
|
||||
+ /* Decide split direction. */
|
||||
+ wider = (focused_client->geom.width >= focused_client->geom.height);
|
||||
+ focused_node->is_client_node = 0;
|
||||
+ focused_node->client = NULL;
|
||||
+ focused_node->is_split_vertically = (wider ? 1 : 0);
|
||||
+
|
||||
+ /* Pick new_client side depending on the cursor position. */
|
||||
+ mid_x = focused_client->geom.x + focused_client->geom.width / 2;
|
||||
+ mid_y = focused_client->geom.y + focused_client->geom.height / 2;
|
||||
+
|
||||
+ if (wider) {
|
||||
+ /* vertical split => left vs right */
|
||||
+ if (cursor->x <= mid_x) {
|
||||
+ focused_node->left = new_client_node;
|
||||
+ focused_node->right = old_client_node;
|
||||
+ } else {
|
||||
+ focused_node->left = old_client_node;
|
||||
+ focused_node->right = new_client_node;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* horizontal split => top vs bottom */
|
||||
+ if (cursor->y <= mid_y) {
|
||||
+ focused_node->left = new_client_node;
|
||||
+ focused_node->right = old_client_node;
|
||||
+ } else {
|
||||
+ focused_node->left = old_client_node;
|
||||
+ focused_node->right = new_client_node;
|
||||
+ }
|
||||
+ }
|
||||
+ old_client_node->split_node = focused_node;
|
||||
+ new_client_node->split_node = focused_node;
|
||||
+ focused_node->split_ratio = 0.5f;
|
||||
+}
|
||||
+
|
||||
+LayoutNode *
|
||||
+remove_client_node(LayoutNode *node, Client *c)
|
||||
+{
|
||||
+ LayoutNode *tmp;
|
||||
+ if (!node)
|
||||
+ return NULL;
|
||||
+ if (node->is_client_node) {
|
||||
+ /* If this client_node is the client we're removing,
|
||||
+ * return NULL to remove it */
|
||||
+ if (node->client == c) {
|
||||
+ free(node);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return node;
|
||||
+ }
|
||||
+
|
||||
+ node->left = remove_client_node(node->left, c);
|
||||
+ node->right = remove_client_node(node->right, c);
|
||||
+
|
||||
+ /* If one of the client node is NULL after removal and the other is not,
|
||||
+ * we "lift" the other client node up to replace this split node. */
|
||||
+ if (!node->left && node->right) {
|
||||
+ tmp = node->right;
|
||||
+
|
||||
+ /* Save pointer to split node */
|
||||
+ if (tmp)
|
||||
+ tmp->split_node = node->split_node;
|
||||
+
|
||||
+ free(node);
|
||||
+ return tmp;
|
||||
+ }
|
||||
+
|
||||
+ if (!node->right && node->left) {
|
||||
+ tmp = node->left;
|
||||
+
|
||||
+ /* Save pointer to split node */
|
||||
+ if (tmp)
|
||||
+ tmp->split_node = node->split_node;
|
||||
+
|
||||
+ free(node);
|
||||
+ return tmp;
|
||||
+ }
|
||||
+
|
||||
+ /* If both children exist or both are NULL (empty tree),
|
||||
+ * return node as is. */
|
||||
+ return node;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+remove_client(Monitor *m, Client *c)
|
||||
+{
|
||||
+ if (!m->root || !c)
|
||||
+ return;
|
||||
+ m->root = remove_client_node(m->root, c);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_h(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 1);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+setratio_v(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ LayoutNode *client_node, *split_node;
|
||||
+ float new_ratio;
|
||||
+
|
||||
+ if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+ client_node = find_client_node(selmon->root, sel);
|
||||
+ if (!client_node)
|
||||
+ return;
|
||||
+
|
||||
+ split_node = find_suitable_split(client_node, 0);
|
||||
+ if (!split_node)
|
||||
+ return;
|
||||
+
|
||||
+ new_ratio = (arg->f != 0.0f) ? (split_node->split_ratio + arg->f) : 0.5f;
|
||||
+ if (new_ratio < 0.05f)
|
||||
+ new_ratio = 0.05f;
|
||||
+ if (new_ratio > 0.95f)
|
||||
+ new_ratio = 0.95f;
|
||||
+ split_node->split_ratio = new_ratio;
|
||||
+
|
||||
+ /* Skip the arrange if done resizing by mouse,
|
||||
+ * we call arrange from motionotify */
|
||||
+ if (!resizing_from_mouse) {
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void swapclients(const Arg *arg) {
|
||||
+ Client *c, *tmp, *target = NULL, *sel = focustop(selmon);
|
||||
+ LayoutNode *sel_node, *target_node;
|
||||
+ int closest_dist = INT_MAX, dist, sel_center_x, sel_center_y,
|
||||
+ cand_center_x, cand_center_y;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen ||
|
||||
+ !selmon->root || !selmon->lt[selmon->sellt]->arrange)
|
||||
+ return;
|
||||
+
|
||||
+
|
||||
+ /* Get the center coordinates of the selected client */
|
||||
+ sel_center_x = sel->geom.x + sel->geom.width / 2;
|
||||
+ sel_center_y = sel->geom.y + sel->geom.height / 2;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon) || c->isfloating || c->isfullscreen || c == sel)
|
||||
+ continue;
|
||||
+
|
||||
+ /* Get the center of candidate client */
|
||||
+ cand_center_x = c->geom.x + c->geom.width / 2;
|
||||
+ cand_center_y = c->geom.y + c->geom.height / 2;
|
||||
+
|
||||
+ /* Check that the candidate lies in the requested direction. */
|
||||
+ switch (arg->ui) {
|
||||
+ case 0:
|
||||
+ if (cand_center_x >= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ if (cand_center_x <= sel_center_x)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (cand_center_y >= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ if (cand_center_y <= sel_center_y)
|
||||
+ continue;
|
||||
+ break;
|
||||
+ default:
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* Get distance between the centers */
|
||||
+ dist = abs(sel_center_x - cand_center_x) + abs(sel_center_y - cand_center_y);
|
||||
+ if (dist < closest_dist) {
|
||||
+ closest_dist = dist;
|
||||
+ target = c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If target is found, swap the two clients’ positions in the layout tree */
|
||||
+ if (target) {
|
||||
+ sel_node = find_client_node(selmon->root, sel);
|
||||
+ target_node = find_client_node(selmon->root, target);
|
||||
+ if (sel_node && target_node) {
|
||||
+ tmp = sel_node->client;
|
||||
+ sel_node->client = target_node->client;
|
||||
+ target_node->client = tmp;
|
||||
+ arrange(selmon);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+unsigned int
|
||||
+visible_count(LayoutNode *node, Monitor *m)
|
||||
+{
|
||||
+ Client *c;
|
||||
+
|
||||
+ if (!node)
|
||||
+ return 0;
|
||||
+ /* Check if this client is visible. */
|
||||
+ if (node->is_client_node) {
|
||||
+ c = node->client;
|
||||
+ if (c && VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* Else it’s a split node. */
|
||||
+ return visible_count(node->left, m) + visible_count(node->right, m);
|
||||
+}
|
||||
+
|
||||
+Client *
|
||||
+xytoclient(double x, double y) {
|
||||
+ Client *c, *closest = NULL;
|
||||
+ double dist, mindist = INT_MAX, dx, dy;
|
||||
+
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen &&
|
||||
+ x >= c->geom.x && x <= (c->geom.x + c->geom.width) &&
|
||||
+ y >= c->geom.y && y <= (c->geom.y + c->geom.height)){
|
||||
+ return c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* If no client was found at cursor position fallback to closest. */
|
||||
+ wl_list_for_each_reverse(c, &clients, link) {
|
||||
+ if (VISIBLEON(c, selmon) && !c->isfloating && !c->isfullscreen) {
|
||||
+ dx = 0, dy = 0;
|
||||
+
|
||||
+ if (x < c->geom.x)
|
||||
+ dx = c->geom.x - x;
|
||||
+ else if (x > (c->geom.x + c->geom.width))
|
||||
+ dx = x - (c->geom.x + c->geom.width);
|
||||
+
|
||||
+ if (y < c->geom.y)
|
||||
+ dy = c->geom.y - y;
|
||||
+ else if (y > (c->geom.y + c->geom.height))
|
||||
+ dy = y - (c->geom.y + c->geom.height);
|
||||
+
|
||||
+ dist = sqrt(dx * dx + dy * dy);
|
||||
+ if (dist < mindist) {
|
||||
+ mindist = dist;
|
||||
+ closest = c;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return closest;
|
||||
+}
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..bc04e3f 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -13,7 +13,10 @@ 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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
+static const float resize_factor = 0.0002f; /* Resize multiplier for mouse resizing, depends on mouse sensivity. */
|
||||
+static const uint32_t resize_interval_ms = 16; /* Resize interval depends on framerate and screen refresh rate. */
|
||||
|
||||
+enum Direction { DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN };
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
|
||||
@@ -30,6 +33,7 @@ static const Rule rules[] = {
|
||||
/* layout(s) */
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
+ { "|w|", btrtile },
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
@@ -144,6 +148,14 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, swapclients, {.i = DIR_UP} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapclients, {.i = DIR_DOWN} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, swapclients, {.i = DIR_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, swapclients, {.i = DIR_LEFT} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Right, setratio_h, {.f = +0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Left, setratio_h, {.f = -0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Up, setratio_v, {.f = -0.025f} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_Down, setratio_v, {.f = +0.025f} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 8101ffa..e4e7074 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* See LICENSE file for copyright and license details.
|
||||
*/
|
||||
+#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <libinput.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
@@ -104,6 +105,7 @@ typedef struct {
|
||||
const Arg arg;
|
||||
} Button;
|
||||
|
||||
+typedef struct LayoutNode LayoutNode;
|
||||
typedef struct Monitor Monitor;
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
@@ -141,8 +143,9 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, was_tiled;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
+ struct wlr_box old_geom;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -209,6 +212,7 @@ struct Monitor {
|
||||
int nmaster;
|
||||
char ltsymbol[16];
|
||||
int asleep;
|
||||
+ LayoutNode *root;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -251,6 +255,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
+static void btrtile(Monitor *m);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
@@ -333,6 +338,9 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
+static void setratio_h(const Arg *arg);
|
||||
+static void setratio_v(const Arg *arg);
|
||||
+static void swapclients(const Arg *arg);
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -458,6 +466,7 @@ static struct wlr_xwayland *xwayland;
|
||||
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
+#include "btrtile.c"
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
@@ -628,7 +637,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
struct wlr_pointer_button_event *event = data;
|
||||
struct wlr_keyboard *keyboard;
|
||||
uint32_t mods;
|
||||
- Client *c;
|
||||
+ Client *c, *target = NULL;
|
||||
const Button *b;
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
@@ -649,7 +658,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
|
||||
- event->button == b->button && b->func) {
|
||||
+ event->button == b->button && b->func) {
|
||||
b->func(&b->arg);
|
||||
return;
|
||||
}
|
||||
@@ -659,6 +668,27 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
/* If you released any buttons, we exit interactive move/resize mode. */
|
||||
/* TODO: should reset to the pointer focus's current setcursor */
|
||||
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
|
||||
+ c = grabc;
|
||||
+ if (c && c->was_tiled && !strcmp(selmon->ltsymbol, "|w|")) {
|
||||
+ if (cursor_mode == CurMove && c->isfloating) {
|
||||
+ target = xytoclient(cursor->x, cursor->y);
|
||||
+
|
||||
+ if (target && !target->isfloating && !target->isfullscreen)
|
||||
+ insert_client(selmon, target, c);
|
||||
+ else
|
||||
+ selmon->root = create_client_node(c);
|
||||
+
|
||||
+ setfloating(c, 0);
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ } else if (cursor_mode == CurResize && !c->isfloating) {
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (cursor_mode == CurResize && resizing_from_mouse)
|
||||
+ resizing_from_mouse = 0;
|
||||
+ }
|
||||
+ /* Default behaviour */
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
cursor_mode = CurNormal;
|
||||
/* Drop the window off on its new monitor */
|
||||
@@ -750,6 +780,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_remove(output_layout, m->wlr_output);
|
||||
wlr_scene_output_destroy(m->scene_output);
|
||||
|
||||
+ destroy_tree(m);
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
free(m);
|
||||
@@ -1094,6 +1125,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
+ init_tree(m);
|
||||
|
||||
/* The xdg-protocol specifies:
|
||||
*
|
||||
@@ -1336,6 +1368,10 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->destroy.link);
|
||||
wl_list_remove(&c->set_title.link);
|
||||
wl_list_remove(&c->fullscreen.link);
|
||||
+ /* We check if the destroyed client was part of any tiled_list, to catch
|
||||
+ * client removals even if they would not be currently managed by btrtile */
|
||||
+ if (selmon && selmon->root)
|
||||
+ remove_client(selmon, c);
|
||||
#ifdef XWAYLAND
|
||||
if (c->type != XDGShell) {
|
||||
wl_list_remove(&c->activate.link);
|
||||
@@ -1866,7 +1902,8 @@ void
|
||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||
double dx_unaccel, double dy_unaccel)
|
||||
{
|
||||
- double sx = 0, sy = 0, sx_confined, sy_confined;
|
||||
+ int tiled = 0;
|
||||
+ double sx = 0, sy = 0, sx_confined, sy_confined, dx_total, dy_total;
|
||||
Client *c = NULL, *w = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@@ -1920,18 +1957,56 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* Update drag icon's position */
|
||||
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
|
||||
|
||||
- /* If we are currently grabbing the mouse, handle and return */
|
||||
+ /* Skip if internal call or already resizing */
|
||||
+ if (time == 0 && resizing_from_mouse)
|
||||
+ goto focus;
|
||||
+
|
||||
+ tiled = grabc && !grabc->isfloating && !grabc->isfullscreen;
|
||||
if (cursor_mode == CurMove) {
|
||||
/* Move the grabbed client to the new position. */
|
||||
- resize(grabc, (struct wlr_box){.x = (int)round(cursor->x) - grabcx, .y = (int)round(cursor->y) - grabcy,
|
||||
- .width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
||||
- return;
|
||||
+ if (grabc && grabc->isfloating) {
|
||||
+ resize(grabc, (struct wlr_box){
|
||||
+ .x = (int)round(cursor->x) - grabcx,
|
||||
+ .y = (int)round(cursor->y) - grabcy,
|
||||
+ .width = grabc->geom.width,
|
||||
+ .height = grabc->geom.height
|
||||
+ }, 1);
|
||||
+ return;
|
||||
+ }
|
||||
} else if (cursor_mode == CurResize) {
|
||||
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
- return;
|
||||
+ if (tiled && resizing_from_mouse) {
|
||||
+ dx_total = cursor->x - resize_last_update_x;
|
||||
+ dy_total = cursor->y - resize_last_update_y;
|
||||
+
|
||||
+ if (time - last_resize_time >= resize_interval_ms) {
|
||||
+ Arg a = {0};
|
||||
+ if (fabs(dx_total) > fabs(dy_total)) {
|
||||
+ a.f = (float)(dx_total * resize_factor);
|
||||
+ setratio_h(&a);
|
||||
+ } else {
|
||||
+ a.f = (float)(dy_total * resize_factor);
|
||||
+ setratio_v(&a);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+
|
||||
+ last_resize_time = time;
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ }
|
||||
+
|
||||
+ } else if (grabc && grabc->isfloating) {
|
||||
+ /* Floating resize as original */
|
||||
+ resize(grabc, (struct wlr_box){
|
||||
+ .x = grabc->geom.x,
|
||||
+ .y = grabc->geom.y,
|
||||
+ .width = (int)round(cursor->x) - grabc->geom.x,
|
||||
+ .height = (int)round(cursor->y) - grabc->geom.y
|
||||
+ }, 1);
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
+focus:
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
* off of a client or over its border. */
|
||||
@@ -1965,22 +2040,41 @@ moveresize(const Arg *arg)
|
||||
if (!grabc || client_is_unmanaged(grabc) || grabc->isfullscreen)
|
||||
return;
|
||||
|
||||
- /* Float the window and tell motionnotify to grab it */
|
||||
- setfloating(grabc, 1);
|
||||
- switch (cursor_mode = arg->ui) {
|
||||
- case CurMove:
|
||||
- grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
- grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "all-scroll");
|
||||
- break;
|
||||
- case CurResize:
|
||||
- /* Doesn't work for X11 output - the next absolute motion event
|
||||
- * returns the cursor to where it started */
|
||||
- wlr_cursor_warp_closest(cursor, NULL,
|
||||
- grabc->geom.x + grabc->geom.width,
|
||||
- grabc->geom.y + grabc->geom.height);
|
||||
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
- break;
|
||||
+ cursor_mode = arg->ui;
|
||||
+ grabc->was_tiled = (!grabc->isfloating && !grabc->isfullscreen);
|
||||
+
|
||||
+ if (grabc->was_tiled) {
|
||||
+ switch (cursor_mode) {
|
||||
+ case CurMove:
|
||||
+ setfloating(grabc, 1);
|
||||
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
|
||||
+ break;
|
||||
+ case CurResize:
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ resize_last_update_x = cursor->x;
|
||||
+ resize_last_update_y = cursor->y;
|
||||
+ resizing_from_mouse = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Default floating logic */
|
||||
+ /* Float the window and tell motionnotify to grab it */
|
||||
+ setfloating(grabc, 1);
|
||||
+ switch (cursor_mode) {
|
||||
+ case CurMove:
|
||||
+ grabcx = (int)round(cursor->x) - grabc->geom.x;
|
||||
+ grabcy = (int)round(cursor->y) - grabc->geom.y;
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
|
||||
+ break;
|
||||
+ case CurResize:
|
||||
+ wlr_cursor_warp_closest(cursor, NULL,
|
||||
+ grabc->geom.x + grabc->geom.width,
|
||||
+ grabc->geom.y + grabc->geom.height);
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
### Description
|
||||
Add a keybinding that toggles centering the terminally horizontally when
|
||||
it's the only window, while still tiling multiple windows.
|
||||
|
||||
This limits the width of long text making it easier to read, and avoids
|
||||
covering the wallpaper more than necessary.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/center-terminal)
|
||||
- [2026-02-09](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/center-terminal/center-terminal.patch)
|
||||
|
||||
### Authors
|
||||
- [Guido Cella](https://codeberg.org/guidocella)
|
||||
@@ -0,0 +1,103 @@
|
||||
From 897765216ac8567a40654b813379a4e074ca6298 Mon Sep 17 00:00:00 2001
|
||||
From: Guido Cella <guido@guidocella.xyz>
|
||||
Date: Mon, 9 Feb 2026 10:21:33 +0100
|
||||
Subject: [PATCH] add a keybinding to center the terminal
|
||||
|
||||
Add a keybinding that toggles centering the terminally horizontally when
|
||||
it's the only window, while still tiling multiple windows.
|
||||
|
||||
This limits the width of long text making it easier to read, and avoids
|
||||
covering the wallpaper more than necessary.
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 20 ++++++++++++++++++++
|
||||
2 files changed, 21 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..8c35c40 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -138,6 +138,7 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_v, togglecenter, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ 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 44f3ad9..9ee397a 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
+#include <strings.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@@ -138,6 +139,7 @@ typedef struct {
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
+ bool centered;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
@@ -334,6 +336,7 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void togglecenter(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -436,6 +439,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
|
||||
+static bool center;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
static void associatex11(struct wl_listener *listener, void *data);
|
||||
@@ -499,6 +504,9 @@ applyrules(Client *c)
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!strcasecmp(appid, termcmd[0]))
|
||||
+ c->centered = true;
|
||||
+
|
||||
c->isfloating |= client_is_float_type(c);
|
||||
setmon(c, mon, newtags);
|
||||
}
|
||||
@@ -2731,6 +2739,11 @@ tile(Monitor *m)
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
+ if (n == 1 && center && c->centered) {
|
||||
+ resize(c, (struct wlr_box){.x = m->w.width / 4, .y = m->w.y,
|
||||
+ .width = m->w.width / 2, .height = m->w.height - 2 * c->bw}, 0);
|
||||
+ return;
|
||||
+ }
|
||||
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
my += c->geom.height;
|
||||
@@ -2743,6 +2756,13 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+togglecenter(const Arg *arg)
|
||||
+{
|
||||
+ center = !center;
|
||||
+ tile(selmon);
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -22,8 +22,6 @@ With one and two clients in master respectively this results in:
|
||||
+------------------------------+ +------------------------------+
|
||||
```
|
||||
|
||||
Version 0.8 includes `centeredmaster_always` setting to always center a window
|
||||
even if only 1 window is visible on a tag.
|
||||
|
||||
### Download
|
||||
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/centeredmaster/centeredmaster-0.8.patch)
|
||||
@@ -34,4 +32,3 @@ even if only 1 window is visible on a tag.
|
||||
### Authors
|
||||
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
- [metalcranium](https://codeberg.org/metalcranium)
|
||||
|
||||
@@ -78,16 +78,34 @@ index def2562..c2456dd 100644
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
# + /* initialize areas */
|
||||
# + mw = m->w.width;
|
||||
# + mx = 0;
|
||||
# + my = 0;
|
||||
# + tw = mw;
|
||||
# +
|
||||
# + if (n > m->nmaster) {
|
||||
# + /* go mfact box in the center if more than nmaster clients */
|
||||
# + mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
# + tw = m->w.width - mw;
|
||||
# +
|
||||
# + if (n - m->nmaster > 1) {
|
||||
# + /* only one client */
|
||||
# + mx = (m->w.width - mw) / 2;
|
||||
# + tw = (m->w.width - mw) / 2;
|
||||
# + }
|
||||
# + }
|
||||
+ /* initialize areas */
|
||||
+ mw = m->w.width;
|
||||
+ mx = 0;
|
||||
+ my = 0;
|
||||
+ tw = mw;
|
||||
+ mw = m->w.width - (m->w.width /2);
|
||||
+ mx = m->w.width / 4;
|
||||
+ my = 0;
|
||||
+ tw = mw;
|
||||
+
|
||||
+ if (n > m->nmaster) {
|
||||
+ /* go mfact box in the center if more than nmaster clients */
|
||||
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
+ tw = m->w.width - mw;
|
||||
+ // mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
+ // tw = m->w.width - mw;
|
||||
+ tw = mw / 2;
|
||||
+
|
||||
+ if (n - m->nmaster > 1) {
|
||||
+ /* only one client */
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
From d3d0000c3e2baa8c2a4633581186f768c909667a Mon Sep 17 00:00:00 2001
|
||||
From 1fb8c15bb02c50279a5ccbd410dc1293abb747f3 Mon Sep 17 00:00:00 2001
|
||||
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||
Date: Mon, 13 Apr 2026 18:24:17 +0200
|
||||
Date: Sat, 8 Feb 2025 16:10:25 +0100
|
||||
Subject: [PATCH] Add centeredmaster layout
|
||||
|
||||
---
|
||||
config.def.h | 3 +++
|
||||
dwl.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 76 insertions(+)
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 65 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..15cbe32 100644
|
||||
index 8a6eda0..70954cc 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -7,6 +7,7 @@
|
||||
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 int centeredmaster_always = 0; /* always center even if only 1 window */
|
||||
static const float rootcolor[] = COLOR(0x222222ff);
|
||||
static const float bordercolor[] = COLOR(0x444444ff);
|
||||
static const float focuscolor[] = COLOR(0x005577ff);
|
||||
@@ -33,6 +34,7 @@ static const Layout layouts[] = {
|
||||
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
@@ -28,7 +20,7 @@ index 8a6eda0..15cbe32 100644
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -135,6 +137,7 @@ static const Key keys[] = {
|
||||
@@ -135,6 +136,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
@@ -37,7 +29,7 @@ index 8a6eda0..15cbe32 100644
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..98ba318 100644
|
||||
index 44f3ad9..bf859b0 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -248,6 +248,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
@@ -48,7 +40,7 @@ index 44f3ad9..98ba318 100644
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
static void cleanup(void);
|
||||
@@ -672,6 +673,78 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
@@ -672,6 +673,68 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
@@ -66,25 +58,15 @@ index 44f3ad9..98ba318 100644
|
||||
+ return;
|
||||
+
|
||||
+ /* initialize areas */
|
||||
+ if (centeredmaster_always) {
|
||||
+ mw = m->w.width / 2;
|
||||
+ mx = m->w.width / 4;
|
||||
+ } else {
|
||||
+ mw = m->w.width;
|
||||
+ mx = 0;
|
||||
+ }
|
||||
+ mw = m->w.width;
|
||||
+ mx = 0;
|
||||
+ my = 0;
|
||||
+ tw = mw;
|
||||
+
|
||||
+ if (n > m->nmaster) {
|
||||
+ /* go mfact box in the center if more than nmaster clients */
|
||||
+ if (centeredmaster_always) {
|
||||
+ mw = m->nmaster ? (int)roundf(m->w.width / 2) : 0;
|
||||
+ tw = mw / 2;
|
||||
+ } else {
|
||||
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
+ tw = m->w.width - mw;
|
||||
+ }
|
||||
+ mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
||||
+ tw = m->w.width - mw;
|
||||
+
|
||||
+ if (n - m->nmaster > 1) {
|
||||
+ /* only one client */
|
||||
|
||||
@@ -7,18 +7,9 @@ Mod+chain is pressed. A subsequent keypress will be matched against bindings
|
||||
for that chain key. If it is configured the action will be triggered, otherwise
|
||||
the keypress will be ignored.
|
||||
|
||||
To use chainkeys, append the key after the argument in the keybindings. Example usage:
|
||||
```c
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_s, setmfact, {.f = -0.05f}, XKB_KEY_h },
|
||||
{ MODKEY, XKB_KEY_s, setmfact, {.f = +0.05f}, XKB_KEY_l },
|
||||
```
|
||||
Here, `MODKEY+i` triggers incnmaster to decrease nmaster, while `MODKEY+s` triggers a chain. After triggering the chain, pressing `h` or `l` changes the monitor's mfact and resets the chain.
|
||||
|
||||
### Download
|
||||
- [chainkeys.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys.patch) Latest version, applies to main branch, tested on commit dwl/dwl@e2038450f2
|
||||
- [chainkeys_2024-05-20.patch](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys_2024-05-20.patch) Legacy version from 2024-05-20
|
||||
- [git branch](https://codeberg.org/bencc/dwl/src/branch/chainkeys)
|
||||
- [2024-05-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/chainkeys/chainkeys.patch)
|
||||
|
||||
### Authors
|
||||
- [atourist](https://codeberg.org/atourist)
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
|
||||
@@ -1,74 +1,157 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 8304245..836cb87 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -9,7 +9,7 @@ DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
|
||||
DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
|
||||
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
|
||||
- -Wfloat-conversion
|
||||
+ -Wfloat-conversion -Wno-missing-field-initializers
|
||||
From 226e204ec7fb6d6840a984ef8e8ec1d2514e985f Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Tue, 2 Jan 2024 10:33:59 +1000
|
||||
Subject: [PATCH] chainkeys
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
PKGS = wayland-server xkbcommon libinput $(XLIBS)
|
||||
---
|
||||
config.def.h | 62 ++++++++++++++++++++++++++--------------------------
|
||||
dwl.c | 23 ++++++++++++++++++-
|
||||
2 files changed, 53 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8f498d2f..1c182547 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -105,10 +105,10 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
+ { MODKEY, -1, KEY, view, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, -1, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,-1,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@@ -119,30 +119,30 @@ static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
- /* modifier key function argument */
|
||||
- { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
- { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
- { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
- { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
- { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
- { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
- { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
- { MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
- { MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
|
||||
- { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
- { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
- { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
- { MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
- { MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
- { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
- { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ /* modifier chain, key function argument */
|
||||
+ { MODKEY, -1, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
+ { MODKEY, -1, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
+ { MODKEY, -1, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY, -1, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
+ { MODKEY, -1, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
+ { MODKEY, -1, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
+ { MODKEY, -1, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
+ { MODKEY, -1, XKB_KEY_Return, zoom, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_Tab, view, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_C, killclient, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
+ { MODKEY, -1, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
+ { MODKEY, -1, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, -1, XKB_KEY_space, setlayout, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_space, togglefloating, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_e, togglefullscreen, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_0, view, {.ui = ~0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
+ { MODKEY, -1, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
+ { MODKEY, -1, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
@@ -152,14 +152,14 @@ static const Key keys[] = {
|
||||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Q, quit, {0} },
|
||||
|
||||
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
|
||||
- { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
+ { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
|
||||
* do not remove them.
|
||||
*/
|
||||
-#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
|
||||
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
|
||||
CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
|
||||
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
|
||||
};
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 216deb5..af011ea 100644
|
||||
index bf763dfc..05e667f8 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -166,6 +166,7 @@ typedef struct {
|
||||
@@ -143,6 +143,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
+ int chain;
|
||||
xkb_keysym_t keysym;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
+ xkb_keysym_t chain;
|
||||
} Key;
|
||||
|
||||
typedef struct {
|
||||
@@ -378,6 +379,7 @@ static void zoom(const Arg *arg);
|
||||
/* variables */
|
||||
@@ -353,6 +354,7 @@ static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
+static xkb_keysym_t chainkey = 0;
|
||||
static Client *focused_client;
|
||||
static void *exclusive_focus;
|
||||
+static int chainkey = -1;
|
||||
static struct wl_display *dpy;
|
||||
static struct wl_event_loop *event_loop;
|
||||
@@ -1735,9 +1737,21 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
* processing.
|
||||
*/
|
||||
static struct wlr_backend *backend;
|
||||
static struct wlr_scene *scene;
|
||||
@@ -1438,11 +1440,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
const Key *k;
|
||||
+ if (chainkey) {
|
||||
+ for (k = keys; k < END(keys); k++) {
|
||||
+ if (chainkey == k->keysym && sym == k->chain) {
|
||||
+ chainkey = 0;
|
||||
+ return k;
|
||||
+ }
|
||||
+ }
|
||||
+ chainkey = 0;
|
||||
+ return NULL;
|
||||
+ }
|
||||
for (k = keys; k < END(keys); k++) {
|
||||
- if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func)
|
||||
+ if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym && k->func) {
|
||||
+ if (k->chain) chainkey = k->keysym;
|
||||
return k;
|
||||
+ }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1771,7 +1785,7 @@ keypress(struct wl_listener *listener, void *data)
|
||||
const Key *key = keybinding(group->mods, group->keysyms[i]);
|
||||
if (key) {
|
||||
consumed[event->keycode] = 1;
|
||||
- key->func(&key->arg);
|
||||
+ if (!chainkey) key->func(&key->arg);
|
||||
handled = 1;
|
||||
break;
|
||||
}
|
||||
@@ -1827,7 +1841,7 @@ keyrepeat(void *data)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
const Key *key = keybinding(group->mods, group->keysyms[i]);
|
||||
if (key) {
|
||||
- key->func(&key->arg);
|
||||
+ if (!chainkey) key->func(&key->arg);
|
||||
break;
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
- && sym == k->keysym && k->func) {
|
||||
+ && sym == k->keysym
|
||||
+ && chainkey == -1
|
||||
+ && k->chain == -1
|
||||
+ && k->func) {
|
||||
k->func(&k->arg);
|
||||
return 1;
|
||||
}
|
||||
+ else if (sym == k->keysym
|
||||
+ && chainkey != -1
|
||||
+ && k->chain == chainkey
|
||||
+ && k->func) {
|
||||
+ k->func(&k->arg);
|
||||
+ chainkey = -1;
|
||||
+ return 1;
|
||||
+ }
|
||||
+ else if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
+ && k->chain == (int)sym
|
||||
+ && chainkey == -1
|
||||
+ && k->func) {
|
||||
+ chainkey = sym;
|
||||
+ return 1;
|
||||
+ }
|
||||
}
|
||||
+ chainkey = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
From 226e204ec7fb6d6840a984ef8e8ec1d2514e985f Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Tue, 2 Jan 2024 10:33:59 +1000
|
||||
Subject: [PATCH] chainkeys
|
||||
|
||||
---
|
||||
config.def.h | 62 ++++++++++++++++++++++++++--------------------------
|
||||
dwl.c | 23 ++++++++++++++++++-
|
||||
2 files changed, 53 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8f498d2f..1c182547 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -105,10 +105,10 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
- { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
+ { MODKEY, -1, KEY, view, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, -1, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,-1,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@@ -119,30 +119,30 @@ static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
|
||||
- /* modifier key function argument */
|
||||
- { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
- { MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
- { MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
- { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
- { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
- { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
- { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
- { MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
- { MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
|
||||
- { MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
- { MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
- { MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
- { MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
- { MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
- { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
- { MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ /* modifier chain, key function argument */
|
||||
+ { MODKEY, -1, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
+ { MODKEY, -1, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
+ { MODKEY, -1, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY, -1, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
+ { MODKEY, -1, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
+ { MODKEY, -1, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
+ { MODKEY, -1, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
+ { MODKEY, -1, XKB_KEY_Return, zoom, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_Tab, view, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_C, killclient, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
+ { MODKEY, -1, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
+ { MODKEY, -1, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, -1, XKB_KEY_space, setlayout, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_space, togglefloating, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_e, togglefullscreen, {0} },
|
||||
+ { MODKEY, -1, XKB_KEY_0, view, {.ui = ~0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
+ { MODKEY, -1, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
+ { MODKEY, -1, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
@@ -152,14 +152,14 @@ static const Key keys[] = {
|
||||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
- { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, quit, {0} },
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, -1, XKB_KEY_Q, quit, {0} },
|
||||
|
||||
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
|
||||
- { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
+ { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,XKB_KEY_Terminate_Server, quit, {0} },
|
||||
/* Ctrl-Alt-Fx is used to switch to another VT, if you don't know what a VT is
|
||||
* do not remove them.
|
||||
*/
|
||||
-#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
|
||||
+#define CHVT(n) { WLR_MODIFIER_CTRL|WLR_MODIFIER_ALT,-1,XKB_KEY_XF86Switch_VT_##n, chvt, {.ui = (n)} }
|
||||
CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
|
||||
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
|
||||
};
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bf763dfc..05e667f8 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -143,6 +143,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
+ int chain;
|
||||
xkb_keysym_t keysym;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
@@ -353,6 +354,7 @@ static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
static void *exclusive_focus;
|
||||
+static int chainkey = -1;
|
||||
static struct wl_display *dpy;
|
||||
static struct wlr_backend *backend;
|
||||
static struct wlr_scene *scene;
|
||||
@@ -1438,11 +1440,30 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
const Key *k;
|
||||
for (k = keys; k < END(keys); k++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
- && sym == k->keysym && k->func) {
|
||||
+ && sym == k->keysym
|
||||
+ && chainkey == -1
|
||||
+ && k->chain == -1
|
||||
+ && k->func) {
|
||||
k->func(&k->arg);
|
||||
return 1;
|
||||
}
|
||||
+ else if (sym == k->keysym
|
||||
+ && chainkey != -1
|
||||
+ && k->chain == chainkey
|
||||
+ && k->func) {
|
||||
+ k->func(&k->arg);
|
||||
+ chainkey = -1;
|
||||
+ return 1;
|
||||
+ }
|
||||
+ else if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
+ && k->chain == (int)sym
|
||||
+ && chainkey == -1
|
||||
+ && k->func) {
|
||||
+ chainkey = sym;
|
||||
+ return 1;
|
||||
+ }
|
||||
}
|
||||
+ chainkey = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
@@ -14,7 +14,7 @@ The opacity levels can be change by short cuts.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/Hansvon/dwl/src/branch/client-opacity-focus)
|
||||
- [2026-04-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity-focus/client-opacity-focus.patch)
|
||||
- [2025-12-11](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/client-opacity-focus/client-opacity-focus.patch)
|
||||
|
||||
### Authors
|
||||
- [Hansvon](https://codeberg.org/Hansvon)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
From 57c5475d7f715b77ec05d69a2bda808b224cf0b4 Mon Sep 17 00:00:00 2001
|
||||
From 694751a31a437bbb28c3a75c917ed922231ab366 Mon Sep 17 00:00:00 2001
|
||||
From: Hans von Hohenstaufen <Hans.von.Hohenstaufen@protonmail.com>
|
||||
Date: Mon, 22 Dec 2025 01:43:50 +0000
|
||||
Subject: [PATCH] Add client opacity focus
|
||||
|
||||
---
|
||||
config.def.h | 12 +++++++---
|
||||
dwl.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 74 insertions(+), 3 deletions(-)
|
||||
dwl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 72 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 95c2afa..55abf84 100644
|
||||
index 95c2afa..b7002f5 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
||||
@@ -26,12 +26,12 @@ index 95c2afa..55abf84 100644
|
||||
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
|
||||
static const Rule rules[] = {
|
||||
- /* app_id title tags mask isfloating monitor */
|
||||
+ /* app_id title tags mask isfloating alpha focus alpha unfocus monitor */
|
||||
+ /* app_id title tags mask isfloating alpha unfocus monitor */
|
||||
/* examples: */
|
||||
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||
+ { "Gimp_EXAMPLE", NULL, 0, 1, 1.00, 0.20, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, 1.00, -1 }, /* Start on ONLY tag "9" */
|
||||
+ { "Gimp_EXAMPLE", NULL, 0, 1, default_opacity_unfocus, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 1.00, -1 }, /* Start on ONLY tag "9" */
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
@@ -47,7 +47,7 @@ index 95c2afa..55abf84 100644
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 12f441e..e45e420 100644
|
||||
index 12f441e..7539738 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -138,6 +138,9 @@ typedef struct {
|
||||
@@ -60,16 +60,15 @@ index 12f441e..e45e420 100644
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
@@ -227,6 +230,8 @@ typedef struct {
|
||||
@@ -227,6 +230,7 @@ typedef struct {
|
||||
const char *title;
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
+ float opacity_focus;
|
||||
+ float opacity_unfocus;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@@ -319,6 +324,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
@@ -319,6 +323,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void requestmonstate(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
static void run(char *startup_cmd);
|
||||
@@ -77,7 +76,7 @@ index 12f441e..e45e420 100644
|
||||
static void setcursor(struct wl_listener *listener, void *data);
|
||||
static void setcursorshape(struct wl_listener *listener, void *data);
|
||||
static void setfloating(Client *c, int floating);
|
||||
@@ -326,6 +332,8 @@ static void setfullscreen(Client *c, int fullscreen);
|
||||
@@ -326,6 +331,8 @@ static void setfullscreen(Client *c, int fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
@@ -86,16 +85,15 @@ index 12f441e..e45e420 100644
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
@@ -490,6 +498,8 @@ applyrules(Client *c)
|
||||
@@ -490,6 +497,7 @@ applyrules(Client *c)
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
+ c->opacity_unfocus = r->opacity_unfocus;
|
||||
+ c->opacity_focus = r->opacity_focus;
|
||||
+ c->opacity = r->opacity_unfocus;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
@@ -1127,6 +1137,10 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
@@ -1127,6 +1135,10 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
c = toplevel->base->data = ecalloc(1, sizeof(*c));
|
||||
c->surface.xdg = toplevel->base;
|
||||
c->bw = borderpx;
|
||||
@@ -106,7 +104,7 @@ index 12f441e..e45e420 100644
|
||||
|
||||
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
|
||||
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
|
||||
@@ -1429,6 +1443,7 @@ focusclient(Client *c, int lift)
|
||||
@@ -1429,6 +1441,7 @@ focusclient(Client *c, int lift)
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
selmon = c->mon;
|
||||
c->isurgent = 0;
|
||||
@@ -114,7 +112,7 @@ index 12f441e..e45e420 100644
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
@@ -1453,6 +1468,7 @@ focusclient(Client *c, int lift)
|
||||
@@ -1453,6 +1466,7 @@ focusclient(Client *c, int lift)
|
||||
client_set_border_color(old_c, bordercolor);
|
||||
|
||||
client_activate_surface(old, 0);
|
||||
@@ -122,7 +120,7 @@ index 12f441e..e45e420 100644
|
||||
}
|
||||
}
|
||||
printstatus();
|
||||
@@ -2159,6 +2175,7 @@ rendermon(struct wl_listener *listener, void *data)
|
||||
@@ -2159,6 +2173,7 @@ rendermon(struct wl_listener *listener, void *data)
|
||||
/* Render if no XDG clients have an outstanding resize and are visible on
|
||||
* this monitor. */
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
@@ -130,7 +128,7 @@ index 12f441e..e45e420 100644
|
||||
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
|
||||
goto skip;
|
||||
}
|
||||
@@ -2295,6 +2312,15 @@ run(char *startup_cmd)
|
||||
@@ -2295,6 +2310,15 @@ run(char *startup_cmd)
|
||||
wl_display_run(dpy);
|
||||
}
|
||||
|
||||
@@ -146,7 +144,7 @@ index 12f441e..e45e420 100644
|
||||
void
|
||||
setcursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2363,6 +2389,7 @@ setfullscreen(Client *c, int fullscreen)
|
||||
@@ -2363,6 +2387,7 @@ setfullscreen(Client *c, int fullscreen)
|
||||
* client positions are set by the user and cannot be recalculated */
|
||||
resize(c, c->prev, 0);
|
||||
}
|
||||
@@ -154,7 +152,7 @@ index 12f441e..e45e420 100644
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2419,6 +2446,44 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
@@ -2419,6 +2444,44 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
||||
@@ -200,5 +198,5 @@ index 12f441e..e45e420 100644
|
||||
setpsel(struct wl_listener *listener, void *data)
|
||||
{
|
||||
--
|
||||
2.53.0
|
||||
2.51.2
|
||||
|
||||
|
||||
@@ -1,83 +1,78 @@
|
||||
From 54ad3a9005a127a957bf081b0be765dcaff18c5d Mon Sep 17 00:00:00 2001
|
||||
From 4d55356e918fd75a07d05db3ea28798a016405a4 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Denes <caskd@redxen.eu>
|
||||
Date: Thu, 10 Jul 2025 12:01:29 +0000
|
||||
Subject: [PATCH] Implement color manager
|
||||
|
||||
---
|
||||
Makefile | 9 ++++++++-
|
||||
config.def.h | 24 ++++++++++++++++++++----
|
||||
dwl.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 79 insertions(+), 5 deletions(-)
|
||||
Makefile | 6 +++++-
|
||||
config.def.h | 8 +++++---
|
||||
config.mk | 4 ++--
|
||||
dwl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 62 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 3981fbb..190f29c 100644
|
||||
index 578194f..570d5f5 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -22,7 +22,8 @@ dwl: dwl.o util.o
|
||||
@@ -21,7 +21,8 @@ dwl: dwl.o util.o
|
||||
$(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
|
||||
ext-image-copy-capture-v1-protocol.h \
|
||||
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
|
||||
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
|
||||
+ color-management-v1-protocol.h color-representation-v1-protocol.h
|
||||
+ color-management-v1-protocol.h
|
||||
util.o: util.c util.h
|
||||
|
||||
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||
@@ -43,6 +44,12 @@ pointer-constraints-unstable-v1-protocol.h:
|
||||
@@ -39,6 +40,9 @@ pointer-constraints-unstable-v1-protocol.h:
|
||||
wlr-layer-shell-unstable-v1-protocol.h:
|
||||
$(WAYLAND_SCANNER) enum-header \
|
||||
protocols/wlr-layer-shell-unstable-v1.xml $@
|
||||
+color-management-v1-protocol.h:
|
||||
+ $(WAYLAND_SCANNER) enum-header \
|
||||
+ $(WAYLAND_PROTOCOLS)/staging/color-management/color-management-v1.xml $@
|
||||
+color-representation-v1-protocol.h:
|
||||
+ $(WAYLAND_SCANNER) enum-header \
|
||||
+ $(WAYLAND_PROTOCOLS)/staging/color-representation/color-representation-v1.xml $@
|
||||
wlr-output-power-management-unstable-v1-protocol.h:
|
||||
$(WAYLAND_SCANNER) server-header \
|
||||
protocols/wlr-output-power-management-unstable-v1.xml $@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..d203edc 100644
|
||||
index 95c2afa..43af85b 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -35,15 +35,31 @@ static const Layout layouts[] = {
|
||||
{ "[M]", monocle },
|
||||
};
|
||||
|
||||
+
|
||||
+/*
|
||||
+static struct wlr_output_image_description generic_bt2020_pq = {
|
||||
+ .primaries = WLR_COLOR_NAMED_PRIMARIES_BT2020,
|
||||
+ .transfer_function = WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,
|
||||
+ .max_cll = 10000,
|
||||
+ .max_fall = 400,
|
||||
+ .mastering_luminance = {
|
||||
+ .min = 0,
|
||||
+ .max = 10000,
|
||||
+ },
|
||||
+};
|
||||
+*/
|
||||
+
|
||||
/* monitors */
|
||||
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
|
||||
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
|
||||
* https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */
|
||||
@@ -43,12 +43,14 @@ static const Layout layouts[] = {
|
||||
*/
|
||||
/* NOTE: ALWAYS add a fallback rule, even if you are completely sure it won't be used */
|
||||
static const MonitorRule monrules[] = {
|
||||
- /* name mfact nmaster scale layout rotate/reflect x y
|
||||
- * example of a HiDPI laptop monitor:
|
||||
- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */
|
||||
- /* name mfact nmaster scale layout rotate/reflect x y */
|
||||
+ /* name mfact nmaster scale layout rotate/reflect x y hdr render_format */
|
||||
/* example of a HiDPI laptop monitor:
|
||||
- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
+ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, DRM_FORMAT_XRGB8888 },
|
||||
+ * HDR Example
|
||||
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 1, DRM_FORMAT_XRGB2101010 },
|
||||
*/
|
||||
/* defaults */
|
||||
- { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
+ /* name mfact nmaster scale layout rotate/reflect x y image_desc pixel_format
|
||||
+ * example of a HiDPI laptop monitor:
|
||||
+ { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, NULL, DRM_FORMAT_XRGB8888 },
|
||||
+ * HDR Example
|
||||
+ { NULL, 0.5f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, &generic_bt2020_pq, DRM_FORMAT_XRGB2101010 }, */
|
||||
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, NULL, DRM_FORMAT_XRGB8888 },
|
||||
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
|
||||
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, DRM_FORMAT_XRGB8888 },
|
||||
};
|
||||
|
||||
/* keyboard */
|
||||
diff --git a/config.mk b/config.mk
|
||||
index eb08a05..f641d04 100644
|
||||
--- a/config.mk
|
||||
+++ b/config.mk
|
||||
@@ -8,8 +8,8 @@ PREFIX = /usr/local
|
||||
MANDIR = $(PREFIX)/share/man
|
||||
DATADIR = $(PREFIX)/share
|
||||
|
||||
-WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`
|
||||
-WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`
|
||||
+WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.20`
|
||||
+WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
|
||||
|
||||
# Allow using an alternative wlroots installation
|
||||
# This has to have all the includes required by wlroots, e.g:
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 8101ffa..4c3f12a 100644
|
||||
index 12f441e..39812ce 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -4,6 +4,7 @@
|
||||
@@ -88,26 +83,25 @@ index 8101ffa..4c3f12a 100644
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -18,6 +19,8 @@
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_alpha_modifier_v1.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
+#include <wlr/types/wlr_color_management_v1.h>
|
||||
+#include <wlr/types/wlr_color_representation_v1.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_cursor_shape_v1.h>
|
||||
#include <wlr/types/wlr_data_control_v1.h>
|
||||
@@ -219,6 +222,9 @@ typedef struct {
|
||||
@@ -215,6 +217,9 @@ typedef struct {
|
||||
const Layout *lt;
|
||||
enum wl_output_transform rr;
|
||||
int x, y;
|
||||
+
|
||||
+ struct wlr_output_image_description *image_desc;
|
||||
+ int hdr;
|
||||
+ uint32_t render_format;
|
||||
} MonitorRule;
|
||||
|
||||
typedef struct {
|
||||
@@ -386,6 +392,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||
@@ -382,6 +387,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
||||
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
|
||||
static struct wlr_output_power_manager_v1 *power_mgr;
|
||||
@@ -115,28 +109,27 @@ index 8101ffa..4c3f12a 100644
|
||||
|
||||
static struct wlr_pointer_constraints_v1 *pointer_constraints;
|
||||
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
|
||||
@@ -1088,6 +1095,20 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -1084,6 +1090,19 @@ createmon(struct wl_listener *listener, void *data)
|
||||
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
|
||||
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
|
||||
|
||||
+ /* Enable HDR if supported and desired */
|
||||
+ if ((r->image_desc) && (drw->features.output_color_transform) &&
|
||||
+ (wlr_output->supported_primaries & r->image_desc->primaries) &&
|
||||
+ (wlr_output->supported_transfer_functions & r->image_desc->transfer_function)) {
|
||||
+ // Set framebuffer pixel format to one requested
|
||||
+ if ((r->hdr) &&
|
||||
+ (wlr_output->supported_primaries & WLR_COLOR_NAMED_PRIMARIES_BT2020) &&
|
||||
+ (wlr_output->supported_transfer_functions & WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ) &&
|
||||
+ (drw->features.output_color_transform)) {
|
||||
+ const struct wlr_output_image_description image_desc = {
|
||||
+ .primaries = WLR_COLOR_NAMED_PRIMARIES_BT2020,
|
||||
+ .transfer_function = WLR_COLOR_TRANSFER_FUNCTION_ST2084_PQ,
|
||||
+ };
|
||||
+ wlr_output_state_set_render_format(&state, r->render_format);
|
||||
+ // Check if unset and use default well-known primaries (white point will never be 0.0 if set)
|
||||
+ struct wlr_color_primaries *prim = &r->image_desc->mastering_display_primaries;
|
||||
+ if (prim->white.x == 0.0 && prim->white.y == 0.0) {
|
||||
+ wlr_color_primaries_from_named (&r->image_desc->mastering_display_primaries, r->image_desc->primaries);
|
||||
+ }
|
||||
+ wlr_output_state_set_image_description(&state, r->image_desc);
|
||||
+ wlr_output_state_set_image_description(&state, &image_desc);
|
||||
+ }
|
||||
+
|
||||
wlr_output_state_set_enabled(&state, 1);
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
@@ -2653,6 +2674,36 @@ setup(void)
|
||||
@@ -2645,6 +2664,37 @@ setup(void)
|
||||
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
|
||||
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
|
||||
|
||||
@@ -150,29 +143,30 @@ index 8101ffa..4c3f12a 100644
|
||||
+ .set_mastering_display_primaries = true,
|
||||
+ };
|
||||
+
|
||||
+ color_mgr_options->render_intents_len = 1;
|
||||
+ color_mgr_options->render_intents_len = 2;
|
||||
+ enum wp_color_manager_v1_render_intent *render_intents = ecalloc(color_mgr_options->render_intents_len, sizeof(*render_intents));
|
||||
+ render_intents[0] = WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL;
|
||||
+ render_intents[1] = WP_COLOR_MANAGER_V1_RENDER_INTENT_ABSOLUTE;
|
||||
+ color_mgr_options->render_intents = render_intents;
|
||||
+
|
||||
+ enum wp_color_manager_v1_primaries *primaries = wlr_color_manager_v1_primaries_list_from_renderer(drw, &color_mgr_options->primaries_len);
|
||||
+ enum wp_color_manager_v1_primaries *primaries = ecalloc(color_mgr_options->primaries_len, sizeof(*primaries));
|
||||
+ primaries[0] = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB;
|
||||
+ primaries[1] = WP_COLOR_MANAGER_V1_PRIMARIES_BT2020;
|
||||
+ color_mgr_options->primaries = primaries;
|
||||
+
|
||||
+ enum wp_color_manager_v1_transfer_function *transfer_functions = wlr_color_manager_v1_transfer_function_list_from_renderer(drw, &color_mgr_options->transfer_functions_len);
|
||||
+ color_mgr_options->transfer_functions_len = 3;
|
||||
+ enum wp_color_manager_v1_transfer_function *transfer_functions = ecalloc(color_mgr_options->transfer_functions_len, sizeof(*transfer_functions));
|
||||
+ transfer_functions[0] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB;
|
||||
+ transfer_functions[1] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ;
|
||||
+ transfer_functions[2] = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR;
|
||||
+ color_mgr_options->transfer_functions = transfer_functions;
|
||||
+
|
||||
+ color_mgr = wlr_color_manager_v1_create(dpy, 2, color_mgr_options);
|
||||
+ wlr_scene_set_color_manager_v1(scene, color_mgr);
|
||||
+
|
||||
+ wlr_color_representation_manager_v1_create_with_renderer(dpy, 1, drw);
|
||||
+
|
||||
+ free(transfer_functions);
|
||||
+ free(primaries);
|
||||
+ color_mgr = wlr_color_manager_v1_create(dpy, 1, color_mgr_options);
|
||||
+ }
|
||||
+
|
||||
/* Make sure XWayland clients don't connect to the parent X server,
|
||||
* e.g when running in the x11 backend or the wayland backend and the
|
||||
* compositor has Xwayland support */
|
||||
--
|
||||
2.54.0
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 9d34e55528ef3e558dcaba7759567707d44ed82d Mon Sep 17 00:00:00 2001
|
||||
From 234dc2774b23d21c647c6967b1dd38e61165fabf Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andr=C3=A9=20Desgualdo=20Pereira?= <desgua@gmail.com>
|
||||
Date: Mon, 4 May 2026 10:49:48 -0300
|
||||
Subject: [PATCH] update controlled_fullscreen to dwl 0.8
|
||||
Date: Sat, 14 Mar 2026 17:20:21 -0300
|
||||
Subject: [PATCH] update to dwl 0.8
|
||||
|
||||
---
|
||||
dwl.c | 32 ++++++++++++--------------------
|
||||
@@ -128,5 +128,5 @@ index 101a45f..0ec8db6 100644
|
||||
/* Try to re-set the gamma LUT when updating monitors,
|
||||
* it's only really needed when enabling a disabled output, but meh. */
|
||||
--
|
||||
2.53.0
|
||||
2.51.0
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ The variable `center_relative_to_monitor` allows the user to choose whether to c
|
||||
<summary>Explanation of center_relative_to_monitor:</summary>
|
||||
<pre>
|
||||
The "Monitor area" refers to the space enclosed by the green rectangle, while the "Window area" refers to the space enclosed by the red rectangle.
|
||||
<img src="customfloat-monitor-vs-window.png"/>
|
||||
<img src="https://i.imgur.com/xhejzPh.png"/>
|
||||
</pre>
|
||||
</details>
|
||||
|
||||
### Download
|
||||
- [customfloat_main-5fd19fe](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_main-5fd19fe.patch)
|
||||
- [customfloat_wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_wlroots-next-f4249db.patch)
|
||||
- [customfloat_0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat_0.8.patch)
|
||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/customfloat)
|
||||
- [wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat-wlroots-next-f4249db.patch)
|
||||
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/customfloat/customfloat-0.8.patch)
|
||||
|
||||
### Authors
|
||||
- [fauxmight](https://codeberg.org/fauxmight)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 286 KiB |
@@ -1,82 +0,0 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 572984b..708d87a 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -13,6 +13,7 @@ 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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
+static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */
|
||||
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
@@ -21,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
|
||||
static int log_level = WLR_ERROR;
|
||||
|
||||
static const Rule rules[] = {
|
||||
- /* app_id title tags mask isfloating monitor */
|
||||
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||
+ /* app_id title tags mask isfloating monitor x y width height */
|
||||
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, -1, -1, 1000, 0.75 }, /* Start on currently visible tags floating, not tiled */
|
||||
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, -1, -1, -1, -1 }, /* Start on ONLY tag "9" */
|
||||
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
|
||||
};
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index f902ace..97e09e6 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -245,6 +245,10 @@ typedef struct {
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
int monitor;
|
||||
+ int x;
|
||||
+ int y;
|
||||
+ float w;
|
||||
+ float h;
|
||||
} Rule;
|
||||
|
||||
typedef struct {
|
||||
@@ -506,6 +510,11 @@ applyrules(Client *c)
|
||||
int i;
|
||||
const Rule *r;
|
||||
Monitor *mon = selmon, *m;
|
||||
+ int newwidth;
|
||||
+ int newheight;
|
||||
+ int newx;
|
||||
+ int newy;
|
||||
+ int apply_resize = 0;
|
||||
|
||||
appid = client_get_appid(c);
|
||||
title = client_get_title(c);
|
||||
@@ -519,12 +528,29 @@ applyrules(Client *c)
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
if (r->monitor == i++)
|
||||
mon = m;
|
||||
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
|
||||
+ /* client is floating or in floating layout */
|
||||
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
|
||||
+ newwidth = (int)round((r->w >= 0) ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
|
||||
+ newheight = (int)round((r->h >= 0) ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
|
||||
+ newx = (int)round((r->x >= 0) ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
|
||||
+ newy = (int)round((r->y >= 0) ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
|
||||
+ apply_resize = 1;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c->isfloating |= client_is_float_type(c);
|
||||
setmon(c, mon, newtags);
|
||||
+ if (apply_resize) {
|
||||
+ resize(c, (struct wlr_box){
|
||||
+ .x = newx,
|
||||
+ .y = newy,
|
||||
+ .width = newwidth,
|
||||
+ .height = newheight,
|
||||
+ }, 1);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -8,8 +8,7 @@ There are also two functions that can be bound to a `Key` or `Button`,
|
||||
2. `toggledimmingclient`: Which toggles dimming for the focused window, as if the client had `neverdim` applied to it. This overwrites an applied `Rule`.
|
||||
|
||||
### Download
|
||||
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20260927.patch)
|
||||
- [2026-03-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20260310.patch)
|
||||
- [2026-03-10](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
|
||||
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240918.patch)
|
||||
- [2024-09-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240903.patch)
|
||||
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240714.patch)
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
diff --git a/client.h b/client.h
|
||||
index d9f90bb..7a7792d 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -318,6 +318,12 @@ client_set_border_color(Client *c, const float color[static 4])
|
||||
wlr_scene_rect_set_color(c->border[i], color);
|
||||
}
|
||||
|
||||
+static inline void
|
||||
+client_set_dimmer_state(Client *c, const int dim)
|
||||
+{
|
||||
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
|
||||
+}
|
||||
+
|
||||
static inline void
|
||||
client_set_fullscreen(Client *c, int fullscreen)
|
||||
{
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..96a020a 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -10,6 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const float rootcolor[] = COLOR(0x222222ff);
|
||||
static const float bordercolor[] = COLOR(0x444444ff);
|
||||
static const float focuscolor[] = COLOR(0x005577ff);
|
||||
+static const float unfocuseddim[] = COLOR(0x00000088);
|
||||
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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
@@ -168,5 +169,6 @@ static const Key keys[] = {
|
||||
static const Button buttons[] = {
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
|
||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||
};
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 101a45f..d6b129a 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -109,6 +109,7 @@ typedef struct {
|
||||
Monitor *mon;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||
+ struct wlr_scene_rect *dimmer;
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wl_list link;
|
||||
struct wl_list flink;
|
||||
@@ -138,7 +139,7 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, neverdim;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
@@ -228,6 +229,7 @@ typedef struct {
|
||||
const char *title;
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
+ int neverdim;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@@ -335,6 +337,8 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void toggledimming(const Arg *arg);
|
||||
+static void toggledimmingclient(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -406,6 +410,7 @@ static struct wlr_output_layout *output_layout;
|
||||
static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
+static int DIMOPT = 1;
|
||||
|
||||
/* global event handlers */
|
||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||
@@ -491,6 +496,7 @@ applyrules(Client *c)
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
+ c->neverdim = r-> neverdim;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
@@ -1433,8 +1439,10 @@ focusclient(Client *c, int lift)
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
- if (!exclusive_focus && !seat->drag)
|
||||
+ if (!exclusive_focus && !seat->drag) {
|
||||
client_set_border_color(c, focuscolor);
|
||||
+ client_set_dimmer_state(c, 0);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Deactivate old client if focus is changing */
|
||||
@@ -1452,7 +1460,7 @@ focusclient(Client *c, int lift)
|
||||
* and probably other clients */
|
||||
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
|
||||
client_set_border_color(old_c, bordercolor);
|
||||
-
|
||||
+ client_set_dimmer_state(old_c, 1);
|
||||
client_activate_surface(old, 0);
|
||||
}
|
||||
}
|
||||
@@ -1739,8 +1747,7 @@ void
|
||||
mapnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||
- Client *p = NULL;
|
||||
- Client *w, *c = wl_container_of(listener, c, map);
|
||||
+ Client *p, *w, *d, *c = wl_container_of(listener, c, map);
|
||||
Monitor *m;
|
||||
int i;
|
||||
|
||||
@@ -1774,6 +1781,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
c->border[i]->node.data = c;
|
||||
}
|
||||
|
||||
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
|
||||
+ c->dimmer->node.data = c;
|
||||
+ client_set_dimmer_state(c, 1);
|
||||
+
|
||||
/* Initialize client geometry with room for border */
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
|
||||
c->geom.width += 2 * c->bw;
|
||||
@@ -1792,6 +1803,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
setmon(c, p->mon, p->tags);
|
||||
} else {
|
||||
applyrules(c);
|
||||
+ d = focustop(selmon);
|
||||
+ if (d) {
|
||||
+ client_set_dimmer_state(d, 0);
|
||||
+ }
|
||||
}
|
||||
printstatus();
|
||||
|
||||
@@ -2218,7 +2233,7 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
c->geom = geo;
|
||||
applybounds(c, bbox);
|
||||
|
||||
- /* Update scene-graph, including borders */
|
||||
+ /* Update scene-graph, including borders and dimmer*/
|
||||
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
@@ -2228,6 +2243,8 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
|
||||
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
|
||||
|
||||
/* this is a no-op if size hasn't changed */
|
||||
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
|
||||
@@ -2745,6 +2762,27 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void toggledimming(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ DIMOPT ^= 1;
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ {
|
||||
+ client_set_dimmer_state(c, 1);
|
||||
+ }
|
||||
+ c = focustop(selmon);
|
||||
+ if (c)
|
||||
+ client_set_dimmer_state(c, 0);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+toggledimmingclient(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ if (sel)
|
||||
+ sel -> neverdim ^= 1;
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
@@ -3022,9 +3060,29 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client *c = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
int layer;
|
||||
-
|
||||
+ struct wlr_scene_node *hidden_dimmers[32];
|
||||
+ int hidden_count = 0;
|
||||
for (layer = NUM_LAYERS - 1; !surface && layer >= 0; layer--) {
|
||||
- if (!(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
|
||||
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
|
||||
+
|
||||
+ while (node && node->type == WLR_SCENE_NODE_RECT && node->data) {
|
||||
+ Client *hit_c = node->data;
|
||||
+ /* Verify the node is actually a client's dimmer */
|
||||
+ if (hit_c->type != LayerShell && hit_c->dimmer && &hit_c->dimmer->node == node) {
|
||||
+ if (hidden_count < 32) {
|
||||
+ wlr_scene_node_set_enabled(node, 0);
|
||||
+ hidden_dimmers[hidden_count++] = node;
|
||||
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ for(int i=0; i<hidden_count; i++)
|
||||
+ wlr_scene_node_set_enabled(hidden_dimmers[i], 1);
|
||||
+
|
||||
+ if (!node)
|
||||
continue;
|
||||
|
||||
if (node->type == WLR_SCENE_NODE_BUFFER)
|
||||
@@ -1,227 +0,0 @@
|
||||
diff --git a/client.h b/client.h
|
||||
index eb1bb47..c41e287 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -347,6 +347,12 @@ client_set_border_color(Client *c, const float color[static 4])
|
||||
wlr_scene_rect_set_color(c->border[i], color);
|
||||
}
|
||||
|
||||
+static inline void
|
||||
+client_set_dimmer_state(Client *c, const int dim)
|
||||
+{
|
||||
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
|
||||
+}
|
||||
+
|
||||
static inline void
|
||||
client_set_fullscreen(Client *c, int fullscreen)
|
||||
{
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a4019d3..bf829c6 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -11,6 +11,7 @@ static const unsigned int snap = 32; /* snap pixel */
|
||||
static const float rootcolor[] = COLOR(0x222222ff);
|
||||
static const float bordercolor[] = COLOR(0x444444ff);
|
||||
static const float focuscolor[] = COLOR(0x005577ff);
|
||||
+static const float unfocuseddim[] = COLOR(0x00000088);
|
||||
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.0f, 0.0f, 0.0f, 1.0f}; /* You can also use glsl colors */
|
||||
@@ -168,6 +169,7 @@ static const Key keys[] = {
|
||||
static const Button buttons[] = {
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
|
||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||
};
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index cca1ea4..af6371b 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -121,6 +121,7 @@ typedef struct {
|
||||
Monitor *mon;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||
+ struct wlr_scene_rect *dimmer;
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
struct wl_list link;
|
||||
struct wl_list flink;
|
||||
@@ -158,7 +159,7 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, neverdim;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
@@ -248,6 +249,7 @@ typedef struct {
|
||||
const char *title;
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
+ int neverdim;
|
||||
int monitor;
|
||||
} Rule;
|
||||
|
||||
@@ -357,6 +359,8 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void toggledimming(const Arg *arg);
|
||||
+static void toggledimmingclient(const Arg *arg);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -431,6 +435,7 @@ static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
static int consumed[KEY_MAX + 1];
|
||||
+static int DIMOPT = 1;
|
||||
|
||||
/* global event handlers */
|
||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||
@@ -533,6 +538,7 @@ applyrules(Client *c)
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
+ c->neverdim = r-> neverdim;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
@@ -1550,8 +1556,10 @@ focusclient(Client *c, LayerSurface *l, int lift)
|
||||
* handling a drag operation */
|
||||
if (!(old_l && old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
|
||||
&& !(old_c && client_wants_focus(old_c))
|
||||
- && !seat->drag)
|
||||
+ && !seat->drag) {
|
||||
client_set_border_color(c, focuscolor);
|
||||
+ client_set_dimmer_state(c, 0);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* If an overlay is focused, don't focus or activate the client,
|
||||
@@ -1566,8 +1574,10 @@ focusclient(Client *c, LayerSurface *l, int lift)
|
||||
|
||||
if (focused_client && focused_client != c && !(c && client_is_unmanaged(c))) {
|
||||
struct wlr_surface *s = client_surface(focused_client);
|
||||
- if (c)
|
||||
+ if (c) {
|
||||
client_set_border_color(focused_client, bordercolor);
|
||||
+ client_set_dimmer_state(focused_client, 1);
|
||||
+ }
|
||||
if (s && s->mapped)
|
||||
client_activate_surface(s, 0);
|
||||
focused_client = NULL;
|
||||
@@ -1887,7 +1897,7 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||
Client *p = NULL;
|
||||
- Client *w, *c = wl_container_of(listener, c, map);
|
||||
+ Client *w, *d, *c = wl_container_of(listener, c, map);
|
||||
Monitor *m;
|
||||
int i;
|
||||
|
||||
@@ -1923,6 +1933,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
c->border[i]->node.data = c;
|
||||
}
|
||||
|
||||
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
|
||||
+ c->dimmer->node.data = c;
|
||||
+ client_set_dimmer_state(c, 1);
|
||||
+
|
||||
/* Initialize client geometry with room for border */
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
||||
WLR_EDGE_RIGHT);
|
||||
@@ -1954,6 +1968,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
setmon(c, p->mon, p->tags);
|
||||
} else {
|
||||
applyrules(c);
|
||||
+ d = focustop(selmon);
|
||||
+ if (d) {
|
||||
+ client_set_dimmer_state(d, 0);
|
||||
+ }
|
||||
}
|
||||
printstatus();
|
||||
|
||||
@@ -2398,7 +2416,7 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
c->geom = geo;
|
||||
applybounds(c, bbox);
|
||||
|
||||
- /* Update scene-graph, including borders */
|
||||
+ /* Update scene-graph, including borders and dimmer*/
|
||||
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
|
||||
@@ -2408,6 +2426,8 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
|
||||
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
||||
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
|
||||
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
|
||||
|
||||
client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
client_get_clip(c, &clip);
|
||||
@@ -2935,6 +2955,27 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void toggledimming(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ DIMOPT ^= 1;
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ {
|
||||
+ client_set_dimmer_state(c, 1);
|
||||
+ }
|
||||
+ c = focustop(selmon);
|
||||
+ if (c)
|
||||
+ client_set_dimmer_state(c, 0);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+toggledimmingclient(const Arg *arg)
|
||||
+{
|
||||
+ Client *sel = focustop(selmon);
|
||||
+ if (sel)
|
||||
+ sel -> neverdim ^= 1;
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
@@ -3237,10 +3278,32 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
struct wlr_scene_node *node;
|
||||
struct wlr_surface *surface = NULL;
|
||||
int layer;
|
||||
+ struct wlr_scene_node *hidden_dimmers[32];
|
||||
+ int hidden_count = 0;
|
||||
|
||||
for (layer = NUM_LAYERS - 1; !surface && layer >= (locked ? LyrBlock : 0); layer--) {
|
||||
- if (layer == LyrIMPopup ||
|
||||
- !(node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny)))
|
||||
+ if (layer == LyrIMPopup)
|
||||
+ continue;
|
||||
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
|
||||
+
|
||||
+ while (node && node->type == WLR_SCENE_NODE_RECT && node->data) {
|
||||
+ Client *hit_c = node->data;
|
||||
+ /* Verify the node is actually a client's dimmer */
|
||||
+ if (hit_c->type != LayerShell && hit_c->dimmer && &hit_c->dimmer->node == node) {
|
||||
+ if (hidden_count < 32) {
|
||||
+ wlr_scene_node_set_enabled(node, 0);
|
||||
+ hidden_dimmers[hidden_count++] = node;
|
||||
+ node = wlr_scene_node_at(&layers[layer]->node, x, y, nx, ny);
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ for(int i=0; i<hidden_count; i++)
|
||||
+ wlr_scene_node_set_enabled(hidden_dimmers[i], 1);
|
||||
+
|
||||
+ if (!node)
|
||||
continue;
|
||||
|
||||
if (node->type == WLR_SCENE_NODE_BUFFER)
|
||||
@@ -0,0 +1 @@
|
||||
09
|
||||
@@ -3,7 +3,6 @@ Change mfact by dragging the mouse.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/Palanix/dwl/src/branch/dragmfact)
|
||||
- [v0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.9.patch)
|
||||
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.7.patch)
|
||||
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact-v0.6.patch)
|
||||
- [2024-02-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dragmfact/dragmfact.patch)
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
From e0bec95eb6527dc5b87244ba025b28d2eaac94fe Mon Sep 17 00:00:00 2001
|
||||
From: Palanix <palanixyt@gmail.com>
|
||||
Date: Fri, 25 Mar 2022 23:45:10 +0100
|
||||
Subject: [PATCH] Change mfact using Middle mouse
|
||||
|
||||
---
|
||||
config.def.h | 2 +-
|
||||
dwl.c | 9 ++++++++-
|
||||
2 files changed, 9 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..ddce20b 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -167,7 +167,7 @@ static const Key keys[] = {
|
||||
|
||||
static const Button buttons[] = {
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
- { MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
+ { MODKEY, BTN_MIDDLE, moveresize, {.ui = Curmfact} },
|
||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||
};
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4cfd0fd..1eb98c2 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -86,7 +86,7 @@
|
||||
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
|
||||
|
||||
/* enums */
|
||||
-enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
+enum { CurNormal, CurPressed, CurMove, CurResize, Curmfact }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay,
|
||||
LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
@@ -2077,6 +2077,9 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
||||
.width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
return;
|
||||
+ } else if (cursor_mode == Curmfact && time) {
|
||||
+ selmon->mfact = (float) (cursor->x / selmon->m.width);
|
||||
+ arrange(selmon);
|
||||
}
|
||||
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
@@ -2128,6 +2131,10 @@ moveresize(const Arg *arg)
|
||||
grabc->geom.y + grabc->geom.height);
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
break;
|
||||
+ case Curmfact:
|
||||
+ setfloating(grabc, 0);
|
||||
+ selmon->mfact = (float) (cursor->x / selmon->m.width);
|
||||
+ arrange(selmon);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -3,7 +3,7 @@ Adds support for drm-lease-v1 for embedded displays such as VR headsets
|
||||
|
||||
### Download
|
||||
- [git branch](/caskd/dwl/src/branch/patches/drm_lease)
|
||||
- [main 2026-02-25](/dwl/dwl-patches/raw/branch/main/patches/drm_lease/drm_lease.patch)
|
||||
- [main 2025-06-18](/dwl/dwl-patches/raw/branch/main/patches/drm_lease/drm_lease.patch)
|
||||
### Authors
|
||||
- [caskd](https://codeberg.org/caskd)
|
||||
caskd@redxen.eu
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
From 155578f30dc91363e7580c3020ad464ab561acd3 Mon Sep 17 00:00:00 2001
|
||||
From be620ef43f6a37bc70331d6db69a3d0f60d2bb0d Mon Sep 17 00:00:00 2001
|
||||
From: Micah Gorrell <micah.gorrell@venafi.com>
|
||||
Date: Fri, 26 May 2023 08:17:20 -0600
|
||||
Subject: [PATCH] Implemented support for the DRM lease protocol, as needed to
|
||||
use devices such as VR headsets
|
||||
|
||||
---
|
||||
dwl.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 36 insertions(+)
|
||||
dwl.c | 33 +++++++++++++++++++++++++++++++++
|
||||
1 file changed, 33 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 101a45f..4740dfe 100644
|
||||
index 12f441e..6864f18 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -23,6 +23,7 @@
|
||||
@@ -18,9 +18,9 @@ index 101a45f..4740dfe 100644
|
||||
#include <wlr/types/wlr_drm.h>
|
||||
+#include <wlr/types/wlr_drm_lease_v1.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_ext_data_control_v1.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
@@ -316,6 +317,7 @@ static void powermgrsetmode(struct wl_listener *listener, void *data);
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
@@ -315,6 +316,7 @@ static void powermgrsetmode(struct wl_listener *listener, void *data);
|
||||
static void quit(const Arg *arg);
|
||||
static void rendermon(struct wl_listener *listener, void *data);
|
||||
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
||||
@@ -28,7 +28,7 @@ index 101a45f..4740dfe 100644
|
||||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void requestmonstate(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
@@ -377,6 +379,7 @@ static struct wl_list clients; /* tiling order */
|
||||
@@ -376,6 +378,7 @@ static struct wl_list clients; /* tiling order */
|
||||
static struct wl_list fstack; /* focus order */
|
||||
static struct wlr_idle_notifier_v1 *idle_notifier;
|
||||
static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
|
||||
@@ -36,7 +36,7 @@ index 101a45f..4740dfe 100644
|
||||
static struct wlr_layer_shell_v1 *layer_shell;
|
||||
static struct wlr_output_manager_v1 *output_mgr;
|
||||
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
||||
@@ -436,6 +439,7 @@ static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
|
||||
@@ -435,6 +438,7 @@ static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
|
||||
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
@@ -44,24 +44,7 @@ index 101a45f..4740dfe 100644
|
||||
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
@@ -727,10 +731,16 @@ cleanup(void)
|
||||
void
|
||||
cleanupmon(struct wl_listener *listener, void *data)
|
||||
{
|
||||
+ struct wlr_output *wlr_output = data;
|
||||
Monitor *m = wl_container_of(listener, m, destroy);
|
||||
LayerSurface *l, *tmp;
|
||||
size_t i;
|
||||
|
||||
+ if (drm_lease_manager && wlr_output->non_desktop) {
|
||||
+ wlr_drm_lease_v1_manager_withdraw_output (drm_lease_manager, wlr_output);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
/* m->layers[i] are intentionally not unlinked */
|
||||
for (i = 0; i < LENGTH(m->layers); i++) {
|
||||
wl_list_for_each_safe(l, tmp, &m->layers[i], link)
|
||||
@@ -783,6 +793,9 @@ cleanuplisteners(void)
|
||||
@@ -782,6 +786,9 @@ cleanuplisteners(void)
|
||||
wl_list_remove(&request_start_drag.link);
|
||||
wl_list_remove(&start_drag.link);
|
||||
wl_list_remove(&new_session_lock.link);
|
||||
@@ -71,19 +54,22 @@ index 101a45f..4740dfe 100644
|
||||
#ifdef XWAYLAND
|
||||
wl_list_remove(&new_xwayland_surface.link);
|
||||
wl_list_remove(&xwayland_ready.link);
|
||||
@@ -1047,6 +1060,11 @@ createmon(struct wl_listener *listener, void *data)
|
||||
struct wlr_output_state state;
|
||||
Monitor *m;
|
||||
|
||||
+ if (drm_lease_manager && wlr_output->non_desktop) {
|
||||
+ wlr_drm_lease_v1_manager_offer_output(drm_lease_manager, wlr_output);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -1049,6 +1056,14 @@ createmon(struct wl_listener *listener, void *data)
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
return;
|
||||
|
||||
@@ -2183,6 +2201,16 @@ requestdecorationmode(struct wl_listener *listener, void *data)
|
||||
+ if (wlr_output->non_desktop) {
|
||||
+ if (drm_lease_manager) {
|
||||
+ wlr_drm_lease_v1_manager_offer_output(drm_lease_manager, wlr_output);
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
m = wlr_output->data = ecalloc(1, sizeof(*m));
|
||||
m->wlr_output = wlr_output;
|
||||
|
||||
@@ -2181,6 +2196,16 @@ requestdecorationmode(struct wl_listener *listener, void *data)
|
||||
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
@@ -100,7 +86,7 @@ index 101a45f..4740dfe 100644
|
||||
void
|
||||
requeststartdrag(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2648,10 +2676,18 @@ setup(void)
|
||||
@@ -2645,10 +2670,18 @@ setup(void)
|
||||
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
|
||||
wl_signal_add(&output_mgr->events.test, &output_mgr_test);
|
||||
|
||||
@@ -120,5 +106,5 @@ index 101a45f..4740dfe 100644
|
||||
/*
|
||||
* Initialise the XWayland X server.
|
||||
--
|
||||
2.54.0
|
||||
2.51.1
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
### Description
|
||||
Adds a dwindle (fibonacci-style) layout to dwl.
|
||||
Windows are arranged by recursively splitting the remaining space,
|
||||
alternating between horizontal and vertical splits
|
||||
|
||||
With two windows:
|
||||
```
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
└───────────────┴────────────────┘
|
||||
```
|
||||
|
||||
With three windows:
|
||||
```
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ ├────────────────┤
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
└───────────────┴────────────────┘
|
||||
```
|
||||
|
||||
With four windows:
|
||||
```
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ ├───────┬────────┤
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
└───────────────┴───────┴────────┘
|
||||
```
|
||||
### Download
|
||||
|
||||
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/dwindle/dwindle.patch)
|
||||
|
||||
### Authors
|
||||
[cana cronica](https://codeberg.org/cana)
|
||||
@@ -1,105 +0,0 @@
|
||||
From 9be9c310cd546c22bd486f11c21e7ffcc09b1e8a Mon Sep 17 00:00:00 2001
|
||||
From: C4FE1 <heitorcdesousa13@gmail.com>
|
||||
Date: Fri, 20 Mar 2026 21:30:41 -0300
|
||||
Subject: [PATCH] dwl: add dwindle layout
|
||||
|
||||
dwl: add dwindle layout
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 55 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..96bb1c0 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "[\\]", dwindle },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -135,6 +136,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 101a45f..5f1b762 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -335,6 +335,7 @@ static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
+static void dwindle(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
@@ -2745,6 +2746,58 @@ tile(Monitor *m)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+dwindle(Monitor *m)
|
||||
+{
|
||||
+ unsigned int i, n = 0;
|
||||
+ int nx, ny, nw, nh;
|
||||
+ int horizontal;
|
||||
+ Client *c;
|
||||
+
|
||||
+ /* count clients */
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
+ n++;
|
||||
+
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ nx = m->w.x;
|
||||
+ ny = m->w.y;
|
||||
+ nw = m->w.width;
|
||||
+ nh = m->w.height;
|
||||
+
|
||||
+ horizontal = 1; // toggle split direction
|
||||
+ i = 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ continue;
|
||||
+
|
||||
+ if (i == n - 1) {
|
||||
+ /* last window gets remaining space */
|
||||
+ resize(c, (struct wlr_box){nx, ny, nw, nh}, 0);
|
||||
+ } else if (horizontal) {
|
||||
+ int w = nw / 2;
|
||||
+
|
||||
+ resize(c, (struct wlr_box){nx, ny, w, nh}, 0);
|
||||
+
|
||||
+ nx += w;
|
||||
+ nw -= w;
|
||||
+ } else {
|
||||
+ int h = nh / 2;
|
||||
+
|
||||
+ resize(c, (struct wlr_box){nx, ny, nw, h}, 0);
|
||||
+
|
||||
+ ny += h;
|
||||
+ nh -= h;
|
||||
+ }
|
||||
+
|
||||
+ horizontal = !horizontal;
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -12,11 +12,6 @@ then `status1` is set as the status of the primary bar,
|
||||
`status2` is set as the left status of extrabar,
|
||||
`status3` is set as the right status of extrabar.
|
||||
|
||||
### Download
|
||||
|
||||
- [2026-10-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/extrabar/extrabar-20261014.patch)
|
||||
- [2026-03-13](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/extrabar/extrabar-20260313.patch)
|
||||
|
||||
### Author
|
||||
|
||||
[dhruva_sambrani](/dhruva_sambrani)
|
||||
|
||||
@@ -1,227 +0,0 @@
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 7fe9468..1c4d5ba 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -205,6 +205,7 @@ struct Monitor {
|
||||
struct wlr_output *wlr_output;
|
||||
struct wlr_scene_output *scene_output;
|
||||
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
|
||||
+ struct wlr_scene_buffer *extra_scene_buffer; /* bar buffer */
|
||||
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
|
||||
struct wl_listener frame;
|
||||
struct wl_listener destroy;
|
||||
@@ -230,6 +231,7 @@ struct Monitor {
|
||||
int asleep;
|
||||
Drwl *drw;
|
||||
Buffer *pool[2];
|
||||
+ Buffer *extra_pool[2];
|
||||
int lrpad;
|
||||
};
|
||||
|
||||
@@ -278,7 +280,7 @@ static void bufdestroy(struct wlr_buffer *buffer);
|
||||
static bool bufdatabegin(struct wlr_buffer *buffer, uint32_t flags,
|
||||
void **data, uint32_t *format, size_t *stride);
|
||||
static void bufdataend(struct wlr_buffer *buffer);
|
||||
-static Buffer *bufmon(Monitor *m);
|
||||
+static Buffer *bufmon(Monitor *m, Buffer **pool);
|
||||
static void bufrelease(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
@@ -444,6 +446,8 @@ static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
static char stext[256];
|
||||
+static char stext2[256];
|
||||
+static char stext3[256];
|
||||
static struct wl_event_source *status_event_source;
|
||||
|
||||
static const struct wlr_buffer_impl buffer_impl = {
|
||||
@@ -627,6 +631,11 @@ arrangelayers(Monitor *m)
|
||||
usable_area.y += topbar ? m->b.real_height : 0;
|
||||
}
|
||||
|
||||
+ if (m->extra_scene_buffer->node.enabled) {
|
||||
+ usable_area.height -= m->b.real_height;
|
||||
+ usable_area.y += topbar ? 0 : m->b.real_height;
|
||||
+ }
|
||||
+
|
||||
/* Arrange exclusive surfaces from top->bottom */
|
||||
for (i = 3; i >= 0; i--)
|
||||
arrangelayer(m, &m->layers[i], &usable_area, 1);
|
||||
@@ -706,23 +715,23 @@ bufdataend(struct wlr_buffer *wlr_buffer)
|
||||
}
|
||||
|
||||
Buffer *
|
||||
-bufmon(Monitor *m)
|
||||
+bufmon(Monitor *m, Buffer **pool)
|
||||
{
|
||||
size_t i;
|
||||
Buffer *buf = NULL;
|
||||
|
||||
for (i = 0; i < LENGTH(m->pool); i++) {
|
||||
- if (m->pool[i]) {
|
||||
- if (m->pool[i]->busy)
|
||||
+ if (pool[i]) {
|
||||
+ if (pool[i]->busy)
|
||||
continue;
|
||||
- buf = m->pool[i];
|
||||
+ buf = pool[i];
|
||||
break;
|
||||
}
|
||||
|
||||
buf = ecalloc(1, sizeof(Buffer) + (m->b.width * 4 * m->b.height));
|
||||
buf->image = drwl_image_create(NULL, m->b.width, m->b.height, buf->data);
|
||||
wlr_buffer_init(&buf->base, &buffer_impl, m->b.width, m->b.height);
|
||||
- m->pool[i] = buf;
|
||||
+ pool[i] = buf;
|
||||
break;
|
||||
}
|
||||
if (!buf)
|
||||
@@ -894,6 +903,9 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
for (i = 0; i < LENGTH(m->pool); i++)
|
||||
wlr_buffer_drop(&m->pool[i]->base);
|
||||
|
||||
+ for (i = 0; i < LENGTH(m->extra_pool); i++)
|
||||
+ wlr_buffer_drop(&m->extra_pool[i]->base);
|
||||
+
|
||||
drwl_setimage(m->drw, NULL);
|
||||
drwl_destroy(m->drw);
|
||||
|
||||
@@ -910,6 +922,7 @@ cleanupmon(struct wl_listener *listener, void *data)
|
||||
closemon(m);
|
||||
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
||||
wlr_scene_node_destroy(&m->scene_buffer->node);
|
||||
+ wlr_scene_node_destroy(&m->extra_scene_buffer->node);
|
||||
free(m);
|
||||
}
|
||||
|
||||
@@ -1255,6 +1268,8 @@ createmon(struct wl_listener *listener, void *data)
|
||||
|
||||
m->scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
|
||||
m->scene_buffer->point_accepts_input = baracceptsinput;
|
||||
+ m->extra_scene_buffer = wlr_scene_buffer_create(layers[LyrBottom], NULL);
|
||||
+ m->extra_scene_buffer->point_accepts_input = baracceptsinput;
|
||||
updatebar(m);
|
||||
|
||||
wl_list_insert(&mons, &m->link);
|
||||
@@ -1580,7 +1595,7 @@ drawbar(Monitor *m)
|
||||
|
||||
if (!m->scene_buffer->node.enabled)
|
||||
return;
|
||||
- if (!(buf = bufmon(m)))
|
||||
+ if (!(buf = bufmon(m, m->pool)))
|
||||
return;
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
@@ -1633,13 +1648,47 @@ drawbar(Monitor *m)
|
||||
wlr_buffer_unlock(&buf->base);
|
||||
}
|
||||
|
||||
+void
|
||||
+extrabar(Monitor *m)
|
||||
+{
|
||||
+ int tw = 0;
|
||||
+ Buffer *buf = NULL;
|
||||
+
|
||||
+ /* Skip if the extra bar scene buffer is not initialized/enabled */
|
||||
+ if (!m->extra_scene_buffer || !m->extra_scene_buffer->node.enabled)
|
||||
+ return;
|
||||
+
|
||||
+ /* Inline bufmon logic for the extra pool to keep changes contained */
|
||||
+ if (!(buf = bufmon(m, m->extra_pool)))
|
||||
+ return;
|
||||
+
|
||||
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
+ drwl_rect(m->drw, 0, 0, m->b.width, m->b.height, 1, 1);
|
||||
+
|
||||
+ drwl_setscheme(m->drw, colors[SchemeNorm]);
|
||||
+ tw = TEXTW(m, stext2) - m->lrpad + 2; /* 2px right padding */
|
||||
+ drwl_text(m->drw, 2, 0, tw, m->b.height, 0, stext2, 0);
|
||||
+
|
||||
+ tw = TEXTW(m, stext3) - m->lrpad + 2; /* 2px right padding */
|
||||
+ drwl_text(m->drw, m->b.width - tw - 4, 0, tw, m->b.height, 0, stext3, 0);
|
||||
+
|
||||
+ wlr_scene_buffer_set_dest_size(m->extra_scene_buffer, m->b.real_width, m->b.real_height);
|
||||
+ wlr_scene_node_set_position(&m->extra_scene_buffer->node, m->m.x,
|
||||
+ m->m.y + (topbar ? m->m.height - m->b.real_height : 0));
|
||||
+
|
||||
+ wlr_scene_buffer_set_buffer(m->extra_scene_buffer, &buf->base);
|
||||
+ wlr_buffer_unlock(&buf->base);
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbars(void)
|
||||
{
|
||||
Monitor *m = NULL;
|
||||
|
||||
- wl_list_for_each(m, &mons, link)
|
||||
+ wl_list_for_each(m, &mons, link) {
|
||||
drawbar(m);
|
||||
+ extrabar(m);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2896,7 +2945,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
int
|
||||
statusin(int fd, unsigned int mask, void *data)
|
||||
{
|
||||
- char status[256];
|
||||
+ char status[3*256];
|
||||
ssize_t n;
|
||||
|
||||
if (mask & WL_EVENT_ERROR)
|
||||
@@ -2911,7 +2960,18 @@ statusin(int fd, unsigned int mask, void *data)
|
||||
status[n] = '\0';
|
||||
status[strcspn(status, "\n")] = '\0';
|
||||
|
||||
- strncpy(stext, status, sizeof(stext));
|
||||
+ char *l1 = strchr(status, ';');
|
||||
+ if (l1) {
|
||||
+ *l1 = '\0';
|
||||
+ char *l2 = strchr(++l1, ';');
|
||||
+ if (l2) {
|
||||
+ *l2 = '\0';
|
||||
+ strncpy(stext3, ++l2, sizeof(stext3));
|
||||
+ }
|
||||
+ strncpy(stext2, l1, sizeof(stext2));
|
||||
+ }
|
||||
+ strncpy(stext, status, sizeof(stext));
|
||||
+
|
||||
drawbars();
|
||||
|
||||
return 0;
|
||||
@@ -3172,10 +3232,9 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
|
||||
if (stext[0] == '\0')
|
||||
strncpy(stext, "dwl-"VERSION, sizeof(stext));
|
||||
- wl_list_for_each(m, &mons, link) {
|
||||
+ wl_list_for_each(m, &mons, link)
|
||||
updatebar(m);
|
||||
- drawbar(m);
|
||||
- }
|
||||
+ drawbars();
|
||||
|
||||
/* FIXME: figure out why the cursor image is at 0,0 after turning all
|
||||
* the monitors on.
|
||||
@@ -3199,6 +3258,7 @@ updatebar(Monitor *m)
|
||||
m->b.real_width = (int)((float)m->b.width / m->wlr_output->scale);
|
||||
|
||||
wlr_scene_node_set_enabled(&m->scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
|
||||
+ wlr_scene_node_set_enabled(&m->extra_scene_buffer->node, m->wlr_output->enabled ? showbar : 0);
|
||||
|
||||
for (i = 0; i < LENGTH(m->pool); i++)
|
||||
if (m->pool[i]) {
|
||||
@@ -3206,6 +3266,12 @@ updatebar(Monitor *m)
|
||||
m->pool[i] = NULL;
|
||||
}
|
||||
|
||||
+ for (i = 0; i < LENGTH(m->extra_pool); i++)
|
||||
+ if (m->extra_pool[i]) {
|
||||
+ wlr_buffer_drop(&m->extra_pool[i]->base);
|
||||
+ m->extra_pool[i] = NULL;
|
||||
+ }
|
||||
+
|
||||
if (m->b.scale == m->wlr_output->scale && m->drw)
|
||||
return;
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
Focus the window to the left, right, above or below the current focused window
|
||||
|
||||
### Download
|
||||
- [0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir-0.9.patch.patch)
|
||||
- [main 2026-09-29](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir-wlroots-next-4fd683c.patch)
|
||||
- [git branch](https://codeberg.org/ldev105/dwl/src/branch/focusdir)
|
||||
- [2023-01-22](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusdir/focusdir.patch)
|
||||
|
||||
### Authors
|
||||
- [pi66](https://codeberg.org/pi66)
|
||||
- [ldev105](https://codeberg.org/ldev105)
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
From 552608256fdd2fcc0a0654651b5ee345b6fb9718 Mon Sep 17 00:00:00 2001
|
||||
From: pi66 <pixel2176@proton.me>
|
||||
Date: Tue, 29 Sep 2026 12:09:59 +0100
|
||||
Subject: [PATCH] focusdir: update for dwl v0.9 and wlroots-next-4fd683c
|
||||
|
||||
---
|
||||
config.def.h | 4 ++++
|
||||
dwl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a4019d3..c36bd6e 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -125,6 +125,10 @@ static const Key keys[] = {
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 26fb3a0..4f66a63 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* See LICENSE file for copyright and license details.
|
||||
*/
|
||||
+#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <libinput.h>
|
||||
#include <limits.h>
|
||||
@@ -308,6 +309,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, LayerSurface *l, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
+static void focusdir(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
@@ -1632,6 +1634,49 @@ focusstack(const Arg *arg)
|
||||
focusclient(c, NULL, 1);
|
||||
}
|
||||
|
||||
+void focusdir(const Arg *arg)
|
||||
+{
|
||||
+ /* Focus the left, right, up, down client relative to the current focused client on selmon */
|
||||
+ int dist=INT_MAX;
|
||||
+ Client *c, *sel = focustop(selmon);
|
||||
+ Client *newsel = NULL;
|
||||
+ int newdist=INT_MAX;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen)
|
||||
+ return;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon))
|
||||
+ continue; /* skip non visible windows */
|
||||
+
|
||||
+ if (arg->ui == 0 && sel->geom.x <= c->geom.x) {
|
||||
+ /* Client isn't on our left */
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (arg->ui == 1 && sel->geom.x >= c->geom.x) {
|
||||
+ /* Client isn't on our right */
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (arg->ui == 2 && sel->geom.y <= c->geom.y) {
|
||||
+ /* Client isn't above us */
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (arg->ui == 3 && sel->geom.y >= c->geom.y) {
|
||||
+ /* Client isn't below us */
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ dist=abs(sel->geom.x-c->geom.x)+abs(sel->geom.y-c->geom.y);
|
||||
+ if (dist < newdist){
|
||||
+ newdist = dist;
|
||||
+ newsel=c;
|
||||
+ }
|
||||
+ }
|
||||
+ if (newsel != NULL){
|
||||
+ focusclient(newsel, NULL, 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* We probably should change the name of this: it sounds like it
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
From 2b10cf7ae87f119627260ec5a17147593697b734 Mon Sep 17 00:00:00 2001
|
||||
From: pi66 <pixel2176@proton.me>
|
||||
Date: Tue, 29 Sep 2026 12:15:43 +0100
|
||||
Subject: [PATCH] focusdir: update for dwl v0.9 and wlroots-next-4fd683c
|
||||
From a0e71a687b7fcaebdaf1da80c09bf5563bff46b1 Mon Sep 17 00:00:00 2001
|
||||
From: ldev <ldev@ldev.eu.org>
|
||||
Date: Mon, 12 Feb 2024 21:50:24 +0100
|
||||
Subject: [PATCH] focusdir
|
||||
|
||||
---
|
||||
config.def.h | 4 ++++
|
||||
@@ -9,22 +9,22 @@ Subject: [PATCH] focusdir: update for dwl v0.9 and wlroots-next-4fd683c
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..d81f9cd 100644
|
||||
index 9009517..2a1a82e 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -125,6 +125,10 @@ static const Key keys[] = {
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
@@ -124,6 +124,10 @@ static const Key keys[] = {
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_h, focusdir, {.ui = 0} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, focusdir, {.ui = 1} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, focusdir, {.ui = 2} },
|
||||
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, focusdir, {.ui = 3} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4cfd0fd..acab367 100644
|
||||
index bf02a6d..64d5de7 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1,6 +1,7 @@
|
||||
@@ -34,30 +34,29 @@ index 4cfd0fd..acab367 100644
|
||||
+#include <limits.h>
|
||||
#include <getopt.h>
|
||||
#include <libinput.h>
|
||||
#include <limits.h>
|
||||
@@ -306,6 +307,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
#include <linux/input-event-codes.h>
|
||||
@@ -268,6 +269,7 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
+static void focusdir(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
@@ -1624,6 +1626,49 @@ focusstack(const Arg *arg)
|
||||
static void handlesig(int signo);
|
||||
@@ -1271,6 +1273,49 @@ focusstack(const Arg *arg)
|
||||
focusclient(c, 1);
|
||||
}
|
||||
|
||||
+void focusdir(const Arg *arg)
|
||||
+{
|
||||
+ /* Focus the left, right, up, down client relative to the current focused client on selmon */
|
||||
+ int dist=INT_MAX;
|
||||
+ Client *c, *sel = focustop(selmon);
|
||||
+ if (!sel || sel->isfullscreen)
|
||||
+ return;
|
||||
+
|
||||
+ int dist=INT_MAX;
|
||||
+ Client *newsel = NULL;
|
||||
+ int newdist=INT_MAX;
|
||||
+
|
||||
+ if (!sel || sel->isfullscreen)
|
||||
+ return;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, selmon))
|
||||
+ continue; /* skip non visible windows */
|
||||
@@ -90,9 +89,10 @@ index 4cfd0fd..acab367 100644
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* We probably should change the name of this: it sounds like it
|
||||
+
|
||||
/* We probably should change the name of this, it sounds like
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
--
|
||||
2.55.0
|
||||
2.43.0
|
||||
|
||||
@@ -7,8 +7,7 @@ This is the approximately the equivalent of the focusonactive patch of dwm.
|
||||
If you want a more controlled behavior, for example setting which clients can focus, check [activation-rule patch](https://codeberg.org/sevz/dwl-patches/src/branch/activation-rules).
|
||||
|
||||
### Download
|
||||
- [dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent_08.patch)
|
||||
- [dwl current 2026/09/28](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent_current.patch)
|
||||
- [main dwl 0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/focusonurgent/focusonurgent.patch)
|
||||
|
||||
### Authors
|
||||
- [André Desgualdo Pereira](https://codeberg.org/Kana)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 3e94fa2..364debd 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -2286,9 +2286,11 @@ printstatus(void)
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
- occ |= c->tags;
|
||||
- if (c->isurgent)
|
||||
- urg |= c->tags;
|
||||
+ if (c->isurgent) {
|
||||
+ view(&((Arg){ .ui = c->tags }));
|
||||
+ focusclient(c, NULL, 1);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
if ((c = focustop(m))) {
|
||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
||||
@@ -2,10 +2,8 @@
|
||||
Implement `foreign-toplevel-management`, it add handlers for activate, close, fullscreen and destroy request events, it's missing minimize and maximize request handlers.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/foreign-toplevel-management)
|
||||
- [2026-10-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/foreign-toplevel-management/foreign-toplevel-management.patch)
|
||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.6-a/foreign-toplevel-management)
|
||||
- [2024-05-02](https://codeberg.org/dwl/dwl-patches/raw/commit/e58c3ec41a39df934d2998161d7187ac965ea77a/foreign-toplevel-management/foreign-toplevel-management.patch)
|
||||
|
||||
### Authors
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
- [Guido Cella](https://codeberg.org/guidocella)
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
From 7820c6ca511de2fc41ab5bcf74dc0a5e0803d33f Mon Sep 17 00:00:00 2001
|
||||
From dc63d64cd69f515013464b3feb8acb411f5a348f Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Thu, 17 Sep 2026 08:22:59 +0200
|
||||
Date: Thu, 2 May 2024 17:25:45 -0500
|
||||
Subject: [PATCH] implement foreign toplevel management
|
||||
|
||||
---
|
||||
Makefile | 5 +-
|
||||
dwl.c | 95 +++++-
|
||||
dwl.c | 93 +++++-
|
||||
...oreign-toplevel-management-unstable-v1.xml | 270 ++++++++++++++++++
|
||||
3 files changed, 367 insertions(+), 3 deletions(-)
|
||||
3 files changed, 366 insertions(+), 2 deletions(-)
|
||||
create mode 100644 protocols/wlr-foreign-toplevel-management-unstable-v1.xml
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 8304245..cfbc0e0 100644
|
||||
index a67fdd3..e0e1260 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -20,7 +20,7 @@ all: dwl
|
||||
dwl: dwl.c client.h config.h ime.h util.h config.mk cursor-shape-v1-protocol.h \
|
||||
ext-image-copy-capture-v1-protocol.h \
|
||||
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
|
||||
- wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+ wlr-foreign-toplevel-management-unstable-v1-protocol.h wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
$(CC) dwl.c $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
@@ -16,7 +16,7 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS)
|
||||
all: dwl
|
||||
dwl: dwl.o util.o
|
||||
$(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@
|
||||
-dwl.o: dwl.c config.mk config.h client.h cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+dwl.o: dwl.c config.mk config.h client.h cursor-shape-v1-protocol.h pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h wlr-foreign-toplevel-management-unstable-v1-protocol.h
|
||||
util.o: util.c util.h
|
||||
|
||||
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||
@@ -47,6 +47,9 @@ wlr-output-power-management-unstable-v1-protocol.h:
|
||||
@@ -37,6 +37,9 @@ wlr-layer-shell-unstable-v1-protocol.h:
|
||||
xdg-shell-protocol.h:
|
||||
$(WAYLAND_SCANNER) server-header \
|
||||
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
|
||||
@@ -34,18 +34,18 @@ index 8304245..cfbc0e0 100644
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 89e8caf..006c615 100644
|
||||
index bf763df..648616d 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <wlr/types/wlr_ext_image_capture_source_v1.h>
|
||||
#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
|
||||
#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_drm.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
+#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_idle_inhibit_v1.h>
|
||||
@@ -151,6 +152,11 @@ typedef struct {
|
||||
@@ -126,6 +127,11 @@ typedef struct {
|
||||
struct wl_listener fullscreen;
|
||||
struct wl_listener set_decoration_mode;
|
||||
struct wl_listener destroy_decoration;
|
||||
@@ -54,10 +54,10 @@ index 89e8caf..006c615 100644
|
||||
+ struct wl_listener fclose;
|
||||
+ struct wl_listener ffullscreen;
|
||||
+ struct wl_listener fdestroy;
|
||||
struct wlr_box prev; /* layout-relative, includes border */
|
||||
struct wlr_box bounds;
|
||||
#ifdef XWAYLAND
|
||||
struct wl_listener activate;
|
||||
struct wl_listener associate;
|
||||
@@ -387,8 +393,14 @@ static Monitor *xytomon(double x, double y);
|
||||
@@ -347,6 +353,11 @@ static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
static void zoom(const Arg *arg);
|
||||
@@ -68,22 +68,19 @@ index 89e8caf..006c615 100644
|
||||
+static void ffullscreennotify(struct wl_listener *listener, void *data);
|
||||
|
||||
/* variables */
|
||||
+static const char broken[] = "broken";
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
static Client *focused_client;
|
||||
@@ -433,6 +445,8 @@ static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
||||
static struct wlr_scene_rect *locked_bg;
|
||||
static const char broken[] = "broken";
|
||||
@@ -392,6 +403,8 @@ static struct wlr_scene_rect *locked_bg;
|
||||
static struct wlr_session_lock_v1 *cur_lock;
|
||||
static struct wl_listener lock_listener = {.notify = locksession};
|
||||
|
||||
+static struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_mgr;
|
||||
+
|
||||
static struct wlr_seat *seat;
|
||||
static KeyboardGroup *kb_group;
|
||||
static unsigned int cursor_mode;
|
||||
@@ -588,6 +602,11 @@ applyrules(Client *c)
|
||||
appid = client_get_appid(c);
|
||||
title = client_get_title(c);
|
||||
static KeyboardGroup kb_group = {0};
|
||||
static KeyboardGroup vkb_group = {0};
|
||||
@@ -458,6 +471,11 @@ applyrules(Client *c)
|
||||
if (!(title = client_get_title(c)))
|
||||
title = broken;
|
||||
|
||||
+ if (c->foreign_toplevel) {
|
||||
+ wlr_foreign_toplevel_handle_v1_set_app_id(c->foreign_toplevel, appid);
|
||||
@@ -93,35 +90,34 @@ index 89e8caf..006c615 100644
|
||||
for (r = rules; r < END(rules); r++) {
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
@@ -1631,6 +1650,8 @@ focusclient(Client *c, LayerSurface *l, int lift)
|
||||
if (s && s->mapped)
|
||||
client_activate_surface(s, 0);
|
||||
focused_client = NULL;
|
||||
+ if (old_c && old_c->foreign_toplevel)
|
||||
+ wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0);
|
||||
@@ -1288,6 +1306,8 @@ focusclient(Client *c, int lift)
|
||||
client_set_border_color(old_c, bordercolor);
|
||||
|
||||
client_activate_surface(old, 0);
|
||||
+ if (old_c->foreign_toplevel)
|
||||
+ wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0);
|
||||
}
|
||||
}
|
||||
printstatus();
|
||||
@@ -1306,6 +1326,8 @@ focusclient(Client *c, int lift)
|
||||
|
||||
@@ -1653,6 +1674,9 @@ focusclient(Client *c, LayerSurface *l, int lift)
|
||||
|
||||
if (!client_is_unmanaged(c))
|
||||
focused_client = c;
|
||||
+
|
||||
/* Activate the new client */
|
||||
client_activate_surface(client_surface(c), 1);
|
||||
+ if (c->foreign_toplevel)
|
||||
+ wlr_foreign_toplevel_handle_v1_set_activated(c->foreign_toplevel, 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1975,6 +1999,8 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
@@ -1599,6 +1621,8 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
c->border[i]->node.data = c;
|
||||
}
|
||||
|
||||
+ createforeigntoplevel(c);
|
||||
+
|
||||
/* Initialize client geometry with room for border */
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
||||
WLR_EDGE_RIGHT);
|
||||
@@ -2661,12 +2687,17 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
|
||||
c->geom.width += 2 * c->bw;
|
||||
@@ -2232,12 +2256,17 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
c->prev = c->geom;
|
||||
|
||||
/* Scene graph sends surface leave/enter events on move and resize */
|
||||
@@ -140,28 +136,29 @@ index 89e8caf..006c615 100644
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
}
|
||||
@@ -2806,7 +2837,10 @@ setup(void)
|
||||
power_mgr = wlr_output_power_manager_v1_create(dpy);
|
||||
wl_signal_add(&power_mgr->events.set_mode, &output_power_mgr_set_mode);
|
||||
@@ -2351,6 +2380,9 @@ setup(void)
|
||||
gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
|
||||
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
|
||||
|
||||
- /* Creates an output layout, which is a wlroots utility for working with an
|
||||
+ /* Initializes foreign toplevel management */
|
||||
+ foreign_toplevel_mgr = wlr_foreign_toplevel_manager_v1_create(dpy);
|
||||
+
|
||||
+ /* Creates an output layout, which a wlroots utility for working with an
|
||||
/* Creates an output layout, which a wlroots utility for working with an
|
||||
* arrangement of screens in a physical layout. */
|
||||
output_layout = wlr_output_layout_create(dpy);
|
||||
wl_signal_add(&output_layout->events.change, &layout_change);
|
||||
@@ -3261,6 +3295,8 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
|
||||
c->foreign_toplevel_handle = NULL;
|
||||
output_layout = wlr_output_layout_create();
|
||||
@@ -2691,6 +2723,11 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->flink);
|
||||
}
|
||||
+ if (c->foreign_toplevel)
|
||||
|
||||
+ if (c->foreign_toplevel) {
|
||||
+ wlr_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel);
|
||||
#ifdef XWAYLAND
|
||||
if (c->type != XDGShell && c->capture.image_capture_scene_surface) {
|
||||
wlr_scene_node_destroy(&c->capture.image_capture_scene_surface->buffer->node);
|
||||
@@ -3393,6 +3429,12 @@ void
|
||||
+ c->foreign_toplevel = NULL;
|
||||
+ }
|
||||
+
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
printstatus();
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
@@ -2802,6 +2839,12 @@ void
|
||||
updatetitle(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
@@ -173,8 +170,8 @@ index 89e8caf..006c615 100644
|
||||
+ }
|
||||
if (c == focustop(c->mon))
|
||||
printstatus();
|
||||
|
||||
@@ -3531,6 +3573,55 @@ zoom(const Arg *arg)
|
||||
}
|
||||
@@ -2929,6 +2972,54 @@ zoom(const Arg *arg)
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
@@ -198,7 +195,7 @@ index 89e8caf..006c615 100644
|
||||
+ } else {
|
||||
+ setmon(c, selmon, 0);
|
||||
+ }
|
||||
+ focusclient(c, NULL, 1);
|
||||
+ focusclient(c, 1);
|
||||
+ arrange(c->mon);
|
||||
+}
|
||||
+
|
||||
@@ -224,7 +221,6 @@ index 89e8caf..006c615 100644
|
||||
+ wl_list_remove(&c->fclose.link);
|
||||
+ wl_list_remove(&c->ffullscreen.link);
|
||||
+ wl_list_remove(&c->fdestroy.link);
|
||||
+ c->foreign_toplevel = NULL;
|
||||
+}
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
@@ -507,5 +503,5 @@ index 0000000..44505bb
|
||||
+ </interface>
|
||||
+</protocol>
|
||||
--
|
||||
2.56.0
|
||||
2.43.2
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
### Description
|
||||
|
||||
# fullscreenadaptivesync - Enables adaptive sync/VRR when a client is fullscreen.
|
||||
# fullscreenadaptivesync — Enables adaptive sync/VRR when a client is fullscreen.
|
||||
|
||||
Adds a function that automatically enables adaptive sync/VRR when a fullscreen client is detected, and disables it once the client exits fullscreen.
|
||||
|
||||
@@ -22,9 +22,8 @@ Adds a function that automatically enables adaptive sync/VRR when a fullscreen c
|
||||
- Enabled by default.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync-0.9)
|
||||
- [fullscreenadaptivesync-v0.9](/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.9.patch)
|
||||
- [fullscreenadaptivesync-v0.8](/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.8.patch)
|
||||
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/fullscreenadaptivesync)
|
||||
- [0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/fullscreenadaptivesync/fullscreenadaptivesync-v0.7.patch)
|
||||
|
||||
### Authors
|
||||
- [julmajustus](https://codeberg.org/julmajustus)
|
||||
|
||||
+27
-50
@@ -1,33 +1,30 @@
|
||||
From b9bb8d48e1be3008d72da414f6f418d77f3ca16b Mon Sep 17 00:00:00 2001
|
||||
From c003f450c197a0c960bbb355511f8dca7a35e3c3 Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Mon, 22 Jun 2026 23:01:00 +0300
|
||||
Subject: [PATCH] fullscreen_adaptive_sync: Minor bug fixes
|
||||
Date: Sat, 4 Jan 2025 14:24:59 +0200
|
||||
Subject: [PATCH] add fullscreenadaptivesync
|
||||
|
||||
- Fixed logic error inside unmapnotify
|
||||
- Added no-op guards inside set_adaptive_sync
|
||||
- Added extra check for the config commit success
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 54 insertions(+)
|
||||
dwl.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 41 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..06b3153 100644
|
||||
index 22d2171..886f1ab 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -138,6 +138,7 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
@@ -142,6 +142,7 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ 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 44f3ad9..e4f6a9d 100644
|
||||
index a2711f6..7be05ef 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -319,6 +319,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
@@ -322,6 +322,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void requestmonstate(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
static void run(char *startup_cmd);
|
||||
@@ -35,7 +32,7 @@ index 44f3ad9..e4f6a9d 100644
|
||||
static void setcursor(struct wl_listener *listener, void *data);
|
||||
static void setcursorshape(struct wl_listener *listener, void *data);
|
||||
static void setfloating(Client *c, int floating);
|
||||
@@ -336,6 +337,7 @@ static void tagmon(const Arg *arg);
|
||||
@@ -340,6 +341,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
@@ -43,16 +40,16 @@ index 44f3ad9..e4f6a9d 100644
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -436,6 +438,8 @@ static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
@@ -413,6 +415,8 @@ static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
+static int fullscreen_adaptive_sync_enabled = 1;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
static void associatex11(struct wl_listener *listener, void *data);
|
||||
@@ -2296,6 +2300,43 @@ run(char *startup_cmd)
|
||||
@@ -2269,6 +2273,31 @@ run(char *startup_cmd)
|
||||
wl_display_run(dpy);
|
||||
}
|
||||
|
||||
@@ -67,25 +64,13 @@ index 44f3ad9..e4f6a9d 100644
|
||||
+ || !fullscreen_adaptive_sync_enabled)
|
||||
+ return;
|
||||
+
|
||||
+ if (enable && m->wlr_output->adaptive_sync_status
|
||||
+ == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)
|
||||
+ return;
|
||||
+
|
||||
+ if (!enable && m->wlr_output->adaptive_sync_status
|
||||
+ == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED)
|
||||
+ return;
|
||||
+
|
||||
+ config = wlr_output_configuration_v1_create();
|
||||
+ config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||
+
|
||||
+ /* Set and commit the adaptive sync state change */
|
||||
+ wlr_output_state_init(&state);
|
||||
+ wlr_output_state_set_adaptive_sync_enabled(&state, enable);
|
||||
+ if (!wlr_output_commit_state(m->wlr_output, &state)) {
|
||||
+ wlr_output_state_finish(&state);
|
||||
+ wlr_output_configuration_v1_destroy(config);
|
||||
+ return;
|
||||
+ }
|
||||
+ wlr_output_commit_state(m->wlr_output, &state);
|
||||
+ wlr_output_state_finish(&state);
|
||||
+
|
||||
+ /* Broadcast the adaptive sync state change to output_mgr */
|
||||
@@ -96,7 +81,7 @@ index 44f3ad9..e4f6a9d 100644
|
||||
void
|
||||
setcursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2359,10 +2400,12 @@ setfullscreen(Client *c, int fullscreen)
|
||||
@@ -2332,10 +2361,12 @@ setfullscreen(Client *c, int fullscreen)
|
||||
if (fullscreen) {
|
||||
c->prev = c->geom;
|
||||
resize(c, c->mon->m, 0);
|
||||
@@ -109,7 +94,7 @@ index 44f3ad9..e4f6a9d 100644
|
||||
}
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
@@ -2760,6 +2803,12 @@ togglefullscreen(const Arg *arg)
|
||||
@@ -2739,6 +2770,12 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
@@ -122,24 +107,16 @@ index 44f3ad9..e4f6a9d 100644
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
@@ -2815,6 +2864,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the surface is unmapped, and should no longer be shown. */
|
||||
Client *c = wl_container_of(listener, c, unmap);
|
||||
+ Monitor *lastmon = c->mon; // fullscreen_adaptive_sync
|
||||
if (c == grabc) {
|
||||
cursor_mode = CurNormal;
|
||||
grabc = NULL;
|
||||
@@ -2830,6 +2880,9 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
@@ -2809,6 +2846,9 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
setmon(c, NULL, 0);
|
||||
wl_list_remove(&c->flink);
|
||||
}
|
||||
+ /* Toggle adaptive sync off when fullscreen client is unmapped */
|
||||
+ if (c->isfullscreen)
|
||||
+ set_adaptive_sync(lastmon, 0);
|
||||
+ set_adaptive_sync(selmon, 0);
|
||||
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
printstatus();
|
||||
--
|
||||
2.53.0
|
||||
2.45.2
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
From 860793b4ff7b03c0fe4be03f2086ae5f25876293 Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Sun, 20 Sep 2026 02:32:01 +0300
|
||||
Subject: [PATCH] fullscreenadaptivesync refactor for d16036e
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 57 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..262e3f3 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -138,6 +138,7 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_F5, togglefullscreenadaptivesync, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_0, tag, {.ui = ~0} },
|
||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4cfd0fd..c3ab2ba 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -340,6 +340,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
static void requestmonstate(struct wl_listener *listener, void *data);
|
||||
static void resize(Client *c, struct wlr_box geo, int interact);
|
||||
static void run(char *startup_cmd);
|
||||
+static void set_adaptive_sync(Monitor *m, int enabled);
|
||||
static void setcursor(struct wl_listener *listener, void *data);
|
||||
static void setcursorshape(struct wl_listener *listener, void *data);
|
||||
static void setfloating(Client *c, int floating);
|
||||
@@ -357,6 +358,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
+static void togglefullscreenadaptivesync(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -462,6 +464,8 @@ static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
|
||||
|
||||
+static int fullscreen_adaptive_sync_enabled = 1;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
static void activatex11(struct wl_listener *listener, void *data);
|
||||
static void associatex11(struct wl_listener *listener, void *data);
|
||||
@@ -2453,6 +2457,43 @@ run(char *startup_cmd)
|
||||
wl_display_run(dpy);
|
||||
}
|
||||
|
||||
+void
|
||||
+set_adaptive_sync(Monitor *m, int enable)
|
||||
+{
|
||||
+ struct wlr_output_state state;
|
||||
+ struct wlr_output_configuration_v1 *config;
|
||||
+ struct wlr_output_configuration_head_v1 *config_head;
|
||||
+
|
||||
+ if (!m || !m->wlr_output || !m->wlr_output->enabled
|
||||
+ || !fullscreen_adaptive_sync_enabled)
|
||||
+ return;
|
||||
+
|
||||
+ if (enable && m->wlr_output->adaptive_sync_status
|
||||
+ == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)
|
||||
+ return;
|
||||
+
|
||||
+ if (!enable && m->wlr_output->adaptive_sync_status
|
||||
+ == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED)
|
||||
+ return;
|
||||
+
|
||||
+ config = wlr_output_configuration_v1_create();
|
||||
+ config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||
+
|
||||
+ /* Set and commit the adaptive sync state change */
|
||||
+ wlr_output_state_init(&state);
|
||||
+ wlr_output_state_set_adaptive_sync_enabled(&state, enable);
|
||||
+ if (!wlr_output_commit_state(m->wlr_output, &state)) {
|
||||
+ wlr_output_state_finish(&state);
|
||||
+ wlr_output_configuration_v1_destroy(config);
|
||||
+ return;
|
||||
+ }
|
||||
+ wlr_output_state_finish(&state);
|
||||
+
|
||||
+ /* Broadcast the adaptive sync state change to output_mgr */
|
||||
+ config_head->state.adaptive_sync_enabled = enable;
|
||||
+ wlr_output_manager_v1_set_configuration(output_mgr, config);
|
||||
+}
|
||||
+
|
||||
void
|
||||
setcursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2516,10 +2557,12 @@ setfullscreen(Client *c, int fullscreen)
|
||||
if (fullscreen) {
|
||||
c->prev = c->geom;
|
||||
resize(c, c->mon->m, 0);
|
||||
+ set_adaptive_sync(c->mon, 1);
|
||||
} else {
|
||||
/* restore previous size instead of arrange for floating windows since
|
||||
* client positions are set by the user and cannot be recalculated */
|
||||
resize(c, c->prev, 0);
|
||||
+ set_adaptive_sync(c->mon, 0);
|
||||
}
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
@@ -2699,7 +2742,7 @@ setup(void)
|
||||
output_layout = wlr_output_layout_create(dpy);
|
||||
wl_signal_add(&output_layout->events.change, &layout_change);
|
||||
|
||||
- wlr_xdg_output_manager_v1_create(dpy, output_layout);
|
||||
+ wlr_xdg_output_manager_v1_create(dpy, output_layout);
|
||||
|
||||
/* Configure a listener to be notified when new outputs are available on the
|
||||
* backend. */
|
||||
@@ -2795,8 +2838,8 @@ setup(void)
|
||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
||||
&new_virtual_keyboard);
|
||||
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
|
||||
- wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
|
||||
- &new_virtual_pointer);
|
||||
+ wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
|
||||
+ &new_virtual_pointer);
|
||||
|
||||
seat = wlr_seat_create(dpy, "seat0");
|
||||
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
|
||||
@@ -2930,6 +2973,12 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
+void
|
||||
+togglefullscreenadaptivesync(const Arg *arg)
|
||||
+{
|
||||
+ fullscreen_adaptive_sync_enabled = !fullscreen_adaptive_sync_enabled;
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
@@ -2985,6 +3034,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Called when the surface is unmapped, and should no longer be shown. */
|
||||
Client *c = wl_container_of(listener, c, unmap);
|
||||
+ Monitor *lastmon = c->mon; // fullscreen_adaptive_sync
|
||||
if (c == grabc) {
|
||||
cursor_mode = CurNormal;
|
||||
grabc = NULL;
|
||||
@@ -3002,6 +3052,9 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
setmon(c, NULL, 0);
|
||||
wl_list_remove(&c->flink);
|
||||
}
|
||||
+ /* Toggle adaptive sync off when fullscreen client is unmapped */
|
||||
+ if (c->isfullscreen)
|
||||
+ set_adaptive_sync(lastmon, 0);
|
||||
|
||||
if (c->foreign_toplevel_handle) {
|
||||
wlr_ext_foreign_toplevel_handle_v1_destroy(c->foreign_toplevel_handle);
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
### Description
|
||||
Gamepad bindings to dwl. Press `LB + RB` toggle gamepad bindings.
|
||||
|
||||
### Download
|
||||
- [2026-07-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gamepad-bindings/gamepad-bindings.patch)
|
||||
### Authors
|
||||
- [dhruva_sambrani](https://codeberg.org/dhruva_sambrani)
|
||||
|
||||
@@ -1,423 +0,0 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 578194f..601c70e 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -12,16 +12,17 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
||||
-Wfloat-conversion
|
||||
|
||||
# CFLAGS / LDFLAGS
|
||||
-PKGS = wayland-server xkbcommon libinput $(XLIBS)
|
||||
+PKGS = wayland-server xkbcommon libinput libevdev libudev $(XLIBS)
|
||||
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
||||
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
|
||||
|
||||
all: dwl
|
||||
-dwl: dwl.o util.o
|
||||
- $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
-dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \
|
||||
+dwl: dwl.o gamepad.o util.o
|
||||
+ $(CC) dwl.o gamepad.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
+dwl.o: dwl.c client.h gamepad.h config.h config.mk cursor-shape-v1-protocol.h \
|
||||
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
|
||||
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h
|
||||
+gamepad.o: gamepad.c gamepad.h
|
||||
util.o: util.c util.h
|
||||
|
||||
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||
@@ -54,7 +55,7 @@ clean:
|
||||
dist: clean
|
||||
mkdir -p dwl-$(VERSION)
|
||||
cp -R LICENSE* Makefile CHANGELOG.md README.md client.h config.def.h \
|
||||
- config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop \
|
||||
+ config.mk protocols dwl.1 dwl.c gamepad.c gamepad.h util.c util.h dwl.desktop \
|
||||
dwl-$(VERSION)
|
||||
tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION)
|
||||
rm -rf dwl-$(VERSION)
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..48270f6 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -165,6 +165,22 @@ static const Key keys[] = {
|
||||
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
|
||||
};
|
||||
|
||||
+static const GamepadButton gamepadbuttons[] = {
|
||||
+ { BTN_DPAD_DOWN, focusstack, {.i = +1} },
|
||||
+ { BTN_DPAD_UP, focusstack, {.i = -1} },
|
||||
+ { BTN_DPAD_LEFT, setmfact, {.f = -0.05f} },
|
||||
+ { BTN_DPAD_RIGHT, setmfact, {.f = +0.05f} },
|
||||
+ { BTN_SOUTH, zoom, {0} },
|
||||
+ { BTN_EAST, setlayout, {.v = &layouts[0]} },
|
||||
+ { BTN_NORTH, setlayout, {.v = &layouts[1]} },
|
||||
+ { BTN_WEST, setlayout, {.v = &layouts[2]} },
|
||||
+ { ABS_Z, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
+ { ABS_RZ, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
+ { BTN_START, spawn, SHCMD("wmenu-run") },
|
||||
+ { BTN_SELECT, winview, {0} },
|
||||
+ { BTN_MODE, spawn, { "steam", NULL }},
|
||||
+};
|
||||
+
|
||||
static const Button buttons[] = {
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 101a45f..96e1c01 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -63,6 +63,7 @@
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
+#include "gamepad.h"
|
||||
#ifdef XWAYLAND
|
||||
#include <wlr/xwayland.h>
|
||||
#include <xcb/xcb.h>
|
||||
@@ -149,6 +150,12 @@ typedef struct {
|
||||
const Arg arg;
|
||||
} Key;
|
||||
|
||||
+typedef struct {
|
||||
+ unsigned int button;
|
||||
+ void (*func)(const Arg *);
|
||||
+ const Arg arg;
|
||||
+} GamepadButton;
|
||||
+
|
||||
typedef struct {
|
||||
struct wlr_keyboard_group *wlr_group;
|
||||
|
||||
@@ -289,6 +296,7 @@ static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
+static void gamepadbutton(unsigned int button, int state);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -398,6 +406,7 @@ static struct wlr_session_lock_v1 *cur_lock;
|
||||
|
||||
static struct wlr_seat *seat;
|
||||
static KeyboardGroup *kb_group;
|
||||
+static struct gamepad *gamepad;
|
||||
static unsigned int cursor_mode;
|
||||
static Client *grabc;
|
||||
static int grabcx, grabcy; /* client-relative */
|
||||
@@ -713,6 +722,7 @@ cleanup(void)
|
||||
wlr_xcursor_manager_destroy(cursor_mgr);
|
||||
|
||||
destroykeyboardgroup(&kb_group->destroy, NULL);
|
||||
+ gamepad_destroy(gamepad);
|
||||
|
||||
/* If it's not destroyed manually, it will cause a use-after-free of wlr_seat.
|
||||
* Destroy it until it's fixed on the wlroots side */
|
||||
@@ -1558,6 +1568,21 @@ gpureset(struct wl_listener *listener, void *data)
|
||||
wlr_renderer_destroy(old_drw);
|
||||
}
|
||||
|
||||
+void
|
||||
+gamepadbutton(unsigned int button, int state)
|
||||
+{
|
||||
+ const GamepadButton *b;
|
||||
+ if (!state || locked)
|
||||
+ return;
|
||||
+ wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
+ for (b = gamepadbuttons; b < END(gamepadbuttons); b++) {
|
||||
+ if (button == b->button && b->func) {
|
||||
+ b->func(&b->arg);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
@@ -2643,6 +2668,7 @@ setup(void)
|
||||
|
||||
kb_group = createkeyboardgroup();
|
||||
wl_list_init(&kb_group->destroy.link);
|
||||
+ gamepad = gamepad_create(event_loop, session, gamepadbutton);
|
||||
|
||||
output_mgr = wlr_output_manager_v1_create(dpy);
|
||||
wl_signal_add(&output_mgr->events.apply, &output_mgr_apply);
|
||||
diff --git a/gamepad.c b/gamepad.c
|
||||
new file mode 100644
|
||||
index 0000000..6bad2f6
|
||||
--- /dev/null
|
||||
+++ b/gamepad.c
|
||||
@@ -0,0 +1,255 @@
|
||||
+#include <fcntl.h>
|
||||
+#include <libevdev/libevdev.h>
|
||||
+#include <libudev.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
+#include <wayland-server-core.h>
|
||||
+#include <wlr/backend/session.h>
|
||||
+
|
||||
+#include "gamepad.h"
|
||||
+
|
||||
+struct pad {
|
||||
+ struct wl_list link;
|
||||
+ char *path;
|
||||
+ int fd;
|
||||
+ struct libevdev *dev;
|
||||
+ struct wl_event_source *src;
|
||||
+ unsigned char key[KEY_CNT];
|
||||
+ unsigned char abs[ABS_CNT];
|
||||
+ int enabled;
|
||||
+ GamepadHandler fn;
|
||||
+};
|
||||
+
|
||||
+struct gamepad {
|
||||
+ struct udev *udev;
|
||||
+ struct udev_monitor *mon;
|
||||
+ struct wl_event_source *msrc;
|
||||
+ struct wl_event_loop *loop;
|
||||
+ struct wl_list pads;
|
||||
+ GamepadHandler fn;
|
||||
+};
|
||||
+
|
||||
+static int
|
||||
+ispad(struct udev_device *d)
|
||||
+{
|
||||
+ const char *p;
|
||||
+
|
||||
+ p = udev_device_get_property_value(d, "ID_INPUT_JOYSTICK");
|
||||
+ return !strcmp(udev_device_get_subsystem(d), "input")
|
||||
+ && !strncmp(udev_device_get_sysname(d), "event", 5)
|
||||
+ && p && !strcmp(p, "1");
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+padstop(struct pad *p)
|
||||
+{
|
||||
+ if (p->src)
|
||||
+ wl_event_source_remove(p->src);
|
||||
+ if (p->dev)
|
||||
+ libevdev_free(p->dev);
|
||||
+ if (p->fd >= 0)
|
||||
+ close(p->fd);
|
||||
+ p->src = NULL;
|
||||
+ p->dev = NULL;
|
||||
+ p->fd = -1;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+padclose(struct pad *p)
|
||||
+{
|
||||
+ padstop(p);
|
||||
+ wl_list_remove(&p->link);
|
||||
+ free(p->path);
|
||||
+ free(p);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+padin(int fd, uint32_t mask, void *data)
|
||||
+{
|
||||
+ struct pad *p = data;
|
||||
+ struct input_event e;
|
||||
+ int r, v;
|
||||
+
|
||||
+ if (mask & (WL_EVENT_HANGUP | WL_EVENT_ERROR)) {
|
||||
+ padclose(p);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ while ((r = libevdev_next_event(p->dev, LIBEVDEV_READ_FLAG_NORMAL, &e)) == 0
|
||||
+ || r == LIBEVDEV_READ_STATUS_SYNC) {
|
||||
+ if (e.type == EV_KEY) {
|
||||
+ v = !!e.value;
|
||||
+ if (p->key[e.code] != v) {
|
||||
+ p->key[e.code] = v;
|
||||
+ if (p->enabled)
|
||||
+ p->fn(e.code, v);
|
||||
+ if ((e.code == BTN_TL || e.code == BTN_TR)
|
||||
+ && p->key[BTN_TL] && p->key[BTN_TR] && v)
|
||||
+ p->enabled ^= 1;
|
||||
+ }
|
||||
+ } else if (e.type == EV_ABS && (e.code == ABS_Z || e.code == ABS_RZ
|
||||
+ || e.code == ABS_GAS || e.code == ABS_BRAKE)) {
|
||||
+ const struct input_absinfo *a = libevdev_get_abs_info(p->dev, e.code);
|
||||
+
|
||||
+ v = e.value > (a->minimum + a->maximum) / 2;
|
||||
+ if (p->abs[e.code] != v) {
|
||||
+ p->abs[e.code] = v;
|
||||
+ if (p->enabled)
|
||||
+ p->fn(e.code, v);
|
||||
+ }
|
||||
+ } else if (e.type == EV_ABS && e.code == ABS_HAT0X) {
|
||||
+ v = e.value + 1;
|
||||
+ if (p->abs[e.code] != v) {
|
||||
+ if (p->enabled) {
|
||||
+ p->fn(BTN_DPAD_LEFT, 0);
|
||||
+ p->fn(BTN_DPAD_RIGHT, 0);
|
||||
+ }
|
||||
+ p->abs[e.code] = v;
|
||||
+ if (p->enabled) {
|
||||
+ p->fn(BTN_DPAD_LEFT, e.value < 0);
|
||||
+ p->fn(BTN_DPAD_RIGHT, e.value > 0);
|
||||
+ }
|
||||
+ }
|
||||
+ } else if (e.type == EV_ABS && e.code == ABS_HAT0Y) {
|
||||
+ v = e.value + 1;
|
||||
+ if (p->abs[e.code] != v) {
|
||||
+ if (p->enabled) {
|
||||
+ p->fn(BTN_DPAD_UP, 0);
|
||||
+ p->fn(BTN_DPAD_DOWN, 0);
|
||||
+ }
|
||||
+ p->abs[e.code] = v;
|
||||
+ if (p->enabled) {
|
||||
+ p->fn(BTN_DPAD_UP, e.value < 0);
|
||||
+ p->fn(BTN_DPAD_DOWN, e.value > 0);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+padstart(struct pad *p, struct wl_event_loop *loop)
|
||||
+{
|
||||
+ if (p->fd >= 0 || (p->fd = open(p->path, O_RDONLY | O_NONBLOCK | O_CLOEXEC)) < 0)
|
||||
+ return;
|
||||
+ if (libevdev_new_from_fd(p->fd, &p->dev)) {
|
||||
+ close(p->fd);
|
||||
+ p->fd = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!(p->src = wl_event_loop_add_fd(loop, p->fd, WL_EVENT_READABLE, padin, p)))
|
||||
+ padstop(p);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+padadd(struct gamepad *g, struct udev_device *d)
|
||||
+{
|
||||
+ struct pad *p;
|
||||
+ struct pad *q;
|
||||
+ const char *path;
|
||||
+
|
||||
+ if (!ispad(d) || !(path = udev_device_get_devnode(d)))
|
||||
+ return;
|
||||
+ wl_list_for_each(q, &g->pads, link) {
|
||||
+ if (!strcmp(q->path, path))
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!(p = calloc(1, sizeof(*p))))
|
||||
+ return;
|
||||
+ if (!(p->path = strdup(path))) {
|
||||
+ free(p);
|
||||
+ return;
|
||||
+ }
|
||||
+ p->fd = -1;
|
||||
+ p->enabled = 0;
|
||||
+ p->fn = g->fn;
|
||||
+ wl_list_insert(&g->pads, &p->link);
|
||||
+ padstart(p, g->loop);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+padremove(struct gamepad *g, const char *path)
|
||||
+{
|
||||
+ struct pad *p, *t;
|
||||
+
|
||||
+ wl_list_for_each_safe(p, t, &g->pads, link) {
|
||||
+ if (!strcmp(p->path, path)) {
|
||||
+ padclose(p);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+monin(int fd, uint32_t mask, void *data)
|
||||
+{
|
||||
+ struct gamepad *g = data;
|
||||
+ struct udev_device *d;
|
||||
+ const char *a;
|
||||
+ const char *path;
|
||||
+
|
||||
+ if (!(d = udev_monitor_receive_device(g->mon)))
|
||||
+ return 0;
|
||||
+ a = udev_device_get_action(d);
|
||||
+ path = udev_device_get_devnode(d);
|
||||
+ if (a && !strcmp(a, "add"))
|
||||
+ padadd(g, d);
|
||||
+ else if (a && !strcmp(a, "remove") && path)
|
||||
+ padremove(g, path);
|
||||
+ udev_device_unref(d);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+struct gamepad *
|
||||
+gamepad_create(struct wl_event_loop *loop, struct wlr_session *s, GamepadHandler fn)
|
||||
+{
|
||||
+ struct gamepad *g;
|
||||
+ struct udev_enumerate *e;
|
||||
+ struct udev_list_entry *l;
|
||||
+ struct udev_device *d;
|
||||
+
|
||||
+ if (!s || !(g = calloc(1, sizeof(*g))) || !(g->udev = udev_new()))
|
||||
+ return NULL;
|
||||
+ g->loop = loop;
|
||||
+ g->fn = fn;
|
||||
+ wl_list_init(&g->pads);
|
||||
+ if ((e = udev_enumerate_new(g->udev))) {
|
||||
+ udev_enumerate_add_match_subsystem(e, "input");
|
||||
+ udev_enumerate_scan_devices(e);
|
||||
+ udev_list_entry_foreach(l, udev_enumerate_get_list_entry(e)) {
|
||||
+ d = udev_device_new_from_syspath(g->udev, udev_list_entry_get_name(l));
|
||||
+ if (d) {
|
||||
+ padadd(g, d);
|
||||
+ udev_device_unref(d);
|
||||
+ }
|
||||
+ }
|
||||
+ udev_enumerate_unref(e);
|
||||
+ }
|
||||
+ if (!(g->mon = udev_monitor_new_from_netlink(g->udev, "udev"))
|
||||
+ || udev_monitor_filter_add_match_subsystem_devtype(g->mon, "input", NULL)
|
||||
+ || udev_monitor_enable_receiving(g->mon)
|
||||
+ || !(g->msrc = wl_event_loop_add_fd(loop, udev_monitor_get_fd(g->mon), WL_EVENT_READABLE, monin, g))) {
|
||||
+ gamepad_destroy(g);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return g;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+gamepad_destroy(struct gamepad *g)
|
||||
+{
|
||||
+ struct pad *p, *t;
|
||||
+
|
||||
+ if (!g)
|
||||
+ return;
|
||||
+ wl_list_for_each_safe(p, t, &g->pads, link)
|
||||
+ padclose(p);
|
||||
+ if (g->msrc)
|
||||
+ wl_event_source_remove(g->msrc);
|
||||
+ if (g->mon)
|
||||
+ udev_monitor_unref(g->mon);
|
||||
+ if (g->udev)
|
||||
+ udev_unref(g->udev);
|
||||
+ free(g);
|
||||
+}
|
||||
diff --git a/gamepad.h b/gamepad.h
|
||||
new file mode 100644
|
||||
index 0000000..5d45d28
|
||||
--- /dev/null
|
||||
+++ b/gamepad.h
|
||||
@@ -0,0 +1,15 @@
|
||||
+#ifndef GAMEPAD_H
|
||||
+#define GAMEPAD_H
|
||||
+
|
||||
+#include <linux/input.h>
|
||||
+
|
||||
+struct gamepad;
|
||||
+struct wl_event_loop;
|
||||
+struct wlr_session;
|
||||
+
|
||||
+typedef void (*GamepadHandler)(unsigned int, int);
|
||||
+
|
||||
+struct gamepad *gamepad_create(struct wl_event_loop *, struct wlr_session *, GamepadHandler);
|
||||
+void gamepad_destroy(struct gamepad *);
|
||||
+
|
||||
+#endif
|
||||
@@ -4,8 +4,7 @@ Arranges windows in a grid. Except it adjusts the number of windows in the first
|
||||
On widescreens (w > 2*h), it splits to three columns before splitting rows.
|
||||
|
||||
### Download
|
||||
- [2026-09-27](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20260927.patch)
|
||||
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20260228.patch)
|
||||
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
|
||||
- [2025-10-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20251031.patch)
|
||||
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240918.patch)
|
||||
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240714.patch)
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a4019d3..d596f0c 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 },
|
||||
+ { "###", gaplessgrid },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -135,6 +136,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index cca1ea4..43ab340 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -311,6 +311,7 @@ static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
+static void gaplessgrid(Monitor *m);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -1696,6 +1697,56 @@ handlesig(int signo)
|
||||
quit(NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+gaplessgrid(Monitor *m)
|
||||
+{
|
||||
+ int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
|
||||
+ Client *c;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating)
|
||||
+ n++;
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ /* grid dimensions */
|
||||
+ for (cols = 0; cols <= (n / 2); cols++)
|
||||
+ if ((cols * cols) >= n)
|
||||
+ break;
|
||||
+
|
||||
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
|
||||
+ cols = 2;
|
||||
+
|
||||
+ /* widescreen is better if 3 columns */
|
||||
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
|
||||
+ cols = 3;
|
||||
+
|
||||
+ rows = n / cols;
|
||||
+
|
||||
+ /* window geometries */
|
||||
+ cw = cols ? m->w.width / cols : m->w.width;
|
||||
+ cn = 0; /* current column number */
|
||||
+ rn = 0; /* current row number */
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ unsigned int cx, cy;
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ continue;
|
||||
+
|
||||
+ if ((i / rows + 1) > (cols - n % cols))
|
||||
+ rows = n / cols + 1;
|
||||
+ ch = rows ? m->w.height / rows : m->w.height;
|
||||
+ cx = m->w.x + cn * cw;
|
||||
+ cy = m->w.y + rn * ch;
|
||||
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
|
||||
+ rn++;
|
||||
+ if (rn >= rows) {
|
||||
+ rn = 0;
|
||||
+ cn++;
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1,12 +0,0 @@
|
||||
### Description
|
||||
Hides all slave clients behind last focused slave in deck layout.
|
||||
|
||||
### Dependencies
|
||||
This patch depends on [decklayout](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/decklayout/) and [hide-behind-monocle](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide-behind-monocle/) patches (suggest installing it in metioned sequence).
|
||||
|
||||
### Download
|
||||
- [0.8](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-deck/hide-behind-deck.patch)
|
||||
|
||||
### Authors
|
||||
- [tvtur](https://codeberg.org/tvtur)
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
From 295945a45db881627501eb4dbca151aaa6b8b8ed Mon Sep 17 00:00:00 2001
|
||||
From: tvtur <tur.timothy@gmail.com>
|
||||
Date: Mon, 13 Apr 2026 13:21:13 +0300
|
||||
Subject: [PATCH] hide-behind-deck
|
||||
|
||||
---
|
||||
dwl.c | 54 +++++++++++++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 37 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 5d6db1a..090d44d 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -137,7 +137,7 @@ typedef struct {
|
||||
#endif
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
- int isfloating, isurgent, isfullscreen;
|
||||
+ int isfloating, isurgent, isfullscreen, ismaster;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
@@ -290,7 +290,7 @@ static Client *focustop(Monitor *m, int onlytiled);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
-static void hidebehindmonocle(Monitor *m);
|
||||
+static void hidebehind(Monitor *m);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -1431,7 +1431,7 @@ focusclient(Client *c, int lift)
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
selmon = c->mon;
|
||||
c->isurgent = 0;
|
||||
- hidebehindmonocle(c->mon);
|
||||
+ hidebehind(c->mon);
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
@@ -1573,21 +1573,38 @@ handlesig(int signo)
|
||||
}
|
||||
|
||||
void
|
||||
-hidebehindmonocle(Monitor *m)
|
||||
+hidebehind(Monitor *m)
|
||||
{
|
||||
Client *c;
|
||||
- if (m && m->lt[m->sellt]->arrange == monocle) {
|
||||
- wl_list_for_each(c, &clients, link) {
|
||||
- if (c->mon != m)
|
||||
- continue;
|
||||
- wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
||||
- }
|
||||
+ int check1 = 0;
|
||||
|
||||
- c = NULL;
|
||||
-
|
||||
- /* Enable top tiled client, fullscreen is considered tiled */
|
||||
- if ((c = focustop(m, 1)))
|
||||
- wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ if (m) {
|
||||
+ if (m && m->lt[m->sellt]->arrange == monocle) {
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon != m)
|
||||
+ continue;
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
||||
+ }
|
||||
+ c = NULL;
|
||||
+ /* Enable top tiled client, fullscreen is considered tiled */
|
||||
+ if ((c = focustop(m, 1)))
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ } else if (m && m->lt[m->sellt]->arrange == deck) {
|
||||
+ wl_list_for_each(c, &fstack, flink) {
|
||||
+ if (!VISIBLEON(c, m))
|
||||
+ continue;
|
||||
+ if (c->isfloating || c->ismaster) {
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!check1 && !c->ismaster) {
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ check1 = 1;
|
||||
+ continue;
|
||||
+ }
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 0);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1859,7 +1876,7 @@ monocle(Monitor *m)
|
||||
}
|
||||
if (n)
|
||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
||||
- hidebehindmonocle(m);
|
||||
+ hidebehind(m);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1871,7 +1888,6 @@ deck(Monitor *m)
|
||||
|
||||
/* count tiled clients */
|
||||
wl_list_for_each(c, &clients, link)
|
||||
-
|
||||
/* if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) */
|
||||
if (VISIBLEON(c, m) && !c->isfloating)
|
||||
n++;
|
||||
@@ -1909,6 +1925,7 @@ deck(Monitor *m)
|
||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)
|
||||
}, 0);
|
||||
my += c->geom.height;
|
||||
+ c->ismaster = 1;
|
||||
} else {
|
||||
/* deck clients: overlap in stack area */
|
||||
resize(c, (struct wlr_box){
|
||||
@@ -1917,9 +1934,12 @@ deck(Monitor *m)
|
||||
.width = m->w.width - mw,
|
||||
.height = m->w.height
|
||||
}, 0);
|
||||
+ c->ismaster = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
+
|
||||
+ hidebehind(m);
|
||||
}
|
||||
|
||||
void
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -5,8 +5,6 @@ Hide all clients behind the focused one in the monocle layout
|
||||
- [git branch](https://codeberg.org/sevz/dwl/src/branch/hide-behind-monocle)
|
||||
- [main 2025-01-20](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle.patch)
|
||||
- [hide-behind-monocle-0.7.patch](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle-0.7.patch)
|
||||
- [hide-behind-monocle-0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/hide-behind-monocle/hide-behind-monocle-0.8.patch)
|
||||
|
||||
### Authors
|
||||
- [tvtur](https://codeberg.org/tvtur)
|
||||
- [sevz](https://codeberg.org/sevz)
|
||||
|
||||
@@ -1,327 +0,0 @@
|
||||
From de87e122a354fde6f22610c1a15d6cc0b17f465a Mon Sep 17 00:00:00 2001
|
||||
From: tvtur <tur.timothy@gmail.com>
|
||||
Date: Sun, 23 Aug 2026 20:45:49 +0300
|
||||
Subject: [PATCH] patch
|
||||
|
||||
---
|
||||
dwl.c | 87 +++++++++++++++++++++++++++++++++++++----------------------
|
||||
1 file changed, 55 insertions(+), 32 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..ec712e9 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -285,10 +285,11 @@ static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
-static Client *focustop(Monitor *m);
|
||||
+static Client *focustop(Monitor *m, int onlytiled);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
+static void hidebehindmonocle(Monitor *m);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -519,7 +520,7 @@ arrange(Monitor *m)
|
||||
}
|
||||
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
||||
- (c = focustop(m)) && c->isfullscreen);
|
||||
+ (c = focustop(m, 0)) && c->isfullscreen);
|
||||
|
||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||
|
||||
@@ -813,7 +814,7 @@ closemon(Monitor *m)
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -1250,7 +1251,7 @@ void
|
||||
destroydragicon(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* Focus enter isn't sent during drag, so refocus the focused node. */
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
wl_list_remove(&listener->link);
|
||||
free(listener);
|
||||
@@ -1289,7 +1290,7 @@ destroylock(SessionLock *lock, int unlock)
|
||||
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||
|
||||
- focusclient(focustop(selmon), 0);
|
||||
+ focusclient(focustop(selmon, 0), 0);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
|
||||
destroy:
|
||||
@@ -1318,7 +1319,7 @@ destroylocksurface(struct wl_listener *listener, void *data)
|
||||
surface = wl_container_of(cur_lock->surfaces.next, surface, link);
|
||||
client_notify_enter(surface->surface, wlr_seat_get_keyboard(seat));
|
||||
} else if (!locked) {
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
} else {
|
||||
wlr_seat_keyboard_clear_focus(seat);
|
||||
}
|
||||
@@ -1429,6 +1430,7 @@ focusclient(Client *c, int lift)
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
selmon = c->mon;
|
||||
c->isurgent = 0;
|
||||
+ hidebehindmonocle(c->mon);
|
||||
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
@@ -1482,14 +1484,14 @@ focusmon(const Arg *arg)
|
||||
selmon = dirtomon(arg->i);
|
||||
while (!selmon->wlr_output->enabled && i++ < nmons);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
/* Focus the next or previous client (in tiling order) on selmon */
|
||||
- Client *c, *sel = focustop(selmon);
|
||||
+ Client *c, *sel = focustop(selmon, 0);
|
||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
@@ -1515,12 +1517,15 @@ focusstack(const Arg *arg)
|
||||
* will focus the topmost client of this mon, when actually will
|
||||
* only return that client */
|
||||
Client *
|
||||
-focustop(Monitor *m)
|
||||
+focustop(Monitor *m, int onlytiled)
|
||||
{
|
||||
Client *c;
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
- if (VISIBLEON(c, m))
|
||||
+ if (VISIBLEON(c, m)) {
|
||||
+ if (onlytiled && c->isfloating)
|
||||
+ continue;
|
||||
return c;
|
||||
+ }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1566,6 +1571,25 @@ handlesig(int signo)
|
||||
quit(NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+hidebehindmonocle(Monitor *m)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ if (m && m->lt[m->sellt]->arrange == monocle) {
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->mon != m)
|
||||
+ continue;
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m) && c->isfloating);
|
||||
+ }
|
||||
+
|
||||
+ c = NULL;
|
||||
+
|
||||
+ /* Enable top tiled client, fullscreen is considered tiled */
|
||||
+ if ((c = focustop(m, 1)))
|
||||
+ wlr_scene_node_set_enabled(&c->scene->node, 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1705,7 +1729,7 @@ keyrepeat(void *data)
|
||||
void
|
||||
killclient(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
client_send_close(sel);
|
||||
}
|
||||
@@ -1834,8 +1858,7 @@ monocle(Monitor *m)
|
||||
}
|
||||
if (n)
|
||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
|
||||
- if ((c = focustop(m)))
|
||||
- wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
+ hidebehindmonocle(m);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2101,7 +2124,7 @@ printstatus(void)
|
||||
if (c->isurgent)
|
||||
urg |= c->tags;
|
||||
}
|
||||
- if ((c = focustop(m))) {
|
||||
+ if ((c = focustop(m, 0))) {
|
||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
||||
printf("%s appid %s\n", m->wlr_output->name, client_get_appid(c));
|
||||
printf("%s fullscreen %d\n", m->wlr_output->name, c->isfullscreen);
|
||||
@@ -2417,7 +2440,7 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2691,12 +2714,12 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
void
|
||||
tag(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (!sel || (arg->ui & TAGMASK) == 0)
|
||||
return;
|
||||
|
||||
sel->tags = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2704,7 +2727,7 @@ tag(const Arg *arg)
|
||||
void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
setmon(sel, dirtomon(arg->i), 0);
|
||||
}
|
||||
@@ -2746,7 +2769,7 @@ tile(Monitor *m)
|
||||
void
|
||||
togglefloating(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
/* return if fullscreen */
|
||||
if (sel && !sel->isfullscreen)
|
||||
setfloating(sel, !sel->isfloating);
|
||||
@@ -2755,7 +2778,7 @@ togglefloating(const Arg *arg)
|
||||
void
|
||||
togglefullscreen(const Arg *arg)
|
||||
{
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (sel)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
@@ -2764,12 +2787,12 @@ void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
uint32_t newtags;
|
||||
- Client *sel = focustop(selmon);
|
||||
+ Client *sel = focustop(selmon, 0);
|
||||
if (!sel || !(newtags = sel->tags ^ (arg->ui & TAGMASK)))
|
||||
return;
|
||||
|
||||
sel->tags = newtags;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2782,7 +2805,7 @@ toggleview(const Arg *arg)
|
||||
return;
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtagset;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -2806,7 +2829,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
|
||||
arrangelayers(l->mon);
|
||||
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -2823,7 +2846,7 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
if (client_is_unmanaged(c)) {
|
||||
if (c == exclusive_focus) {
|
||||
exclusive_focus = NULL;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
}
|
||||
} else {
|
||||
wl_list_remove(&c->link);
|
||||
@@ -2904,7 +2927,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
/* Don't move clients to the left output when plugging monitors */
|
||||
arrange(m);
|
||||
/* make sure fullscreen clients have the right size */
|
||||
- if ((c = focustop(m)) && c->isfullscreen)
|
||||
+ if ((c = focustop(m, 0)) && c->isfullscreen)
|
||||
resize(c, m->m, 0);
|
||||
|
||||
/* Try to re-set the gamma LUT when updating monitors,
|
||||
@@ -2924,7 +2947,7 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (!c->mon && client_surface(c)->mapped)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
if (selmon->lock_surface) {
|
||||
client_notify_enter(selmon->lock_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
@@ -2946,7 +2969,7 @@ void
|
||||
updatetitle(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
- if (c == focustop(c->mon))
|
||||
+ if (c == focustop(c->mon, 0))
|
||||
printstatus();
|
||||
}
|
||||
|
||||
@@ -2956,7 +2979,7 @@ urgent(struct wl_listener *listener, void *data)
|
||||
struct wlr_xdg_activation_v1_request_activate_event *event = data;
|
||||
Client *c = NULL;
|
||||
toplevel_from_wlr_surface(event->surface, &c, NULL);
|
||||
- if (!c || c == focustop(selmon))
|
||||
+ if (!c || c == focustop(selmon, 0))
|
||||
return;
|
||||
|
||||
c->isurgent = 1;
|
||||
@@ -2974,7 +2997,7 @@ view(const Arg *arg)
|
||||
selmon->seltags ^= 1; /* toggle sel tagset */
|
||||
if (arg->ui & TAGMASK)
|
||||
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
|
||||
- focusclient(focustop(selmon), 1);
|
||||
+ focusclient(focustop(selmon, 0), 1);
|
||||
arrange(selmon);
|
||||
printstatus();
|
||||
}
|
||||
@@ -3045,7 +3068,7 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
- Client *c, *sel = focustop(selmon);
|
||||
+ Client *c, *sel = focustop(selmon, 0);
|
||||
|
||||
if (!sel || !selmon || !selmon->lt[selmon->sellt]->arrange || sel->isfloating)
|
||||
return;
|
||||
@@ -3156,7 +3179,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, set_hints);
|
||||
struct wlr_surface *surface = client_surface(c);
|
||||
- if (c == focustop(selmon) || !c->surface.xwayland->hints)
|
||||
+ if (c == focustop(selmon, 0) || !c->surface.xwayland->hints)
|
||||
return;
|
||||
|
||||
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);
|
||||
--
|
||||
2.54.0
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
From a73f5a4c7dd636d999cfab15610e68e170d2f597 Mon Sep 17 00:00:00 2001
|
||||
From c72de058e6635c5bb3d973995ccbdb6e028f354d Mon Sep 17 00:00:00 2001
|
||||
From: nate zhou <gnuunixchad@outlook.com>
|
||||
Date: Fri, 10 Apr 2026 19:38:43 +0800
|
||||
Date: Tue, 3 Mar 2026 16:48:46 +0800
|
||||
Subject: [PATCH] Patch: hide-cursor-when-typing-0.8.patch
|
||||
|
||||
Hide the cursor when start typing, and restore it when start moving
|
||||
cursor again, just like xbanish.
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++----
|
||||
2 files changed, 85 insertions(+), 7 deletions(-)
|
||||
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++------
|
||||
2 files changed, 63 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..6205c0a 100644
|
||||
@@ -22,29 +24,29 @@ index 8a6eda0..6205c0a 100644
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..7325f7a 100644
|
||||
index 44f3ad9..9a076b6 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -288,6 +288,8 @@ static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
@@ -289,6 +289,8 @@ static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
+static void handlecursoractivity(void);
|
||||
+static int hidecursor(void *data);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
@@ -389,6 +391,14 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
|
||||
|
||||
static struct wlr_cursor *cursor;
|
||||
static struct wlr_xcursor_manager *cursor_mgr;
|
||||
+static struct wl_event_source *hide_source;
|
||||
+static bool cursor_hidden = false;
|
||||
+static struct {
|
||||
+ enum wp_cursor_shape_device_v1_shape shape;
|
||||
+ struct wlr_surface *surface;
|
||||
+ int hotspot_x;
|
||||
+ int hotspot_y;
|
||||
+ struct wl_listener destroy;
|
||||
+} last_cursor;
|
||||
|
||||
static struct wlr_scene_rect *root_bg;
|
||||
@@ -53,7 +55,7 @@ index 44f3ad9..7325f7a 100644
|
||||
* for example when you move the scroll wheel. */
|
||||
struct wlr_pointer_axis_event *event = data;
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
+ handlecursoractivity();
|
||||
+ handlecursoractivity();
|
||||
/* TODO: allow usage of scroll wheel for mousebindings, it can be implemented
|
||||
* by checking the event's orientation and the delta of the event */
|
||||
/* Notify the client with pointer focus of the axis event. */
|
||||
@@ -61,11 +63,11 @@ index 44f3ad9..7325f7a 100644
|
||||
const Button *b;
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
+ handlecursoractivity();
|
||||
+ handlecursoractivity();
|
||||
|
||||
switch (event->state) {
|
||||
case WL_POINTER_BUTTON_STATE_PRESSED:
|
||||
@@ -1566,6 +1578,33 @@ handlesig(int signo)
|
||||
@@ -1566,6 +1578,30 @@ handlesig(int signo)
|
||||
quit(NULL);
|
||||
}
|
||||
|
||||
@@ -77,15 +79,12 @@ index 44f3ad9..7325f7a 100644
|
||||
+
|
||||
+ cursor_hidden = false;
|
||||
+
|
||||
+ if (last_cursor.shape) {
|
||||
+ if (last_cursor.shape)
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
||||
+ wlr_cursor_shape_v1_name(last_cursor.shape));
|
||||
+ } else if (last_cursor.surface) {
|
||||
+ wlr_cursor_shape_v1_name(last_cursor.shape));
|
||||
+ else
|
||||
+ wlr_cursor_set_surface(cursor, last_cursor.surface,
|
||||
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
|
||||
+ } else {
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
+ }
|
||||
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
|
||||
+}
|
||||
+
|
||||
+int
|
||||
@@ -99,27 +98,27 @@ index 44f3ad9..7325f7a 100644
|
||||
void
|
||||
incnmaster(const Arg *arg)
|
||||
{
|
||||
@@ -1645,6 +1684,11 @@ keypress(struct wl_listener *listener, void *data)
|
||||
@@ -1645,6 +1681,11 @@ keypress(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
|
||||
+ /* hide cursor when typing starts */
|
||||
+ if (hide_cursor_when_typing && !cursor_hidden && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
+ hidecursor(NULL);
|
||||
+ }
|
||||
+ /* hide cursor when typing starts */
|
||||
+ if (hide_cursor_when_typing && !cursor_hidden && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
+ hidecursor(NULL);
|
||||
+ }
|
||||
+
|
||||
/* On _press_ if there is no active screen locker,
|
||||
* attempt to process a compositor keybinding. */
|
||||
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
@@ -1907,6 +1951,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
@@ -1907,6 +1948,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
|
||||
wlr_cursor_move(cursor, device, dx, dy);
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
+ handlecursoractivity();
|
||||
+ handlecursoractivity();
|
||||
|
||||
/* Update selmon (even while dragging a window) */
|
||||
if (sloppyfocus)
|
||||
@@ -1931,7 +1976,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
@@ -1931,7 +1973,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* If there's no client surface under the cursor, set the cursor image to a
|
||||
* default. This is what makes the cursor image appear when you move it
|
||||
* off of a client or over its border. */
|
||||
@@ -128,23 +127,7 @@ index 44f3ad9..7325f7a 100644
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
|
||||
|
||||
pointerfocus(c, surface, sx, sy, time);
|
||||
@@ -2296,6 +2341,15 @@ run(char *startup_cmd)
|
||||
wl_display_run(dpy);
|
||||
}
|
||||
|
||||
+void
|
||||
+unlastcursor(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ /* When the surface is destroyed, clear our reference to it */
|
||||
+ last_cursor.surface = NULL;
|
||||
+ wl_list_remove(&last_cursor.destroy.link);
|
||||
+ wl_list_init(&last_cursor.destroy.link);
|
||||
+}
|
||||
+
|
||||
void
|
||||
setcursor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2311,9 +2365,23 @@ setcursor(struct wl_listener *listener, void *data)
|
||||
@@ -2311,9 +2353,16 @@ setcursor(struct wl_listener *listener, void *data)
|
||||
* use the provided surface as the cursor image. It will set the
|
||||
* hardware cursor on the output that it's currently on and continue to
|
||||
* do so as the cursor moves between outputs. */
|
||||
@@ -152,26 +135,19 @@ index 44f3ad9..7325f7a 100644
|
||||
- wlr_cursor_set_surface(cursor, event->surface,
|
||||
- event->hotspot_x, event->hotspot_y);
|
||||
+ if (event->seat_client == seat->pointer_state.focused_client) {
|
||||
+ last_cursor.shape = 0;
|
||||
+ last_cursor.surface = event->surface;
|
||||
+ last_cursor.hotspot_x = event->hotspot_x;
|
||||
+ last_cursor.hotspot_y = event->hotspot_y;
|
||||
+ last_cursor.shape = 0;
|
||||
+ last_cursor.surface = event->surface;
|
||||
+ last_cursor.hotspot_x = event->hotspot_x;
|
||||
+ last_cursor.hotspot_y = event->hotspot_y;
|
||||
+
|
||||
+ wl_list_remove(&last_cursor.destroy.link);
|
||||
+ wl_list_init(&last_cursor.destroy.link);
|
||||
+ if (event->surface) {
|
||||
+ last_cursor.destroy.notify = unlastcursor;
|
||||
+ wl_signal_add(&event->surface->events.destroy, &last_cursor.destroy);
|
||||
+ }
|
||||
+
|
||||
+ if (!cursor_hidden)
|
||||
+ wlr_cursor_set_surface(cursor, event->surface,
|
||||
+ event->hotspot_x, event->hotspot_y);
|
||||
+ }
|
||||
+ if (!cursor_hidden)
|
||||
+ wlr_cursor_set_surface(cursor, event->surface,
|
||||
+ event->hotspot_x, event->hotspot_y);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2325,9 +2393,14 @@ setcursorshape(struct wl_listener *listener, void *data)
|
||||
@@ -2325,9 +2374,14 @@ setcursorshape(struct wl_listener *listener, void *data)
|
||||
/* This can be sent by any client, so we check to make sure this one
|
||||
* actually has pointer focus first. If so, we can tell the cursor to
|
||||
* use the provided cursor shape. */
|
||||
@@ -184,21 +160,11 @@ index 44f3ad9..7325f7a 100644
|
||||
+
|
||||
+ if (!cursor_hidden)
|
||||
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
||||
+ wlr_cursor_shape_v1_name(event->shape));
|
||||
+ wlr_cursor_shape_v1_name(event->shape));
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2592,6 +2665,9 @@ setup(void)
|
||||
cursor = wlr_cursor_create();
|
||||
wlr_cursor_attach_output_layout(cursor, output_layout);
|
||||
|
||||
+ /* Initialize the last_cursor destroy listener link so it's safe to remove later */
|
||||
+ wl_list_init(&last_cursor.destroy.link);
|
||||
+
|
||||
/* Creates an xcursor manager, another wlroots utility which loads up
|
||||
* Xcursor themes to source cursor images from and makes sure that cursor
|
||||
* images are available at all scale factors on the screen (necessary for
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ Examples provided:
|
||||
- exclude certain keyboards (eg ydotool) from keyboard group
|
||||
|
||||
### Download
|
||||
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.8.patch)
|
||||
- [git branch](https://codeberg.org/bencc/dwl/src/branch/inputdevicerules)
|
||||
- [v0.7](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.7.patch)
|
||||
- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/inputdevicerules/inputdevicerules-v0.6.patch)
|
||||
|
||||
### Authors
|
||||
- [Viktor Woloszczuk](https://codeberg.org/vwoloszczuk)
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
From 31c8493d7f2a863949a91cd14769e28894f259e7 Mon Sep 17 00:00:00 2001
|
||||
From: Viktor Woloszczuk <viktor@woloszcz.uk>
|
||||
Date: Wed, 11 Mar 2026 19:41:02 +0000
|
||||
Subject: [PATCH] input device rules (v0.8)
|
||||
|
||||
* customise input device handling
|
||||
* ignore unwanted input devices
|
||||
* configure a toggle for an input device
|
||||
---
|
||||
config.def.h | 13 ++++++++++
|
||||
dwl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 79 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..4dbcfd1 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -56,6 +56,18 @@ static const struct xkb_rule_names xkb_rules = {
|
||||
.options = NULL,
|
||||
};
|
||||
|
||||
+/* input devices */
|
||||
+static const InputRule inputrules[] = {
|
||||
+ /* name kbcreate ptrcreate */
|
||||
+ /* ignore bad device - like a touchpad ;) */
|
||||
+ { "BAD DEVICE", NULL, NULL },
|
||||
+ /* ungroup ydotool device - fixes a bug */
|
||||
+ { "ydotoold virtual device", createungroupedkeyboard, createpointer },
|
||||
+ /* put your touchpad name here to enable toggle touchpad */
|
||||
+ { "Elan Touchpad", createkeyboard, createtogglepointer },
|
||||
+ { NULL, createkeyboard, createpointer },
|
||||
+};
|
||||
+
|
||||
static const int repeat_rate = 25;
|
||||
static const int repeat_delay = 600;
|
||||
|
||||
@@ -138,6 +150,7 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_u, togglepointer, {0} },
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ 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 44f3ad9..42557fe 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -141,6 +141,12 @@ typedef struct {
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
+typedef struct {
|
||||
+ const char *name;
|
||||
+ void (*kbcreate)(struct wlr_keyboard *);
|
||||
+ void (*ptrcreate)(struct wlr_pointer *);
|
||||
+} InputRule;
|
||||
+
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
xkb_keysym_t keysym;
|
||||
@@ -268,6 +274,8 @@ static void createnotify(struct wl_listener *listener, void *data);
|
||||
static void createpointer(struct wlr_pointer *pointer);
|
||||
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
||||
static void createpopup(struct wl_listener *listener, void *data);
|
||||
+static void createtogglepointer(struct wlr_pointer *pointer);
|
||||
+static void createungroupedkeyboard(struct wlr_keyboard *keyboard);
|
||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void cursorwarptohint(void);
|
||||
@@ -336,6 +344,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
+static void togglepointer(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -406,6 +415,8 @@ static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
|
||||
+static struct libinput_device *togglepointerdevice = NULL;
|
||||
+
|
||||
/* global event handlers */
|
||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||
static struct wl_listener cursor_button = {.notify = buttonpress};
|
||||
@@ -1199,6 +1210,33 @@ createpopup(struct wl_listener *listener, void *data)
|
||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||
}
|
||||
|
||||
+void
|
||||
+createtogglepointer(struct wlr_pointer *pointer)
|
||||
+{
|
||||
+ struct libinput_device *device;
|
||||
+
|
||||
+ createpointer(pointer);
|
||||
+
|
||||
+ if (wlr_input_device_is_libinput(&pointer->base)
|
||||
+ && (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
+ togglepointerdevice = device;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+createungroupedkeyboard(struct wlr_keyboard *keyboard)
|
||||
+{
|
||||
+ /* for keyboards that need their own keyboard group */
|
||||
+ KeyboardGroup *group = createkeyboardgroup();
|
||||
+
|
||||
+ /* Set the keymap to match the group keymap */
|
||||
+ wlr_keyboard_set_keymap(keyboard, group->wlr_group->keyboard.keymap);
|
||||
+ LISTEN(&keyboard->base.events.destroy, &group->destroy, destroykeyboardgroup);
|
||||
+
|
||||
+ /* Add the new keyboard to the group */
|
||||
+ wlr_keyboard_group_add_keyboard(group->wlr_group, keyboard);
|
||||
+}
|
||||
+
|
||||
void
|
||||
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
||||
{
|
||||
@@ -1582,13 +1620,27 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
* available. */
|
||||
struct wlr_input_device *device = data;
|
||||
uint32_t caps;
|
||||
+ const InputRule *r;
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
- createkeyboard(wlr_keyboard_from_input_device(device));
|
||||
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||
+ if (!r->name || strstr(device->name, r->name)) {
|
||||
+ if (r->kbcreate)
|
||||
+ r->kbcreate(wlr_keyboard_from_input_device(device));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
- createpointer(wlr_pointer_from_input_device(device));
|
||||
+ for (r = inputrules; r < END(inputrules); r++) {
|
||||
+ if (!r->name || strstr(device->name, r->name)) {
|
||||
+ if (r->ptrcreate)
|
||||
+ r->ptrcreate(wlr_pointer_from_input_device(device));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
break;
|
||||
default:
|
||||
/* TODO handle other input device types */
|
||||
@@ -2760,6 +2812,18 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
+void
|
||||
+togglepointer(const Arg *arg)
|
||||
+{
|
||||
+ if (!togglepointerdevice)
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_send_events_set_mode(
|
||||
+ togglepointerdevice,
|
||||
+ libinput_device_config_send_events_get_mode(togglepointerdevice) ^ LIBINPUT_CONFIG_SEND_EVENTS_DISABLED
|
||||
+ );
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
### Description
|
||||
Largely based on [raphi](https://sr.ht/~raphi/)'s [somebar](https://sr.ht/~raphi/somebar/), this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [dwlmsg](https://codeberg.org/julmajustus/dwlmsg).
|
||||
|
||||
Status information to stdout is currently disabled as dwl tends to freeze. For now, `dwlmsg -w` should act as a drop-in replacement.
|
||||
|
||||
Note to [pertag](../pertag/) users: apply [this](./ipcpertag.patch) for ipc tagsetting to work as expected
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/julmajustus/dwl/src/branch/ipc-0.9)
|
||||
- [v0.9](/dwl/dwl-patches/raw/branch/main/patches/ipc/ipc.patch)
|
||||
|
||||
### Authors
|
||||
- [MadcowOG](https://github.com/MadcowOG)
|
||||
- [fbushstone](https://github.com/fbushstone)
|
||||
- [notchoc](https://codeberg.org/notchoc)
|
||||
- [snuk](https://codeberg.org/snuk)
|
||||
- [julmajustus](https://codeberg.org/julmajustus)
|
||||
@@ -1,24 +0,0 @@
|
||||
From e3b5143bbc21a13cf55b843d8a0f7f042f299595 Mon Sep 17 00:00:00 2001
|
||||
From: julmajustus <julmajustus@tutanota.com>
|
||||
Date: Mon, 21 Sep 2026 21:43:44 +0300
|
||||
Subject: [PATCH] ipc: update focus-tagset-output patch for v0.9
|
||||
|
||||
---
|
||||
dwl.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index d24fcb3..6c52e78 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1707,6 +1707,7 @@ dwl_ipc_output_set_tags(struct wl_client *client, struct wl_resource *resource,
|
||||
if (!ipc_output)
|
||||
return;
|
||||
monitor = ipc_output->mon;
|
||||
+ selmon = monitor;
|
||||
|
||||
if (!newtags || newtags == monitor->tagset[monitor->seltags])
|
||||
return;
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -4,7 +4,6 @@ Allows more monitor configuration in config.h
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/Palanix/dwl/src/branch/monitorconfig)
|
||||
- [wlroots-next-f4249db](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-wlroots-next-f4249db.patch)
|
||||
- [0.9](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-0.9.patch)
|
||||
- [0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/monitorconfig/monitorconfig-0.8.patch)
|
||||
|
||||
### Authors
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
From 55494409072aad907aea0c02c796d56a9e925459 Mon Sep 17 00:00:00 2001
|
||||
From: Palanix <palanixyt@gmail.com>
|
||||
Date: Mon, 4 Apr 2022 16:08:29 +0200
|
||||
Subject: [PATCH] Updated patch now allowing setting x and y
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Co-authored-by: Leonardo Hernández Hernández <leohdz172@proton.me>
|
||||
---
|
||||
config.def.h | 12 ++++++++----
|
||||
dwl.c | 25 +++++++++++++++++++------
|
||||
2 files changed, 27 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 13c5322..2d1fcb5 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -41,10 +41,14 @@ static const Layout layouts[] = {
|
||||
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
|
||||
* https://gitlab.freedesktop.org/xorg/xserver/-/issues/899 */
|
||||
static const MonitorRule monrules[] = {
|
||||
- /* name mfact nmaster scale layout rotate/reflect x y
|
||||
- * example of a HiDPI laptop monitor:
|
||||
- { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 }, */
|
||||
- { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
+ /* name mfact nmaster scale layout rotate/reflect x y resx resy rate mode adaptive*/
|
||||
+ /* example of a HiDPI laptop monitor at 120Hz: { "eDP-1", 0.5f, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0, 0, 0, 120.000f, 1, 1}, */
|
||||
+ /*
|
||||
+ * mode let's the user decide on how dwl should implement the modes:
|
||||
+ * -1 Sets a custom mode following the users choice
|
||||
+ * All other number's set the mode at the index n, 0 is the standard mode; see wlr-randr
|
||||
+ */
|
||||
+ { NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1, 0, 0, 0.0f, 0 ,1},
|
||||
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
|
||||
};
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 4cfd0fd..755a826 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -235,6 +235,11 @@ typedef struct {
|
||||
const Layout *lt;
|
||||
enum wl_output_transform rr;
|
||||
int x, y;
|
||||
+ int resx;
|
||||
+ int resy;
|
||||
+ float rate;
|
||||
+ int mode;
|
||||
+ int adaptive;
|
||||
} MonitorRule;
|
||||
|
||||
typedef struct {
|
||||
@@ -1139,6 +1144,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
/* This event is raised by the backend when a new output (aka a display or
|
||||
* monitor) becomes available. */
|
||||
struct wlr_output *wlr_output = data;
|
||||
+ struct wlr_output_mode *mode = wl_container_of(wlr_output->modes.next, mode, link);
|
||||
const MonitorRule *r;
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
@@ -1167,16 +1173,23 @@ createmon(struct wl_listener *listener, void *data)
|
||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||
wlr_output_state_set_scale(&state, r->scale);
|
||||
wlr_output_state_set_transform(&state, r->rr);
|
||||
+
|
||||
+ wlr_output_state_set_adaptive_sync_enabled(&state, r->adaptive);
|
||||
+
|
||||
+ if(r->mode == -1)
|
||||
+ wlr_output_state_set_custom_mode(&state, r->resx, r->resy,
|
||||
+ (int) (r->rate > 0 ? r->rate * 1000 : 0));
|
||||
+ else if (!wl_list_empty(&wlr_output->modes)) {
|
||||
+ for (int j = 0; j < r->mode; j++) {
|
||||
+ mode = wl_container_of(mode->link.next, mode, link);
|
||||
+ }
|
||||
+ wlr_output_state_set_mode(&state, mode);
|
||||
+ }
|
||||
+
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- /* The mode is a tuple of (width, height, refresh rate), and each
|
||||
- * monitor supports only a specific set of modes. We just pick the
|
||||
- * monitor's preferred mode; a more sophisticated compositor would let
|
||||
- * the user configure it. */
|
||||
- wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output));
|
||||
-
|
||||
/* Set up event listeners */
|
||||
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
|
||||
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
|
||||
--
|
||||
2.55.0
|
||||
|
||||
@@ -13,8 +13,8 @@ This allows the user to change size and placement of floating windows using only
|
||||
| <kbd>MODKEY</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | grow width 40px |
|
||||
|
||||
### Download
|
||||
- [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/moveresizekb/moveresizekb.patch)
|
||||
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/moveresizekb)
|
||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/moveresizekb/moveresizekb.patch)
|
||||
|
||||
### Authors
|
||||
- [cana](https://codeberg.org/cana)
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
From f19c162ba64c2c4860e5d16e48e08cebd7a7e46c Mon Sep 17 00:00:00 2001
|
||||
From: C4FE1 <heitorcdesousa13@gmail.com>
|
||||
Date: Wed, 10 Jun 2026 19:50:26 -0300
|
||||
Subject: [PATCH] Change moveresizekb logic to allow it's use in floating
|
||||
(NULL) Layout
|
||||
From c8af428f964679089599e4ffbe7d28d08a4e875f Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Tue, 5 Mar 2024 23:42:55 -0500
|
||||
Subject: [PATCH] implement keybindings to move and resize focused floating
|
||||
window
|
||||
|
||||
---
|
||||
config.def.h | 8 ++++++++
|
||||
dwl.c | 23 +++++++++++++++++++++++
|
||||
2 files changed, 31 insertions(+)
|
||||
dwl.c | 19 +++++++++++++++++++
|
||||
2 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..b8398f9 100644
|
||||
index db0babc..d0570b8 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -138,6 +138,14 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 40, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, -40, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Right, moveresizekb, {.v = (int []){ 40, 0, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Left, moveresizekb, {.v = (int []){ -40, 0, 0, 0 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 0, 0, 40 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, 0, 0, -40 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, moveresizekb, {.v = (int []){ 0, 0, 40, 0 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, moveresizekb, {.v = (int []){ 0, 0, -40, 0 }}},
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
@@ -135,6 +135,14 @@ 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} },
|
||||
+ { MODKEY, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 40, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, -40, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Right, moveresizekb, {.v = (int []){ 40, 0, 0, 0 }}},
|
||||
+ { MODKEY, XKB_KEY_Left, moveresizekb, {.v = (int []){ -40, 0, 0, 0 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 0, 0, 40 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, 0, 0, -40 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, moveresizekb, {.v = (int []){ 0, 0, 40, 0 }}},
|
||||
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, moveresizekb, {.v = (int []){ 0, 0, -40, 0 }}},
|
||||
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
|
||||
{ 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 44f3ad9..a6450f5 100644
|
||||
index ef27a1d..251472b 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -336,6 +336,7 @@ static void tagmon(const Arg *arg);
|
||||
@@ -313,6 +313,7 @@ static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
@@ -40,7 +40,7 @@ index 44f3ad9..a6450f5 100644
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -2760,6 +2761,28 @@ togglefullscreen(const Arg *arg)
|
||||
@@ -2454,6 +2455,24 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
@@ -50,11 +50,7 @@ index 44f3ad9..a6450f5 100644
|
||||
+ Client *c = focustop(selmon);
|
||||
+ Monitor *m = selmon;
|
||||
+
|
||||
+ if(!(m && arg && arg->v && c)){
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if(!(c->isfloating || m->lt[m->sellt]->arrange == NULL)){
|
||||
+ if(!(m && arg && arg->v && c && c->isfloating)) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -70,5 +66,5 @@ index 44f3ad9..a6450f5 100644
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.54.0
|
||||
2.42.0
|
||||
|
||||
|
||||
@@ -10,11 +10,10 @@ This patch adds the following functions:
|
||||
If you don't assign keybindings to any of the above functions and so get a compiler warning about them not being used, just remove them from your dwl branch to stop the warning.
|
||||
|
||||
### Download
|
||||
- [git branch (v0.6)](https://codeberg.org/bencc/dwl/src/branch/namedscratchpads)
|
||||
- [2024-07-13 (v0.6)](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/namedscratchpads/namedscratchpads.patch)
|
||||
- [namedscratchpads-0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/namedscratchpads/namedscratchpads-0.8.patch)
|
||||
|
||||
### Authors
|
||||
- [nshan651](https://codeberg.org/nshan651)
|
||||
- [Ben Collerson](https://codeberg.org/bencc)
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
- [Louis-Michel Raynauld](https://github.com/loumray)
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
From 40ef197886f402c44a5a5c6856478cad5277e0bb Mon Sep 17 00:00:00 2001
|
||||
From: nshan651 <nshan651@proton.me>
|
||||
Date: Fri, 19 Jun 2026 13:04:21 -0500
|
||||
Subject: [PATCH 1/2] namedscratchpads: v0.8 compatibility
|
||||
|
||||
---
|
||||
config.def.h | 11 ++++++++---
|
||||
dwl.c | 39 +++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 47 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..79b4efb 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -21,9 +21,10 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
|
||||
static int log_level = WLR_ERROR;
|
||||
|
||||
static const Rule rules[] = {
|
||||
- /* app_id title tags mask isfloating monitor */
|
||||
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||
+ /* app_id title tags mask isfloating monitor scratchkey */
|
||||
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, 0 }, /* Start on currently visible tags floating, not tiled */
|
||||
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, 0 }, /* Start on ONLY tag "9" */
|
||||
+ { NULL, "scratchpad", 0, 1, -1, 's' },
|
||||
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
|
||||
};
|
||||
|
||||
@@ -118,11 +119,15 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||
static const char *termcmd[] = { "foot", NULL };
|
||||
static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
|
||||
+/* named scratchpads - First arg only serves to match against key in rules*/
|
||||
+static const char *scratchpadcmd[] = { "s", "foot", "-T", "scratchpad", NULL };
|
||||
+
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
+ { MODKEY, XKB_KEY_grave, togglescratch, {.v = scratchpadcmd } },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..3e3db4c 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -138,6 +138,7 @@ typedef struct {
|
||||
unsigned int bw;
|
||||
uint32_t tags;
|
||||
int isfloating, isurgent, isfullscreen;
|
||||
+ char scratchkey;
|
||||
uint32_t resize; /* configure serial of a pending resize */
|
||||
} Client;
|
||||
|
||||
@@ -228,6 +229,7 @@ typedef struct {
|
||||
uint32_t tags;
|
||||
int isfloating;
|
||||
int monitor;
|
||||
+ const char scratchkey;
|
||||
} Rule;
|
||||
|
||||
typedef struct {
|
||||
@@ -330,12 +332,14 @@ static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
static void spawn(const Arg *arg);
|
||||
+static void spawnscratch(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
static void tagmon(const Arg *arg);
|
||||
static void tile(Monitor *m);
|
||||
static void togglefloating(const Arg *arg);
|
||||
static void togglefullscreen(const Arg *arg);
|
||||
+static void togglescratch(const Arg *arg);
|
||||
static void toggletag(const Arg *arg);
|
||||
static void toggleview(const Arg *arg);
|
||||
static void unlocksession(struct wl_listener *listener, void *data);
|
||||
@@ -483,6 +487,7 @@ applyrules(Client *c)
|
||||
const Rule *r;
|
||||
Monitor *mon = selmon, *m;
|
||||
|
||||
+ c->scratchkey = 0;
|
||||
appid = client_get_appid(c);
|
||||
title = client_get_title(c);
|
||||
|
||||
@@ -490,6 +495,7 @@ applyrules(Client *c)
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
+ c->scratchkey = r->scratchkey;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
@@ -2677,6 +2683,16 @@ spawn(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+void spawnscratch(const Arg *arg)
|
||||
+{
|
||||
+ if (fork() == 0) {
|
||||
+ dup2(STDERR_FILENO, STDOUT_FILENO);
|
||||
+ setsid();
|
||||
+ execvp(((char **)arg->v)[1], ((char **)arg->v)+1);
|
||||
+ die("dwl: execvp %s failed:", ((char **)arg->v)[1]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
startdrag(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2760,6 +2776,29 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
+void
|
||||
+togglescratch(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ unsigned int found = 0;
|
||||
+
|
||||
+ /* search for first window that matches the scratchkey */
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
||||
+ found = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (found) {
|
||||
+ c->tags = VISIBLEON(c, selmon) ? 0 : selmon->tagset[selmon->seltags];
|
||||
+
|
||||
+ focusclient(c->tags == 0 ? focustop(selmon) : c, 1);
|
||||
+ arrange(selmon);
|
||||
+ } else{
|
||||
+ spawnscratch(arg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.52.0
|
||||
|
||||
|
||||
From e21146a0924c5940c7fb912d0c99790e2553b613 Mon Sep 17 00:00:00 2001
|
||||
From: nshan651 <nshan651@proton.me>
|
||||
Date: Fri, 19 Jun 2026 13:05:33 -0500
|
||||
Subject: [PATCH 2/2] namedscratchpads: focusortoggle functions v0.8
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 89 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 79b4efb..e253862 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -128,6 +128,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
{ MODKEY, XKB_KEY_grave, togglescratch, {.v = scratchpadcmd } },
|
||||
+ // { MODKEY, XKB_KEY_grave, focusortogglescratch, {.v = scratchpadcmd } },
|
||||
+ // { MODKEY, XKB_KEY_grave, focusortogglematchingscratch, {.v = scratchpadcmd } },
|
||||
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 3e3db4c..0f406d9 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -286,6 +286,8 @@ static void destroykeyboardgroup(struct wl_listener *listener, void *data);
|
||||
static Monitor *dirtomon(enum wlr_direction dir);
|
||||
static void focusclient(Client *c, int lift);
|
||||
static void focusmon(const Arg *arg);
|
||||
+static void focusortogglematchingscratch(const Arg *arg);
|
||||
+static void focusortogglescratch(const Arg *arg);
|
||||
static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
@@ -1491,6 +1493,91 @@ focusmon(const Arg *arg)
|
||||
focusclient(focustop(selmon), 1);
|
||||
}
|
||||
|
||||
+void
|
||||
+focusortogglematchingscratch(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ unsigned int found = 0;
|
||||
+ unsigned int hide = 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->scratchkey == 0) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
||||
+ if (VISIBLEON(c, selmon)) {
|
||||
+ if (found == 1) {
|
||||
+ if (hide == 1) {
|
||||
+ c->tags = 0;
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (focustop(selmon) == c) {
|
||||
+ // hide
|
||||
+ c->tags = 0;
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+ hide = 1;
|
||||
+ } else {
|
||||
+ // focus
|
||||
+ focusclient(c, 1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ // show
|
||||
+ c->tags = selmon->tagset[selmon->seltags];
|
||||
+ // focus
|
||||
+ focusclient(c, 1);
|
||||
+ }
|
||||
+ found = 1;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (VISIBLEON(c, selmon)) {
|
||||
+ // hide
|
||||
+ c->tags = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (found) {
|
||||
+ arrange(selmon);
|
||||
+ } else {
|
||||
+ spawnscratch(arg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+focusortogglescratch(const Arg *arg)
|
||||
+{
|
||||
+ Client *c;
|
||||
+ unsigned int found = 0;
|
||||
+
|
||||
+ /* search for first window that matches the scratchkey */
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (c->scratchkey == ((char**)arg->v)[0][0]) {
|
||||
+ found = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (found) {
|
||||
+ if (VISIBLEON(c, selmon)) {
|
||||
+ if (focustop(selmon) == c) {
|
||||
+ // hide
|
||||
+ c->tags = 0;
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+ } else {
|
||||
+ // focus
|
||||
+ focusclient(c, 1);
|
||||
+ }
|
||||
+ } else {
|
||||
+ // show
|
||||
+ c->tags = selmon->tagset[selmon->seltags];
|
||||
+ focusclient(c, 1);
|
||||
+ }
|
||||
+ arrange(selmon);
|
||||
+ } else{
|
||||
+ spawnscratch(arg);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
focusstack(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
### Description
|
||||
|
||||
Set natural scrolling only for trackpads. Without this patch, setting
|
||||
`natural_scrolling` to 1 in `config.h` results in a regular mouse wheel having
|
||||
natural scrolling enabled as well.
|
||||
|
||||
### Download
|
||||
|
||||
- [0.7](/dwl/dwl-patches/raw/branch/main/patches/naturalscrolltrackpad/naturalscrolltrackpad.patch)
|
||||
|
||||
### Authors
|
||||
|
||||
- [Nikita Ivanov](https://codeberg.org/nikitaivanov) ([GitHub](https://github.com/NikitaIvanovV))
|
||||
- [Neuromagus](https://codeberg.org/neuromagus)
|
||||
@@ -1,30 +0,0 @@
|
||||
From 63f38e7ccda8067a0558a6e81baad89ffbba9d6a Mon Sep 17 00:00:00 2001
|
||||
From: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
|
||||
Date: Sat, 8 Feb 2025 16:31:09 +0100
|
||||
Subject: [PATCH] Set natural scrolling only for trackpads
|
||||
|
||||
---
|
||||
dwl.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index def2562..f6bb544 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -1085,10 +1085,10 @@ createpointer(struct wlr_pointer *pointer)
|
||||
libinput_device_config_tap_set_drag_enabled(device, tap_and_drag);
|
||||
libinput_device_config_tap_set_drag_lock_enabled(device, drag_lock);
|
||||
libinput_device_config_tap_set_button_map(device, button_map);
|
||||
- }
|
||||
|
||||
- if (libinput_device_config_scroll_has_natural_scroll(device))
|
||||
- libinput_device_config_scroll_set_natural_scroll_enabled(device, natural_scrolling);
|
||||
+ if (libinput_device_config_scroll_has_natural_scroll(device))
|
||||
+ libinput_device_config_scroll_set_natural_scroll_enabled(device, natural_scrolling);
|
||||
+ }
|
||||
|
||||
if (libinput_device_config_dwt_is_available(device))
|
||||
libinput_device_config_dwt_set_enabled(device, disable_while_typing);
|
||||
--
|
||||
2.48.1
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
Allows activating numlock or capslock at startup.
|
||||
|
||||
### Download
|
||||
- [numlock-capslock_main-5fd19fe.patch](/dwl/dwl-patches/raw/branch/main/patches/numlock-capslock/numlock-capslock_main-5fd19fe.patch)
|
||||
- [numlock-capslock_wlroots-next-f4249db.patch](/dwl/dwl-patches/raw/branch/main/patches/numlock-capslock/numlock-capslock_wlroots-next-f4249db.patch)
|
||||
- [numlock-capslock_0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/numlock-capslock/numlock-capslock_0.8.patch)
|
||||
- [numlock-capslock-wlroots-next-f4249db.patch](/dwl/dwl-patches/raw/branch/main/patches/numlock-capslock/numlock-capslock-wlroots-next-f4249db.patch)
|
||||
- [numlock-capslock-0.8.patch](/dwl/dwl-patches/raw/branch/main/patches/numlock-capslock/numlock-capslock-0.8.patch)
|
||||
|
||||
### Authors
|
||||
- [fauxmight](https://codeberg.org/fauxmight)
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 572984b..5dae6d3 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -56,6 +56,10 @@ static const struct xkb_rule_names xkb_rules = {
|
||||
.options = NULL,
|
||||
};
|
||||
|
||||
+/* numlock and capslock */
|
||||
+static const int numlock = 1;
|
||||
+static const int capslock = 0;
|
||||
+
|
||||
static const int repeat_rate = 25;
|
||||
static const int repeat_delay = 600;
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index f902ace..7023cab 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/libinput.h>
|
||||
+#include <wlr/interfaces/wlr_keyboard.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_alpha_modifier_v1.h>
|
||||
@@ -373,6 +374,7 @@ static void zoom(const Arg *arg);
|
||||
/* variables */
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
+static uint32_t locked_mods = 0;
|
||||
static void *exclusive_focus;
|
||||
static struct wl_display *dpy;
|
||||
static struct wl_event_loop *event_loop;
|
||||
@@ -1019,6 +1021,8 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
||||
/* Set the keymap to match the group keymap */
|
||||
wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap);
|
||||
|
||||
+ wlr_keyboard_notify_modifiers(keyboard, 0, 0, locked_mods, 0);
|
||||
+
|
||||
/* Add the new keyboard to the group */
|
||||
wlr_keyboard_group_add_keyboard(kb_group->wlr_group, keyboard);
|
||||
}
|
||||
@@ -1040,6 +1044,21 @@ createkeyboardgroup(void)
|
||||
die("failed to compile keymap");
|
||||
|
||||
wlr_keyboard_set_keymap(&group->wlr_group->keyboard, keymap);
|
||||
+ if (numlock) {
|
||||
+ xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
|
||||
+ if (mod_index != XKB_MOD_INVALID)
|
||||
+ locked_mods |= (uint32_t)1 << mod_index;
|
||||
+ }
|
||||
+
|
||||
+ if (capslock) {
|
||||
+ xkb_mod_index_t mod_index = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_CAPS);
|
||||
+ if (mod_index != XKB_MOD_INVALID)
|
||||
+ locked_mods |= (uint32_t)1 << mod_index;
|
||||
+ }
|
||||
+
|
||||
+ if (locked_mods)
|
||||
+ wlr_keyboard_notify_modifiers(&group->wlr_group->keyboard, 0, 0, locked_mods, 0);
|
||||
+
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
### Description
|
||||
Adds per-window screen sharing aka toplevel capture via `ext-foreign-toplevel-image-capture-source-v1` based on the sway implementation <br>
|
||||
XWayland clients work in basic testing but it should be considered rather experimental. There is some possible restacking edge-cases but I was not able to reproduce them yet <br>
|
||||
Note that the captured surface is rendered a second time into its own scene, so there's a small GPU cost while a capture is active
|
||||
|
||||
Targets the dwl **`wlroots-next`** branch (base commit `d41ecb745c`).
|
||||
|
||||
### Requirements
|
||||
| Requirement | Notes |
|
||||
| --- | --- |
|
||||
| `wlroots` ≥ 0.20 | mandatory |
|
||||
| `xdg-desktop-portal-wlr` ≥ 0.8 | `chooser_type` has to be configured as `dmenu` |
|
||||
|
||||
### Download
|
||||
- [per-app-share-wlroots-next-d41ecb745c](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/per-app-cast/per-app-share-wlroots-next-d41ecb745c.patch)
|
||||
|
||||
### Authors
|
||||
- [skeetamine](https://codeberg.org/skeetamine)
|
||||
@@ -1,194 +0,0 @@
|
||||
From e0fe17a27625440a1a4ac8cfe91639a938589925 Mon Sep 17 00:00:00 2001
|
||||
From: skeetamine <lesrallidenud@gmail.com>
|
||||
Date: Fri, 19 Jun 2026 18:37:41 +0300
|
||||
Subject: [PATCH] per-app-cast: capture individual toplevels
|
||||
|
||||
Implement ext-foreign-toplevel-image-capture-source-v1 so portals can
|
||||
offer per-window screen sharing alongside per-output. Each toplevel is
|
||||
rendered into a dedicated offscreen scene so capture isolates the window
|
||||
regardless of tag/position.
|
||||
---
|
||||
dwl.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 83 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 8101ffa..7f4d059 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <wlr/types/wlr_drm.h>
|
||||
#include <wlr/types/wlr_export_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_ext_data_control_v1.h>
|
||||
+#include <wlr/types/wlr_ext_foreign_toplevel_list_v1.h>
|
||||
#include <wlr/types/wlr_ext_image_capture_source_v1.h>
|
||||
#include <wlr/types/wlr_ext_image_copy_capture_v1.h>
|
||||
#include <wlr/types/wlr_fractional_scale_v1.h>
|
||||
@@ -123,6 +124,7 @@ typedef struct {
|
||||
struct wlr_xwayland_surface *xwayland;
|
||||
} surface;
|
||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||
+ struct wlr_ext_foreign_toplevel_handle_v1 *ext_foreign_toplevel;
|
||||
struct wl_listener commit;
|
||||
struct wl_listener map;
|
||||
struct wl_listener maximize;
|
||||
@@ -243,6 +245,11 @@ typedef struct {
|
||||
struct wl_listener destroy;
|
||||
} SessionLock;
|
||||
|
||||
+typedef struct {
|
||||
+ struct wlr_scene *scene;
|
||||
+ struct wl_listener source_destroy;
|
||||
+} CaptureScene;
|
||||
+
|
||||
/* function declarations */
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
@@ -252,6 +259,7 @@ static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
+static void capturescenedestroy(struct wl_listener *listener, void *data);
|
||||
static void chvt(const Arg *arg);
|
||||
static void checkidleinhibitor(struct wlr_surface *exclude);
|
||||
static void cleanup(void);
|
||||
@@ -292,6 +300,7 @@ static void focusstack(const Arg *arg);
|
||||
static Client *focustop(Monitor *m);
|
||||
static void fullscreennotify(struct wl_listener *listener, void *data);
|
||||
static void gpureset(struct wl_listener *listener, void *data);
|
||||
+static void handlecapturerequest(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
@@ -399,6 +408,10 @@ static struct wlr_session_lock_manager_v1 *session_lock_mgr;
|
||||
static struct wlr_scene_rect *locked_bg;
|
||||
static struct wlr_session_lock_v1 *cur_lock;
|
||||
|
||||
+static struct wlr_ext_foreign_toplevel_list_v1 *ext_foreign_toplevel_list;
|
||||
+static struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1 *toplevel_capture_mgr;
|
||||
+static struct wl_listener ext_foreign_toplevel_capture_request = {.notify = handlecapturerequest};
|
||||
+
|
||||
static struct wlr_seat *seat;
|
||||
static KeyboardGroup *kb_group;
|
||||
static unsigned int cursor_mode;
|
||||
@@ -676,6 +689,15 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
+void
|
||||
+capturescenedestroy(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ CaptureScene *cs = wl_container_of(listener, cs, source_destroy);
|
||||
+ wl_list_remove(&cs->source_destroy.link);
|
||||
+ wlr_scene_node_destroy(&cs->scene->tree.node);
|
||||
+ free(cs);
|
||||
+}
|
||||
+
|
||||
void
|
||||
chvt(const Arg *arg)
|
||||
{
|
||||
@@ -786,6 +808,7 @@ cleanuplisteners(void)
|
||||
wl_list_remove(&request_start_drag.link);
|
||||
wl_list_remove(&start_drag.link);
|
||||
wl_list_remove(&new_session_lock.link);
|
||||
+ wl_list_remove(&ext_foreign_toplevel_capture_request.link);
|
||||
#ifdef XWAYLAND
|
||||
wl_list_remove(&new_xwayland_surface.link);
|
||||
wl_list_remove(&xwayland_ready.link);
|
||||
@@ -1561,6 +1584,41 @@ gpureset(struct wl_listener *listener, void *data)
|
||||
wlr_renderer_destroy(old_drw);
|
||||
}
|
||||
|
||||
+void
|
||||
+handlecapturerequest(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *req = data;
|
||||
+ Client *c;
|
||||
+ CaptureScene *cs;
|
||||
+ struct wlr_ext_image_capture_source_v1 *source;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (c->ext_foreign_toplevel != req->toplevel_handle)
|
||||
+ continue;
|
||||
+
|
||||
+ cs = ecalloc(1, sizeof(*cs));
|
||||
+ cs->scene = wlr_scene_create();
|
||||
+ if (c->type == XDGShell)
|
||||
+ wlr_scene_xdg_surface_create(&cs->scene->tree, c->surface.xdg);
|
||||
+ else
|
||||
+ wlr_scene_subsurface_tree_create(&cs->scene->tree, client_surface(c));
|
||||
+
|
||||
+ source =
|
||||
+ wlr_ext_image_capture_source_v1_create_with_scene_node(
|
||||
+ &cs->scene->tree.node, event_loop, alloc, drw);
|
||||
+
|
||||
+ if (source) {
|
||||
+ cs->source_destroy.notify = capturescenedestroy;
|
||||
+ wl_signal_add(&source->events.destroy, &cs->source_destroy);
|
||||
+ wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_accept(req, source);
|
||||
+ } else {
|
||||
+ wlr_scene_node_destroy(&cs->scene->tree.node);
|
||||
+ free(cs);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
handlesig(int signo)
|
||||
{
|
||||
@@ -1786,6 +1844,14 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
wl_list_insert(&clients, &c->link);
|
||||
wl_list_insert(&fstack, &c->flink);
|
||||
|
||||
+ {
|
||||
+ struct wlr_ext_foreign_toplevel_handle_v1_state ft_state = {
|
||||
+ .title = client_get_title(c),
|
||||
+ .app_id = client_get_appid(c),
|
||||
+ };
|
||||
+ c->ext_foreign_toplevel = wlr_ext_foreign_toplevel_handle_v1_create(ext_foreign_toplevel_list, &ft_state);
|
||||
+ }
|
||||
+
|
||||
/* Set initial monitor, tags, floating status, and focus:
|
||||
* we always consider floating, clients that have parent and thus
|
||||
* we set the same tags and monitor as its parent.
|
||||
@@ -2532,6 +2598,10 @@ setup(void)
|
||||
wlr_presentation_create(dpy, backend, 2);
|
||||
wlr_alpha_modifier_v1_create(dpy);
|
||||
|
||||
+ ext_foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy, 1);
|
||||
+ toplevel_capture_mgr = wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
|
||||
+ wl_signal_add(&toplevel_capture_mgr->events.new_request, &ext_foreign_toplevel_capture_request);
|
||||
+
|
||||
/* Initializes the interface used to implement urgency hints */
|
||||
activation = wlr_xdg_activation_v1_create(dpy);
|
||||
wl_signal_add(&activation->events.request_activate, &request_activate);
|
||||
@@ -2838,6 +2908,11 @@ unmapnotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->flink);
|
||||
}
|
||||
|
||||
+ if (c->ext_foreign_toplevel) {
|
||||
+ wlr_ext_foreign_toplevel_handle_v1_destroy(c->ext_foreign_toplevel);
|
||||
+ c->ext_foreign_toplevel = NULL;
|
||||
+ }
|
||||
+
|
||||
wlr_scene_node_destroy(&c->scene->node);
|
||||
printstatus();
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
@@ -2955,6 +3030,14 @@ updatetitle(struct wl_listener *listener, void *data)
|
||||
Client *c = wl_container_of(listener, c, set_title);
|
||||
if (c == focustop(c->mon))
|
||||
printstatus();
|
||||
+
|
||||
+ if (c->ext_foreign_toplevel) {
|
||||
+ struct wlr_ext_foreign_toplevel_handle_v1_state ft_state = {
|
||||
+ .title = client_get_title(c),
|
||||
+ .app_id = client_get_appid(c),
|
||||
+ };
|
||||
+ wlr_ext_foreign_toplevel_handle_v1_update_state(c->ext_foreign_toplevel, &ft_state);
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
--
|
||||
2.54.0
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
### Reorganize Tags
|
||||
|
||||
Implements the functionality of the reorganize tags patch in the dwm patch.
|
||||
|
||||
From the dwm patch:
|
||||
> Shifts all clients per tag to leftmost unoccupied tags.
|
||||
|
||||
> For example, if clients A, B, C are tagged on tags 1, 5, 9 respectively, when
|
||||
> this function is called, they will now be on 1, 2, and 3. The focused client
|
||||
> will also remain focused.
|
||||
|
||||
> Clients on multiple tags will be treated as if they only were only on their
|
||||
> leftmost tag, and will be reduced to one tag after the operation is complete.
|
||||
|
||||
#### Distribute Tags
|
||||
> This provides an additional feature to distribute the clients through
|
||||
> the tags as evenly as possible.
|
||||
|
||||
> (The tags are filled left-to-right, looping back if necessary.)
|
||||
|
||||
> Eg, if there are 9 clients and 9 tags then each tag will have one
|
||||
> client. If there are 19 clients, then 3 will be tagged onto tag 1, and
|
||||
> 2 will be tagged onto each of tags 2 to 9.
|
||||
|
||||
### Download
|
||||
|
||||
- [main 2026-03-25](/dwl/dwl-patches/raw/branch/rmain/patches/reorganizetags/reorganizetags.patch)
|
||||
- [with bar patch](/dwl/dwl-patches/raw/branch/rmain/patches/reorganizetags/reorganizetags-bar.patch)
|
||||
|
||||
With the bar patch, it will be necessary to replace `TAGCOUNT` with `LENGTH(tags)`. This is done in a separate patch.
|
||||
|
||||
### Authors
|
||||
- [zoigmant](codeberg.org/zoigmant)
|
||||
|
||||
### Credits (Authors of the dwm patch)
|
||||
- [Paul Baldaray](paulbaldaray@gmail.com)
|
||||
- [kleinbottle4](kleinbottle4@gmail.com)
|
||||
@@ -1,93 +0,0 @@
|
||||
From ec0ff716f4096e8552c0d142e41a36468c65ed1d Mon Sep 17 00:00:00 2001
|
||||
From: zoigmant <zoigmant@noreply.codeberg.org>
|
||||
Date: Sun, 29 Mar 2026 18:08:04 -0700
|
||||
Subject: [PATCH] [PATCH] reorganize tags patch. Mostly imported from dwm.
|
||||
Allows the users to move occupied tags as far left as possible. Patched to
|
||||
accomodate the bar patch
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 49 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 7da50d2..70c36dd 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -136,6 +136,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
+ { MODKEY, XKB_KEY_r, reorganizetags, {0} },
|
||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 7b2abf5..4d80bd6 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -346,6 +346,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||
double sx, double sy, uint32_t time);
|
||||
static void powermgrsetmode(struct wl_listener *listener, void *data);
|
||||
static void quit(const Arg *arg);
|
||||
+static void reorganizetags(const Arg *arg);
|
||||
static void rendermon(struct wl_listener *listener, void *data);
|
||||
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
||||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
@@ -2405,6 +2406,53 @@ requestmonstate(struct wl_listener *listener, void *data)
|
||||
updatemons(NULL, NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+reorganizetags(const Arg *arg) {
|
||||
+ Client *c;
|
||||
+ unsigned int occ, unocc, i;
|
||||
+ unsigned int tagdest[LENGTH(tags)];
|
||||
+ for (i = 0; i < LENGTH(tags); i++)
|
||||
+ tagdest[i] = 0; /* so no uninitialized memory warning */
|
||||
+
|
||||
+ occ = 0;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if ((c->mon == selmon) && c->tags) {
|
||||
+ for(i = 0;; i++) { /* because no ffs() in this C standard */
|
||||
+ if ((c->tags) & (1 << i)) {
|
||||
+ occ |= (1 << i);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ unocc = 0;
|
||||
+ for (i = 0; i < LENGTH(tags); ++i) {
|
||||
+ while (unocc < i && (occ & (1 << unocc)))
|
||||
+ unocc++;
|
||||
+ if (occ & (1 << i)) {
|
||||
+ tagdest[i] = unocc;
|
||||
+ occ &= ~(1 << i);
|
||||
+ occ |= 1 << unocc;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if ((c->mon == selmon) && c->tags) {
|
||||
+ for(i = 0;; i++) {
|
||||
+ if ((c->tags) & (1 << i)) {
|
||||
+ c->tags = 1 << tagdest[i];
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (focustop(selmon))
|
||||
+ selmon->tagset[selmon->seltags] = focustop(selmon)->tags;
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+ drawbars();
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resize(Client *c, struct wlr_box geo, int interact)
|
||||
{
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
From c7efef1814c12b8f10de1c32568eaf9241e8518d Mon Sep 17 00:00:00 2001
|
||||
From: zoigmant <zoigmant@noreply.codeberg.org>
|
||||
Date: Wed, 25 Mar 2026 15:10:30 -0700
|
||||
Subject: [PATCH] [PATCH] reorganizetags patch. Mostly imported from dwm.
|
||||
Allows the users to move occupied tags over so as to remove empty tags
|
||||
inbetween occupied tags. It preserves the order of the tags.
|
||||
|
||||
---
|
||||
config.def.h | 1 +
|
||||
dwl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 48 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8a6eda0..12f6d92 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -129,6 +129,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
|
||||
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
|
||||
+ { MODKEY, XKB_KEY_r, reorganizetags, {0} },
|
||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_c, killclient, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..8ea1345 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -313,6 +313,7 @@ static void pointerfocus(Client *c, struct wlr_surface *surface,
|
||||
static void printstatus(void);
|
||||
static void powermgrsetmode(struct wl_listener *listener, void *data);
|
||||
static void quit(const Arg *arg);
|
||||
+static void reorganizetags(const Arg *arg);
|
||||
static void rendermon(struct wl_listener *listener, void *data);
|
||||
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
||||
static void requeststartdrag(struct wl_listener *listener, void *data);
|
||||
@@ -2202,6 +2203,52 @@ requestmonstate(struct wl_listener *listener, void *data)
|
||||
updatemons(NULL, NULL);
|
||||
}
|
||||
|
||||
+void
|
||||
+reorganizetags(const Arg *arg) {
|
||||
+ Client *c;
|
||||
+ unsigned int occ, unocc, i;
|
||||
+ unsigned int tagdest[TAGCOUNT];
|
||||
+ for (i = 0; i < TAGCOUNT; i++)
|
||||
+ tagdest[i] = 0; /* so no uninitialized memory warning */
|
||||
+
|
||||
+ occ = 0;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if ((c->mon == selmon) && c->tags) {
|
||||
+ for(i = 0;; i++) { /* because no ffs() in this C standard */
|
||||
+ if ((c->tags) & (1 << i)) {
|
||||
+ occ |= (1 << i);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ unocc = 0;
|
||||
+ for (i = 0; i < TAGCOUNT; ++i) {
|
||||
+ while (unocc < i && (occ & (1 << unocc)))
|
||||
+ unocc++;
|
||||
+ if (occ & (1 << i)) {
|
||||
+ tagdest[i] = unocc;
|
||||
+ occ &= ~(1 << i);
|
||||
+ occ |= 1 << unocc;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if ((c->mon == selmon) && c->tags) {
|
||||
+ for(i = 0;; i++) {
|
||||
+ if ((c->tags) & (1 << i)) {
|
||||
+ c->tags = 1 << tagdest[i];
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (focustop(selmon))
|
||||
+ selmon->tagset[selmon->seltags] = focustop(selmon)->tags;
|
||||
+ focusclient(focustop(selmon), 1);
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
void
|
||||
resize(Client *c, struct wlr_box geo, int interact)
|
||||
{
|
||||
--
|
||||
2.52.0
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
Moves clients to their old output when it is reattached.
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/6z7y/dwl-patches/src/branch/restore-monitor)
|
||||
- [2026-06-20](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/restore-monitor/restore-monitor.patch)
|
||||
- [git branch](https://codeberg.org/eyusupov/dwl/src/branch/restore-monitor)
|
||||
- [2024-04-07](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/restore-monitor/restore-monitor.patch)
|
||||
### Authors
|
||||
#### Current
|
||||
- [6z7y](https://codeberg.org/6z7y)
|
||||
#### Historic
|
||||
- [eyusupov](https://codeberg.org/eyusupov)
|
||||
|
||||
|
||||
@@ -1,95 +1,79 @@
|
||||
From e42ca1c539437d3098d80983cfe2ad6f938d7a08 Mon Sep 17 00:00:00 2001
|
||||
From: Eldar Yusupov <eyusupov@gmail.com>
|
||||
Date: Sun, 17 Mar 2024 19:12:29 +0300
|
||||
Subject: [PATCH] Restore correct monitor and floating position when reattached
|
||||
Subject: [PATCH] Restore correct monitor for client when it is reattached
|
||||
|
||||
---
|
||||
dwl.c | 33 ++++++++++++++++++++++++++++++---
|
||||
1 file changed, 30 insertions(+), 3 deletions(-)
|
||||
dwl.c | 24 ++++++++++++++++++++++--
|
||||
1 file changed, 22 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 44f3ad9..41548cd 100644
|
||||
index bf763df..d8d8139 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -106,6 +106,8 @@ typedef struct {
|
||||
@@ -107,6 +107,7 @@ typedef struct {
|
||||
unsigned int type; /* XDGShell or X11* */
|
||||
|
||||
struct wlr_box geom; /* layout-relative, includes border */
|
||||
Monitor *mon;
|
||||
+ char *output;
|
||||
+ struct wlr_box floatgeom; /* saved geom for floating restore after monitor reconnect */
|
||||
+ char *output;
|
||||
struct wlr_scene_tree *scene;
|
||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
||||
struct wlr_scene_tree *scene_surface;
|
||||
@@ -807,6 +809,13 @@ closemon(Monitor *m)
|
||||
}
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
+
|
||||
+ /* Save floating geom now, before destroymon modifies it below.
|
||||
+ * destroymon subtracts m->w.width from c->geom.x for floating
|
||||
+ * windows, which corrupts the layout-absolute position we need
|
||||
+ * to restore on reconnect. */
|
||||
+ if (c->isfloating && c->mon == m) c->floatgeom = c->geom;
|
||||
+
|
||||
if (c->isfloating && c->geom.x > m->m.width)
|
||||
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
|
||||
.width = c->geom.width, .height = c->geom.height}, 0);
|
||||
@@ -1045,6 +1054,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -869,6 +870,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m;
|
||||
+ Client *c;
|
||||
+ Client *c;
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
return;
|
||||
@@ -1114,6 +1124,15 @@ createmon(struct wl_listener *listener, void *data)
|
||||
@@ -938,6 +940,13 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
else
|
||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!c->output || strcmp(wlr_output->name, c->output) != 0)
|
||||
+ continue;
|
||||
+ c->mon = m;
|
||||
+ if (c->isfloating)
|
||||
+ resize(c, c->floatgeom, 0);
|
||||
+ }
|
||||
+ updatemons(NULL, NULL);
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (strcmp(wlr_output->name, c->output) == 0) {
|
||||
+ c->mon = m;
|
||||
+ }
|
||||
+ }
|
||||
+ updatemons(NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1347,7 +1366,8 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
@@ -1186,6 +1195,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->map.link);
|
||||
wl_list_remove(&c->unmap.link);
|
||||
wl_list_remove(&c->maximize.link);
|
||||
}
|
||||
- free(c);
|
||||
+ free(c->output);
|
||||
+ free(c);
|
||||
+ free(c->output);
|
||||
free(c);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1792,6 +1812,9 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
@@ -1618,6 +1628,10 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
} else {
|
||||
applyrules(c);
|
||||
}
|
||||
+ c->output = strdup(c->mon->wlr_output->name);
|
||||
+ if (c->output == NULL) die("oom");
|
||||
+
|
||||
+ c->output = strdup(c->mon->wlr_output->name);
|
||||
+ if (c->output == NULL) {
|
||||
+ die("oom");
|
||||
+ }
|
||||
printstatus();
|
||||
|
||||
unset_fullscreen:
|
||||
@@ -2705,8 +2728,12 @@ void
|
||||
@@ -2565,8 +2579,14 @@ void
|
||||
tagmon(const Arg *arg)
|
||||
{
|
||||
Client *sel = focustop(selmon);
|
||||
- if (sel)
|
||||
- setmon(sel, dirtomon(arg->i), 0);
|
||||
+ if (!sel) return;
|
||||
+
|
||||
+ setmon(sel, dirtomon(arg->i), 0);
|
||||
+ free(sel->output);
|
||||
+ sel->output = strdup(sel->mon->wlr_output->name);
|
||||
+ if (sel->output == NULL) die("oom");
|
||||
+ if (!sel)
|
||||
+ return;
|
||||
+ setmon(sel, dirtomon(arg->i), 0);
|
||||
+ free(sel->output);
|
||||
+ sel->output = strdup(sel->mon->wlr_output->name);
|
||||
+ if (sel->output == NULL) {
|
||||
+ die("oom");
|
||||
+ }
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
### Description
|
||||
|
||||
Implement rounded corners, shadows and blur with [scenefx](https://github.com/wlrfx/scenefx) 0.5.
|
||||
|
||||
- [git branch](https://codeberg.org/guidocella/dwl/src/branch/scenefx)
|
||||
- [2026-10-29](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/scenefx/scenefx.patch)
|
||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/7a5c3420822074c544fa102e030b7c30aa6b6be8/scenefx/scenefx.patch)
|
||||
|
||||
### Authors
|
||||
|
||||
- [wochap](https://codeberg.org/wochap)
|
||||
- [Guido Cella](https://codeberg.org/guidocella)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user