mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-10 05:04:51 +00:00
reintroduce customfloat
This commit is contained in:
parent
bfb6f8392b
commit
2fe0d17761
@ -1,26 +0,0 @@
|
|||||||
### Description
|
|
||||||
Rules for floating windows support default x, y, width, height. Defaults to the center of the screen and the client size.
|
|
||||||
|
|
||||||
### Changelog
|
|
||||||
|
|
||||||
2023-09-11:
|
|
||||||
- Rewrite the patch so that it works with the latest dwl
|
|
||||||
- If the width or height is less than or equal to 1, then the value will be interpreted as a percentage. For example, 0.5 represents 50%, 0.25 represents 25%, and 1 represents 100%. **NOTE**: Some clients, like Thunar, have minimum width/height
|
|
||||||
- A variable `center_relative_to_monitor` has been added, allowing 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:customfloat.patch)
|
|
||||||
- [2020-09-02](https://github.com/djpohly/dwl/compare/main...Stivvo:customFloat.patch)
|
|
||||||
|
|
||||||
### Authors
|
|
||||||
- [Stivvo](https://github.com/Stivvo)
|
|
||||||
- [wochap](https://github.com/wochap)
|
|
77
customfloat/customfloat.patch
Normal file
77
customfloat/customfloat.patch
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
From c02452204c40663f9a7094e59efa12131555fbc6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: wochap <gean.marroquin@gmail.com>
|
||||||
|
Date: Wed, 6 Mar 2024 00:02:35 -0500
|
||||||
|
Subject: [PATCH] apply Stivvo customfloat patch
|
||||||
|
|
||||||
|
source: https://github.com/djpohly/dwl/wiki/customfloat
|
||||||
|
rewrite so it works with latest dwl
|
||||||
|
if width or height is less than or equal to 1, then the value will be taken as a percentage value, e.g. 0.5 is 50%, 0.25 is 25%, 1 is 100%
|
||||||
|
**NOTE**, some clients such as Thunar, have a minimal width/height
|
||||||
|
---
|
||||||
|
config.def.h | 7 ++++---
|
||||||
|
dwl.c | 16 ++++++++++++++++
|
||||||
|
2 files changed, 20 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index db0babc..05de8ee 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)
|
||||||
|
@@ -20,11 +21,11 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can al
|
||||||
|
static int log_level = WLR_ERROR;
|
||||||
|
|
||||||
|
static const Rule rules[] = {
|
||||||
|
- /* app_id title tags mask isfloating monitor */
|
||||||
|
+ /* app_id title tags mask isfloating monitor x y width height */
|
||||||
|
/* examples:
|
||||||
|
- { "Gimp", NULL, 0, 1, -1 },
|
||||||
|
+ { "Gimp", NULL, 0, 1, -1, 0, 0, 1000, 0.75 },
|
||||||
|
*/
|
||||||
|
- { "firefox", NULL, 1 << 8, 0, -1 },
|
||||||
|
+ { "firefox", NULL, 1 << 8, 0, -1, 0, 0, 0, 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layout(s) */
|
||||||
|
diff --git a/dwl.c b/dwl.c
|
||||||
|
index ef27a1d..bbb3740 100644
|
||||||
|
--- a/dwl.c
|
||||||
|
+++ b/dwl.c
|
||||||
|
@@ -215,6 +215,10 @@ typedef struct {
|
||||||
|
uint32_t tags;
|
||||||
|
int isfloating;
|
||||||
|
int monitor;
|
||||||
|
+ int x;
|
||||||
|
+ int y;
|
||||||
|
+ float w;
|
||||||
|
+ float h;
|
||||||
|
} Rule;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
@@ -438,6 +442,18 @@ applyrules(Client *c)
|
||||||
|
wl_list_for_each(m, &mons, link)
|
||||||
|
if (r->monitor == i++)
|
||||||
|
mon = m;
|
||||||
|
+ if (c->isfloating) {
|
||||||
|
+ struct wlr_box b = center_relative_to_monitor ? mon->m : mon->w;
|
||||||
|
+ float newwidth = r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width;
|
||||||
|
+ float newheight = r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height;
|
||||||
|
+
|
||||||
|
+ resize(c, (struct wlr_box){
|
||||||
|
+ .x = r->x ? r->x + b.x : (b.width - newwidth) / 2 + b.x,
|
||||||
|
+ .y = r->y ? r->y + b.y : (b.height - newheight) / 2 + b.y,
|
||||||
|
+ .width = newwidth,
|
||||||
|
+ .height = newheight,
|
||||||
|
+ }, 1);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wlr_scene_node_reparent(&c->scene->node, layers[c->isfloating ? LyrFloat : LyrTile]);
|
||||||
|
--
|
||||||
|
2.42.0
|
Loading…
x
Reference in New Issue
Block a user