summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0scar <qgt268@alumni.ku.dk>2023-03-01 10:43:12 +0000
committer0scar <qgt268@alumni.ku.dk>2024-10-01 11:53:32 +0000
commite6b0bc835fdc3eecc6ca8c78f852be17ed106d4a (patch)
treecee685598e7d928f0c7d2137cdc88dececb33f0d
parent7fa3c98f91c4eb44ac9bf79136d119eb64874be4 (diff)
Patch: center
Source: https://github.com/djpohly/dwl/compare/main...dm1tz:04-center.patch
-rw-r--r--config.def.h12
-rw-r--r--dwl.c10
2 files changed, 15 insertions, 7 deletions
diff --git a/config.def.h b/config.def.h
index 6489de3..3a1d088 100644
--- a/config.def.h
+++ b/config.def.h
@@ -29,13 +29,13 @@ 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) */
#define TAG(t) (1 << (t - 1))
static const Rule rules[] = {
- /* app_id title tags mask isfloating isterm noswallow monitor scratchkey */
+ /* app_id title tags mask iscentered isfloating isterm noswallow monitor scratchkey */
/* examples: */
- { "Gimp", NULL, TAG(9), 1, 0, 0, -1, 0 }, /* Start on currently visible tags floating, not tiled */
- { "firefox", NULL, TAG(2), 0, 0, 0, -1, 0 }, /* Start on ONLY tag "9" */
- { TERMINAL, NULL, 0, 0, 1, 1, -1, 0 }, /* Start on ONLY tag "9" */
- { NULL, "scratchpad", 0, 1, 1, 1, -1, 's' }, /* Used for terminal scratchpad */
- { NULL, "spadcalc", 0, 1, 1, 0, -1, 'c' }, /* Used for terminal scratchpad */
+ { "Gimp", NULL, TAG(9), 0, 1, 0, 0, -1, 0 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox", NULL, TAG(2), 0, 0, 0, 0, -1, 0 }, /* Start on ONLY tag "9" */
+ { TERMINAL, NULL, 0, 0, 0, 1, 1, -1, 0 }, /* Start on ONLY tag "9" */
+ { NULL, "scratchpad", 0, 1, 1, 1, 1, -1, 's' }, /* Used for terminal scratchpad */
+ { NULL, "spadcalc", 0, 1, 1, 1, 0, -1, 'c' }, /* Used for terminal scratchpad */
};
#undef TAG
diff --git a/dwl.c b/dwl.c
index 0e07ac4..74840e4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -143,7 +143,7 @@ struct Client {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen, issticky, isterm, noswallow;
+ int iscentered, isfloating, isurgent, isfullscreen, issticky, isterm, noswallow;
char scratchkey;
uint32_t resize; /* configure serial of a pending resize */
pid_t pid;
@@ -236,6 +236,7 @@ typedef struct {
const char *id;
const char *title;
uint32_t tags;
+ int iscentered;
int isfloating;
int isterm;
int noswallow;
@@ -490,6 +491,7 @@ applyrules(Client *c)
for (r = rules; r < END(rules); r++) {
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
+ c->iscentered = r->iscentered;
c->isfloating = r->isfloating;
c->scratchkey = r->scratchkey;
c->isterm = r->isterm;
@@ -517,6 +519,12 @@ applyrules(Client *c)
newtags = p->tags;
}
}
+
+ if (c->iscentered) {
+ c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
+ c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
+ }
+
setmon(c, mon, newtags);
}