summaryrefslogtreecommitdiffstats
path: root/dwl-patches/patches/movecenter
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2025-05-23 11:41:09 +0000
committerLeonard Kugis <leonard@kug.is>2025-05-23 11:41:09 +0000
commitc70505d7c7b7b48600f273357694b56ccf5d2a15 (patch)
tree21c27ac6ffced8d6d904e35bdb39baa5d685d829 /dwl-patches/patches/movecenter
downloaddotfiles-master.tar.gz
dotfiles-master.tar.bz2
dotfiles-master.zip
Initial commitHEADmaster
Diffstat (limited to 'dwl-patches/patches/movecenter')
-rw-r--r--dwl-patches/patches/movecenter/README.md28
-rw-r--r--dwl-patches/patches/movecenter/movecenter.patch82
2 files changed, 110 insertions, 0 deletions
diff --git a/dwl-patches/patches/movecenter/README.md b/dwl-patches/patches/movecenter/README.md
new file mode 100644
index 0000000..aff8f7d
--- /dev/null
+++ b/dwl-patches/patches/movecenter/README.md
@@ -0,0 +1,28 @@
+### Description
+
+> This patch is no longer being maintained by me [wochap](https://codeberg.org/wochap), since I'm now using a different patch specific to my use case: https://codeberg.org/wochap/dwl/src/branch/v0.6-c/betterfloat/betterfloat-diff.patch.
+
+This patch provides a keybinding to center the focused floating window.
+
+Press <kbd>MODKEY</kbd> + <kbd>x</kbd> to center the focused floating window.
+
+It does NOT center windows that are not floating.
+
+The variable `respect_monitor_reserved_area` allows the user to choose whether to center relative to the monitor or relative to the window area.
+
+<details>
+<summary>Explanation of respect_monitor_reserved_area:</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="https://i.imgur.com/xhejzPh.png"/>
+</pre>
+</details>
+
+### Download
+- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.6/movecenter)
+- [v0.6](https://codeberg.org/dwl/dwl-patches/raw/commit/b1ca929ee645cd3e175f198e250448b54624acd6/patches/movecenter/movecenter.patch)
+- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/commit/187d7f511572457750fcf6e42c99cdc7befe05e7/patches/movecenter/movecenter.patch)
+
+### Authors
+- [wochap](https://codeberg.org/wochap)
+
diff --git a/dwl-patches/patches/movecenter/movecenter.patch b/dwl-patches/patches/movecenter/movecenter.patch
new file mode 100644
index 0000000..f96bd36
--- /dev/null
+++ b/dwl-patches/patches/movecenter/movecenter.patch
@@ -0,0 +1,82 @@
+From bc5206882c71b32198dae5f1c85601a863a7c0a9 Mon Sep 17 00:00:00 2001
+From: wochap <gean.marroquin@gmail.com>
+Date: Wed, 31 Jul 2024 07:43:10 -0500
+Subject: [PATCH] implement movecenter fn
+
+---
+ config.def.h | 2 ++
+ dwl.c | 31 +++++++++++++++++++++++++++++++
+ 2 files changed, 33 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 22d2171..f5225d9 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.1f, 0.1f, 0.1f, 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)
+@@ -142,6 +143,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_x, movecenter, {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 145fd01..791e598 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -336,6 +336,8 @@ 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 _movecenter(Client *c, int interact);
++static void movecenter(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unlocksession(struct wl_listener *listener, void *data);
+@@ -2683,6 +2685,35 @@ togglefullscreen(const Arg *arg)
+ setfullscreen(sel, !sel->isfullscreen);
+ }
+
++void
++_movecenter(Client *c, int interact)
++{
++ struct wlr_box b;
++
++ if (!c || !c->mon) {
++ return;
++ }
++
++ if (!c->isfloating) {
++ return;
++ }
++
++ b = respect_monitor_reserved_area ? c->mon->w : c->mon->m;
++ resize(c, (struct wlr_box){
++ .x = (b.width - c->geom.width) / 2 + b.x,
++ .y = (b.height - c->geom.height) / 2 + b.y,
++ .width = c->geom.width,
++ .height = c->geom.height,
++ }, interact);
++}
++
++void
++movecenter(const Arg *arg)
++{
++ Client *c = focustop(selmon);
++ _movecenter(c, 1);
++}
++
+ void
+ toggletag(const Arg *arg)
+ {
+--
+2.45.2
+