Compare commits

...

3 Commits

Author SHA1 Message Date
korei999
33bf4e208e update tearing 2024-09-18 20:36:37 +03:00
Dhruva Sambrani
f4a18a4bcc fix link 2024-09-18 19:00:50 +02:00
Dhruva Sambrani
0ed712244f rebase to upstream/main 2024-09-18 18:56:25 +02:00
19 changed files with 13453 additions and 118 deletions

6103
PatchList.html Normal file

File diff suppressed because it is too large Load Diff

2923
PatchList.md Normal file

File diff suppressed because it is too large Load Diff

25
list_all_readme.py Normal file
View File

@ -0,0 +1,25 @@
import os
patchlist = os.listdir("./patches")
patchlist.sort()
for patch in patchlist:
print(f"# {patch}\n")
for file in os.listdir(f"./patches/{patch}"):
if file.lower() == "readme.md":
print(open(f"./patches/{patch}/{file}").read())
print("---")
print("# STALE PATCHES")
patchlist = os.listdir("./_STALE_PATCHES")
patchlist.sort()
for patch in patchlist:
print(f"## {patch.split(".")[0]}\n")
if (os.path.isdir(f"./_STALE_PATCHES/{patch}")):
for file in os.listdir(f"./_STALE_PATCHES/{patch}"):
if file.lower() == "readme.md":
print(open(f"./_STALE_PATCHES/{patch}/{file}").read())
else:
print(open(f"./_STALE_PATCHES/{patch}").read())
print("---")

View File

@ -8,7 +8,8 @@ There are also two functions that can be bound to a `Key` or `Button`,
2. `toggledimmingclient`: Which toggles dimming for the focused window, as if the client had `neverdim` applied to it. This overwrites an applied `Rule`.
### Download
- [2024-09-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused.patch)
- [2024-09-03](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240903.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240714.patch)
- [2024-05-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240516.patch)
- [2024-04-16](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/dim-unfocused/dim-unfocused-20240416.patch)

View File

