summaryrefslogtreecommitdiff
path: root/dev/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'dev/gui/gui.zig')
-rw-r--r--dev/gui/gui.zig44
1 files changed, 38 insertions, 6 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index d9d38f06..3193d966 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -1132,6 +1132,9 @@ const Client = struct {
titled: bool = false,
moving: bool = false,
blink: ?Blink = null,
+ /// The session's WindowOpacity this window last took (P47: each
+ /// window applies it to the view it draws; none answers the core).
+ opacity: ?u8 = null,
fn deinit(cl: *Client) void {
cl.pending.deinit(cl.gpa);
@@ -1173,6 +1176,7 @@ const Client = struct {
const g = cl.g;
const core = l.link.r.core();
g.session_font_request = null;
+ cl.opacity = null;
cl.shell.core = core;
cl.shell.gview = cl.joins.joined.view;
cl.shell.surface = null;
@@ -1206,6 +1210,14 @@ const Client = struct {
const link = &l.link;
l.frames.period_ns = refreshNs(g);
if (syncReplicaFont(g, &cl.in.core.settings.font, gpa)) link.dirty = true;
+ const opacity = cl.in.core.settings.window_opacity;
+ if (cl.opacity != opacity) {
+ cl.opacity = opacity;
+ if (applyWindowOpacity(g, opacity) catch return false) |why| {
+ log.warn("WindowOpacity: {s}", .{why});
+ } else g.applied_window_opacity = opacity;
+ link.dirty = true;
+ }
if (scrollRows(g, &cl.in, gpa)) link.dirty = true;
if (fitTaglineFont(g, g.facts.tagline_percent)) link.dirty = true;
const geom = windowCells(g);
@@ -3025,12 +3037,24 @@ fn finishWindowOpacity(core: *pardes.Pardes, applied: *u8, failure: ?[]const u8)
fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void {
if (!core.settings.window_opacity_pending) return;
+ const failure = applyWindowOpacity(g, core.settings.window_opacity) catch blk: {
+ core.quit = true;
+ break :blk null;
+ };
+ finishWindowOpacity(core, &g.applied_window_opacity, failure);
+}
+
+/// What the window does at a WindowOpacity, the own window's and a
+/// client's (P47: a window's facts are the process's that draws it): why
+/// it cannot, or null; error.NoWindow when it was made again and could
+/// not be.
+fn applyWindowOpacity(g: *Gui, opacity: u8) error{NoWindow}!?[]const u8 {
// The first opacity under 100 on Wayland: the window made again,
// transparent, presenting through SDL_Renderer from then on (the
// capture's format, the swapchain's, is one it uploads). At a start's
// own WindowOpacity this is before its first frame, so unseen.
const unorm = g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM or g.present.swapchain_format == c.SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM;
- if (g.wayland and !g.present.surface_opacity and core.settings.window_opacity < 100 and unorm) {
+ if (g.wayland and !g.present.surface_opacity and opacity < 100 and unorm) {
// A `--detach` session's window stays hidden.
const hidden = c.SDL_GetWindowFlags(g.window) & c.SDL_WINDOW_HIDDEN;
const mode = g.present.present_mode;
@@ -3046,16 +3070,16 @@ fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void {
g.present.surface_opacity = false;
g.present.present_mode = mode;
g.win_flags &= ~@as(c.SDL_WindowFlags, c.SDL_WINDOW_TRANSPARENT);
- if (!reopenWindow(g)) core.quit = true;
+ if (!reopenWindow(g)) return error.NoWindow;
}
g.win_flags &= ~hidden;
}
// Offscreen captures also support per-pixel alpha. Never approximate this
// with SDL_SetWindowOpacity: that would make foreground text translucent.
- finishWindowOpacity(core, &g.applied_window_opacity, if (g.present.surface_opacity or g.present.capture or core.settings.window_opacity == 100)
+ return if (g.present.surface_opacity or g.present.capture or opacity == 100)
null
else
- "background transparency requires a native Wayland or alpha-capable SDL window");
+ "background transparency requires a native Wayland or alpha-capable SDL window";
}
fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
@@ -4891,7 +4915,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
else => {},
} else false;
if (grid_bottom < win_h and tag_last) try addDecor(g, gpa, 0, grid_bottom, win_w, win_h, chrome.tag_bg, 1, win_w, win_h);
- try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], chrome, layout, surface.cols, surface.rows, win_w, win_h);
+ try paneDecor(g, gpa, regions, surface.rail_ticks[0..surface.nrail_ticks], surface.heat.items, chrome, layout, surface.cols, surface.rows, win_w, win_h);
// The changes' lanes (jj.paint): a strip a level in the gutter's
// lane cells, each a third of a cell wide with half that of air
// before it, so three take one and a half cells (the ruled
@@ -4934,7 +4958,7 @@ fn buildDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, g
/// Each pane's rule between its tag and body, and its scroll rail: a page
/// coloured gutter with a thin track and its thumb, running down through the
/// pixels past the last whole row.
-fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
+fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ticks: []const pardes.RailTick, heat: []const pardes.RailHeat, chrome: *const pardes.Chrome, layout: CellLayout, cols: u16, rows: u16, win_w: f32, win_h: f32) !void {
const page = chrome.page orelse bg_default;
for (regions) |rail| {
if (rail.kind != .rail or rail.rect.h == 0) continue;
@@ -5013,6 +5037,14 @@ fn paneDecor(g: *Gui, gpa: std.mem.Allocator, regions: []const pardes.Region, ti
const ty = y0 + std.math.clamp(at * track_px, 0, track_px - h);
try addDecor(g, gpa, column[0], ty, column[1], ty + h, if (tick.current) chrome.match_current else chrome.match_tick, 1, win_w, win_h);
};
+ // Churn's strip (jj.railHeat): beside the track, at the rail's
+ // right edge, a rail row each.
+ const strip_x1 = x0 + @as(f32, @floatFromInt(config.GUTTER)) * layout.w - dp(1);
+ const strip_x0 = @max(column[1], strip_x1 - dp(2));
+ for (heat) |h| if (h.owner == rail.owner and h.row < rail.rect.h) {
+ const hy = y0 + @as(f32, @floatFromInt(h.row)) * layout.h;
+ try addDecor(g, gpa, strip_x0, hy, strip_x1, hy + layout.h, h.rgb, 1, win_w, win_h);
+ };
}
}