mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-08 12:14:50 +00:00
update movecenter patch to v0.6
fix bug where not floating windows are being centered
This commit is contained in:
parent
187d7f5115
commit
b1ca929ee6
@ -1,26 +1,26 @@
|
|||||||
From f0d50d609a04cbcc1ae4d3cf27b68024f256207c Mon Sep 17 00:00:00 2001
|
From bc5206882c71b32198dae5f1c85601a863a7c0a9 Mon Sep 17 00:00:00 2001
|
||||||
From: wochap <gean.marroquin@gmail.com>
|
From: wochap <gean.marroquin@gmail.com>
|
||||||
Date: Tue, 5 Mar 2024 23:39:01 -0500
|
Date: Wed, 31 Jul 2024 07:43:10 -0500
|
||||||
Subject: [PATCH] implement keybinding to center focused windows
|
Subject: [PATCH] implement movecenter fn
|
||||||
|
|
||||||
---
|
---
|
||||||
config.def.h | 2 ++
|
config.def.h | 2 ++
|
||||||
dwl.c | 23 +++++++++++++++++++++++
|
dwl.c | 31 +++++++++++++++++++++++++++++++
|
||||||
2 files changed, 25 insertions(+)
|
2 files changed, 33 insertions(+)
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
diff --git a/config.def.h b/config.def.h
|
||||||
index db0babc..71b01ab 100644
|
index 22d2171..f5225d9 100644
|
||||||
--- a/config.def.h
|
--- a/config.def.h
|
||||||
+++ b/config.def.h
|
+++ b/config.def.h
|
||||||
@@ -12,6 +12,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
@@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
||||||
static const float urgentcolor[] = COLOR(0xff0000ff);
|
static const float urgentcolor[] = COLOR(0xff0000ff);
|
||||||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
/* This conforms to 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 */
|
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
|
||||||
+static const int center_relative_to_monitor = 0; /* 0 means center floating relative to the window area */
|
+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 */
|
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||||
#define TAGCOUNT (9)
|
#define TAGCOUNT (9)
|
||||||
@@ -135,6 +136,7 @@ static const Key keys[] = {
|
@@ -142,6 +143,7 @@ static const Key keys[] = {
|
||||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||||
@ -29,45 +29,54 @@ index db0babc..71b01ab 100644
|
|||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
diff --git a/dwl.c b/dwl.c
|
diff --git a/dwl.c b/dwl.c
|
||||||
index ef27a1d..fb39d13 100644
|
index 145fd01..791e598 100644
|
||||||
--- a/dwl.c
|
--- a/dwl.c
|
||||||
+++ b/dwl.c
|
+++ b/dwl.c
|
||||||
@@ -313,6 +313,7 @@ static void tagmon(const Arg *arg);
|
@@ -336,6 +336,8 @@ static void tagmon(const Arg *arg);
|
||||||
static void tile(Monitor *m);
|
static void tile(Monitor *m);
|
||||||
static void togglefloating(const Arg *arg);
|
static void togglefloating(const Arg *arg);
|
||||||
static void togglefullscreen(const Arg *arg);
|
static void togglefullscreen(const Arg *arg);
|
||||||
|
+static void _movecenter(Client *c, int interact);
|
||||||
+static void movecenter(const Arg *arg);
|
+static void movecenter(const Arg *arg);
|
||||||
static void toggletag(const Arg *arg);
|
static void toggletag(const Arg *arg);
|
||||||
static void toggleview(const Arg *arg);
|
static void toggleview(const Arg *arg);
|
||||||
static void unlocksession(struct wl_listener *listener, void *data);
|
static void unlocksession(struct wl_listener *listener, void *data);
|
||||||
@@ -2454,6 +2455,28 @@ togglefullscreen(const Arg *arg)
|
@@ -2683,6 +2685,35 @@ togglefullscreen(const Arg *arg)
|
||||||
setfullscreen(sel, !sel->isfullscreen);
|
setfullscreen(sel, !sel->isfullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
+void
|
+void
|
||||||
+movecenter(const Arg *arg)
|
+_movecenter(Client *c, int interact)
|
||||||
+{
|
+{
|
||||||
+ Client *c = focustop(selmon);
|
+ struct wlr_box b;
|
||||||
+ Monitor *m = selmon;
|
|
||||||
+
|
+
|
||||||
+ if (!m) {
|
+ if (!c || !c->mon) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (c) {
|
+ if (!c->isfloating) {
|
||||||
+ // const int center_relative_to_monitor = arg->i;
|
+ return;
|
||||||
+ struct wlr_box b = center_relative_to_monitor ? m->m : m->w;
|
|
||||||
+ 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,
|
|
||||||
+ }, 1);
|
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ 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
|
void
|
||||||
toggletag(const Arg *arg)
|
toggletag(const Arg *arg)
|
||||||
{
|
{
|
||||||
--
|
--
|
||||||
2.42.0
|
2.45.2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user