diff --git a/src/apprt/gtk/class/surface.zig b/src/apprt/gtk/class/surface.zig index e9aea6d51..5937fab76 100644 --- a/src/apprt/gtk/class/surface.zig +++ b/src/apprt/gtk/class/surface.zig @@ -3650,6 +3650,21 @@ pub const Surface = extern struct { }; } + fn closureShouldDragHandleBeShown( + _: *Self, + config_: ?*Config, + is_split: c_int, + ) callconv(.c) c_int { + const config = config_ orelse return @intFromBool(false); + + const shown = switch (config.get().@"drag-handle") { + .always => true, + .auto => is_split != 0, + .never => false, + }; + return @intFromBool(shown); + } + fn surfaceDragPrepare( src: *gtk.DragSource, x: f64, @@ -3722,7 +3737,6 @@ pub const Surface = extern struct { const dropped = self.core().?.app.findSurfaceByID(dropped_id) orelse return; const from = dropped.rt_surface.gobj(); - // TODO: Find a better way to access the split tree from here const st = ext.getAncestor( SplitTree, self.as(gtk.Widget), @@ -3892,6 +3906,7 @@ pub const Surface = extern struct { class.bindTemplateCallback("search_changed", &searchChanged); class.bindTemplateCallback("search_next_match", &searchNextMatch); class.bindTemplateCallback("search_previous_match", &searchPreviousMatch); + class.bindTemplateCallback("should_drag_handle_be_shown", &closureShouldDragHandleBeShown); class.bindTemplateCallback("surface_drag_prepare", &surfaceDragPrepare); class.bindTemplateCallback("surface_drag_begin", &surfaceDragBegin); class.bindTemplateCallback("surface_drop", &surfaceDrop); diff --git a/src/apprt/gtk/ui/1.2/surface.blp b/src/apprt/gtk/ui/1.2/surface.blp index b7d07cb3e..fc14fd3b5 100644 --- a/src/apprt/gtk/ui/1.2/surface.blp +++ b/src/apprt/gtk/ui/1.2/surface.blp @@ -232,6 +232,7 @@ Overlay terminal_page { CenterBox drag_handle { halign: fill; valign: start; + visible: bind $should_drag_handle_be_shown(template.config, template.is-split) as ; styles [ "drag-handle",