@ -0,0 +1,216 @@
diff --git a/client.h b/client.h
index dabea35..3a31c25 100644
--- a/client.h
+++ b/client.h
@@ -319,6 +319,12 @@ client_set_border_color(Client *c, const float color[static 4])
wlr_scene_rect_set_color(c->border[i], color);
}
+static inline void
+client_set_dimmer_state(Client *c, const int dim)
+{
+ wlr_scene_node_set_enabled(&c->dimmer->node, DIMOPT && !c->neverdim && dim);
+}
+
static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
diff --git a/config.def.h b/config.def.h
index 22d2171..4ca21c9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -10,6 +10,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
+static const float unfocuseddim[] = COLOR(0x00000088);
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 */
@@ -22,10 +23,11 @@ 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 */
- /* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ /* app_id title tags mask isfloating neverdim monitor */
+ /* examples:
+ { "Gimp_example", NULL, 0, 1, 0, -1 },
+ */
+ { "firefox_example", NULL, 1 << 8, 0, 1, -1 },
};
/* layout(s) */
@@ -140,8 +142,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
+ { MODKEY, XKB_KEY_apostrophe, toggledimming, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
- { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
@@ -172,5 +175,6 @@ static const Key keys[] = {
static const Button buttons[] = {
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
+ { MODKEY|ShiftMask, BTN_MIDDLE, toggledimmingclient, {0} },
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index 9021e44..e1f32e9 100644
--- a/dwl.c
+++ b/dwl.c
@@ -112,6 +112,7 @@ typedef struct {
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
+ struct wlr_scene_rect *dimmer;
struct wlr_scene_tree *scene_surface;
struct wl_list link;
struct wl_list flink;
@@ -141,7 +142,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, neverdim;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -231,6 +232,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int neverdim;
int monitor;
} Rule;
@@ -338,6 +340,8 @@ static void startdrag(struct wl_listener *listener, void *data);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
+static void toggledimming(const Arg *arg);
+static void toggledimmingclient(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
@@ -410,6 +414,7 @@ static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static int DIMOPT = 1;
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
@@ -466,6 +471,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->neverdim = r-> neverdim;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1366,8 +1372,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
- if (!exclusive_focus && !seat->drag)
+ if (!exclusive_focus && !seat->drag) {
client_set_border_color(c, focuscolor);
+ client_set_dimmer_state(c, 0);
+ }
}
/* Deactivate old client if focus is changing */
@@ -1385,7 +1393,7 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
-
+ client_set_dimmer_state(old_c, 1);
client_activate_surface(old, 0);
}
}
@@ -1682,8 +1690,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
- Client *p = NULL;
- Client *w, *c = wl_container_of(listener, c, map);
+ Client *p, *w, *d, *c = wl_container_of(listener, c, map);
Monitor *m;
int i;
@@ -1717,6 +1724,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
+ c->dimmer = wlr_scene_rect_create(c->scene, 0, 0, unfocuseddim);
+ c->dimmer->node.data = c;
+ client_set_dimmer_state(c, 1);
+
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1735,6 +1746,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
+ d = focustop(selmon);
+ if (d) {
+ client_set_dimmer_state(d, 0);
+ }
}
printstatus();
@@ -2161,7 +2176,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
- /* Update scene-graph, including borders */
+ /* Update scene-graph, including borders and dimmer*/
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2171,6 +2186,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
+ wlr_scene_rect_set_size(c->dimmer, c->geom.width - 2*c->bw, c-> geom.height - 2*c->bw);
+ wlr_scene_node_set_position(&c->dimmer->node, c->bw, c->bw);
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2682,6 +2699,27 @@ tile(Monitor *m)
}
}
+void toggledimming(const Arg *arg)
+{
+ Client *c;
+ DIMOPT ^= 1;
+ wl_list_for_each(c, &clients, link)
+ {
+ client_set_dimmer_state(c, 1);
+ }
+ c = focustop(selmon);
+ if (c)
+ client_set_dimmer_state(c, 0);
+}
+
+void
+toggledimmingclient(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ sel -> neverdim ^= 1;
+}
+
void
togglefloating(const Arg *arg)
{

View File

@ -62,7 +62,7 @@ index 22d2171..4ca21c9 100644
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
};
diff --git a/dwl.c b/dwl.c
index 9021e44..e1f32e9 100644
index dc0c861..dcc3ece 100644
--- a/dwl.c
+++ b/dwl.c
@@ -112,6 +112,7 @@ typedef struct {
@ -115,7 +115,7 @@ index 9021e44..e1f32e9 100644
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1366,8 +1372,10 @@ focusclient(Client *c, int lift)
@@ -1365,8 +1371,10 @@ focusclient(Client *c, int lift)
/* Don't change border color if there is an exclusive focus or we are
* handling a drag operation */
@ -127,7 +127,7 @@ index 9021e44..e1f32e9 100644
}
/* Deactivate old client if focus is changing */
@@ -1385,7 +1393,7 @@ focusclient(Client *c, int lift)
@@ -1384,7 +1392,7 @@ focusclient(Client *c, int lift)
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
client_set_border_color(old_c, bordercolor);
@ -136,7 +136,7 @@ index 9021e44..e1f32e9 100644
client_activate_surface(old, 0);
}
}
@@ -1682,8 +1690,7 @@ void
@@ -1681,8 +1689,7 @@ void
mapnotify(struct wl_listener *listener, void *data)
{
/* Called when the surface is mapped, or ready to display on-screen. */
@ -146,7 +146,7 @@ index 9021e44..e1f32e9 100644
Monitor *m;
int i;
@@ -1717,6 +1724,10 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1716,6 +1723,10 @@ mapnotify(struct wl_listener *listener, void *data)
c->border[i]->node.data = c;
}
@ -157,7 +157,7 @@ index 9021e44..e1f32e9 100644
/* Initialize client geometry with room for border */
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT);
c->geom.width += 2 * c->bw;
@@ -1735,6 +1746,10 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1734,6 +1745,10 @@ mapnotify(struct wl_listener *listener, void *data)
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
@ -168,7 +168,7 @@ index 9021e44..e1f32e9 100644
}
printstatus();
@@ -2161,7 +2176,7 @@ resize(Client *c, struct wlr_box geo, int interact)
@@ -2160,7 +2175,7 @@ resize(Client *c, struct wlr_box geo, int interact)
c->geom = geo;
applybounds(c, bbox);
@ -177,7 +177,7 @@ index 9021e44..e1f32e9 100644
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
wlr_scene_rect_set_size(c->border[0], c->geom.width, c->bw);
@@ -2171,6 +2186,8 @@ resize(Client *c, struct wlr_box geo, int interact)
@@ -2170,6 +2185,8 @@ resize(Client *c, struct wlr_box geo, int interact)
wlr_scene_node_set_position(&c->border[1]->node, 0, c->geom.height - c->bw);
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
@ -186,7 +186,7 @@ index 9021e44..e1f32e9 100644
/* this is a no-op if size hasn't changed */
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
@@ -2682,6 +2699,27 @@ tile(Monitor *m)
@@ -2681,6 +2698,27 @@ tile(Monitor *m)
}
}

