diff --git a/src/apprt/gtk/class/split_tree.zig b/src/apprt/gtk/class/split_tree.zig index 0fe06a0b1..6ea84d055 100644 --- a/src/apprt/gtk/class/split_tree.zig +++ b/src/apprt/gtk/class/split_tree.zig @@ -399,12 +399,7 @@ pub const SplitTree = extern struct { const tree = self.getTree() orelse return null; var it = tree.iterator(); while (it.next()) |entry| { - if (!entry.view.getFocused() and it.nodes.len > 1) { - entry.view.setUnfocused(); - } - if (entry.view.getFocused()) { - return entry.handle; - } + if (entry.view.getFocused()) return entry.handle; } // If none are currently focused, the most previously focused @@ -715,7 +710,13 @@ pub const SplitTree = extern struct { // We never CLEAR our last_focused because the property is specifically // the last focused surface. We let the weakref clear itself when // the surface is destroyed. - if (!surface.getFocused()) return; + if (!surface.getFocused()) { + // If we have more than 1 active surface and we aren't focused we want to apply unfocused-split-fill + if (self.getTree()) |tree| { + if (tree.nodes.len > 1) surface.setUnfocused(); + } + return; + } self.private().last_focused.set(surface); // Our active surface probably changed diff --git a/src/apprt/gtk/class/surface.zig b/src/apprt/gtk/class/surface.zig index 9906a1baf..eb1e17823 100644 --- a/src/apprt/gtk/class/surface.zig +++ b/src/apprt/gtk/class/surface.zig @@ -1492,6 +1492,7 @@ pub const Surface = extern struct { return self.private().focused; } + /// If unfocused add the unfocused-split widget for this surface pub fn setUnfocused(self: *Self) void { const priv = self.private(); if (!priv.focused and (priv.unfocused_widget == null)) { @@ -2018,16 +2019,6 @@ pub const Surface = extern struct { priv.im_context.as(gtk.IMContext).focusOut(); _ = glib.idleAddOnce(idleFocus, self.ref()); self.as(gobject.Object).notifyByPspec(properties.focused.impl.param_spec); - - // if (priv.unfocused_widget) |_| return; - // add unfocused-split-fill - // priv.unfocused_widget = unfocused_widget: { - // const drawing_area = gtk.DrawingArea.new(); - // const unfocused_widget = drawing_area.as(gtk.Widget); - // unfocused_widget.addCssClass("unfocused-split"); - // priv.terminal_page.addOverlay(unfocused_widget); - // break :unfocused_widget unfocused_widget; - // }; } /// The focus callback must be triggered on an idle loop source because