mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
1 Commits
xwayland-h
...
bottomstac
| Author | SHA1 | Date | |
|---|---|---|---|
| 43bf716e36 |
140
bottomstack.patch
Normal file
140
bottomstack.patch
Normal file
@@ -0,0 +1,140 @@
|
||||
From b352fb08f40b1ee2d8c4748be4922df711e3aaa9 Mon Sep 17 00:00:00 2001
|
||||
From: wochap <gean.marroquin@gmail.com>
|
||||
Date: Fri, 5 Jul 2024 10:44:29 -0500
|
||||
Subject: [PATCH] implement bottomstack
|
||||
|
||||
---
|
||||
config.def.h | 4 +++
|
||||
dwl.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 88 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 22d2171..5aac3e9 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -34,6 +34,8 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
+ { "TTT", bstack },
|
||||
+ { "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -139,6 +141,8 @@ 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_u, setlayout, {.v = &layouts[3]} },
|
||||
+ { MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} },
|
||||
{ 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 dc0437e..5648d5f 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
+#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
@@ -351,6 +352,8 @@ 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);
|
||||
static void zoom(const Arg *arg);
|
||||
+static void bstack(Monitor *m);
|
||||
+static void bstackhoriz(Monitor *m);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -3160,3 +3163,84 @@ main(int argc, char *argv[])
|
||||
usage:
|
||||
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
|
||||
}
|
||||
+
|
||||
+static void
|
||||
+bstack(Monitor *m)
|
||||
+{
|
||||
+ int w, h, mh, mx, tx, ty, tw;
|
||||
+ int i, n = 0;
|
||||
+ Client *c;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating)
|
||||
+ n++;
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (n > m->nmaster) {
|
||||
+ mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
+ tw = m->w.width / (n - m->nmaster);
|
||||
+ ty = m->w.y + mh;
|
||||
+ } else {
|
||||
+ mh = m->w.height;
|
||||
+ tw = m->w.width;
|
||||
+ ty = m->w.y;
|
||||
+ }
|
||||
+
|
||||
+ i = mx = 0;
|
||||
+ tx = m-> w.x;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c, m) || c->isfloating)
|
||||
+ continue;
|
||||
+ if (i < m->nmaster) {
|
||||
+ w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
+ resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
+ mx += c->geom.width;
|
||||
+ } else {
|
||||
+ h = m->w.height - mh;
|
||||
+ resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0);
|
||||
+ if (tw != m->w.width)
|
||||
+ tx += c->geom.width;
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+bstackhoriz(Monitor *m) {
|
||||
+ int w, mh, mx, tx, ty, th;
|
||||
+ int i, n = 0;
|
||||
+ Client *c;
|
||||
+
|
||||
+ wl_list_for_each(c, &clients, link)
|
||||
+ if (VISIBLEON(c, m) && !c->isfloating)
|
||||
+ n ++;
|
||||
+ if (n == 0)
|
||||
+ return;
|
||||
+
|
||||
+ if (n > m->nmaster) {
|
||||
+ mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
+ th = (m->w.height - mh) / (n - m->nmaster);
|
||||
+ ty = m->w.y + mh;
|
||||
+ } else {
|
||||
+ th = mh = m->w.height;
|
||||
+ ty = m->w.y;
|
||||
+ }
|
||||
+
|
||||
+ i = mx = 0;
|
||||
+ tx = m-> w.x;
|
||||
+ wl_list_for_each(c, &clients, link) {
|
||||
+ if (!VISIBLEON(c,m) || c->isfloating)
|
||||
+ continue;
|
||||
+ if (i < m->nmaster) {
|
||||
+ w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
+ resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
+ mx += c->geom.width;
|
||||
+ } else {
|
||||
+ resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0);
|
||||
+ if (th != m->w.height)
|
||||
+ ty += c->geom.height;
|
||||
+ }
|
||||
+ i++;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.45.1
|
||||
9
client.h
9
client.h
@@ -94,12 +94,9 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
struct wlr_xwayland_surface *surface;
|
||||
if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
if (activated && surface->minimized)
|
||||
wlr_xwayland_surface_set_minimized(surface, false);
|
||||
|
||||
wlr_xwayland_surface_activate(surface, activated);
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
wlr_xwayland_surface_activate(xsurface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -34,6 +34,8 @@ static const Layout layouts[] = {
|
||||
{ "[]=", tile },
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
{ "TTT", bstack },
|
||||
{ "===", bstackhoriz },
|
||||
};
|
||||
|
||||
/* monitors */
|
||||
@@ -139,6 +141,8 @@ 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_u, setlayout, {.v = &layouts[3]} },
|
||||
{ MODKEY, XKB_KEY_o, setlayout, {.v = &layouts[4]} },
|
||||
{ MODKEY, XKB_KEY_space, setlayout, {0} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
|
||||
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
|
||||
|
||||
103
dwl.c
103
dwl.c
@@ -59,6 +59,7 @@
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
@@ -131,7 +132,6 @@ typedef struct {
|
||||
#ifdef XWAYLAND
|
||||
struct wl_listener activate;
|
||||
struct wl_listener associate;
|
||||
struct wl_listener minimize;
|
||||
struct wl_listener dissociate;
|
||||
struct wl_listener configure;
|
||||
struct wl_listener set_hints;
|
||||
@@ -352,6 +352,8 @@ 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);
|
||||
static void zoom(const Arg *arg);
|
||||
static void bstack(Monitor *m);
|
||||
static void bstackhoriz(Monitor *m);
|
||||
|
||||
/* variables */
|
||||
static pid_t child_pid = -1;
|
||||
@@ -443,7 +445,6 @@ static void associatex11(struct wl_listener *listener, void *data);
|
||||
static void configurex11(struct wl_listener *listener, void *data);
|
||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||
static void minimizenotify(struct wl_listener *listener, void *data);
|
||||
static void sethints(struct wl_listener *listener, void *data);
|
||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
||||
@@ -1336,7 +1337,6 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->activate.link);
|
||||
wl_list_remove(&c->associate.link);
|
||||
wl_list_remove(&c->configure.link);
|
||||
wl_list_remove(&c->minimize.link);
|
||||
wl_list_remove(&c->dissociate.link);
|
||||
wl_list_remove(&c->set_hints.link);
|
||||
} else
|
||||
@@ -3135,7 +3135,6 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||
LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||
@@ -3150,21 +3149,6 @@ dissociatex11(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->unmap.link);
|
||||
}
|
||||
|
||||
void
|
||||
minimizenotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, minimize);
|
||||
struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||
struct wlr_xwayland_minimize_event *e = data;
|
||||
int focused;
|
||||
|
||||
if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||
return;
|
||||
|
||||
focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||
wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||
}
|
||||
|
||||
void
|
||||
sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -3227,3 +3211,84 @@ main(int argc, char *argv[])
|
||||
usage:
|
||||
die("Usage: %s [-v] [-d] [-s startup command]", argv[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
bstack(Monitor *m)
|
||||
{
|
||||
int w, h, mh, mx, tx, ty, tw;
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating)
|
||||
n++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n > m->nmaster) {
|
||||
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
tw = m->w.width / (n - m->nmaster);
|
||||
ty = m->w.y + mh;
|
||||
} else {
|
||||
mh = m->w.height;
|
||||
tw = m->w.width;
|
||||
ty = m->w.y;
|
||||
}
|
||||
|
||||
i = mx = 0;
|
||||
tx = m-> w.x;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c, m) || c->isfloating)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
mx += c->geom.width;
|
||||
} else {
|
||||
h = m->w.height - mh;
|
||||
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = tw, .height = h }, 0);
|
||||
if (tw != m->w.width)
|
||||
tx += c->geom.width;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bstackhoriz(Monitor *m) {
|
||||
int w, mh, mx, tx, ty, th;
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating)
|
||||
n ++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
if (n > m->nmaster) {
|
||||
mh = (int)round(m->nmaster ? m->mfact * m->w.height : 0);
|
||||
th = (m->w.height - mh) / (n - m->nmaster);
|
||||
ty = m->w.y + mh;
|
||||
} else {
|
||||
th = mh = m->w.height;
|
||||
ty = m->w.y;
|
||||
}
|
||||
|
||||
i = mx = 0;
|
||||
tx = m-> w.x;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (!VISIBLEON(c,m) || c->isfloating)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
w = (m->w.width - mx) / (MIN(n, m->nmaster) - i);
|
||||
resize(c, (struct wlr_box) { .x = m->w.x + mx, .y = m->w.y, .width = w, .height = mh }, 0);
|
||||
mx += c->geom.width;
|
||||
} else {
|
||||
resize(c, (struct wlr_box) { .x = tx, .y = ty, .width = m->w.width, .height = th }, 0);
|
||||
if (th != m->w.height)
|
||||
ty += c->geom.height;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
From 7277f668f19f5a7fcfbbc96e80cb2829487848ca Mon Sep 17 00:00:00 2001
|
||||
From: korei999 <ju7t1xe@gmail.com>
|
||||
Date: Mon, 1 Apr 2024 15:13:11 +0300
|
||||
Subject: [PATCH] handle minimize request for xwayland clients
|
||||
|
||||
---
|
||||
client.h | 9 ++++++---
|
||||
dwl.c | 19 +++++++++++++++++++
|
||||
2 files changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/client.h b/client.h
|
||||
index 800b867..c46cfb2 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -94,9 +94,12 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
- struct wlr_xwayland_surface *xsurface;
|
||||
- if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
- wlr_xwayland_surface_activate(xsurface, activated);
|
||||
+ struct wlr_xwayland_surface *surface;
|
||||
+ if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
+ if (activated && surface->minimized)
|
||||
+ wlr_xwayland_surface_set_minimized(surface, false);
|
||||
+
|
||||
+ wlr_xwayland_surface_activate(surface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 39ce68c..b49f57b 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -131,6 +131,7 @@ typedef struct {
|
||||
#ifdef XWAYLAND
|
||||
struct wl_listener activate;
|
||||
struct wl_listener associate;
|
||||
+ struct wl_listener minimize;
|
||||
struct wl_listener dissociate;
|
||||
struct wl_listener configure;
|
||||
struct wl_listener set_hints;
|
||||
@@ -412,6 +413,7 @@ static void configurex11(struct wl_listener *listener, void *data);
|
||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||
static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
|
||||
+static void minimizenotify(struct wl_listener *listener, void *data);
|
||||
static void sethints(struct wl_listener *listener, void *data);
|
||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||
static struct wlr_xwayland *xwayland;
|
||||
@@ -1177,6 +1179,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->activate.link);
|
||||
wl_list_remove(&c->associate.link);
|
||||
wl_list_remove(&c->configure.link);
|
||||
+ wl_list_remove(&c->minimize.link);
|
||||
wl_list_remove(&c->dissociate.link);
|
||||
wl_list_remove(&c->set_hints.link);
|
||||
} else
|
||||
@@ -2984,6 +2987,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||
+ LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||
@@ -3011,6 +3015,21 @@ getatom(xcb_connection_t *xc, const char *name)
|
||||
return atom;
|
||||
}
|
||||
|
||||
+void
|
||||
+minimizenotify(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ Client *c = wl_container_of(listener, c, minimize);
|
||||
+ struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||
+ struct wlr_xwayland_minimize_event *e = data;
|
||||
+ int focused;
|
||||
+
|
||||
+ if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||
+ return;
|
||||
+
|
||||
+ focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||
+ wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||
+}
|
||||
+
|
||||
void
|
||||
sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
--
|
||||
2.44.0
|
||||
|
||||
Reference in New Issue
Block a user