View File

@ -1,8 +1,11 @@
### Description
Arranges windows in a grid. Except it adjusts the number of windows in the first few columns to avoid empty cells.
On widescreens (w > 2*h), it splits to three columns before splitting rows.
### Download
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20240714.patch)
- [2023-08-01](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/gaplessgrid/gaplessgrid-20230801.patch)
- [git branch](https://codeberg.org/dhruva_sambrani/dwl/src/branch/gaplessgrid)

View File

@ -0,0 +1,89 @@
diff --git a/config.def.h b/config.def.h
index 22d2171..014a909 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "###", gaplessgrid },
};
/* monitors */
@@ -139,6 +140,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_g, 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 145fd01..dae1d1a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -287,6 +287,7 @@ static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1467,6 +1468,56 @@ handlesig(int signo)
}
}
+void
+gaplessgrid(Monitor *m)
+{
+ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
void
incnmaster(const Arg *arg)
{

View File

@ -19,18 +19,18 @@ index 22d2171..014a909 100644
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index 145fd01..dae1d1a 100644
index dc0c861..875d8cd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -287,6 +287,7 @@ static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1467,6 +1468,56 @@ handlesig(int signo)
@@ -1510,6 +1511,56 @@ handlesig(int signo)
}
}

View File

@ -8,8 +8,9 @@ Adds a rule-based ability to skip automatically focusing a window on creation. E
| 2 | skipfocus entirely |
### Download
- [20240714](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus.patch)
- [20240108](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus20240108.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus.patch)
- [2024-07-14](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20240714.patch)
- [2024-01-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/skipfocus/skipfocus-20240108.patch)
- [git branch](https://codeberg.org/dhruva_sambrani/dwl/src/branch/skipfocus)
### Authors

View File

@ -0,0 +1,81 @@
diff --git a/config.def.h b/config.def.h
index 22d2171..9f6599c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,10 +22,11 @@ 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 skipfocus monitor */
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, 0, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, 0, -1 }, /* Start on ONLY tag "9" */
+ { "mako_EXAMPLE", NULL, 0, 1, 1, -1 }, /* Start floating and skip focus
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index 145fd01..ec9d1af 100644
--- a/dwl.c
+++ b/dwl.c
@@ -138,7 +138,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, skipfocus;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -229,6 +229,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
+ int skipfocus;
int monitor;
} Rule;
@@ -465,6 +466,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
+ c->skipfocus = r->skipfocus;
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1323,6 +1325,13 @@ focusclient(Client *c, int lift)
if (locked)
return;
+ if (c && c->skipfocus != 0){
+ if (c -> skipfocus == 1) {
+ c->skipfocus = 0;
+ }
+ return;
+ }
+
/* Raise client in stacking order if requested */
if (c && lift)
wlr_scene_node_raise_to_top(&c->scene->node);
@@ -1692,11 +1701,13 @@ mapnotify(struct wl_listener *listener, void *data)
printstatus();
unset_fullscreen:
- m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
- wl_list_for_each(w, &clients, link) {
- if (w != c && w->isfullscreen && m == w->mon && (w->tags & c->tags))
- setfullscreen(w, 0);
- }
+ if (!c->skipfocus) {
+ m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
+ wl_list_for_each(w, &clients, link) {
+ if (w != c && w->isfullscreen && m == w->mon && (w->tags & c->tags))
+ setfullscreen(w, 0);
+ }
+ }
}
void

