mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-09 12:45:00 +00:00
reintroduce movecenter
This commit is contained in:
parent
f64436c121
commit
33588e9fe4
@ -1,22 +0,0 @@
|
||||
### Description
|
||||
This patch provides a keybinding to center focused windows.
|
||||
|
||||
Press <kbd>MODKEY</kbd> + <kbd>x</kbd> to center the focused floating window.
|
||||
|
||||
It does NOT uncenter the window back to its previous location. It does not center windows that are not floating.
|
||||
|
||||
The variable `center_relative_to_monitor` allows the user to choose whether to center relative to the monitor or relative to the window area.
|
||||
|
||||
<details>
|
||||
<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="https://i.imgur.com/xhejzPh.png"/>
|
||||
</pre>
|
||||
</details>
|
||||
|
||||
### Download
|
||||
- [2023-09-11](https://github.com/djpohly/dwl/compare/main...wochap:movecenter.patch)
|
||||
|
||||
### Authors
|
||||
- [wochap](https://github.com/wochap)
|
73
movecenter/movecenter.patch
Normal file
73
movecenter/movecenter.patch
Normal file
@ -0,0 +1,73 @@
|
||||
From f0d50d609a04cbcc1ae4d3cf27b68024f256207c Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Tue, 5 Mar 2024 23:39:01 -0500
|
||||
Subject: [PATCH] implement keybinding to center focused windows
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 23 +++++++++++++++++++++++
|
||||
2 files changed, 25 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index db0babc..71b01ab 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -12,6 +12,7 @@ static const float focuscolor[] = COLOR(0x005577ff);
|
||||
static const float urgentcolor[] = COLOR(0xff0000ff);
|
||||
/* 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 */
|
||||
+static const int center_relative_to_monitor = 0; /* 0 means center floating relative to the window area */
|
||||
|
||||
/* tagging - TAGCOUNT must be no greater than 31 */
|
||||
#define TAGCOUNT (9)
|
||||
@@ -135,6 +136,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 ef27a1d..fb39d13 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -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);
|
||||
+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);
|
||||
@@ -2454,6 +2455,28 @@ togglefullscreen(const Arg *arg)
|
||||
setfullscreen(sel, !sel->isfullscreen);
|
||||
}
|
||||
|
||||
+void
|
||||
+movecenter(const Arg *arg)
|
||||
+{
|
||||
+ Client *c = focustop(selmon);
|
||||
+ Monitor *m = selmon;
|
||||
+
|
||||
+ if (!m) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (c) {
|
||||
+ // const int center_relative_to_monitor = arg->i;
|
||||
+ 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);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
toggletag(const Arg *arg)
|
||||
{
|
||||
--
|
||||
2.42.0
|
Loading…
x
Reference in New Issue
Block a user