diff --git a/patches/animation/README.md b/patches/animation/README.md index 8273535..cee47d8 100644 --- a/patches/animation/README.md +++ b/patches/animation/README.md @@ -4,7 +4,7 @@ Add simple animation support with a [cubic-bezier](https://en.wikipedia.org/wiki ### Download - [git branch](/pi66/dwl-patches/src/branch/animation) - [animation-0.9.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-0.9.patch) -- [animation-d29259c.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-d29259c.patch) +- [animation-e203845.patch](/dwl/dwl-patches/raw/branch/main/patches/animation/animation-e203845.patch) ### Authors - [Pi66](https://codeberg.org/pi66) diff --git a/patches/animation/animation-0.9.patch b/patches/animation/animation-0.9.patch index db4f083..5f35d99 100644 --- a/patches/animation/animation-0.9.patch +++ b/patches/animation/animation-0.9.patch @@ -1,13 +1,41 @@ -From 63675bf00dc9570424317f2ea87371d753ff5fae Mon Sep 17 00:00:00 2001 +From 302ace232def0685dfccefe5d48570996263619d Mon Sep 17 00:00:00 2001 From: pi66 -Date: Mon, 28 Sep 2026 18:03:22 +0100 -Subject: [PATCH] add: zoom and bezier animation support +Date: Wed, 30 Sep 2026 00:05:37 +0100 +Subject: [PATCH] fix: animation glitches and zoom logic --- + client.h | 9 +-- config.def.h | 4 ++ - dwl.c | 127 +++++++++++++++++++++++++++++++++++++++++++++------ - 2 files changed, 117 insertions(+), 14 deletions(-) + dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++------- + 3 files changed, 144 insertions(+), 24 deletions(-) +diff --git a/client.h b/client.h +index dc0615e..9300417 100644 +--- a/client.h ++++ b/client.h +@@ -365,7 +365,7 @@ client_set_scale(struct wlr_surface *s, float scale) + wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale)); + } + +-static inline void ++static inline uint32_t + client_set_size(Client *c, uint32_t width, uint32_t height) + { + #ifdef XWAYLAND +@@ -375,9 +375,10 @@ client_set_size(Client *c, uint32_t width, uint32_t height) + return; + } + #endif +- if ((int32_t)width != c->surface.xdg->toplevel->current.width +- || (int32_t)height != c->surface.xdg->toplevel->current.height) +- wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height); ++ if ((int32_t)width == c->surface.xdg->toplevel->current.width ++ && (int32_t)height == c->surface.xdg->toplevel->current.height) ++ return 0; ++ return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height); + } + + static inline void diff --git a/config.def.h b/config.def.h index 13c5322..b0c17e8 100644 --- a/config.def.h @@ -24,19 +52,26 @@ index 13c5322..b0c17e8 100644 #define TAGCOUNT (9) diff --git a/dwl.c b/dwl.c -index 4cfd0fd..c2276bb 100644 +index 4cfd0fd..81f157d 100644 --- a/dwl.c +++ b/dwl.c -@@ -159,6 +159,12 @@ typedef struct { +@@ -86,6 +86,7 @@ + #define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0) + + /* enums */ ++enum { CliNormal, CliClosing, CliOpening }; /* client events */ + enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ + enum { XDGShell, LayerShell, X11 }; /* client types */ + enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay, +@@ -159,6 +160,11 @@ typedef struct { unsigned int bw; uint32_t tags; int isfloating, isurgent, isfullscreen; + + /* Animation */ + struct wlr_box anim_from, anim_to, anim_cur; -+ uint32_t anim_start; -+ int animating; -+ int anim_zoom; ++ uint32_t anim_start, serial; ++ int animating, status; } Client; typedef struct { @@ -59,7 +94,7 @@ index 4cfd0fd..c2276bb 100644 static pid_t child_pid = -1; static int locked; static void *exclusive_focus; -@@ -485,6 +496,87 @@ static struct wlr_xwayland *xwayland; +@@ -485,6 +496,86 @@ static struct wlr_xwayland *xwayland; #include "ime.h" /* function implementations */ @@ -105,7 +140,6 @@ index 4cfd0fd..c2276bb 100644 + if (t >= 1) { + t = 1; + c->animating = 0; -+ c->anim_zoom = 0; + } + p = animation_bezier(t); + c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p); @@ -147,7 +181,33 @@ index 4cfd0fd..c2276bb 100644 void applybounds(Client *c, struct wlr_box *bbox) { -@@ -2365,7 +2457,6 @@ void +@@ -1873,6 +1964,7 @@ mapnotify(struct wl_listener *listener, void *data) + .title = client_get_title(c), + }; + ++ c->status = CliOpening; + /* Create scene tree for this client and its border */ + c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); + /* Enabled later by a call to arrange() */ +@@ -2322,12 +2414,17 @@ rendermon(struct wl_listener *listener, void *data) + * generally at the output's refresh rate (e.g. 60Hz). */ + Monitor *m = wl_container_of(listener, m, frame); + struct timespec now; ++ Client *c; + + if (!wlr_scene_output_needs_frame(m->scene_output)) { + return; + } ++ wl_list_for_each(c, &clients, link) ++ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c)) ++ goto skip; + + wlr_scene_output_commit(m->scene_output, NULL); ++skip: + clock_gettime(CLOCK_MONOTONIC, &now); + wlr_scene_output_send_frame_done(m->scene_output, &now); + } +@@ -2365,7 +2462,6 @@ void resize(Client *c, struct wlr_box geo, int interact) { struct wlr_box *bbox; @@ -155,11 +215,11 @@ index 4cfd0fd..c2276bb 100644 if (!c->mon || !client_surface(c)->mapped) return; -@@ -2375,21 +2466,28 @@ resize(Client *c, struct wlr_box geo, int interact) +@@ -2375,21 +2471,27 @@ resize(Client *c, struct wlr_box geo, int interact) client_set_bounds(c, geo.width, geo.height); c->geom = geo; applybounds(c, bbox); -+ client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); ++ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); - /* Update scene-graph, including borders */ - wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); @@ -186,7 +246,6 @@ index 4cfd0fd..c2276bb 100644 + c->anim_cur.height = c->geom.height / 2; + c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2; + c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2; -+ c->anim_zoom = 1; + } + + c->anim_from = c->anim_cur; @@ -197,7 +256,7 @@ index 4cfd0fd..c2276bb 100644 } void -@@ -2615,6 +2713,7 @@ setup(void) +@@ -2615,6 +2717,7 @@ setup(void) * clients from the Unix socket, managing Wayland globals, and so on. */ dpy = wl_display_create(); event_loop = wl_display_get_event_loop(dpy); @@ -205,6 +264,44 @@ index 4cfd0fd..c2276bb 100644 /* The backend is a wlroots feature which abstracts the underlying input and * output hardware. The autocreate option will choose the most suitable +@@ -2896,19 +2999,31 @@ tile(Monitor *m) + mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + else + mw = m->w.width; ++ + i = my = ty = 0; + wl_list_for_each(c, &clients, link) { ++ struct wlr_box geo; ++ + 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; ++ geo = (struct wlr_box){m->w.x, m->w.y + my, mw, ++ (m->w.height - my) / (MIN(n, m->nmaster) - i)}; ++ my += geo.height; + } else { +- resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, +- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0); +- ty += c->geom.height; ++ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw, ++ (m->w.height - ty) / (n - i)}; ++ ty += geo.height; ++ } ++ ++ if (c->status == CliOpening) { ++ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4, ++ geo.width / 2, geo.height / 2}; ++ c->anim_from = c->anim_cur; ++ c->status = CliNormal; + } ++ resize(c, geo, 0); + i++; + } + } -- 2.55.0 diff --git a/patches/animation/animation-d29259c.patch b/patches/animation/animation-e203845.patch similarity index 59% rename from patches/animation/animation-d29259c.patch rename to patches/animation/animation-e203845.patch index 8732cdd..c6e2c0b 100644 --- a/patches/animation/animation-d29259c.patch +++ b/patches/animation/animation-e203845.patch @@ -1,13 +1,41 @@ -From 91ca9657e49f501f2765eb2afa01785bbe88a2c2 Mon Sep 17 00:00:00 2001 +From e8f65d36d788cfb0a02984ecaf979d639388913c Mon Sep 17 00:00:00 2001 From: pi66 -Date: Mon, 28 Sep 2026 18:10:19 +0100 -Subject: [PATCH] add: zoom and bezier animation support +Date: Wed, 30 Sep 2026 00:03:31 +0100 +Subject: [PATCH] fix: animation glitches and zoom logic --- + client.h | 9 +-- config.def.h | 4 ++ - dwl.c | 127 +++++++++++++++++++++++++++++++++++++++++++++------ - 2 files changed, 117 insertions(+), 14 deletions(-) + dwl.c | 155 ++++++++++++++++++++++++++++++++++++++++++++------- + 3 files changed, 144 insertions(+), 24 deletions(-) +diff --git a/client.h b/client.h +index eb1bb47..a271446 100644 +--- a/client.h ++++ b/client.h +@@ -366,7 +366,7 @@ client_set_scale(struct wlr_surface *s, float scale) + wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale)); + } + +-static inline void ++static inline uint32_t + client_set_size(Client *c, uint32_t width, uint32_t height) + { + #ifdef XWAYLAND +@@ -376,9 +376,10 @@ client_set_size(Client *c, uint32_t width, uint32_t height) + return; + } + #endif +- if ((int32_t)width != c->surface.xdg->toplevel->current.width +- || (int32_t)height != c->surface.xdg->toplevel->current.height) +- wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height); ++ if ((int32_t)width == c->surface.xdg->toplevel->current.width ++ && (int32_t)height == c->surface.xdg->toplevel->current.height) ++ return 0; ++ return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height); + } + + static inline void diff --git a/config.def.h b/config.def.h index a4019d3..d37aa10 100644 --- a/config.def.h @@ -24,19 +52,26 @@ index a4019d3..d37aa10 100644 #define TAGCOUNT (9) diff --git a/dwl.c b/dwl.c -index e07a269..570f862 100644 +index 216deb5..50e1687 100644 --- a/dwl.c +++ b/dwl.c -@@ -159,6 +159,12 @@ typedef struct { +@@ -86,6 +86,7 @@ + #define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0) + + /* enums */ ++enum { CliNormal, CliClosing, CliOpening }; /* client events */ + enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ + enum { XDGShell, LayerShell, X11 }; /* client types */ + enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrUnmanaged, LyrOverlay, +@@ -159,6 +160,11 @@ typedef struct { unsigned int bw; uint32_t tags; int isfloating, isurgent, isfullscreen; + + /* Animation */ + struct wlr_box anim_from, anim_to, anim_cur; -+ uint32_t anim_start; -+ int animating; -+ int anim_zoom; ++ uint32_t anim_start, serial; ++ int animating, status; } Client; typedef struct { @@ -59,7 +94,7 @@ index e07a269..570f862 100644 static pid_t child_pid = -1; static int locked; static Client *focused_client; -@@ -486,6 +497,87 @@ static struct wlr_xwayland *xwayland; +@@ -486,6 +497,86 @@ static struct wlr_xwayland *xwayland; #include "ime.h" /* function implementations */ @@ -105,7 +140,6 @@ index e07a269..570f862 100644 + if (t >= 1) { + t = 1; + c->animating = 0; -+ c->anim_zoom = 0; + } + p = animation_bezier(t); + c->anim_cur.x = (int)(c->anim_from.x + (c->anim_to.x - c->anim_from.x) * p); @@ -147,7 +181,33 @@ index e07a269..570f862 100644 void applybounds(Client *c, struct wlr_box *bbox) { -@@ -2378,7 +2470,6 @@ void +@@ -1887,6 +1978,7 @@ mapnotify(struct wl_listener *listener, void *data) + .title = client_get_title(c), + }; + ++ c->status = CliOpening; + /* Create scene tree for this client and its border */ + c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]); + /* Enabled later by a call to arrange() */ +@@ -2340,12 +2432,17 @@ rendermon(struct wl_listener *listener, void *data) + * generally at the output's refresh rate (e.g. 60Hz). */ + Monitor *m = wl_container_of(listener, m, frame); + struct timespec now; ++ Client *c; + + if (!wlr_scene_output_needs_frame(m->scene_output)) { + return; + } ++ wl_list_for_each(c, &clients, link) ++ if (c->serial && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c)) ++ goto skip; + + wlr_scene_output_commit(m->scene_output, NULL); ++skip: + clock_gettime(CLOCK_MONOTONIC, &now); + wlr_scene_output_send_frame_done(m->scene_output, &now); + } +@@ -2383,7 +2480,6 @@ void resize(Client *c, struct wlr_box geo, int interact) { struct wlr_box *bbox; @@ -155,11 +215,11 @@ index e07a269..570f862 100644 if (!c->mon || !client_surface(c)->mapped) return; -@@ -2388,21 +2479,28 @@ resize(Client *c, struct wlr_box geo, int interact) +@@ -2393,21 +2489,27 @@ resize(Client *c, struct wlr_box geo, int interact) client_set_bounds(c, geo.width, geo.height); c->geom = geo; applybounds(c, bbox); -+ client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); ++ c->serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); - /* Update scene-graph, including borders */ - wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y); @@ -186,7 +246,6 @@ index e07a269..570f862 100644 + c->anim_cur.height = c->geom.height / 2; + c->anim_cur.x = c->geom.x + (c->geom.width - c->anim_cur.width) / 2; + c->anim_cur.y = c->geom.y + (c->geom.height - c->anim_cur.height) / 2; -+ c->anim_zoom = 1; + } + + c->anim_from = c->anim_cur; @@ -197,7 +256,7 @@ index e07a269..570f862 100644 } void -@@ -2628,6 +2726,7 @@ setup(void) +@@ -2633,6 +2735,7 @@ setup(void) * clients from the Unix socket, managing Wayland globals, and so on. */ dpy = wl_display_create(); event_loop = wl_display_get_event_loop(dpy); @@ -205,6 +264,44 @@ index e07a269..570f862 100644 /* The backend is a wlroots feature which abstracts the underlying input and * output hardware. The autocreate option will choose the most suitable +@@ -2914,19 +3017,31 @@ tile(Monitor *m) + mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0; + else + mw = m->w.width; ++ + i = my = ty = 0; + wl_list_for_each(c, &clients, link) { ++ struct wlr_box geo; ++ + 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; ++ geo = (struct wlr_box){m->w.x, m->w.y + my, mw, ++ (m->w.height - my) / (MIN(n, m->nmaster) - i)}; ++ my += geo.height; + } else { +- resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty, +- .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0); +- ty += c->geom.height; ++ geo = (struct wlr_box){m->w.x + mw, m->w.y + ty, m->w.width - mw, ++ (m->w.height - ty) / (n - i)}; ++ ty += geo.height; ++ } ++ ++ if (c->status == CliOpening) { ++ c->anim_cur = (struct wlr_box){geo.x + geo.width / 4, geo.y + geo.height / 4, ++ geo.width / 2, geo.height / 2}; ++ c->anim_from = c->anim_cur; ++ c->status = CliNormal; + } ++ resize(c, geo, 0); + i++; + } + } -- 2.55.0