View File

@ -18,10 +18,10 @@ index 22d2171..9f6599c 100644
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index 145fd01..ec9d1af 100644
index dc0c861..b6a4cbb 100644
--- a/dwl.c
+++ b/dwl.c
@@ -138,7 +138,7 @@ typedef struct {
@@ -141,7 +141,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
@ -30,7 +30,7 @@ index 145fd01..ec9d1af 100644
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -229,6 +229,7 @@ typedef struct {
@@ -231,6 +231,7 @@ typedef struct {
const char *title;
uint32_t tags;
int isfloating;
@ -38,7 +38,7 @@ index 145fd01..ec9d1af 100644
int monitor;
} Rule;
@@ -465,6 +466,7 @@ applyrules(Client *c)
@@ -466,6 +467,7 @@ applyrules(Client *c)
if ((!r->title || strstr(title, r->title))
&& (!r->id || strstr(appid, r->id))) {
c->isfloating = r->isfloating;
@ -46,7 +46,7 @@ index 145fd01..ec9d1af 100644
newtags |= r->tags;
i = 0;
wl_list_for_each(m, &mons, link) {
@@ -1323,6 +1325,13 @@ focusclient(Client *c, int lift)
@@ -1343,6 +1345,13 @@ focusclient(Client *c, int lift)
if (locked)
return;
@ -60,19 +60,19 @@ index 145fd01..ec9d1af 100644
/* Raise client in stacking order if requested */
if (c && lift)
wlr_scene_node_raise_to_top(&c->scene->node);
@@ -1692,11 +1701,13 @@ mapnotify(struct wl_listener *listener, void *data)
@@ -1738,11 +1747,13 @@ mapnotify(struct wl_listener *listener, void *data)
printstatus();
unset_fullscreen:
- m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
- wl_list_for_each(w, &clients, link) {
- if (w != c && w->isfullscreen && m == w->mon && (w->tags & c->tags))
- if (w != c && w != p && w->isfullscreen && m == w->mon && (w->tags & c->tags))
- setfullscreen(w, 0);
- }
+ if (!c->skipfocus) {
+ m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
+ wl_list_for_each(w, &clients, link) {
+ if (w != c && w->isfullscreen && m == w->mon && (w->tags & c->tags))
+ if (w != c && w != p && w->isfullscreen && m == w->mon && (w->tags & c->tags))
+ setfullscreen(w, 0);
+ }
+ }

View File

@ -1,17 +1,17 @@
### Description
This patch adds support for tearing protocol. To get it working `export WLR_DRM_NO_ATOMIC=1` is probably required.
Setting `ForceTearingRule` is also probably required since surfaces always receive presentation hint 0 (VSYNC) as far as i can tell.
Some apps would send ASYNC hint and tearing will "just work", otherwise it's possible to force specified clients to tear with a rule.
Set rules in the config.h (exact string match):
```
static const ForceTearingRule force_tearing[] = {
{.title = "", .appid = "oni.exe"},
{.title = "", .appid = "hl_linux"},
{.title = "", .appid = "steam_app_210970"},
{.title = "Warcraft III", .appid = ""},
{.title = "", .appid = "gamescope"},
};
```
### Download
- [git branch](https://codeberg.org/korei999/dwl/src/branch/tearing)
- [2024-08-15](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tearing/tearing.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/tearing/tearing.patch)
### Authors
- [korei999](https://codeberg.org/korei999)

View File

@ -1,13 +1,13 @@
From d8856938de1e41b820c5e7b27d317a305c1b0ab8 Mon Sep 17 00:00:00 2001
From 66b2e1646bee8502a3715403c165015bd019438c Mon Sep 17 00:00:00 2001
From: korei999 <ju7t1xe@gmail.com>
Date: Thu, 15 Aug 2024 01:25:59 +0300
Date: Wed, 18 Sep 2024 20:11:22 +0300
Subject: [PATCH] implement tearing protocol
---
Makefile | 5 +-
config.def.h | 5 ++
dwl.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 173 insertions(+), 15 deletions(-)
config.def.h | 8 +++
dwl.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 182 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 8db7409..6edc7d7 100644
@ -33,23 +33,26 @@ index 8db7409..6edc7d7 100644
config.h:
cp config.def.h $@
diff --git a/config.def.h b/config.def.h
index 22d2171..c928330 100644
index 22d2171..52d38d3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -28,6 +28,11 @@ static const Rule rules[] = {
@@ -28,6 +28,14 @@ static const Rule rules[] = {
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
};
+/* tearing */
+static int tearing_allowed = 1;
+static const ForceTearingRule force_tearing[] = {
+ {.title = "", .appid = "oni.exe"},
+ {.title = "", .appid = "hl_linux"},
+ {.title = "Warcraft III", .appid = ""},
+ {.title = "", .appid = "gamescope"},
+};
+
/* layout(s) */
static const Layout layouts[] = {
/* symbol arrange function */
diff --git a/dwl.c b/dwl.c
index 8a587d1..5546e26 100644
index dc0c861..44be1bf 100644
--- a/dwl.c
+++ b/dwl.c
@@ -51,6 +51,7 @@
@ -72,7 +75,7 @@ index 8a587d1..5546e26 100644
typedef union {
int i;
uint32_t ui;
@@ -142,6 +148,7 @@ typedef struct {
@@ -143,6 +149,7 @@ typedef struct {
uint32_t tags;
int isfloating, isurgent, isfullscreen;
uint32_t resize; /* configure serial of a pending resize */
@ -100,15 +103,7 @@ index 8a587d1..5546e26 100644
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -256,6 +276,7 @@ static void chvt(const Arg *arg);
static void checkidleinhibitor(struct wlr_surface *exclude);
static void cleanup(void);
static void cleanupmon(struct wl_listener *listener, void *data);
+static bool clientcantear(Client* c);
static void closemon(Monitor *m);
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data);
@@ -293,6 +314,9 @@ static Client *focustop(Monitor *m);
@@ -293,6 +313,9 @@ static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
static void handlesig(int signo);
@ -118,15 +113,15 @@ index 8a587d1..5546e26 100644
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -309,6 +333,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
@@ -309,6 +332,7 @@ static void motionnotify(uint32_t time, struct wlr_input_device *device, double
double sy, double sx_unaccel, double sy_unaccel);
static void motionrelative(struct wl_listener *listener, void *data);
static void moveresize(const Arg *arg);
+static bool moncantear(Monitor* m);
+static int moncantear(Monitor* m);
static void outputmgrapply(struct wl_listener *listener, void *data);
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
static void outputmgrtest(struct wl_listener *listener, void *data);
@@ -323,6 +348,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
@@ -323,6 +347,7 @@ static void requeststartdrag(struct wl_listener *listener, void *data);
static void requestmonstate(struct wl_listener *listener, void *data);
static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd);
@ -134,7 +129,7 @@ index 8a587d1..5546e26 100644
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
@@ -400,6 +426,10 @@ static struct wlr_scene_rect *locked_bg;
@@ -400,6 +425,10 @@ static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock;
static struct wl_listener lock_listener = {.notify = locksession};
@ -145,41 +140,7 @@ index 8a587d1..5546e26 100644
static struct wlr_seat *seat;
static KeyboardGroup *kb_group;
static unsigned int cursor_mode;
@@ -722,6 +752,33 @@ cleanupmon(struct wl_listener *listener, void *data)
free(m);
}
+bool
+clientcantear(Client* c)
+{
+ bool res = false;
+ const char* appid = client_get_appid(c);
+ const char* title = client_get_title(c);
+
+ switch (c->tearing_hint) {
+ case WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC:
+ res = false;
+ break;
+
+ case WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC:
+ return true;
+ };
+
+ for (unsigned i = 0; i < LENGTH(force_tearing); i++) {
+ if (strcmp(force_tearing[i].appid, appid) == 0)
+ return true;
+
+ if (strcmp(force_tearing[i].title, title) == 0)
+ return true;
+ }
+
+ return res;
+}
+
void
closemon(Monitor *m)
{
@@ -1512,6 +1569,61 @@ handlesig(int signo)
@@ -1510,6 +1539,69 @@ handlesig(int signo)
}
}
@ -190,18 +151,27 @@ index 8a587d1..5546e26 100644
+ struct TearingController *controller = wl_container_of(listener, controller, set_hint);
+
+ struct wlr_xdg_surface *surface = wlr_xdg_surface_try_from_wlr_surface(controller->tearing_control->surface);
+#ifdef XWAYLAND
+ struct wlr_xwayland_surface *xsurface = wlr_xwayland_surface_try_from_wlr_surface(controller->tearing_control->surface);
+#endif
+
+ /* FIXME: broken appearantly */
+ wl_list_for_each(i, &fstack, flink) {
+ if (VISIBLEON(i, selmon))
+ if (i->surface.xdg == surface) {
+ if (i->surface.xdg == surface
+#ifdef XWAYLAND
+ || i->surface.xwayland == xsurface
+#endif
+ ) {
+ c = i;
+ break;
+ }
+ }
+
+ if (c) {
+ fprintf(stderr, "FOUND\n");
+ enum wp_tearing_control_v1_presentation_hint hint = controller->tearing_control->current;
+ fprintf(
+ stderr, "TEARING: found surface: %p(appid: '%s', title: '%s'), hint: %d(%s)\n",
+ (void*)c, client_get_appid(c), client_get_title(c), hint, hint ? "ASYNC" : "VSYNC"
+ );
+ c->tearing_hint = controller->tearing_control->current;
+ }
+}
@ -210,6 +180,9 @@ index 8a587d1..5546e26 100644
+handletearingcontrollerdestroy(struct wl_listener *listener, void *data)
+{
+ struct TearingController *controller = wl_container_of(listener, controller, destroy);
+
+ wl_list_remove(&controller->set_hint.link);
+ wl_list_remove(&controller->destroy.link);
+ wl_list_remove(&controller->link);
+ free(controller);
+}
@ -218,47 +191,83 @@ index 8a587d1..5546e26 100644
+handlenewtearinghint(struct wl_listener *listener, void *data)
+{
+ struct wlr_tearing_control_v1 *tearing_control = data;
+ enum wp_tearing_control_v1_presentation_hint hint = wlr_tearing_control_manager_v1_surface_hint_from_surface(tearing_control_v1, tearing_control->surface);
+ struct TearingController *controller = calloc(1, sizeof(struct TearingController));
+
+ fprintf(stderr, "New presentation hint %d received for surface %p\n\n", hint, (void*)tearing_control->surface);
+
+ if (!controller) {
+ fprintf(stderr, "!controller\n");
+ if (!controller)
+ return;
+ }
+
+ controller->tearing_control = tearing_control;
+ controller->set_hint.notify = handletearingcontrollersethint;
+ wl_signal_add(&tearing_control->events.set_hint, &controller->set_hint);
+
+ controller->destroy.notify = handletearingcontrollerdestroy;
+ wl_signal_add(&tearing_control->events.destroy, &controller->destroy);
+ wl_list_init(&controller->link);
+
+ wl_list_init(&controller->link);
+ wl_list_insert(&tearing_controllers, &controller->link);
+}
+
void
incnmaster(const Arg *arg)
{
@@ -1924,6 +2036,16 @@ moveresize(const Arg *arg)
@@ -1677,6 +1769,33 @@ locksession(struct wl_listener *listener, void *data)
wlr_session_lock_v1_send_locked(session_lock);
}
+static inline void
+forcetearingrule(Client *c)
+{
+ int success = 0;
+ const char* appid = client_get_appid(c);
+ const char* title = client_get_title(c);
+
+ for (unsigned i = 0; i < LENGTH(force_tearing); i++) {
+ if (appid)
+ if (strcmp(force_tearing[i].appid, appid) == 0) {
+ success = 1;
+ break;
+ }
+
+ if (title)
+ if (strcmp(force_tearing[i].title, title) == 0) {
+ success = 1;
+ break;
+ }
+ }
+
+ if (success) {
+ c->tearing_hint = WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
+ fprintf(stderr, "tearing forced for: appid: '%s', title: '%s'\n", appid, title);
+ }
+}
+
void
mapnotify(struct wl_listener *listener, void *data)
{
@@ -1686,6 +1805,8 @@ mapnotify(struct wl_listener *listener, void *data)
Monitor *m;
int i;
+ forcetearingrule(c);
+
/* 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() */
@@ -1924,6 +2045,13 @@ moveresize(const Arg *arg)
}
}
+bool
+int
+moncantear(Monitor* m)
+{
+ Client *c = focustop(m);
+ if (c && c->isfullscreen && clientcantear(c))
+ return true;
+
+ return false;
+ return (c && c->isfullscreen && c->tearing_hint); /* 1 == ASYNC */
+}
+
void
outputmgrapply(struct wl_listener *listener, void *data)
{
@@ -2093,27 +2215,40 @@ quit(const Arg *arg)
@@ -2093,27 +2221,40 @@ quit(const Arg *arg)
void
rendermon(struct wl_listener *listener, void *data)
{
@ -288,7 +297,7 @@ index 8a587d1..5546e26 100644
+ goto skip;
+ }
+
+ if (moncantear(m)) {
+ if (tearing_allowed && moncantear(m)) {
+ pending.tearing_page_flip = true;
+
+ if (!wlr_output_test_state(m->wlr_output, &pending)) {
@ -313,7 +322,7 @@ index 8a587d1..5546e26 100644
}
void
@@ -2237,6 +2372,16 @@ run(char *startup_cmd)
@@ -2237,6 +2378,16 @@ run(char *startup_cmd)
wl_display_run(dpy);
}
@ -330,7 +339,7 @@ index 8a587d1..5546e26 100644
void
setcursor(struct wl_listener *listener, void *data)
{
@@ -2584,6 +2729,11 @@ setup(void)
@@ -2584,6 +2735,11 @@ setup(void)
LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
LISTEN_STATIC(&output_mgr->events.test, outputmgrtest);

View File

@ -26,7 +26,8 @@ This patch is inspired from <https://dwm.suckless.org/patches/winview/>. Citing
> An example of how to insert this line can be found in the default config file template, config.def.h.
### Download
- [2023-11-26](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview.patch)
- [2024-09-18](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview.patch)
- [2024-06-06](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/winview/winview-20240606.patch)
- [git branch](https://codeberg.org/dhruva_sambrani/dwl/src/branch/winview)
### Authors

View File

@ -0,0 +1,42 @@
diff --git a/config.def.h b/config.def.h
index a784eb4..d09ee55 100644
--- a/config.def.h
+++ b/config.def.h
@@ -140,6 +140,7 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
+ { MODKEY, XKB_KEY_o, winview, {0}},
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
diff --git a/dwl.c b/dwl.c
index 6f041a0..65df112 100644
--- a/dwl.c
+++ b/dwl.c
@@ -346,6 +346,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 winview(const Arg *a);
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);
@@ -2877,6 +2878,17 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
}
+void
+winview(const Arg *a) {
+ Arg b = {0};
+ Client *sel = focustop(selmon);
+ if(!sel)
+ return;
+ b.ui = sel -> tags;
+ view(&b);
+ return;
+}
+
Monitor *
xytomon(double x, double y)
{

View File

@ -1,8 +1,8 @@
diff --git a/config.def.h b/config.def.h
index a784eb4..d09ee55 100644
index 22d2171..b812525 100644
--- a/config.def.h
+++ b/config.def.h
@@ -140,6 +140,7 @@ static const Key keys[] = {
@@ -143,6 +143,7 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
@ -11,10 +11,10 @@ index a784eb4..d09ee55 100644
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
diff --git a/dwl.c b/dwl.c
index 6f041a0..65df112 100644
index dc0c861..5c6862c 100644
--- a/dwl.c
+++ b/dwl.c
@@ -346,6 +346,7 @@ static void urgent(struct wl_listener *listener, void *data);
@@ -351,6 +351,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);
@ -22,8 +22,8 @@ index 6f041a0..65df112 100644
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);
@@ -2877,6 +2878,17 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
@@ -2942,6 +2943,17 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
}
+void

3841
readme.html Normal file

File diff suppressed because it is too large Load Diff