sync wochap patches with latest dwl

This commit is contained in:
wochap
2024-07-09 10:56:43 -05:00
parent 14928cda03
commit ff57f0b2e7
4 changed files with 96 additions and 110 deletions
+44 -28
View File
@@ -1,33 +1,28 @@
From ff29aba2f45d5acdee66efaf7cf94ab66145c0ed Mon Sep 17 00:00:00 2001
From 4f19f5499610d56f2616da5d44039403ac9d4c06 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Thu, 11 Apr 2024 14:19:24 -0500
Subject: [PATCH] rules for floating windows support default x, y, width,
height 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
Date: Tue, 9 Jul 2024 10:52:37 -0500
Subject: [PATCH] implement customfloat and generate patches
`floating_relative_to_monitor` allows the user to choose whether to position relative to the monitor or relative to the window area.
---
config.def.h | 7 ++++---
dwl.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
dwl.c | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8847e58..ebaf1ab 100644
index 22d2171..dee53f4 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 floating_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 */
#define TAGCOUNT (9)
@@ -21,10 +22,10 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
@@ -22,10 +23,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor x y width height */
@@ -40,10 +35,10 @@ index 8847e58..ebaf1ab 100644
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index bf763df..94e4d7d 100644
index dc0437e..be0340f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -228,6 +228,10 @@ typedef struct {
@@ -230,6 +230,10 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
@@ -54,24 +49,45 @@ index bf763df..94e4d7d 100644
} Rule;
typedef struct {
@@ -468,6 +472,18 @@ applyrules(Client *c)
@@ -454,6 +458,11 @@ applyrules(Client *c)
int i;
const Rule *r;
Monitor *mon = selmon, *m;
+ int newwidth;
+ int newheight;
+ int newx;
+ int newy;
+ int apply_resize = 0;
c->isfloating = client_is_float_type(c);
if (!(appid = client_get_appid(c)))
@@ -471,9 +480,27 @@ applyrules(Client *c)
if (r->monitor == i++)
mon = m;
}
+ if (c->isfloating) {
+ struct wlr_box b = floating_relative_to_monitor ? mon->m : mon->w;
+ int newwidth = ROUND(r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ int newheight = ROUND(r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ if (c->isfloating || !mon->lt[mon->sellt]->arrange) {
+ /* client is floating or in floating layout */
+ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m;
+ newwidth = (int)round(r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width);
+ newheight = (int)round(r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height);
+ newx = (int)round(r->x ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x);
+ newy = (int)round(r->y ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y);
+ apply_resize = 1;
+
+ 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);
+ }
}
}
setmon(c, mon, newtags);
+ if (apply_resize) {
+ resize(c, (struct wlr_box){
+ .x = newx,
+ .y = newy,
+ .width = newwidth,
+ .height = newheight,
+ }, 1);
+ }
}
void
--
2.43.2
2.45.1