bind is-split property between split_tree class and surface class
parent
3254bb41d5
commit
fdcaeebb99
|
|
@ -112,6 +112,25 @@ pub const SplitTree = extern struct {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const @"is-split" = struct {
|
||||||
|
pub const name = "is-split";
|
||||||
|
const impl = gobject.ext.defineProperty(
|
||||||
|
name,
|
||||||
|
Self,
|
||||||
|
bool,
|
||||||
|
.{
|
||||||
|
.default = false,
|
||||||
|
.accessor = gobject.ext.typedAccessor(
|
||||||
|
Self,
|
||||||
|
bool,
|
||||||
|
.{
|
||||||
|
.setter = setIsSplit,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const signals = struct {
|
pub const signals = struct {
|
||||||
|
|
@ -153,6 +172,9 @@ pub const SplitTree = extern struct {
|
||||||
/// close dialog.
|
/// close dialog.
|
||||||
pending_close: ?Surface.Tree.Node.Handle,
|
pending_close: ?Surface.Tree.Node.Handle,
|
||||||
|
|
||||||
|
/// True if the current split tree contains more than one surface
|
||||||
|
is_split: bool = false,
|
||||||
|
|
||||||
pub var offset: c_int = 0;
|
pub var offset: c_int = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -210,6 +232,14 @@ pub const SplitTree = extern struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind is-split property for new surface
|
||||||
|
_ = self.as(gobject.Object).bindProperty(
|
||||||
|
"is-split",
|
||||||
|
surface.as(gobject.Object),
|
||||||
|
"is-split",
|
||||||
|
.{ .sync_create = true },
|
||||||
|
);
|
||||||
|
|
||||||
// Create our tree
|
// Create our tree
|
||||||
var single_tree = try Surface.Tree.init(alloc, surface);
|
var single_tree = try Surface.Tree.init(alloc, surface);
|
||||||
defer single_tree.deinit();
|
defer single_tree.deinit();
|
||||||
|
|
@ -511,6 +541,12 @@ pub const SplitTree = extern struct {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn setIsSplit(self: *Self, v: bool) void {
|
||||||
|
const priv = self.private();
|
||||||
|
priv.is_split = v;
|
||||||
|
self.as(gobject.Object).notifyByPspec(properties.@"is-split".impl.param_spec);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Virtual methods
|
// Virtual methods
|
||||||
|
|
||||||
|
|
@ -808,6 +844,16 @@ pub const SplitTree = extern struct {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Determine if tree has more than one surface
|
||||||
|
const root_handle: Surface.Tree.Node.Handle = .root;
|
||||||
|
const root = tree.nodes[root_handle.idx()];
|
||||||
|
const is_split: bool = switch (root) {
|
||||||
|
.leaf => false,
|
||||||
|
.split => true,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.setIsSplit(is_split);
|
||||||
|
|
||||||
// If we have a last focused surface, we need to refocus it, because
|
// If we have a last focused surface, we need to refocus it, because
|
||||||
// during the frame between setting the bin to null and rebuilding,
|
// during the frame between setting the bin to null and rebuilding,
|
||||||
// GTK will reset our focus state (as it should!)
|
// GTK will reset our focus state (as it should!)
|
||||||
|
|
@ -873,6 +919,7 @@ pub const SplitTree = extern struct {
|
||||||
properties.@"has-surfaces".impl,
|
properties.@"has-surfaces".impl,
|
||||||
properties.@"is-zoomed".impl,
|
properties.@"is-zoomed".impl,
|
||||||
properties.tree.impl,
|
properties.tree.impl,
|
||||||
|
properties.@"is-split".impl,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bindings
|
// Bindings
|
||||||
|
|
|
||||||
|
|
@ -275,21 +275,19 @@ pub const Surface = extern struct {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const @"n-siblings" = struct {
|
pub const @"is-split" = struct {
|
||||||
pub const name = "n-siblings";
|
pub const name = "is-split";
|
||||||
const impl = gobject.ext.defineProperty(
|
const impl = gobject.ext.defineProperty(
|
||||||
name,
|
name,
|
||||||
Self,
|
Self,
|
||||||
u64,
|
bool,
|
||||||
.{
|
.{
|
||||||
.default = 0,
|
.default = false,
|
||||||
.minimum = 0,
|
|
||||||
.maximum = std.math.maxInt(c_uint),
|
|
||||||
.accessor = gobject.ext.privateFieldAccessor(
|
.accessor = gobject.ext.privateFieldAccessor(
|
||||||
Self,
|
Self,
|
||||||
Private,
|
Private,
|
||||||
&Private.offset,
|
&Private.offset,
|
||||||
"n_siblings",
|
"is_split",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -522,10 +520,9 @@ pub const Surface = extern struct {
|
||||||
/// A weak reference to an inspector window.
|
/// A weak reference to an inspector window.
|
||||||
inspector: ?*InspectorWindow = null,
|
inspector: ?*InspectorWindow = null,
|
||||||
|
|
||||||
/// Number of siblings related to this surface. This is used for
|
// True if the current surface is a split, this is used to apply
|
||||||
/// the unfocused-split-* options which are only applied when their is
|
// unfocused-split-* options
|
||||||
/// more than once surface (split) in a tab
|
is_split: bool = false,
|
||||||
n_siblings: u64 = 0,
|
|
||||||
|
|
||||||
// Template binds
|
// Template binds
|
||||||
child_exited_overlay: *ChildExited,
|
child_exited_overlay: *ChildExited,
|
||||||
|
|
@ -630,9 +627,9 @@ pub const Surface = extern struct {
|
||||||
fn closureShouldUnfocusedSplitBeShown(
|
fn closureShouldUnfocusedSplitBeShown(
|
||||||
_: *Self,
|
_: *Self,
|
||||||
focused: c_int,
|
focused: c_int,
|
||||||
n_siblings: c_int,
|
is_split: c_int,
|
||||||
) callconv(.c) c_int {
|
) callconv(.c) c_int {
|
||||||
return @intFromBool(focused == 0 and n_siblings > 0);
|
return @intFromBool(focused == 0 and is_split != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggleFullscreen(self: *Self) void {
|
pub fn toggleFullscreen(self: *Self) void {
|
||||||
|
|
@ -1526,13 +1523,6 @@ pub const Surface = extern struct {
|
||||||
return self.private().focused;
|
return self.private().focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set number of siblings related to this surface.
|
|
||||||
pub fn setNSiblings(self: *Self, siblings: u64) void {
|
|
||||||
const priv = self.private();
|
|
||||||
priv.n_siblings = siblings;
|
|
||||||
self.as(gobject.Object).notifyByPspec(properties.@"n-siblings".impl.param_spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Change the configuration for this surface.
|
/// Change the configuration for this surface.
|
||||||
pub fn setConfig(self: *Self, config: *Config) void {
|
pub fn setConfig(self: *Self, config: *Config) void {
|
||||||
const priv = self.private();
|
const priv = self.private();
|
||||||
|
|
@ -1630,6 +1620,12 @@ pub const Surface = extern struct {
|
||||||
self.as(gobject.Object).notifyByPspec(properties.@"error".impl.param_spec);
|
self.as(gobject.Object).notifyByPspec(properties.@"error".impl.param_spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn setIsSplit(self: *Self, v: bool) void {
|
||||||
|
// const priv = self.private();
|
||||||
|
// priv.is_split = v;
|
||||||
|
// self.as(gobject.Object).notifyByPspec(properties.@"is-split".impl.param_spec);
|
||||||
|
// }
|
||||||
|
|
||||||
fn propConfig(
|
fn propConfig(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
_: *gobject.ParamSpec,
|
_: *gobject.ParamSpec,
|
||||||
|
|
@ -2824,7 +2820,7 @@ pub const Surface = extern struct {
|
||||||
properties.title.impl,
|
properties.title.impl,
|
||||||
properties.@"title-override".impl,
|
properties.@"title-override".impl,
|
||||||
properties.zoom.impl,
|
properties.zoom.impl,
|
||||||
properties.@"n-siblings".impl,
|
properties.@"is-split".impl,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ Overlay terminal_page {
|
||||||
// Apply unfocused-split-fill and unfocused-split-opacity to current surface
|
// Apply unfocused-split-fill and unfocused-split-opacity to current surface
|
||||||
// this is only applied when a tab has more than one surface
|
// this is only applied when a tab has more than one surface
|
||||||
Revealer {
|
Revealer {
|
||||||
reveal-child: bind $should_unfocused_split_be_shown(template.focused, template.n-siblings) as <bool>;
|
reveal-child: bind $should_unfocused_split_be_shown(template.focused, template.is-split) as <bool>;
|
||||||
transition-duration: 0;
|
transition-duration: 0;
|
||||||
|
|
||||||
DrawingArea {
|
DrawingArea {
|
||||||
|
|
|
||||||
|
|
@ -507,16 +507,12 @@ pub fn SplitTree(comptime V: type) type {
|
||||||
// We need to increase the reference count of all the nodes.
|
// We need to increase the reference count of all the nodes.
|
||||||
try refNodes(gpa, nodes);
|
try refNodes(gpa, nodes);
|
||||||
|
|
||||||
const result: Self = .{
|
return .{
|
||||||
.arena = arena,
|
.arena = arena,
|
||||||
.nodes = nodes,
|
.nodes = nodes,
|
||||||
// Splitting always resets zoom state.
|
// Splitting always resets zoom state.
|
||||||
.zoomed = null,
|
.zoomed = null,
|
||||||
};
|
};
|
||||||
|
|
||||||
result.updateNodesNumberSiblings();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a node from the tree.
|
/// Remove a node from the tree.
|
||||||
|
|
@ -560,8 +556,6 @@ pub fn SplitTree(comptime V: type) type {
|
||||||
// Increase the reference count of all the nodes.
|
// Increase the reference count of all the nodes.
|
||||||
try refNodes(gpa, nodes);
|
try refNodes(gpa, nodes);
|
||||||
|
|
||||||
result.updateNodesNumberSiblings();
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -871,14 +865,6 @@ pub fn SplitTree(comptime V: type) type {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the number of siblings for each split in the tree
|
|
||||||
fn updateNodesNumberSiblings(self: *const Self) void {
|
|
||||||
var it = self.iterator();
|
|
||||||
while (it.next()) |entry| {
|
|
||||||
entry.view.setNSiblings(self.nodes.len - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Spatial representation of the split tree. See spatial.
|
/// Spatial representation of the split tree. See spatial.
|
||||||
pub const Spatial = struct {
|
pub const Spatial = struct {
|
||||||
/// The slots of the spatial representation in the same order
|
/// The slots of the spatial representation in the same order
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue