mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2026-11-03 20:02:31 +00:00
210 lines
8.4 KiB
Diff
210 lines
8.4 KiB
Diff
diff --git a/Makefile b/Makefile
|
|
index 09ae285..02e7e13 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -12,7 +12,7 @@ DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
|
|
-Wfloat-conversion
|
|
|
|
# CFLAGS / LDFLAGS
|
|
-PKGS = wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
|
+PKGS = scenefx-0.5 wayland-server xkbcommon libinput pixman-1 fcft $(XLIBS)
|
|
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
|
|
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
|
|
|
|
diff --git a/config.def.h b/config.def.h
|
|
index 1c50fc5..90e17d6 100644
|
|
--- a/config.def.h
|
|
+++ b/config.def.h
|
|
@@ -20,6 +20,9 @@ static uint32_t colors[][3] = {
|
|
[SchemeUrg] = { 0, 0, 0x770000ff },
|
|
};
|
|
|
|
+#define blur_params 2, 2, 0, 0.703125, 0.4375, 0.875 // passes, radius, noise, brightness, contrast, saturation
|
|
+static int blur_enabled = 1;
|
|
+
|
|
/* tagging */
|
|
static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
|
|
@@ -130,6 +133,8 @@ static const Key keys[] = {
|
|
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
|
{ MODKEY, XKB_KEY_b, togglebar, {0} },
|
|
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_B, toggleblur, {0} },
|
|
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_b, toggleblurfocused,{0} },
|
|
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
|
|
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
|
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
|
diff --git a/dwl.c b/dwl.c
|
|
index 2afec86..9bec152 100644
|
|
--- a/dwl.c
|
|
+++ b/dwl.c
|
|
@@ -12,6 +12,8 @@
|
|
#include <stdlib.h>
|
|
#include <sys/wait.h>
|
|
#include <time.h>
|
|
+#include <scenefx/render/fx_renderer/fx_renderer.h>
|
|
+#include <scenefx/types/wlr_scene.h>
|
|
#include <unistd.h>
|
|
#include <wayland-server-core.h>
|
|
#include <wlr/backend.h>
|
|
@@ -50,7 +52,6 @@
|
|
#include <wlr/types/wlr_primary_selection.h>
|
|
#include <wlr/types/wlr_primary_selection_v1.h>
|
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
|
-#include <wlr/types/wlr_scene.h>
|
|
#include <wlr/types/wlr_screencopy_v1.h>
|
|
#include <wlr/types/wlr_seat.h>
|
|
#include <wlr/types/wlr_server_decoration.h>
|
|
@@ -91,7 +92,7 @@
|
|
enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
|
|
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
|
enum { XDGShell, LayerShell, X11 }; /* client types */
|
|
-enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
|
+enum { LyrBg, LyrBlur, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrIMPopup, LyrBlock, NUM_LAYERS }; /* scene layers */
|
|
enum { AxisUp, AxisRight, AxisDown, AxisLeft };
|
|
enum { ClkTagBar, ClkLtSymbol, ClkStatus, ClkTitle, ClkClient, ClkRoot }; /* clicks */
|
|
|
|
@@ -163,6 +164,7 @@ typedef struct {
|
|
uint32_t tags;
|
|
int isfloating, isurgent, isfullscreen;
|
|
uint32_t resize; /* configure serial of a pending resize */
|
|
+ struct wlr_scene_blur *blur;
|
|
} Client;
|
|
|
|
typedef struct {
|
|
@@ -221,6 +223,7 @@ struct Monitor {
|
|
struct wlr_output *wlr_output;
|
|
struct wlr_scene_output *scene_output;
|
|
struct wlr_scene_buffer *scene_buffer; /* bar buffer */
|
|
+ struct wlr_scene_blur *bar_blur;
|
|
struct wlr_scene_rect *fullscreen_bg; /* See createmon() for info */
|
|
struct wl_listener frame;
|
|
struct wl_listener destroy;
|
|
@@ -247,6 +250,7 @@ struct Monitor {
|
|
Drwl *drw;
|
|
Buffer *pool[2];
|
|
int lrpad;
|
|
+ struct wlr_scene_optimized_blur *blur;
|
|
};
|
|
|
|
typedef struct {
|
|
@@ -387,6 +391,8 @@ static void tag(const Arg *arg);
|
|
static void tagmon(const Arg *arg);
|
|
static void tile(Monitor *m);
|
|
static void togglebar(const Arg *arg);
|
|
+static void toggleblur(const Arg *arg);
|
|
+static void toggleblurfocused(const Arg *arg);
|
|
static void togglefloating(const Arg *arg);
|
|
static void togglefullscreen(const Arg *arg);
|
|
static void toggletag(const Arg *arg);
|
|
@@ -979,6 +985,8 @@ cleanupmon(struct wl_listener *listener, void *data)
|
|
closemon(m);
|
|
wlr_scene_node_destroy(&m->fullscreen_bg->node);
|
|
wlr_scene_node_destroy(&m->scene_buffer->node);
|
|
+ wlr_scene_node_destroy(&m->blur->node);
|
|
+ m->blur = NULL;
|
|
free(m);
|
|
}
|
|
|
|
@@ -1087,6 +1095,7 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|
}
|
|
|
|
arrangelayers(l->mon);
|
|
+ if ((layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
|
}
|
|
|
|
void
|
|
@@ -1120,6 +1129,7 @@ commitnotify(struct wl_listener *listener, void *data)
|
|
/* mark a pending resize as completed */
|
|
if (c->resize && c->resize <= c->surface.xdg->current.configure_serial)
|
|
c->resize = 0;
|
|
+ wlr_scene_blur_set_size(c->blur, c->geom.width, c->geom.height);
|
|
}
|
|
|
|
void
|
|
@@ -1347,6 +1357,16 @@ createmon(struct wl_listener *listener, void *data)
|
|
m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
|
|
wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
|
|
|
|
+ m->blur = wlr_scene_optimized_blur_create(&scene->tree, m->m.width, m->m.height);
|
|
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
|
+ wlr_scene_node_reparent(&m->blur->node, layers[LyrBlur]);
|
|
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
|
+ m->bar_blur = wlr_scene_blur_create(layers[LyrBottom], m->b.real_width, m->b.real_height);
|
|
+ wlr_scene_node_set_position(&m->bar_blur->node, m->m.x, m->m.y);
|
|
+ wlr_scene_node_lower_to_bottom(&m->bar_blur->node);
|
|
+ wlr_scene_blur_set_should_only_blur_bottom_layer(m->bar_blur, true);
|
|
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
|
|
+
|
|
/* Adds this to the output layout in the order it was configured.
|
|
*
|
|
* The output layout utility automatically adds a wl_output global to the
|
|
@@ -2154,6 +2174,11 @@ mapnotify(struct wl_listener *listener, void *data)
|
|
}
|
|
drawbars();
|
|
|
|
+ c->blur = wlr_scene_blur_create(c->scene, c->geom.width, c->geom.height);
|
|
+ wlr_scene_node_lower_to_bottom(&c->blur->node);
|
|
+ wlr_scene_blur_set_should_only_blur_bottom_layer(c->blur, true);
|
|
+ wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
|
+
|
|
unset_fullscreen:
|
|
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
|
|
wl_list_for_each(w, &clients, link) {
|
|
@@ -2785,11 +2810,13 @@ setup(void)
|
|
drag_icon = wlr_scene_tree_create(&scene->tree);
|
|
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
|
|
|
+ wlr_scene_set_blur_data(scene, blur_params);
|
|
+
|
|
/* Autocreates a renderer, either Pixman, GLES2 or Vulkan for us. The user
|
|
* can also specify a renderer using the WLR_RENDERER env var.
|
|
* The renderer is responsible for defining the various pixel formats it
|
|
* supports for shared memory, this configures that for clients. */
|
|
- if (!(drw = wlr_renderer_autocreate(backend)))
|
|
+ if (!(drw = fx_renderer_create(backend)))
|
|
die("couldn't create renderer");
|
|
wl_signal_add(&drw->events.lost, &gpu_reset);
|
|
|
|
@@ -3108,6 +3135,22 @@ togglebar(const Arg *arg)
|
|
drawbars();
|
|
}
|
|
|
|
+void toggleblur(const Arg *arg) {
|
|
+ Client *c;
|
|
+ Monitor *m = NULL;
|
|
+ blur_enabled = !blur_enabled;
|
|
+ wl_list_for_each(m, &mons, link) {
|
|
+ wlr_scene_node_set_enabled(&m->blur->node, blur_enabled);
|
|
+ wlr_scene_node_set_enabled(&m->bar_blur->node, blur_enabled);
|
|
+ }
|
|
+ wl_list_for_each(c, &clients, link) wlr_scene_node_set_enabled(&c->blur->node, blur_enabled);
|
|
+}
|
|
+
|
|
+void toggleblurfocused(const Arg *arg) {
|
|
+ Client *sel = focustop(selmon);
|
|
+ if (sel && sel->blur) wlr_scene_node_set_enabled(&sel->blur->node, !sel->blur->node.enabled);
|
|
+}
|
|
+
|
|
void
|
|
togglefloating(const Arg *arg)
|
|
{
|
|
@@ -3172,6 +3215,7 @@ unmaplayersurfacenotify(struct wl_listener *listener, void *data)
|
|
arrangelayers(l->mon);
|
|
if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
|
|
focusclient(focustop(selmon), 1);
|
|
+ if ((l->layer_surface->current.layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) && (l->mon)) wlr_scene_optimized_blur_mark_dirty(l->mon->blur);
|
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
}
|
|
|
|
@@ -3274,6 +3318,9 @@ updatemons(struct wl_listener *listener, void *data)
|
|
wlr_scene_node_set_position(&m->fullscreen_bg->node, m->m.x, m->m.y);
|
|
wlr_scene_rect_set_size(m->fullscreen_bg, m->m.width, m->m.height);
|
|
|
|
+ wlr_scene_node_set_position(&m->blur->node, m->m.x, m->m.y);
|
|
+ wlr_scene_optimized_blur_set_size(m->blur, m->m.width, m->m.height);
|
|
+
|
|
if (m->lock_surface) {
|
|
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
|
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|