Created
June 17, 2023 17:53
-
-
Save mjkloeckner/c296e05ab343bd537e85d802f5612c71 to your computer and use it in GitHub Desktop.
Allows the user to specify the position on the screen where a window should be spawned in percentage of the screen size.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit a6d41f067eb1bc64eb5d721df4d2880c457fe82a | |
Author: mjkloeckner <[email protected]> | |
Date: Sat Apr 15 21:09:02 2023 -0300 | |
flaotrules relative to monitor size | |
floatrules now accepts a new option which is `isrel` in case of being 1 | |
the floatx, floaty, floatw, floath can be specified in terms of the | |
percentage of the monitor with floating values in the range 0.00 - 1.00, | |
being 0.00: 0% and 1.00: 100%, 0.50: 50%, etc. | |
diff --git a/config.def.h b/config.def.h | |
index 9006959..fae47ca 100644 | |
--- a/config.def.h | |
+++ b/config.def.h | |
@@ -64,17 +64,17 @@ static const Rule rules[] = { | |
* WM_CLASS(STRING) = instance, class | |
* WM_NAME(STRING) = title | |
*/ | |
-/* class instance title tags mask isfloating monitor float x,y,w,h floatborderpx */ | |
- { "Gimp", NULL, NULL, 1<<6, 0, -1, 50,50,500,500, 0 }, | |
- { "scratchpad", NULL, NULL, 0, 1, -1, 80,50,1284,954, 0 }, | |
+/* class instance title tags mask isfloating monitor isrel x,y, w, h, floatborderpx */ | |
+ { "Gimp", NULL, NULL, 1<<6, 0, -1, 0, 0,0, 500, 500, 0, }, | |
+ { "scratchpad", NULL, NULL, 0, 1, -1, 1, 0,0, 0.73,0.915, 1, }, | |
}; | |
/* layout(s) */ | |
diff --git a/dwm.c b/dwm.c | |
index 23132f3..c1b98ec 100644 | |
--- a/dwm.c | |
+++ b/dwm.c | |
@@ -174,7 +174,8 @@ typedef struct { | |
unsigned int tags; | |
int isfloating; | |
int monitor; | |
- int floatx, floaty, floatw, floath; | |
+ int isrel; | |
+ float floatx, floaty, floatw, floath; | |
int floatborderpx; | |
} Rule; | |
@@ -388,10 +389,17 @@ applyrules(Client *c) | |
c->hasfloatbw = 1; | |
} | |
if (r->isfloating) { | |
- if (r->floatx >= 0) c->x = c->mon->mx + r->floatx; | |
- if (r->floaty >= 0) c->y = c->mon->my + r->floaty; | |
- if (r->floatw >= 0) c->w = r->floatw; | |
- if (r->floath >= 0) c->h = r->floath; | |
+ if (r->isrel) { | |
+ if (r->floatx >= 0) c->x = c->mon->mx + r->floatx; | |
+ if (r->floaty >= 0) c->y = c->mon->my + r->floaty; | |
+ if (r->floatw >= 0) c->w = c->mon->mw * r->floatw; | |
+ if (r->floath >= 0) c->h = c->mon->mh * r->floath; | |
+ } else { | |
+ if (r->floatx >= 0) c->x = c->mon->mx + (int)r->floatx; | |
+ if (r->floaty >= 0) c->y = c->mon->my + (int)r->floaty; | |
+ if (r->floatw >= 0) c->w = r->floatw; | |
+ if (r->floath >= 0) c->h = r->floath; | |
+ } | |
} | |
for (m = mons; m && m->num != r->monitor; m = m->next); | |
if (m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made to be applied on top of dwm floatrules patch.
Allows the user to specify the position on the screen where a window should be
spawned in percentage of the screen size.
To specify the position in percentage of the screen size you should set
isrel
to
1
in the rules array for the given application.