From 5b41cad6473ad55ac874d7bd1c1806441a6d97d5 Mon Sep 17 00:00:00 2001 From: Asmir A Date: Sat, 29 Aug 2026 15:49:02 +0200 Subject: [PATCH] optimize out double rendering --- src/Window.zig | 18 +++++------------- src/Wm.zig | 6 ++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Window.zig b/src/Window.zig index 2a12de1..6a93fb8 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -174,15 +174,6 @@ pub fn applyRules(self: *Window) void { } } -/// Whether this window currently has a tab drawn for it, i.e. it is tiled and -/// visible on an output that is showing the tabbed layout. -fn onTabBar(self: *Window) bool { - if (config.tabbar_height <= 0) return false; - if (!self.visible or self.floating or self.fullscreen or self.closed) return false; - const out = self.output orelse return false; - return out.state().layout == .tabbed; -} - /// Replace an owned string field, returning whether the value actually /// changed. Clients re-send strings that have not moved — a terminal animating /// a spinner in its title re-sets the same text several times a second — and @@ -253,10 +244,11 @@ fn onEvent(_: *river.WindowV1, event: river.WindowV1.Event, self: *Window) void if (self.setString(&self.title, ev.title)) { self.applyRules(); self.wm.ipcDirty(); - // The tab bar has this title painted into it, so a window that - // is wearing a tab needs the strip redrawn. Terminals retitle - // themselves constantly, so ask only when it will show. - if (self.onTabBar()) self.wm.needsManage(); + // No needsManage: river sent this event, so it already knows + // the title moved and starts a manage sequence of its own. + // Asking for one here bought a second, identical manage and + // render pass for every retitle — and terminals retitle + // themselves constantly. } }, diff --git a/src/Wm.zig b/src/Wm.zig index a5b9902..1ec9822 100644 --- a/src/Wm.zig +++ b/src/Wm.zig @@ -505,6 +505,12 @@ fn updateDefaultLayerOutput(self: *Wm) void { self.default_layer_output = out; } +/// Ask river for a manage sequence. +/// +/// Only needed for state changes river cannot see for itself: key bindings, +/// pointer gestures and IPC commands. River already follows every batch of +/// state events it sends us with a manage_start of its own, so calling this +/// from an event handler asks for a second, redundant sequence. pub fn needsManage(self: *Wm) void { if (self.manage_requested) return; self.manage_requested = true;