gtk: drag overlay toggle

This commit is contained in:
Leah Amelia Chen
2026-08-08 17:25:06 +08:00
parent c6e7e9e4e2
commit 65a3e666ef
2 changed files with 17 additions and 1 deletions

View File

@@ -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);

View File

@@ -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 <bool>;
styles [
"drag-handle",