RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
added window border glow
oxydizer9c985cfbdb5b
diff --git a/assets/themes/redi-blue.toml b/assets/themes/redi-blue.tomlindex 94816f0..bb25bc2 100644--- a/assets/themes/redi-blue.toml+++ b/assets/themes/redi-blue.toml@@ -51,6 +51,7 @@ border_focus = "rgba(0,209,255,0.45)"glass = "rgba(8,20,38,0.62)"glass_strong = "rgba(8,18,32,0.82)"shadow = "rgba(0,0,0,0.55)"+border_glow = "rgba(0,209,255,0.50)"# Taskbartaskbar_bg = "rgba(10,20,38,0.96)"diff --git a/assets/themes/redi-mocha.toml b/assets/themes/redi-mocha.tomlindex 50beb67..1876369 100644--- a/assets/themes/redi-mocha.toml+++ b/assets/themes/redi-mocha.toml@@ -60,6 +60,7 @@ border_focus = "#cba6f7"glass = "rgba(30,30,46,0.56)"glass_strong = "rgba(24,24,37,0.74)"shadow = "rgba(17,17,27,0.55)"+border_glow = "rgba(203,166,247,0.55)"# Taskbar and shared controlstaskbar_bg = "rgba(24,24,37,0.96)"diff --git a/assets/themes/rediwm-dark.toml b/assets/themes/rediwm-dark.tomlindex 3676fd4..a13c2b5 100644--- a/assets/themes/rediwm-dark.toml+++ b/assets/themes/rediwm-dark.toml@@ -74,6 +74,7 @@ on_accent = "rgba(8,33,28,1.000)"field_bg = "rgba(21,26,31,1.000)"field_border = "rgba(63,70,77,1.000)"shadow = "rgba(0,0,0,0.350)"+border_glow = "rgba(237,27,46,0.600)"start_menu_bg = "rgba(29,34,41,0.980)"start_menu_border = "rgba(255,255,255,0.120)"start_menu_search_bg = "rgba(21,26,31,1.000)"diff --git a/assets/themes/rediwm-light.toml b/assets/themes/rediwm-light.tomlindex 6bf1fb1..a66f5f0 100644--- a/assets/themes/rediwm-light.toml+++ b/assets/themes/rediwm-light.toml@@ -76,6 +76,7 @@ border_focus = "rgba(14,165,160,0.35)"glass = "rgba(255,255,255,0.62)"glass_strong = "rgba(255,255,255,0.82)"shadow = "rgba(0,0,0,0.12)"+border_glow = "rgba(14,165,160,0.45)"# Taskbartaskbar_bg = "rgba(241,244,247,0.94)"diff --git a/docs/wiki/Theme.md b/docs/wiki/Theme.mdindex 9127093..8ac7f23 100644--- a/docs/wiki/Theme.md+++ b/docs/wiki/Theme.md@@ -175,6 +175,8 @@ geometry retain their content or structural dimensions.| `field_border` | `"rgba(63,70,77,1)"` || `field_border_focus` | `unset` || `shadow` | `"rgba(0,0,0,0.35)"` |+| `border_glow_enabled` | `true` |+| `border_glow` | `"rgba(237,27,46,0.6)"` (alpha 0 turns the highlight off) || `start_menu_bg` | `"rgba(29,34,41,0.98)"` || `start_menu_border` | `"rgba(255,255,255,0.12)"` || `start_menu_search_bg` | `"rgba(21,26,31,1)"` |@@ -287,6 +289,9 @@ Numeric tokens accept 0–4096 unless constrained below. Fractions ending in| `field_radius` | `8.0` || `shadow_size` | `24.0` || `shadow_offset_y` | `8.0` |+| `border_glow_length` | `72.0` |+| `border_glow_reach` | `56.0` |+| `border_glow_depth` | `3.0` || `start_menu_width` | `0` (automatic) || `start_menu_max_height` | `0` (automatic) || `start_menu_radius` | `14.0` |diff --git a/src/Input.zig b/src/Input.zigindex b47bb60..0a5f8a7 100644--- a/src/Input.zig+++ b/src/Input.zig@@ -158,6 +158,8 @@ cursor_hold_end: wl.Listener(*wlr.Pointer.event.HoldEnd) = .init(cursorHoldEnd),cursor_mode: enum { passthrough, move, resize, pan } = .passthrough,hovered_toplevel: ?*Toplevel = null,+/// The window whose edge highlight follows the pointer (`updateBorderGlow`).+glow_toplevel: ?*Toplevel = null,hovered_taskbar: ?*Taskbar = null,tray_buttons: u32 = 0,hovered_toast: ?*@import("notifications/toast.zig").Toast = null,@@ -1119,6 +1121,7 @@ pub fn detachOutput(input: *Input, output: *Output) void {pub fn detachToplevel(input: *Input, toplevel: *Toplevel) void {if (input.window_menu.target == toplevel) input.window_menu.close();if (input.hovered_toplevel == toplevel) input.hovered_toplevel = null;+ if (input.glow_toplevel == toplevel) input.glow_toplevel = null;input.drag_dodge.detach(toplevel);if (input.grabbed_toplevel == toplevel) input.clearGrab();if (input.resize_session) |session| {@@ -1521,6 +1524,7 @@ fn passthroughMotion(input: *Input, time_msec: u32) void {}}const hit = scene_data.hitTest(input.server, input.cursor.x, input.cursor.y);+ input.updateBorderGlow(hit);if (hit != .toast) {input.clearToastHover();}@@ -2216,6 +2220,26 @@ fn processClientButton(}}+/// The focused window's edge lights up where the pointer nears it, unless+/// something else (another window, shell UI) is under the pointer.+fn updateBorderGlow(input: *Input, hit: scene_data.Hit) void {+ var target: ?*Toplevel = null;+ if (@import("config_runtime/actions.zig").focusedToplevel(input.server)) |top| {+ const clear = switch (hit) {+ .none, .layer, .desktop => true,+ .chrome => |h| h.toplevel == top,+ .surface => |h| h.toplevel == top,+ else => false,+ };+ if (clear) target = top;+ }+ if (input.glow_toplevel) |previous| {+ if (previous != target) previous.setGlow(null);+ }+ input.glow_toplevel = target;+ if (target) |top| top.setGlow(top.glowProbe(input.cursor.x, input.cursor.y));+}+pub fn setHover(input: *Input, toplevel: ?*Toplevel, control: ?chrome.ControlKind) void {if (input.hovered_toplevel) |previous| {if (previous != toplevel) previous.applyHover(false, null);diff --git a/src/Toplevel.zig b/src/Toplevel.zigindex d4313dc..513e294 100644--- a/src/Toplevel.zig+++ b/src/Toplevel.zig@@ -31,6 +31,7 @@ const window_rules = @import("config").window_rules;const loader = @import("config").loader;const actions = @import("config_runtime/actions.zig");const anim = @import("ui").anim;+const border_glow = @import("border_glow.zig");const window_sizes = @import("window_sizes.zig");const placeholder_match = @import("placeholder_match.zig");const applications = @import("start_menu/applications.zig");@@ -249,6 +250,13 @@ hover_anim: anim.Anim = .{},chip_pos: anim.Anim = .{},chip_alpha: anim.Anim = .{ .property = .opacity },last_painted_hover: f32 = 0,+/// Edge highlight near the pointer (`setGlow`): `glow_anim` is its strength,+/// eased toward `glow_near`, and (`glow_x`, `glow_y`) the point of the frame's+/// edge it is centred on, in frame units.+glow_anim: anim.Anim = .{ .property = .opacity },+glow_near: f32 = 0,+glow_x: f32 = 0,+glow_y: f32 = 0,/// The window opacity the border colour of the shape was last given, so a/// hover or focus repaint keeps the ring as faded as the body.shape_opacity: f32 = 1,@@ -1102,6 +1110,7 @@ fn syncXwaylandStack(toplevel: *Toplevel) void {pub fn setActivated(toplevel: *Toplevel, activated: bool) void {const changed = toplevel.activated != activated;toplevel.activated = activated;+ if (!activated) toplevel.setGlow(null);if (toplevel.wlr_foreign) |handle| handle.setActivated(activated);switch (toplevel.backend) {.xdg => |*adapter| _ = adapter.xdg_toplevel.setActivated(activated),@@ -2848,13 +2857,24 @@ fn applyShape(toplevel: *Toplevel) void {}const radius: f64 = toplevel.cornerRadius();const ring = toplevel.borderColor().scale(toplevel.shape_opacity);- if (!projection.setTreeClip(node, .{+ var spec: projection.ClipSpec = .{.width = toplevel.chrome_width,.height = toplevel.chrome_height,.radii = .{ radius, radius, radius, radius },.border = @floatFromInt(chrome.frame_border),.border_color = ring.rgba,- })) {+ };+ const t = theme.global;+ const glow = toplevel.glow_anim.value(nowMs()) * toplevel.shape_opacity;+ if (t.border_glow_enabled and glow * t.border_glow[3] >= 0.004) {+ const density = toplevel.chromeDensity();+ spec.glow_x = toplevel.glow_x;+ spec.glow_y = toplevel.glow_y;+ spec.glow_radius = @max(0.5 * t.border_glow_length * density, 1);+ spec.glow_depth = @max(t.border_glow_depth * density, 0);+ spec.glow_color = col.Straight.fromRgba(t.border_glow).premultiply().scale(glow).rgba;+ }+ if (!projection.setTreeClip(node, spec)) {log.warn("could not set the window shape ({d}x{d})", .{ toplevel.chrome_width, toplevel.chrome_height });}}@@ -2980,6 +3000,54 @@ fn resetChip(toplevel: *Toplevel) void {toplevel.chip_alpha.cancel(0);}+/// The pointer's place relative to this window's frame, or null away from it+/// (`border_glow.probe`; `lx`, `ly` in layout space).+pub fn glowProbe(toplevel: *const Toplevel, lx: f64, ly: f64) ?border_glow.Probe {+ if (!chrome.shapes or !theme.global.border_glow_enabled or theme.global.border_glow[3] <= 0) return null;+ if (!toplevel.hasServerDecorations() or toplevel.isMaximized() or toplevel.isFullscreen()) return null;+ const density = toplevel.chromeDensity();+ const local = toplevel.frameLocal(lx, ly);+ return border_glow.probe(+ @floatFromInt(toplevel.chrome_width),+ @floatFromInt(toplevel.chrome_height),+ toplevel.cornerRadius(),+ @floatCast(local.x),+ @floatCast(local.y),+ theme.global.border_glow_reach * density,+ );+}++/// Shows the highlight of the frame's edge at `probe` (null: fades it out). Only+/// a change of strength or of the whole-pixel place repaints, so a still pointer+/// costs nothing and the focused window alone ever calls this with a probe.+pub fn setGlow(toplevel: *Toplevel, probe: ?border_glow.Probe) void {+ const near: f32 = if (probe) |p| @round(p.near * 64) / 64 else 0;+ const now = nowMs();+ var changed = false;+ if (near != toplevel.glow_near) {+ toplevel.glow_near = near;+ toplevel.glow_anim.retargetTo(now, near, anim.curveFor(.titlebar_hover));+ changed = true;+ }+ if (probe) |p| {+ const x = @round(p.x);+ const y = @round(p.y);+ if (near > 0 and (x != toplevel.glow_x or y != toplevel.glow_y)) {+ toplevel.glow_x = x;+ toplevel.glow_y = y;+ changed = true;+ }+ }+ if (!changed) return;+ toplevel.applyShape();+ toplevel.server.scheduleFrames();+}++pub fn tickGlow(toplevel: *Toplevel, now_ms: i64) bool {+ if (toplevel.glow_anim.sampleChanged(now_ms, anim.rasterAlphaQuantum())) toplevel.applyShape();+ return !toplevel.glow_anim.settled(now_ms);+}+pub fn tickHover(toplevel: *Toplevel, now_ms: i64) bool {// Every sampler must run each frame (they track their own last value).const border = toplevel.hover_anim.sampleChanged(now_ms, anim.rasterAlphaQuantum());diff --git a/src/World.zig b/src/World.zigindex 9e253e3..eb267a0 100644--- a/src/World.zig+++ b/src/World.zig@@ -273,6 +273,7 @@ pub fn tickHover(world: *World, now_ms: i64) bool {while (it.next()) |toplevel| {if (focused != toplevel) toplevel.setZoomBoost(false);if (toplevel.tickHover(now_ms)) animating = true;+ if (toplevel.tickGlow(now_ms)) animating = true;if (toplevel.tickZoom(now_ms)) animating = true;if (toplevel.tickZoomBoost(now_ms)) animating = true;if (toplevel.tickMap(now_ms)) animating = true;diff --git a/src/border_glow.zig b/src/border_glow.zignew file mode 100644index 0000000..a418043--- /dev/null+++ b/src/border_glow.zig@@ -0,0 +1,42 @@+//! Where the pointer is relative to a window's edge, for the highlight the frame+//! shows near it (`Toplevel.setGlow`). Pure geometry, in frame units.+const std = @import("std");++pub const Probe = struct {+ /// 0 at `reach` from the edge or beyond, 1 on it, eased.+ near: f32,+ /// The point of the edge closest to the pointer.+ x: f32,+ y: f32,+};++/// The frame is `width` by `height` at the origin with corner `radius`. Null when+/// the pointer is `reach` or more from the edge, on either side of it.+pub fn probe(width: f32, height: f32, radius: f32, px: f32, py: f32, reach: f32) ?Probe {+ if (!(reach > 0) or !(width > 0) or !(height > 0)) return null;+ const r = @min(radius, 0.5 * @min(width, height));+ const qx = @abs(px - 0.5 * width) - (0.5 * width - r);+ const qy = @abs(py - 0.5 * height) - (0.5 * height - r);+ const outside = std.math.hypot(@max(qx, 0), @max(qy, 0));+ const distance = @abs(outside + @min(@max(qx, qy), 0) - r);+ if (!(distance < reach)) return null;++ var ex: f32 = undefined;+ var ey: f32 = undefined;+ if (px < 0 or px > width or py < 0 or py > height) {+ ex = std.math.clamp(px, 0, width);+ ey = std.math.clamp(py, 0, height);+ } else {+ // Inside: the nearest side.+ const to_left = px;+ const to_right = width - px;+ const to_top = py;+ const to_bottom = height - py;+ const nearest = @min(@min(to_left, to_right), @min(to_top, to_bottom));+ ex = px;+ ey = py;+ if (nearest == to_left) ex = 0 else if (nearest == to_right) ex = width else if (nearest == to_top) ey = 0 else ey = height;+ }+ const n = 1 - distance / reach;+ return .{ .near = n * n * (3 - 2 * n), .x = ex, .y = ey };+}diff --git a/src/control_center/sections/appearance.zig b/src/control_center/sections/appearance.zigindex 6e827e6..2c5fe9a 100644--- a/src/control_center/sections/appearance.zig+++ b/src/control_center/sections/appearance.zig@@ -102,7 +102,7 @@ pub const Section = struct {cursor_themes: ?[]cursor_theme.Theme = null,cursor_row_children: [2]Widget = undefined,family_row_children: [2]Widget = undefined,- row_storage: [26]Widget = undefined,+ row_storage: [27]Widget = undefined,dock_children: [2]Widget = undefined,dock_group_children: [2]Widget = undefined,focus_zoom_children: [3]Widget = undefined,@@ -147,6 +147,8 @@ pub const Section = struct {font_row_children: [2]Widget = undefined,radius_row_children: [2]Widget = undefined,shadow_row_children: [2]Widget = undefined,+ glow_row_children: [2]Widget = undefined,+ glow_label_children: [2]Widget = undefined,opacity_header_children: [2]Widget = undefined,opacity_group_children: [2]Widget = undefined,opacity_value_buf: [16]u8 = undefined,@@ -534,6 +536,15 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {},};+ out.glow_label_children = .{+ .{ .kind = .{ .text = .{ .content = "Edge glow", .font_size = 13, .weight = 600, .color = pal.fg } } },+ .{ .kind = .{ .text = .{ .content = "Light the active window's edge near the pointer", .font_size = 12, .color = pal.dim } } },+ };+ out.glow_row_children = .{+ .{ .kind = .container, .direction = .column, .gap = 2, .width = .{ .flex = 1 }, .children = &out.glow_label_children },+ .{ .name = "border_glow", .kind = .{ .toggle = .{ .on = t.border_glow_enabled, .owner = out, .on_change = &onBorderGlowChanged } } },+ };+const opacity_val = std.math.clamp(t.window_bg[3], 0.0, 1.0);const opacity_formatted = std.fmt.bufPrint(&out.opacity_value_buf, "{d}%", .{@as(i32, @intFromFloat(@round(opacity_val * 100.0)))}) catch "?";out.opacity_header_children = .{ labelWidget("Window chrome opacity"), pillWidget(opacity_formatted) };@@ -760,6 +771,7 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {.{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.font_row_children },.{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.radius_row_children },.{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.shadow_row_children },+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.glow_row_children },chrome_row,buildWindowTabs(out),inactive_opacity_row,@@ -1393,6 +1405,12 @@ fn onShadowChanged(owner: ?*anyopaque, _: usize, index: usize) void {applyThemeChange(section(owner));}+fn onBorderGlowChanged(owner: ?*anyopaque, _: usize, on: bool) void {+ if (theme.global.border_glow_enabled == on) return;+ theme.global.border_glow_enabled = on;+ applyThemeChange(section(owner));+}+fn onChromeOpacityChanged(owner: ?*anyopaque, _: usize, value: f32) void {const s = section(owner);const clamped = std.math.clamp(value, 0.0, 1.0);diff --git a/src/projection.c b/src/projection.cindex a3043fc..aed044b 100644--- a/src/projection.c+++ b/src/projection.c@@ -196,7 +196,12 @@ bool rediwm_projection_set_tree_clip(struct wlr_scene_node *node,}if (spec->width <= 0 || spec->height <= 0 || !finite_at_least_zero(spec->border)) return false;for (int i = 0; i < 4; i++)- if (!finite_at_least_zero(spec->radii[i]) || !isfinite(spec->border_color[i])) return false;+ if (!finite_at_least_zero(spec->radii[i]) || !isfinite(spec->border_color[i]) ||+ !isfinite(spec->glow_color[i]))+ return false;+ if (!isfinite(spec->glow_x) || !isfinite(spec->glow_y) || !finite_at_least_zero(spec->glow_radius) ||+ !finite_at_least_zero(spec->glow_depth))+ return false;struct tree_props *props = tree_props_get(node);if (!props) return false;props->clip = *spec;@@ -495,13 +500,30 @@ static bool clip_same_shape(const struct rediwm_clip *a, const struct rediwm_cliif (a->radii[i] != b->radii[i] || a->border_color[i] != b->border_color[i]) return false;return true;}-static void clip_rim(pixman_region32_t *out, const struct rediwm_clip *c) {+// Where the highlight is, as far as it can be seen: a square around its point.+static bool clip_glow_box(const struct rediwm_clip *c, pixman_box32_t *out) {+ if (c->glow_radius <= 0 || c->glow_color[3] <= 0) return false;+ const double reach = c->glow_radius + 1;+ *out = (pixman_box32_t){(int)floor(c->glow_x - reach), (int)floor(c->glow_y - reach),+ (int)ceil(c->glow_x + reach), (int)ceil(c->glow_y + reach)};+ return true;+}+static bool clip_same_glow(const struct rediwm_clip *a, const struct rediwm_clip *b) {+ if (a->glow_radius != b->glow_radius || a->glow_depth != b->glow_depth) return false;+ if (a->glow_radius <= 0) return true;+ if (a->glow_x != b->glow_x || a->glow_y != b->glow_y) return false;+ for (int i = 0; i < 4; i++)+ if (a->glow_color[i] != b->glow_color[i]) return false;+ return true;+}+// `only` limits the rim to a box (a moved highlight changes nothing else).+static void clip_rim(pixman_region32_t *out, const struct rediwm_clip *c, const pixman_box32_t *only) {const struct rediwm_snap f = rediwm_edges_snap(c->edges);if (f.width <= 0 || f.height <= 0) return;double radius = 0;for (int i = 0; i < 4; i++)if (c->radii[i] > radius) radius = c->radii[i];- const int inset = (int)ceil(radius) + (int)ceil(c->border) + 2;+ const int inset = (int)ceil(radius) + (int)ceil(c->border) + (int)ceil(c->glow_depth) + 2;pixman_region32_t rim;pixman_region32_init_rect(&rim, f.x, f.y, f.width, f.height);if (f.width > 2 * inset && f.height > 2 * inset) {@@ -511,6 +533,7 @@ static void clip_rim(pixman_region32_t *out, const struct rediwm_clip *c) {pixman_region32_subtract(&rim, &rim, &inner);pixman_region32_fini(&inner);}+ if (only) pixman_region32_intersect_rect(&rim, &rim, only->x1, only->y1, only->x2 - only->x1, only->y2 - only->y1);pixman_region32_union(out, out, &rim);pixman_region32_fini(&rim);}@@ -518,8 +541,15 @@ static void damage_clip_change(struct rediwm_projection *p, const struct rediwm_const struct rediwm_clip *after) {pixman_region32_t region;pixman_region32_init(®ion);- if (before) clip_rim(®ion, before);- if (after) clip_rim(®ion, after);+ if (before && after && clip_same_shape(before, after)) {+ // Only the highlight changed: its old and new places.+ pixman_box32_t box;+ if (clip_glow_box(before, &box)) clip_rim(®ion, before, &box);+ if (clip_glow_box(after, &box)) clip_rim(®ion, after, &box);+ } else {+ if (before) clip_rim(®ion, before, NULL);+ if (after) clip_rim(®ion, after, NULL);+ }pixman_region32_union(&p->pending, &p->pending, ®ion);pixman_region32_fini(®ion);}@@ -548,7 +578,8 @@ static void resolve_node(struct rediwm_projection *p, struct group *g,here = rediwm_clip_resolve(t, x, y, &props->clip);clip = &here;// A hidden window damages nothing; showing it will.- if (enabled && (!props->has_applied || !clip_same_shape(&props->applied, &here)))+ if (enabled && (!props->has_applied || !clip_same_shape(&props->applied, &here) ||+ !clip_same_glow(&props->applied, &here)))damage_clip_change(p, props->has_applied ? &props->applied : NULL, &here);props->applied = here;props->has_applied = true;diff --git a/src/projection.zig b/src/projection.zigindex 42cd52e..83480bc 100644--- a/src/projection.zig+++ b/src/projection.zig@@ -44,6 +44,13 @@ pub const ClipSpec = extern struct {radii: [4]f64,border: f64,border_color: [4]f32,+ /// A highlight on the edge near a point of the tree (see scene_graph.h);+ /// `glow_color` is premultiplied, opacity applied. No radius, no highlight.+ glow_x: f64 = 0,+ glow_y: f64 = 0,+ glow_radius: f64 = 0,+ glow_depth: f64 = 0,+ glow_color: [4]f32 = .{ 0, 0, 0, 0 },};extern fn rediwm_projection_set_tree_clip(node: *wlr.SceneNode, spec: ?*const ClipSpec) bool;/// A null spec removes the clip. False for a size that is not positive or adiff --git a/src/projection_test.c b/src/projection_test.cindex 815b59d..368b30c 100644--- a/src/projection_test.c+++ b/src/projection_test.c@@ -390,8 +390,8 @@ static void test_clip_opaque(void) {// pill keeps the full-height column between its two semicircles.struct rediwm_snap one[3];const struct rediwm_xform identity = {1, 0, 0};- assert(rediwm_clip_opaque(&(struct rediwm_clip){rediwm_xform_rect(identity, 0, 0, 8, 8), {4, 4, 4, 4}, 0, {0}}, one) == 0);- assert(rediwm_clip_opaque(&(struct rediwm_clip){rediwm_xform_rect(identity, 5, 7, 120, 80), {40, 40, 40, 40}, 0, {0}}, one) == 1);+ assert(rediwm_clip_opaque(&(struct rediwm_clip){rediwm_xform_rect(identity, 0, 0, 8, 8), {4, 4, 4, 4}, 0, {0}, 0, 0, 0, 0, {0}}, one) == 0);+ assert(rediwm_clip_opaque(&(struct rediwm_clip){rediwm_xform_rect(identity, 5, 7, 120, 80), {40, 40, 40, 40}, 0, {0}, 0, 0, 0, 0, {0}}, one) == 1);assert(one[0].x == 5 + 42 && one[0].y == 7 && one[0].width == 120 - 84 && one[0].height == 80);}static void test_clip_projection(struct wlr_scene *scene) {diff --git a/src/scene_graph.h b/src/scene_graph.hindex d461304..3af505a 100644--- a/src/scene_graph.h+++ b/src/scene_graph.h@@ -81,12 +81,21 @@ struct rediwm_clip_spec {// Premultiplied, with the window's opacity already applied: the ring is// composited over the body, so a translucent border tints what is under it.float border_color[4];+ // A highlight on the frame's edge near a point: `glow_color` (premultiplied,+ // opacity applied) fades out with the distance from (glow_x, glow_y), in the+ // tree's own units, to `glow_radius`, and reaches `glow_depth` inward past the+ // ring. A radius of 0 draws none.+ double glow_x, glow_y, glow_radius, glow_depth;+ float glow_color[4];};struct rediwm_clip {struct rediwm_edges edges;double radii[4];double border;float border_color[4];+ // In layout space, like the edges.+ double glow_x, glow_y, glow_radius, glow_depth;+ float glow_color[4];};// Radii are capped at half the short side before scaling, as the CPU chrome// does, so a small window never asks for an impossible arc.@@ -100,6 +109,13 @@ static inline struct rediwm_clip rediwm_clip_resolve(struct rediwm_xform t, doubfor (int i = 0; i < 4; i++)clip.radii[i] = (spec->radii[i] < cap ? spec->radii[i] : cap) * t.scale;for (int i = 0; i < 4; i++) clip.border_color[i] = spec->border_color[i];+ if (spec->glow_radius > 0) {+ clip.glow_x = clip.edges.x1 + spec->glow_x * t.scale;+ clip.glow_y = clip.edges.y1 + spec->glow_y * t.scale;+ clip.glow_radius = spec->glow_radius * t.scale;+ clip.glow_depth = spec->glow_depth * t.scale;+ for (int i = 0; i < 4; i++) clip.glow_color[i] = spec->glow_color[i];+ }return clip;}// Signed distance, negative inside, from (px, py) to the rounded rectanglediff --git a/src/scene_output.c b/src/scene_output.cindex ebb0eaa..9645751 100644--- a/src/scene_output.c+++ b/src/scene_output.c@@ -10,6 +10,7 @@#include "glass.h"#include <math.h>#include <stdlib.h>+#include <string.h>#ifdef REDIWM_DAMAGE_AUDIT#include <drm_fourcc.h>#include <wlr/render/allocator.h>@@ -185,6 +186,19 @@ static void shape_for(struct rediwm_pass_shape *s, const struct rediwm_clip *c,device_radii(s->radii, radii, v->transform);s->border = c->border > 0 ? fmaxf(1.f, roundf((float)(c->border * v->scale))) : 0.f;for (int i = 0; i < 4; i++) s->border_color[i] = c->border_color[i];+ s->glow_radius = s->glow_depth = 0;+ memset(s->glow_center, 0, sizeof(s->glow_center));+ memset(s->glow_color, 0, sizeof(s->glow_color));+ if (c->glow_radius > 0 && c->glow_color[3] > 0) {+ // The highlight's point goes through the same transform as the box, as a+ // one-pixel box (the loss is under a layout pixel, far inside its radius).+ const struct wlr_box at = device_box((struct wlr_box){(int)floor(c->glow_x), (int)floor(c->glow_y), 1, 1}, v);+ s->glow_center[0] = at.x + at.width * .5f - s->box.x;+ s->glow_center[1] = at.y + at.height * .5f - s->box.y;+ s->glow_radius = (float)(c->glow_radius * v->scale);+ s->glow_depth = (float)(c->glow_depth * v->scale);+ for (int i = 0; i < 4; i++) s->glow_color[i] = c->glow_color[i];+ }}// What of a clipped item may be drawn without the shape and without blending: the// model's opaque cover, minus a margin around the edge where the ring is drawn.@@ -682,7 +696,7 @@ static bool render_entry(struct rediwm_output_renderer *r, struct entry *e, stru// window for what a rim of a few shaded pixels costs far less than: draws// dominated the output build in a drag.float depth = fmaxf(fmaxf(shape.radii[0], shape.radii[1]), fmaxf(shape.radii[2], shape.radii[3]));- const int inset = (int)ceilf(fmaxf(depth, shape.border)) + REDIWM_CLIP_OPAQUE_MARGIN;+ const int inset = (int)ceilf(fmaxf(depth, shape.border + shape.glow_depth)) + REDIWM_CLIP_OPAQUE_MARGIN;if (shape.box.width > 2 * inset && shape.box.height > 2 * inset)pixman_region32_intersect_rect(&core, &core, shape.box.x + inset, shape.box.y + inset,shape.box.width - 2 * inset, shape.box.height - 2 * inset);diff --git a/src/scene_pass.c b/src/scene_pass.cindex dc57815..02fa3bb 100644--- a/src/scene_pass.c+++ b/src/scene_pass.c@@ -22,7 +22,7 @@ struct program {unsigned bit; // which bit of pass.targets_set tracks this program's target sizeGLint target, dst, color, alpha, opaque, sampler, coords;// Shaped programs only (-1 elsewhere): the shape, and the shadow's own terms.- GLint mode, origin, size, radii, border, bcolor, offset, softness, hide, use_shape;+ GLint mode, origin, size, radii, border, bcolor, glow, gcolor, offset, softness, hide, use_shape;// The backdrop composite (shaped mode 3) and the blur program.GLint bmap, fmap, saturation, front, front_alpha, has_front;GLint step_uv, sigma, limits, src_scale;@@ -171,7 +171,7 @@ static const char shaped_vertex[] =#define SHAPED_HEAD \"#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n" \"varying vec2 uv; varying vec2 local; uniform vec2 size; uniform vec4 radii, bcolor, color;" \- "uniform float border;" \+ "uniform float border; uniform vec4 glow, gcolor;" \"float sdf(vec2 p, vec4 r){ vec2 q=p-size*.5;" \"float rad=q.x<0.?(q.y<0.?r.x:r.w):(q.y<0.?r.y:r.z);" \"rad=clamp(rad,0.,min(size.x,size.y)*.5);" \@@ -212,7 +212,13 @@ static const char shaped_fragment[] = SHAPED_HEAD"if(use_shape<.5){ gl_FragColor=c; return; }""float d=sdf(local,radii);""float w=border>0.?1.-cov(d+border):0.;"- "gl_FragColor=(c*(1.-bcolor.a*w)+bcolor*w)*cov(d); }";+ "vec4 o=c*(1.-bcolor.a*w)+bcolor*w;"+ // The highlight (a smoothstep of the distance from its point), over the ring+ // and, when it has depth, fading inward past it.+ "if(glow.z>0.){ float g=clamp(1.-length(local-glow.xy)/glow.z,0.,1.); g=g*g*(3.-2.*g);"+ "float t=glow.w>0.?1.-smoothstep(0.,1.,(-d-border)/glow.w):w;"+ "o=o*(1.-gcolor.a*g*t)+gcolor*(g*t); }"+ "gl_FragColor=o*cov(d); }";// The backdrop blur (stage 5b): glass.c's kernel, 49 taps, sigma in texels of the// target, reading a source texture that may be larger than the region (scratch),@@ -285,6 +291,8 @@ static bool program_init(struct program *p, unsigned bit, const char *vertex_soup->radii = glGetUniformLocation(p->id, "radii");p->border = glGetUniformLocation(p->id, "border");p->bcolor = glGetUniformLocation(p->id, "bcolor");+ p->glow = glGetUniformLocation(p->id, "glow");+ p->gcolor = glGetUniformLocation(p->id, "gcolor");p->offset = glGetUniformLocation(p->id, "offset");p->softness = glGetUniformLocation(p->id, "softness");p->hide = glGetUniformLocation(p->id, "hide");@@ -423,8 +431,9 @@ static void draw(const struct pass *p, const pixman_region32_t *clip) {static bool shape_usable(const struct rediwm_pass_shape *s) {if (!isfinite(s->border) || s->border < 0) return false;for (int i = 0; i < 4; i++) if (!isfinite(s->radii[i]) || s->radii[i] < 0) return false;- for (int i = 0; i < 4; i++) if (!isfinite(s->border_color[i])) return false;- return true;+ for (int i = 0; i < 4; i++) if (!isfinite(s->border_color[i]) || !isfinite(s->glow_color[i])) return false;+ return isfinite(s->glow_radius) && isfinite(s->glow_depth) && s->glow_radius >= 0 && s->glow_depth >= 0 &&+ isfinite(s->glow_center[0]) && isfinite(s->glow_center[1]);}static void set_shape(const struct pass *p, const struct program *g, const struct rediwm_pass_shape *s) {glUniform1f(g->use_shape, 1.f);@@ -435,6 +444,8 @@ static void set_shape(const struct pass *p, const struct program *g, const strucglUniform1f(g->border, s->border);glUniform4f(g->bcolor, s->border_color[0], s->border_color[1], s->border_color[2],s->border_color[3]);+ glUniform4f(g->glow, s->glow_center[0], s->glow_center[1], s->glow_radius, s->glow_depth);+ glUniform4f(g->gcolor, s->glow_color[0], s->glow_color[1], s->glow_color[2], s->glow_color[3]);}static void add_rect(struct wlr_render_pass *base, const struct wlr_render_rect_options *o) {struct pass *p = wl_container_of(base, p, base);diff --git a/src/scene_pass.h b/src/scene_pass.hindex 84e7f69..136134f 100644--- a/src/scene_pass.h+++ b/src/scene_pass.h@@ -39,6 +39,12 @@ struct rediwm_pass_shape {// 0 draws no ring.float border;float border_color[4]; // premultiplied+ // A highlight over the ring near `glow_center` (device pixels from the box's+ // corner): `glow_color` (premultiplied) fades with the distance to+ // `glow_radius`, and past the ring it reaches `glow_depth` inward. 0 radius: none.+ float glow_center[2];+ float glow_radius, glow_depth;+ float glow_color[4];};struct rediwm_pass_shadow {float offset_x, offset_y; // how far the shadow is shifted from the shapediff --git a/src/ui/theme.zig b/src/ui/theme.zigindex 7a84b54..113c862 100644--- a/src/ui/theme.zig+++ b/src/ui/theme.zig@@ -130,6 +130,14 @@ pub const Theme = struct {field_border_focus: ?[4]f32 = null,field_radius: f32 = 8.0,shadow: [4]f32 = .{ 0, 0, 0, 0.35 },+ /// Highlight on the focused window's edge where the pointer comes near+ /// (`Toplevel.setGlow`). Its alpha is the strength at full proximity; zero+ /// turns it off.+ border_glow_enabled: bool = true,+ border_glow: [4]f32 = .{ 237.0 / 255.0, 27.0 / 255.0, 46.0 / 255.0, 0.60 },+ border_glow_length: f32 = 72.0, // along the edge, logical px; fades out smoothly+ border_glow_reach: f32 = 56.0, // pointer distance from the edge where it appears+ border_glow_depth: f32 = 3.0, // how far it bleeds inward past the 1 px ringshadow_size: f32 = 24.0, // blur/softness radius, logical pxshadow_offset_y: f32 = 8.0, // vertical offset, logical px// 0 sizes the menu to the output (`start_menu/size.zig`); set either to pin it.