From 5eb7925446dd3a351afc0d7c206accdfc0817338 Mon Sep 17 00:00:00 2001 From: karei Date: Mon, 22 Jul 2024 21:03:49 +0300 Subject: [PATCH] apprt/gtk: don't dim surface when opening context menu --- src/apprt/gtk/Surface.zig | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 9cd3d62f4..ee6c6869e 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -1887,7 +1887,7 @@ fn gtkFocusLeave(_: *c.GtkEventControllerFocus, ud: ?*anyopaque) callconv(.C) vo // Notify our IM context c.gtk_im_context_focus_out(self.im_context); - // We only dim the surface if we are a split + // We only try dimming the surface if we are a split switch (self.container) { .split_br, .split_tl, @@ -1904,6 +1904,16 @@ fn gtkFocusLeave(_: *c.GtkEventControllerFocus, ud: ?*anyopaque) callconv(.C) vo /// Adds the unfocused_widget to the overlay. If the unfocused_widget has already been added, this /// is a no-op pub fn dimSurface(self: *Surface) void { + const window = self.container.window() orelse { + log.warn("dimSurface invalid for container={}", .{self.container}); + return; + }; + + // Don't dim surface if context menu is open. + // This means we got unfocused due to it opening. + const context_menu_open = c.gtk_widget_get_visible(window.context_menu); + if (context_menu_open == c.True) return; + if (self.unfocused_widget != null) return; self.unfocused_widget = c.gtk_drawing_area_new(); c.gtk_widget_add_css_class(self.unfocused_widget.?, "unfocused-split");