Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

Keep desktop proximity glow live over overlays

Petar Margetićfb776ce50ee7
diff --git a/src/desktop/app_pointer.zig b/src/desktop/app_pointer.zig
index 329cb0e..13aabc8 100644
--- a/src/desktop/app_pointer.zig
+++ b/src/desktop/app_pointer.zig
@@ -47,6 +47,18 @@ fn damageProximityAt(self: *App, x: f64, y: f64) void {
}
}
+/// Keep pointer-dependent desktop lighting current even while an overlay
+/// handles the pointer event instead of the desktop.
+fn updateProximityPointer(self: *App, x: f64, y: f64) void {
+ const moved = self.x != x or self.y != y;
+ const newly_present = !self.pointer_present;
+ if (moved and self.pointer_present) damageProximityAt(self, self.x, self.y);
+ self.x = x;
+ self.y = y;
+ self.pointer_present = true;
+ if (moved or newly_present) damageProximityAt(self, x, y);
+}
+
pub fn motion(self: *App, x: f64, y: f64) void {
self.pointerMotion(x, y);
self.syncCursor();
@@ -60,8 +72,7 @@ pub fn pointerMotion(self: *App, x: f64, y: f64) void {
const old_hit = picker.hit(w, h, self.x, self.y);
if (picker.motion(w, h, x, y) or old_hit != picker.hit(w, h, x, y)) self.invalidate();
}
- self.x = x;
- self.y = y;
+ updateProximityPointer(self, x, y);
return;
}
if (self.edit == .trash_properties) {
@@ -71,29 +82,20 @@ pub fn pointerMotion(self: *App, x: f64, y: f64) void {
const old_hit = card.hit(w, h, self.x, self.y);
if (card.motion(w, h, x, y) or old_hit != card.hit(w, h, x, y)) self.invalidate();
}
- self.x = x;
- self.y = y;
+ updateProximityPointer(self, x, y);
return;
}
if (self.edit == .trash) {
if (self.deletion.motion(self.geometry.w, self.geometry.h - self.geometry.bottom, x, y)) self.invalidate();
const g = self.deletion.geometry(self.geometry.w, self.geometry.h - self.geometry.bottom);
const changed = g.target(self.x, self.y) != g.target(x, y);
- self.x = x;
- self.y = y;
+ updateProximityPointer(self, x, y);
if (changed) self.invalidate();
return;
}
const moved = self.x != x or self.y != y;
- const newly_present = !self.pointer_present;
- if (moved) {
- self.damageDrag();
- if (self.pointer_present) damageProximityAt(self, self.x, self.y);
- }
- self.x = x;
- self.y = y;
- self.pointer_present = true;
- if (moved or newly_present) damageProximityAt(self, x, y);
+ if (moved) self.damageDrag();
+ updateProximityPointer(self, x, y);
const hover = if (self.edit == .rename) null else self.hit(x, y);
if (self.hover != hover) {
if (self.hover) |i| self.damageIcon(i);
diff --git a/src/desktop/app_tests.zig b/src/desktop/app_tests.zig
index 436b40d..cadd762 100644
--- a/src/desktop/app_tests.zig
+++ b/src/desktop/app_tests.zig
@@ -113,6 +113,53 @@ test "desktop icon-card proximity damages only nearby cards and clears on leave"
try std.testing.expect(!app.dirty);
}
+test "desktop proximity damage stays live over desktop overlays" {
+ const picker = @import("../files/open_with.zig");
+ var icons = [_]Icon{
+ .{ .item = .{ .path = "", .name = "Near", .icon = null }, .cell = .{}, .born = 0 },
+ .{ .item = .{ .path = "", .name = "Distant", .icon = null }, .cell = .{ .col = 2 }, .born = 0 },
+ };
+ var app = App{
+ .worker = undefined,
+ .geometry = .{ .w = 400, .h = 240 },
+ .icons = .fromOwnedSlice(&icons),
+ .dirty = false,
+ };
+ defer app.closePicker();
+ defer app.closeTrashCard();
+
+ // Establish a visible pointer near the first card, then clear its damage.
+ app.motion(250, 50);
+ app.presented();
+ const near = app.iconRect(0);
+ const distant = app.iconRect(1);
+
+ // The shortcut picker handles motion without changing its hover target.
+ app.applications = picker.State.initShortcuts(a, &.{});
+ app.edit = .add_app;
+ app.motion(249, 50);
+ try std.testing.expect(!app.damage.full);
+ try std.testing.expect(app.damage.intersects(near));
+ try std.testing.expect(!app.damage.intersects(distant));
+
+ // Trash properties must keep the desktop glow current too.
+ app.presented();
+ app.trash_card = .{ .path = try a.dupe(u8, "/tmp/Trash/files") };
+ app.edit = .trash_properties;
+ app.motion(248, 50);
+ try std.testing.expect(!app.damage.full);
+ try std.testing.expect(app.damage.intersects(near));
+ try std.testing.expect(!app.damage.intersects(distant));
+
+ // The delete dialog's target tracking must not bypass glow invalidation.
+ app.presented();
+ app.edit = .trash;
+ app.motion(247, 50);
+ try std.testing.expect(!app.damage.full);
+ try std.testing.expect(app.damage.intersects(near));
+ try std.testing.expect(!app.damage.intersects(distant));
+}
+
test "desktop motion keeps menu highlights and moving selections live" {
var app = App{ .worker = undefined, .menu = true, .dirty = false };
app.menu_layout.layout(100, 100, 3, false);