mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-24 16:11:43 +00:00
gtk: drag overlay toggle
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user