mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
2 Commits
deck
...
warpcursor
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e9c5a374f | |||
| 9c78e36a36 |
@@ -34,7 +34,6 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "[D]", deck },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -140,7 +139,6 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
{ MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
|
||||
87
deck.patch
87
deck.patch
@@ -1,87 +0,0 @@
|
||||
From d56f732d3b5bba4ea0bdf56a91d0992b0cb25bfb Mon Sep 17 00:00:00 2001
|
||||
From: anabasis <anabasis@noreply.codeberg.org>
|
||||
Date: Fri, 10 May 2024 13:45:33 -0400
|
||||
Subject: [PATCH] add deck layout
|
||||
|
||||
---
|
||||
config.def.h | 2 ++
|
||||
dwl.c | 36 ++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 38 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 8f498d2..9238da0 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -33,6 +33,7 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "[D]", deck },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -134,6 +135,7 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
|
||||
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
|
||||
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
|
||||
+ { MODKEY, XKB_KEY_r, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index bf763df..1a7ce8e 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -267,6 +267,7 @@ static void createpointerconstraint(struct wl_listener *listener, void *data);
|
||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void cursorwarptohint(void);
|
||||
+static void deck(Monitor *m);
|
||||
static void destroydecoration(struct wl_listener *listener, void *data);
|
||||
static void destroydragicon(struct wl_listener *listener, void *data);
|
||||
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
|
||||
@@ -1080,6 +1081,41 @@ cursorwarptohint(void)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+deck(Monitor *m)
|
||||
+{
|
||||
+ unsigned int mw, my;
|
||||
+ int i, n = 0;
|
||||
+ Client *c;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
+ n++;
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (n > m->nmaster)
|
||||
+ mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0;
|
||||
+ else
|
||||
+ mw = m->w.width;
|
||||
+ i = my = 0;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
+ continue;
|
||||
+ if (i < m->nmaster) {
|
||||
+ resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
+ .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
+ my += c->geom.height;
|
||||
+ } else {
|
||||
+ resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y,
|
||||
+ .width = m->w.width - mw, .height = m->w.height}, 0);
|
||||
+ if (c == focustop(m))
|
||||
+ wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
destroydecoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
--
|
||||
2.45.0
|
||||
|
||||
64
dwl.c
64
dwl.c
@@ -271,7 +271,6 @@ static void createpopup(struct wl_listener *listener, void *data);
|
||||
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
||||
static void cursorframe(struct wl_listener *listener, void *data);
|
||||
static void cursorwarptohint(void);
|
||||
static void deck(Monitor *m);
|
||||
static void destroydecoration(struct wl_listener *listener, void *data);
|
||||
static void destroydragicon(struct wl_listener *listener, void *data);
|
||||
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
|
||||
@@ -348,6 +347,7 @@ static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||
static void virtualpointer(struct wl_listener *listener, void *data);
|
||||
static void warpcursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
@@ -541,6 +541,7 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
warpcursor(focustop(selmon));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1235,42 +1236,6 @@ cursorwarptohint(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
deck(Monitor *m)
|
||||
{
|
||||
unsigned int mw, my;
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
n++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n > m->nmaster)
|
||||
mw = m->nmaster ? round(m->w.width * m->mfact) : 0;
|
||||
else
|
||||
mw = m->w.width;
|
||||
i = my = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
my += c->geom.height;
|
||||
} else {
|
||||
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y,
|
||||
.width = m->w.width - mw, .height = m->w.height}, 0);
|
||||
snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "%d", n-1);
|
||||
if (c == focustop(m))
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
destroydecoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -1444,6 +1409,10 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
/* Warp cursor to center of client if it is outside */
|
||||
if (lift)
|
||||
warpcursor(c);
|
||||
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@@ -3036,6 +3005,27 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
||||
}
|
||||
|
||||
void
|
||||
warpcursor(const Client *c) {
|
||||
if (cursor_mode != CurNormal) {
|
||||
return;
|
||||
}
|
||||
if (!c && selmon) {
|
||||
wlr_cursor_warp_closest(cursor,
|
||||
NULL,
|
||||
selmon->w.x + selmon->w.width / 2.0 ,
|
||||
selmon->w.y + selmon->w.height / 2.0);
|
||||
}
|
||||
else if ( c && (cursor->x < c->geom.x ||
|
||||
cursor->x > c->geom.x + c->geom.width ||
|
||||
cursor->y < c->geom.y ||
|
||||
cursor->y > c->geom.y + c->geom.height))
|
||||
wlr_cursor_warp_closest(cursor,
|
||||
NULL,
|
||||
c->geom.x + c->geom.width / 2.0,
|
||||
c->geom.y + c->geom.height / 2.0);
|
||||
}
|
||||
|
||||
Monitor *
|
||||
xytomon(double x, double y)
|
||||
{
|
||||
|
||||
71
warpcursor.patch
Normal file
71
warpcursor.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
From 4951ccc89dac2b557994b2f6c3aacb2398e2d1b1 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Thu, 4 Jan 2024 20:30:01 +1000
|
||||
Subject: [PATCH] warpcursor
|
||||
|
||||
---
|
||||
dwl.c | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 145fd018..f7ad6c13 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -347,6 +347,7 @@ static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||
static void virtualpointer(struct wl_listener *listener, void *data);
|
||||
+static void warpcursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
@@ -514,6 +515,7 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
+ warpcursor(focustop(selmon));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1323,6 +1325,10 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
+ /* Warp cursor to center of client if it is outside */
|
||||
+ if (lift)
|
||||
+ warpcursor(c);
|
||||
+
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@@ -2927,6 +2933,27 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
|
||||
}
|
||||
|
||||
+void
|
||||
+warpcursor(const Client *c) {
|
||||
+ if (cursor_mode != CurNormal) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!c && selmon) {
|
||||
+ wlr_cursor_warp_closest(cursor,
|
||||
+ NULL,
|
||||
+ selmon->w.x + selmon->w.width / 2.0 ,
|
||||
+ selmon->w.y + selmon->w.height / 2.0);
|
||||
+ }
|
||||
+ else if ( c && (cursor->x < c->geom.x ||
|
||||
+ cursor->x > c->geom.x + c->geom.width ||
|
||||
+ cursor->y < c->geom.y ||
|
||||
+ cursor->y > c->geom.y + c->geom.height))
|
||||
+ wlr_cursor_warp_closest(cursor,
|
||||
+ NULL,
|
||||
+ c->geom.x + c->geom.width / 2.0,
|
||||
+ c->geom.y + c->geom.height / 2.0);
|
||||
+}
|
||||
+
|
||||
Monitor *
|
||||
xytomon(double x, double y)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
||||
Reference in New Issue
Block a user