mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-10-27 10:14:16 +00:00
Move dimkr patches from dwl/dwl.wiki
This commit is contained in:
parent
979ea455f1
commit
6fc039c151
298
env/env.patch
vendored
Normal file
298
env/env.patch
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
From f51bfab9b90536518a8f2eb9ac9ecb082bcf270d Mon Sep 17 00:00:00 2001
|
||||
From: Dima Krasner <dima@dimakrasner.com>
|
||||
Date: Sat, 25 Nov 2023 11:55:58 +0200
|
||||
Subject: [PATCH] allow environment variables to override config.h
|
||||
|
||||
---
|
||||
Makefile | 1 +
|
||||
config.def.h | 9 ++-
|
||||
dwl.c | 5 ++
|
||||
env.c | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 228 insertions(+), 4 deletions(-)
|
||||
create mode 100644 env.c
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index f0ff805..506ed09 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -17,6 +17,7 @@ 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 xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h
|
||||
+dwl.o: env.c
|
||||
util.o: util.c util.h
|
||||
|
||||
# wayland-scanner is a tool which generates C headers and rigging for Wayland
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index db0babc..c201b84 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -6,10 +6,11 @@
|
||||
/* appearance */
|
||||
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 float bordercolor[] = COLOR(0x444444ff);
|
||||
-static const float focuscolor[] = COLOR(0x005577ff);
|
||||
-static const float urgentcolor[] = COLOR(0xff0000ff);
|
||||
+static unsigned int borderpx = 1; /* border pixel of windows */
|
||||
+static float bordercolor[] = COLOR(0x444444ff);
|
||||
+static float focuscolor[] = COLOR(0x005577ff);
|
||||
+static float urgentcolor[] = COLOR(0xff0000ff);
|
||||
+static float rootcolor[] = COLOR(0x111122ff);
|
||||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
||||
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can also use glsl colors */
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bbb27e4..1f8d5fb 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -396,6 +396,8 @@ static xcb_atom_t netatom[NetLast];
|
||||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
|
||||
+#include "env.c"
|
||||
+
|
||||
/* function implementations */
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
@@ -1017,6 +1019,8 @@ createpointer(struct wlr_pointer *pointer)
|
||||
libinput_device_config_accel_set_profile(libinput_device, accel_profile);
|
||||
libinput_device_config_accel_set_speed(libinput_device, accel_speed);
|
||||
}
|
||||
+
|
||||
+ inputconfig(libinput_device);
|
||||
}
|
||||
|
||||
wlr_cursor_attach_input_device(cursor, &pointer->base);
|
||||
@@ -2886,6 +2890,7 @@ main(int argc, char *argv[])
|
||||
/* Wayland requires XDG_RUNTIME_DIR for creating its communications socket */
|
||||
if (!getenv("XDG_RUNTIME_DIR"))
|
||||
die("XDG_RUNTIME_DIR must be set");
|
||||
+ loadtheme();
|
||||
setup();
|
||||
run(startup_cmd);
|
||||
cleanup();
|
||||
diff --git a/env.c b/env.c
|
||||
new file mode 100644
|
||||
index 0000000..618f81e
|
||||
--- /dev/null
|
||||
+++ b/env.c
|
||||
@@ -0,0 +1,217 @@
|
||||
+static int
|
||||
+isenabled(const char *val, int def)
|
||||
+{
|
||||
+ return ((def && (!val || !val[0] || (val[0] != '0'))) || (!def && (val && val[0] && (val[0] != '0'))));
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setclickmethod(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+ long l;
|
||||
+ char *end = NULL;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_CLICK_METHOD");
|
||||
+ if (!val || !val[0])
|
||||
+ return;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ l = strtol(val, &end, 10);
|
||||
+ if (errno || (end && *end))
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_click_set_method(libinput_device,
|
||||
+ (enum libinput_config_click_method)l);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+settap(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_TAP");
|
||||
+ if (val) {
|
||||
+ if (!val[0])
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_tap_set_enabled(libinput_device,
|
||||
+ isenabled(val, 1) ? LIBINPUT_CONFIG_TAP_ENABLED :
|
||||
+ LIBINPUT_CONFIG_TAP_DISABLED);
|
||||
+ } else if (tap_to_click && libinput_device_config_tap_get_finger_count(libinput_device))
|
||||
+ libinput_device_config_tap_set_enabled(libinput_device,
|
||||
+ LIBINPUT_CONFIG_TAP_ENABLED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+settapanddrag(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_DRAG");
|
||||
+ if (val && val[0])
|
||||
+ libinput_device_config_tap_set_drag_enabled(libinput_device,
|
||||
+ isenabled(val, 1) ? LIBINPUT_CONFIG_DRAG_ENABLED :
|
||||
+ LIBINPUT_CONFIG_DRAG_DISABLED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setnaturalscroll(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_NATURAL_SCROLL");
|
||||
+ if (val && val[0])
|
||||
+ libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||
+ libinput_device, isenabled(val, 0));
|
||||
+ else if (!val && libinput_device_config_scroll_has_natural_scroll(libinput_device))
|
||||
+ libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||
+ libinput_device, natural_scrolling);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setaccelprofile(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+ double profile;
|
||||
+ char *end = NULL;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_ACCELERATION_PROFILE");
|
||||
+ if (!val || !val[0])
|
||||
+ return;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ profile = strtod(val, &end);
|
||||
+ if (errno || (end && *end))
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_accel_set_profile(libinput_device,
|
||||
+ (enum libinput_config_accel_profile)profile);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setaccelspeed(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+ double accel = 0;
|
||||
+ char *end = NULL;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_ACCELERATION");
|
||||
+ if (!val || !val[0])
|
||||
+ return;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ accel = strtod(val, &end);
|
||||
+ if (errno || (end && *end) || (accel < -1) || (accel > 1))
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_accel_set_speed(libinput_device, accel);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setscrollmethod(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+ long l;
|
||||
+ char *end = NULL;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_SCROLL_METHOD");
|
||||
+ if (!val || !val[0])
|
||||
+ return;
|
||||
+
|
||||
+ errno = 0;
|
||||
+ l = strtol(val, &end, 10);
|
||||
+ if (errno || (end && *end))
|
||||
+ return;
|
||||
+
|
||||
+ libinput_device_config_scroll_set_method(libinput_device,
|
||||
+ (enum libinput_config_scroll_method)l);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setdwt(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_DISABLE_WHILE_TYPING");
|
||||
+ if (val && val[0])
|
||||
+ libinput_device_config_dwt_set_enabled(libinput_device,
|
||||
+ isenabled(val, false) ? LIBINPUT_CONFIG_DWT_ENABLED :
|
||||
+ LIBINPUT_CONFIG_DWT_DISABLED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setmiddleemul(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_MIDDLE_EMULATION");
|
||||
+ if (val && val[0])
|
||||
+ libinput_device_config_middle_emulation_set_enabled(libinput_device,
|
||||
+ isenabled(val, false) ? LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
|
||||
+ LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+setlefthanded(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ const char *val;
|
||||
+
|
||||
+ val = getenv("LIBINPUT_DEFAULT_LEFT_HANDED");
|
||||
+ if (val && val[0])
|
||||
+ libinput_device_config_left_handed_set(libinput_device,
|
||||
+ isenabled(val, 0));
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+inputconfig(struct libinput_device *libinput_device)
|
||||
+{
|
||||
+ setclickmethod(libinput_device);
|
||||
+ settap(libinput_device);
|
||||
+ settapanddrag(libinput_device);
|
||||
+ setnaturalscroll(libinput_device);
|
||||
+ setaccelprofile(libinput_device);
|
||||
+ setaccelspeed(libinput_device);
|
||||
+ setscrollmethod(libinput_device);
|
||||
+ setdwt(libinput_device);
|
||||
+ setmiddleemul(libinput_device);
|
||||
+ setlefthanded(libinput_device);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+parsecolor(const char *val, float color[4])
|
||||
+{
|
||||
+ uint8_t r, g, b;
|
||||
+ if (sscanf(val, "#%02hhx%02hhx%02hhx", &r, &g, &b) == 3) {
|
||||
+ color[0] = (float)r / 0xFF;
|
||||
+ color[1] = (float)g / 0xFF;
|
||||
+ color[2] = (float)b / 0xFF;
|
||||
+ color[3] = 1.0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+loadtheme(void)
|
||||
+{
|
||||
+ const char *val;
|
||||
+ unsigned int tmp;
|
||||
+
|
||||
+ val = getenv("DWL_ROOT_COLOR");
|
||||
+ if (val)
|
||||
+ parsecolor(val, rootcolor);
|
||||
+
|
||||
+ val = getenv("DWL_BORDER_COLOR");
|
||||
+ if (val)
|
||||
+ parsecolor(val, bordercolor);
|
||||
+
|
||||
+ val = getenv("DWL_FOCUS_COLOR");
|
||||
+ if (val)
|
||||
+ parsecolor(val, focuscolor);
|
||||
+
|
||||
+ val = getenv("DWL_URGENT_COLOR");
|
||||
+ if (val)
|
||||
+ parsecolor(val, urgentcolor);
|
||||
+
|
||||
+ val = getenv("DWL_BORDER");
|
||||
+ if (val && sscanf(val, "%u", &tmp) == 1)
|
||||
+ borderpx = tmp;
|
||||
+}
|
||||
41
fallback/fallback.patch
Normal file
41
fallback/fallback.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 5fbb468e37b9a1e25e0e32462a2ca58758c3f824 Mon Sep 17 00:00:00 2001
|
||||
From: Dima Krasner <dima@dimakrasner.com>
|
||||
Date: Sat, 2 Dec 2023 10:36:35 +0200
|
||||
Subject: [PATCH] fall back to a lower output mode if needed
|
||||
(swaywm/sway@4cdc4ac)
|
||||
|
||||
---
|
||||
dwl.c | 13 ++++++++++++-
|
||||
1 file changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bbb27e4..ea2a3cb 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -856,6 +856,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 *preferred_mode, *mode;
|
||||
const MonitorRule *r;
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
@@ -890,7 +891,17 @@ createmon(struct wl_listener *listener, void *data)
|
||||
* 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));
|
||||
+ preferred_mode = wlr_output_preferred_mode(wlr_output);
|
||||
+ wlr_output_state_set_mode(&state, preferred_mode);
|
||||
+ if (!wlr_output_test_state(wlr_output, &state) && !wl_list_empty(&wlr_output->modes)) {
|
||||
+ wl_list_for_each(mode, &wlr_output->modes, link) {
|
||||
+ if (mode != preferred_mode) {
|
||||
+ wlr_output_state_set_mode(&state, mode);
|
||||
+ if (wlr_output_test_state(wlr_output, &state))
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/* Set up event listeners */
|
||||
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
|
||||
47
right/right.patch
Normal file
47
right/right.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From ae70de3793109624ae7f8cdfebd214ef3e883f79 Mon Sep 17 00:00:00 2001
|
||||
From: Dima Krasner <dima@dimakrasner.com>
|
||||
Date: Thu, 21 Jul 2022 21:14:14 +0300
|
||||
Subject: [PATCH] extend the display to the right
|
||||
|
||||
---
|
||||
dwl.c | 13 +++++++++++--
|
||||
1 file changed, 11 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bbb27e4..2ae003e 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -859,7 +859,8 @@ createmon(struct wl_listener *listener, void *data)
|
||||
const MonitorRule *r;
|
||||
size_t i;
|
||||
struct wlr_output_state state;
|
||||
- Monitor *m;
|
||||
+ Monitor *om, *m;
|
||||
+ int max_x = 0, max_x_y = 0, width, height;
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
return;
|
||||
@@ -901,6 +902,14 @@ createmon(struct wl_listener *listener, void *data)
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
+ wl_list_for_each(om, &mons, link) {
|
||||
+ wlr_output_effective_resolution(om->wlr_output, &width, &height);
|
||||
+ if (om->m.x + width > max_x) {
|
||||
+ max_x = om->m.x + width;
|
||||
+ max_x_y = om->m.y;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
wl_list_insert(&mons, &m->link);
|
||||
printstatus();
|
||||
|
||||
@@ -924,7 +933,7 @@ createmon(struct wl_listener *listener, void *data)
|
||||
*/
|
||||
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
||||
if (m->m.x < 0 || m->m.y < 0)
|
||||
- wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
+ wlr_output_layout_add(output_layout, wlr_output, max_x, max_x_y);
|
||||
else
|
||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
||||
246
snail/snail.patch
Normal file
246
snail/snail.patch
Normal file
@ -0,0 +1,246 @@
|
||||
From ad717ddd80ec86b2c1f87b88c673bd272332790a Mon Sep 17 00:00:00 2001
|
||||
From: Dima Krasner <dima@dimakrasner.com>
|
||||
Date: Sat, 15 Jul 2023 15:45:58 +0300
|
||||
Subject: [PATCH] add the snail layout
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This layout is a scalable alternative to the "tile" and "spiral" layouts, optimized for wide monitors. Both the master area and the stack are "spirals", but windows in the master area are split horizontally as long as the master area has enough horizontal space, and the first window in the stack is split vertically unless the stack is wide.
|
||||
|
||||
With one window in the master area and mfact = 0.5, it behaves like the spiral layout:
|
||||
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ ├───┬───┬────────┤
|
||||
│ │ │ │ │
|
||||
│ ├───┴───┤ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
└───────────────┴───────┴────────┘
|
||||
|
||||
With 2 windows in the master area and 2 in the stack:
|
||||
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
├───────────────┼────────────────┤
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
└───────────────┴────────────────┘
|
||||
|
||||
With 3 windows in the master area and 2 in the stack:
|
||||
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
├───────┬───────┼────────────────┤
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
└───────┴───────┴────────────────┘
|
||||
|
||||
With many windows in both areas:
|
||||
|
||||
┌───────────────┬────────────────┐
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
├───┬───┬───────┼───┬───┬────────┤
|
||||
│ │ │ │ │ │ │
|
||||
├───┴───┤ ├───┴───┤ │
|
||||
│ │ │ │ │
|
||||
│ │ │ │ │
|
||||
└───────┴───────┴───────┴────────┘
|
||||
|
||||
With 2 windows in the master area, many windows in the stack and high mfact:
|
||||
|
||||
┌──────────┬──────────┬──────────┐
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ master ├──┬stack──┤
|
||||
│ │ │ │ │ │
|
||||
│ │ ├──┴──┤ │
|
||||
│ │ │ │ │
|
||||
│ │ │ │ │
|
||||
└──────────┴──────────┴─────┴────┘
|
||||
|
||||
With 2 windows in the master area, many windows in the stack and low mfact:
|
||||
|
||||
┌──────────┬──────────┬──────────┐
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
│ │ │ │
|
||||
├──master──┤ stack┬──┬────┤
|
||||
│ │ │ │ │ │
|
||||
│ │ ├──┴──┤ │
|
||||
│ │ │ │ │
|
||||
│ │ │ │ │
|
||||
└──────────┴──────────┴─────┴────┘
|
||||
---
|
||||
config.def.h | 4 +-
|
||||
dwl.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 104 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index db0babc..fae7887 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 },
|
||||
+ { "@|@", snail },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -42,7 +43,7 @@ static const MonitorRule monrules[] = {
|
||||
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
*/
|
||||
/* defaults */
|
||||
- { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
+ { NULL, 0.64, 1, 1, &layouts[3], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
};
|
||||
|
||||
/* keyboard */
|
||||
@@ -132,6 +133,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_s, 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 6a96179..25e0137 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -306,6 +306,7 @@ 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 snail(Monitor *m);
|
||||
static void spawn(const Arg *arg);
|
||||
static void startdrag(struct wl_listener *listener, void *data);
|
||||
static void tag(const Arg *arg);
|
||||
@@ -2361,6 +2362,106 @@ setup(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
+void
|
||||
+snail(Monitor *m)
|
||||
+{
|
||||
+ unsigned int i = 0, n = 0, mw = m->w.width;
|
||||
+ Client *c, *prev;
|
||||
+ enum wlr_direction dir = WLR_DIRECTION_RIGHT;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
+ n++;
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (n > m->nmaster)
|
||||
+ mw = m->nmaster ? m->w.width * m->mfact : 0;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ continue;
|
||||
+
|
||||
+ /*
|
||||
+ * If the master area exists and this is the first window, fill the
|
||||
+ * master area with this window
|
||||
+ */
|
||||
+ if (mw > 0 && i == 0) {
|
||||
+ c->geom = (struct wlr_box){.x = m->w.x, .y = m->w.y,
|
||||
+ .width = mw, .height = m->w.height};
|
||||
+ /*
|
||||
+ * If the first window in the master area is wide, split it
|
||||
+ * horizontally and put next one on its right; otherwise, split it
|
||||
+ * vertically and put the next one below it
|
||||
+ */
|
||||
+ dir = c->geom.width > m->w.height ? WLR_DIRECTION_RIGHT : WLR_DIRECTION_DOWN;
|
||||
+ /*
|
||||
+ * If the master area is full or doesn't exist, fill the stack with the
|
||||
+ * m->nmaster-th window
|
||||
+ */
|
||||
+ } else if (i == m->nmaster) {
|
||||
+ c->geom = (struct wlr_box){.x = m->w.x + mw, .y = m->w.y,
|
||||
+ .width = m->w.width - mw, .height = m->w.height};
|
||||
+ /*
|
||||
+ * If the first window in the stack is wide, split it horizontally
|
||||
+ * and put next one on its right; otherwise, split it vertically and
|
||||
+ * put the next one below it
|
||||
+ */
|
||||
+ dir = c->geom.width > m->w.height ? WLR_DIRECTION_RIGHT : WLR_DIRECTION_DOWN;
|
||||
+ /*
|
||||
+ * Split the previous horizontally and put the current window on the right
|
||||
+ */
|
||||
+ } else if (dir == WLR_DIRECTION_RIGHT) {
|
||||
+ c->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width / 2, .height = prev->geom.height};
|
||||
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width / 2, .height = prev->geom.height};
|
||||
+ /*
|
||||
+ * If it's a stack window or the first narrow window in the master
|
||||
+ * area, put the next one below it
|
||||
+ */
|
||||
+ if (i >= m->nmaster || c->geom.width < m->w.height)
|
||||
+ dir = WLR_DIRECTION_DOWN;
|
||||
+ /*
|
||||
+ * Split the previous vertically and put the current window below it
|
||||
+ */
|
||||
+ } else if (dir == WLR_DIRECTION_DOWN) {
|
||||
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2,
|
||||
+ .width = prev->geom.width, .height = prev->geom.height / 2};
|
||||
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width, .height = prev->geom.height / 2};
|
||||
+ dir = WLR_DIRECTION_LEFT;
|
||||
+ /*
|
||||
+ * Split the previous horizontally and put the current window on the left
|
||||
+ */
|
||||
+ } else if (dir == WLR_DIRECTION_LEFT) {
|
||||
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width / 2, .height = prev->geom.height};
|
||||
+ prev->geom = (struct wlr_box){.x = prev->geom.x + prev->geom.width / 2, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width / 2, .height = prev->geom.height};
|
||||
+ dir = WLR_DIRECTION_UP;
|
||||
+ /*
|
||||
+ * Split the previous vertically and put the current window above it
|
||||
+ */
|
||||
+ } else {
|
||||
+ c->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y,
|
||||
+ .width = prev->geom.width, .height = prev->geom.height / 2};
|
||||
+ prev->geom = (struct wlr_box){.x = prev->geom.x, .y = prev->geom.y + prev->geom.height / 2,
|
||||
+ .width = prev->geom.width, .height = prev->geom.height / 2};
|
||||
+ dir = WLR_DIRECTION_RIGHT;
|
||||
+ }
|
||||
+ i++;
|
||||
+ prev = c;
|
||||
+ }
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ continue;
|
||||
+
|
||||
+ resize(c, c->geom, 0);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
spawn(const Arg *arg)
|
||||
{
|
||||
Loading…
x
Reference in New Issue
Block a user