From ff57f0b2e7c33f2a831af4b7481aa0ffc85bed72 Mon Sep 17 00:00:00 2001 From: wochap Date: Tue, 9 Jul 2024 10:56:43 -0500 Subject: [PATCH] sync wochap patches with latest dwl --- patches/cursortheme/cursortheme.patch | 41 +++++------ patches/customfloat/customfloat.patch | 72 +++++++++++-------- patches/minimalborders/minimalborders.patch | 37 +++++----- patches/swapandfocusdir/swapandfocusdir.patch | 56 +++++---------- 4 files changed, 96 insertions(+), 110 deletions(-) diff --git a/patches/cursortheme/cursortheme.patch b/patches/cursortheme/cursortheme.patch index e92ab8c..3c34222 100644 --- a/patches/cursortheme/cursortheme.patch +++ b/patches/cursortheme/cursortheme.patch @@ -1,51 +1,46 @@ -From 55c22683c88c9816ceba6351a716fbe005555abd Mon Sep 17 00:00:00 2001 +From f08376a2a04929a3907612e6c1f980ad3cdf939f Mon Sep 17 00:00:00 2001 From: wochap -Date: Thu, 11 Apr 2024 12:43:29 -0500 -Subject: [PATCH] add ability to change cursor's theme and size +Date: Fri, 5 Jul 2024 11:10:39 -0500 +Subject: [PATCH] implement cursortheme --- config.def.h | 2 ++ - dwl.c | 6 ++++-- - 2 files changed, 6 insertions(+), 2 deletions(-) + dwl.c | 8 ++++++-- + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h -index 8847e58..3189d48 100644 +index 22d2171..1f9ff56 100644 --- a/config.def.h +++ b/config.def.h @@ -13,6 +13,8 @@ static const float focuscolor[] = COLOR(0x005577ff); static const float urgentcolor[] = COLOR(0xff0000ff); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ -+static const char cursortheme[] = ""; /* theme from /usr/share/cursors/xorg-x11 */ -+static const unsigned int cursorsize = 24; ++static const char *cursor_theme = NULL; ++static const char cursor_size[] = "24"; /* Make sure it's a valid integer, otherwise things will break */ /* tagging - TAGCOUNT must be no greater than 31 */ #define TAGCOUNT (9) diff --git a/dwl.c b/dwl.c -index bf763df..961e2f1 100644 +index dc0437e..a91d42b 100644 --- a/dwl.c +++ b/dwl.c -@@ -2274,7 +2274,9 @@ setup(void) - - int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE}; - struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig}; -+ char cursorsize_str[3]; - sigemptyset(&sa.sa_mask); -+ sprintf(cursorsize_str, "%d", cursorsize); - - for (i = 0; i < (int)LENGTH(sig); i++) - sigaction(sig[i], &sa, NULL); -@@ -2412,8 +2414,8 @@ setup(void) +@@ -2522,8 +2522,12 @@ setup(void) * Xcursor themes to source cursor images from and makes sure that cursor * images are available at all scale factors on the screen (necessary for * HiDPI support). Scaled cursors will be loaded with each output. */ - cursor_mgr = wlr_xcursor_manager_create(NULL, 24); - setenv("XCURSOR_SIZE", "24", 1); -+ cursor_mgr = wlr_xcursor_manager_create(cursortheme, cursorsize); -+ setenv("XCURSOR_SIZE", cursorsize_str, 1); ++ cursor_mgr = wlr_xcursor_manager_create(cursor_theme, atoi(cursor_size)); ++ setenv("XCURSOR_SIZE", cursor_size, 1); ++ if (cursor_theme) ++ setenv("XCURSOR_THEME", cursor_theme, 1); ++ else ++ unsetenv("XCURSOR_THEME"); /* * wlr_cursor *only* displays an image on screen. It does not move around -- -2.43.2 +2.45.1 + diff --git a/patches/customfloat/customfloat.patch b/patches/customfloat/customfloat.patch index 3f7627a..d295571 100644 --- a/patches/customfloat/customfloat.patch +++ b/patches/customfloat/customfloat.patch @@ -1,33 +1,28 @@ -From ff29aba2f45d5acdee66efaf7cf94ab66145c0ed Mon Sep 17 00:00:00 2001 +From 4f19f5499610d56f2616da5d44039403ac9d4c06 Mon Sep 17 00:00:00 2001 From: wochap -Date: Thu, 11 Apr 2024 14:19:24 -0500 -Subject: [PATCH] rules for floating windows support default x, y, width, - height If the width or height is less than or equal to 1, then the value will - be interpreted as a percentage. For example, 0.5 represents 50%, 0.25 - represents 25%, and 1 represents 100%. NOTE: Some clients, like Thunar, have - minimum width/height +Date: Tue, 9 Jul 2024 10:52:37 -0500 +Subject: [PATCH] implement customfloat and generate patches -`floating_relative_to_monitor` allows the user to choose whether to position relative to the monitor or relative to the window area. --- config.def.h | 7 ++++--- - dwl.c | 16 ++++++++++++++++ - 2 files changed, 20 insertions(+), 3 deletions(-) + dwl.c | 27 +++++++++++++++++++++++++++ + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h -index 8847e58..ebaf1ab 100644 +index 22d2171..dee53f4 100644 --- a/config.def.h +++ b/config.def.h @@ -13,6 +13,7 @@ static const float focuscolor[] = COLOR(0x005577ff); static const float urgentcolor[] = COLOR(0xff0000ff); /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ -+static const int floating_relative_to_monitor = 0; /* 0 means center floating relative to the window area */ ++static const int respect_monitor_reserved_area = 0; /* 1 to monitor center while respecting the monitor's reserved area, 0 to monitor center */ /* tagging - TAGCOUNT must be no greater than 31 */ #define TAGCOUNT (9) -@@ -21,10 +22,10 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca - static int log_level = WLR_ERROR; +@@ -22,10 +23,10 @@ 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) */ static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ + /* app_id title tags mask isfloating monitor x y width height */ @@ -40,10 +35,10 @@ index 8847e58..ebaf1ab 100644 /* layout(s) */ diff --git a/dwl.c b/dwl.c -index bf763df..94e4d7d 100644 +index dc0437e..be0340f 100644 --- a/dwl.c +++ b/dwl.c -@@ -228,6 +228,10 @@ typedef struct { +@@ -230,6 +230,10 @@ typedef struct { uint32_t tags; int isfloating; int monitor; @@ -54,24 +49,45 @@ index bf763df..94e4d7d 100644 } Rule; typedef struct { -@@ -468,6 +472,18 @@ applyrules(Client *c) +@@ -454,6 +458,11 @@ applyrules(Client *c) + int i; + const Rule *r; + Monitor *mon = selmon, *m; ++ int newwidth; ++ int newheight; ++ int newx; ++ int newy; ++ int apply_resize = 0; + + c->isfloating = client_is_float_type(c); + if (!(appid = client_get_appid(c))) +@@ -471,9 +480,27 @@ applyrules(Client *c) if (r->monitor == i++) mon = m; } -+ if (c->isfloating) { -+ struct wlr_box b = floating_relative_to_monitor ? mon->m : mon->w; -+ int newwidth = ROUND(r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width); -+ int newheight = ROUND(r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height); ++ if (c->isfloating || !mon->lt[mon->sellt]->arrange) { ++ /* client is floating or in floating layout */ ++ struct wlr_box b = respect_monitor_reserved_area ? mon->w : mon->m; ++ newwidth = (int)round(r->w ? (r->w <= 1 ? b.width * r->w : r->w) : c->geom.width); ++ newheight = (int)round(r->h ? (r->h <= 1 ? b.height * r->h : r->h) : c->geom.height); ++ newx = (int)round(r->x ? (r->x <= 1 ? b.width * r->x + b.x : r->x + b.x) : c->geom.x); ++ newy = (int)round(r->y ? (r->y <= 1 ? b.height * r->y + b.y : r->y + b.y) : c->geom.y); ++ apply_resize = 1; + -+ resize(c, (struct wlr_box){ -+ .x = r->x ? r->x + b.x : (b.width - newwidth) / 2 + b.x, -+ .y = r->y ? r->y + b.y : (b.height - newheight) / 2 + b.y, -+ .width = newwidth, -+ .height = newheight, -+ }, 1); + } } } setmon(c, mon, newtags); ++ if (apply_resize) { ++ resize(c, (struct wlr_box){ ++ .x = newx, ++ .y = newy, ++ .width = newwidth, ++ .height = newheight, ++ }, 1); ++ } + } + + void -- -2.43.2 +2.45.1 diff --git a/patches/minimalborders/minimalborders.patch b/patches/minimalborders/minimalborders.patch index 4098d27..cb19900 100644 --- a/patches/minimalborders/minimalborders.patch +++ b/patches/minimalborders/minimalborders.patch @@ -1,16 +1,15 @@ -From 225fcc26d1b0fd696a90817c996b670ced8964f2 Mon Sep 17 00:00:00 2001 +From ce0eb92fb100801f343fbe9b76639847a9e39160 Mon Sep 17 00:00:00 2001 From: wochap -Date: Thu, 11 Apr 2024 14:34:45 -0500 -Subject: [PATCH] apply minimal borders +Date: Fri, 5 Jul 2024 11:22:57 -0500 +Subject: [PATCH] implement minimalborders -dynamically adjusts the borders between adjacent clients to make them visually merge --- config.def.h | 1 + dwl.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h -index 8847e58..55d8796 100644 +index 22d2171..0322dbf 100644 --- a/config.def.h +++ b/config.def.h @@ -7,6 +7,7 @@ @@ -22,10 +21,10 @@ index 8847e58..55d8796 100644 static const float bordercolor[] = COLOR(0x444444ff); static const float focuscolor[] = COLOR(0x005577ff); diff --git a/dwl.c b/dwl.c -index bf763df..d581f31 100644 +index dc0437e..198061b 100644 --- a/dwl.c +++ b/dwl.c -@@ -105,6 +105,7 @@ typedef struct Monitor Monitor; +@@ -106,6 +106,7 @@ typedef struct Monitor Monitor; typedef struct { /* Must keep these three elements in this order */ unsigned int type; /* XDGShell or X11* */ @@ -33,7 +32,7 @@ index bf763df..d581f31 100644 struct wlr_box geom; /* layout-relative, includes border */ Monitor *mon; struct wlr_scene_tree *scene; -@@ -312,7 +313,8 @@ static void rendermon(struct wl_listener *listener, void *data); +@@ -316,7 +317,8 @@ static void rendermon(struct wl_listener *listener, void *data); static void requestdecorationmode(struct wl_listener *listener, void *data); static void requeststartdrag(struct wl_listener *listener, void *data); static void requestmonstate(struct wl_listener *listener, void *data); @@ -43,7 +42,7 @@ index bf763df..d581f31 100644 static void run(char *startup_cmd); static void setcursor(struct wl_listener *listener, void *data); static void setcursorshape(struct wl_listener *listener, void *data); -@@ -405,6 +407,8 @@ static struct wlr_box sgeom; +@@ -408,6 +410,8 @@ static struct wlr_box sgeom; static struct wl_list mons; static Monitor *selmon; @@ -52,7 +51,7 @@ index bf763df..d581f31 100644 #ifdef XWAYLAND static void activatex11(struct wl_listener *listener, void *data); static void associatex11(struct wl_listener *listener, void *data); -@@ -473,6 +477,35 @@ applyrules(Client *c) +@@ -476,6 +480,35 @@ applyrules(Client *c) setmon(c, mon, newtags); } @@ -88,9 +87,9 @@ index bf763df..d581f31 100644 void arrange(Monitor *m) { -@@ -493,8 +526,28 @@ arrange(Monitor *m) - - strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol)); +@@ -510,8 +543,28 @@ arrange(Monitor *m) + : c->scene->node.parent); + } - if (m->lt[m->sellt]->arrange) - m->lt[m->sellt]->arrange(m); @@ -119,10 +118,10 @@ index bf763df..d581f31 100644 motionnotify(0, NULL, 0, 0, 0, 0); checkidleinhibitor(NULL); } -@@ -1883,8 +1936,13 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, +@@ -1962,8 +2015,13 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, struct timespec now; - if ((!active_constraint || active_constraint->surface != surface) && + if (surface != seat->pointer_state.focused_surface && - sloppyfocus && time && c && !client_is_unmanaged(c)) - focusclient(c, 0); + sloppyfocus && time && c && !client_is_unmanaged(c)) { @@ -135,16 +134,16 @@ index bf763df..d581f31 100644 /* If surface is NULL, clear pointer focus */ if (!surface) { -@@ -2032,7 +2090,7 @@ requestmonstate(struct wl_listener *listener, void *data) +@@ -2128,7 +2186,7 @@ requestmonstate(struct wl_listener *listener, void *data) } void -resize(Client *c, struct wlr_box geo, int interact) +resizeapply(Client *c, struct wlr_box geo, int interact) { - struct wlr_box *bbox = interact ? &sgeom : &c->mon->w; + struct wlr_box *bbox; struct wlr_box clip; -@@ -2058,6 +2116,13 @@ resize(Client *c, struct wlr_box geo, int interact) +@@ -2160,6 +2218,13 @@ resize(Client *c, struct wlr_box geo, int interact) wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); } @@ -159,4 +158,4 @@ index bf763df..d581f31 100644 run(char *startup_cmd) { -- -2.43.2 +2.45.1 diff --git a/patches/swapandfocusdir/swapandfocusdir.patch b/patches/swapandfocusdir/swapandfocusdir.patch index 7515f90..3636387 100644 --- a/patches/swapandfocusdir/swapandfocusdir.patch +++ b/patches/swapandfocusdir/swapandfocusdir.patch @@ -1,36 +1,18 @@ -From d224594e8f077ac49a1369670f6ff6a5d27ec75a Mon Sep 17 00:00:00 2001 +From 285470897406b653e77d732a77356aaf9a70b799 Mon Sep 17 00:00:00 2001 From: wochap -Date: Tue, 5 Mar 2024 23:50:01 -0500 -Subject: [PATCH] implement swap and focus direction functions +Date: Fri, 5 Jul 2024 12:37:39 -0500 +Subject: [PATCH] implement swapandfocusdir -you should expect the same behavior as in river wm, - -swap only works on tiling windows -focus works on tiling and floating windows --- - Makefile | 2 +- config.def.h | 8 +++ - dwl.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 172 insertions(+), 1 deletion(-) + dwl.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 172 insertions(+) -diff --git a/Makefile b/Makefile -index 6cde460..22f4372 100644 ---- a/Makefile -+++ b/Makefile -@@ -11,7 +11,7 @@ DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unu - # CFLAGS / LDFLAGS - PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS) - DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS) --LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(LIBS) -+LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` -lm $(LIBS) - - all: dwl - dwl: dwl.o util.o diff --git a/config.def.h b/config.def.h -index db0babc..b584f3e 100644 +index 22d2171..724e15e 100644 --- a/config.def.h +++ b/config.def.h -@@ -122,6 +122,14 @@ static const Key keys[] = { +@@ -129,6 +129,14 @@ static const Key keys[] = { { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, @@ -44,20 +26,12 @@ index db0babc..b584f3e 100644 + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, swapdir, {.ui = 3} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, - { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} }, + { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} }, diff --git a/dwl.c b/dwl.c -index ef27a1d..8d3540e 100644 +index dc0437e..844c1f5 100644 --- a/dwl.c +++ b/dwl.c -@@ -4,6 +4,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -226,6 +227,11 @@ typedef struct { +@@ -241,6 +241,11 @@ typedef struct { struct wl_listener destroy; } SessionLock; @@ -69,7 +43,7 @@ index ef27a1d..8d3540e 100644 /* function declarations */ static void applybounds(Client *c, struct wlr_box *bbox); static void applyrules(Client *c); -@@ -264,6 +270,8 @@ static Monitor *dirtomon(enum wlr_direction dir); +@@ -285,6 +290,8 @@ static Monitor *dirtomon(enum wlr_direction dir); static void focusclient(Client *c, int lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); @@ -78,7 +52,7 @@ index ef27a1d..8d3540e 100644 static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); static void handlesig(int signo); -@@ -1282,6 +1290,161 @@ focusstack(const Arg *arg) +@@ -1425,6 +1432,163 @@ focusstack(const Arg *arg) focusclient(c, 1); } @@ -126,7 +100,7 @@ index ef27a1d..8d3540e 100644 +client_in_direction(const char *direction, const int *skipfloat) +{ + Client *cfocused = focustop(selmon); -+ Vector cfocusedposition = position_of_box(&cfocused->geom); ++ Vector cfocusedposition; + Client *ctarget = NULL; + double targetdistance = INFINITY; + Client *c; @@ -134,6 +108,8 @@ index ef27a1d..8d3540e 100644 + if (!cfocused || cfocused->isfullscreen || (skipfloat && cfocused->isfloating)) + return NULL; + ++ cfocusedposition = position_of_box(&cfocused->geom); ++ + wl_list_for_each(c, &clients, link) { + Vector cposition; + Vector positiondiff; @@ -241,5 +217,5 @@ index ef27a1d..8d3540e 100644 * will focus the topmost client of this mon, when actually will * only return that client */ -- -2.42.0 +2.45.1