mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
gtk: add unfocused_widget when split created from menu
When a split is created from a menu action, the focus is lost before the split is made which prevents the surface from having the unfocused_widget. Move the logic to add the unfocused_widget to the overlay to an exported function which is called when the split is created.
This commit is contained in:
@ -77,6 +77,7 @@ pub fn init(
|
|||||||
.parent = &sibling.core_surface,
|
.parent = &sibling.core_surface,
|
||||||
});
|
});
|
||||||
errdefer surface.destroy(alloc);
|
errdefer surface.destroy(alloc);
|
||||||
|
sibling.dimSurface();
|
||||||
|
|
||||||
// Create the actual GTKPaned, attach the proper children.
|
// Create the actual GTKPaned, attach the proper children.
|
||||||
const orientation: c_uint = switch (direction) {
|
const orientation: c_uint = switch (direction) {
|
||||||
|
@ -1836,16 +1836,11 @@ fn gtkFocusLeave(_: *c.GtkEventControllerFocus, ud: ?*anyopaque) callconv(.C) vo
|
|||||||
// Notify our IM context
|
// Notify our IM context
|
||||||
c.gtk_im_context_focus_out(self.im_context);
|
c.gtk_im_context_focus_out(self.im_context);
|
||||||
|
|
||||||
// We only add the unfocused-split widget if we are actually a split
|
// We only dim the surface if we are a split
|
||||||
switch (self.container) {
|
switch (self.container) {
|
||||||
.split_br,
|
.split_br,
|
||||||
.split_tl,
|
.split_tl,
|
||||||
=> blk: {
|
=> self.dimSurface(),
|
||||||
if (self.unfocused_widget != null) break :blk;
|
|
||||||
self.unfocused_widget = c.gtk_drawing_area_new();
|
|
||||||
c.gtk_widget_add_css_class(self.unfocused_widget.?, "unfocused-split");
|
|
||||||
c.gtk_overlay_add_overlay(self.overlay, self.unfocused_widget.?);
|
|
||||||
},
|
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1855,6 +1850,15 @@ fn gtkFocusLeave(_: *c.GtkEventControllerFocus, ud: ?*anyopaque) callconv(.C) vo
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the unfocused_widget to the overlay. If the unfocused_widget has already been added, this
|
||||||
|
/// is a no-op
|
||||||
|
pub fn dimSurface(self: *Surface) void {
|
||||||
|
if (self.unfocused_widget != null) return;
|
||||||
|
self.unfocused_widget = c.gtk_drawing_area_new();
|
||||||
|
c.gtk_widget_add_css_class(self.unfocused_widget.?, "unfocused-split");
|
||||||
|
c.gtk_overlay_add_overlay(self.overlay, self.unfocused_widget.?);
|
||||||
|
}
|
||||||
|
|
||||||
fn gtkCloseConfirmation(
|
fn gtkCloseConfirmation(
|
||||||
alert: *c.GtkMessageDialog,
|
alert: *c.GtkMessageDialog,
|
||||||
response: c.gint,
|
response: c.gint,
|
||||||
|
Reference in New Issue
Block a user