From a6c40d04172d1a760ab400aacc11a75c93cac190 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 6 Sep 2023 11:23:42 -0700 Subject: [PATCH] renderer: always show cursor if window is not focused Fixes #400 This ensures the hollow box is shown even if the cursor is not in a blinking state when unfocus happens. We still hide the cursor even on unfocus if the terminal mode explictly asks for a hidden cursor. --- src/renderer/Metal.zig | 4 ++++ src/renderer/OpenGL.zig | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 84c4b192e..c0f5b3ac9 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -494,6 +494,10 @@ pub fn render( // If the cursor isn't a blinking style, then never blink. if (!selected_cursor_style.blinking()) break :visible true; + // If we're not focused, our cursor is always visible so that + // we can show the hollow box. + if (!self.focused) break :visible true; + // Otherwise, adhere to our current state. break :visible self.cursor_visible; }; diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index b6e251711..d3db137ce 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -736,6 +736,10 @@ pub fn render( // If the cursor isn't a blinking style, then never blink. if (!selected_cursor_style.blinking()) break :visible true; + // If we're not focused, our cursor is always visible so that + // we can show the hollow box. + if (!self.focused) break :visible true; + // Otherwise, adhere to our current state. break :visible self.cursor_visible; };