mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
gtk: always remember focused surface before grabbing focus
This commit is contained in:

committed by
Mitchell Hashimoto

parent
a1fb74d8aa
commit
f1e81563d9
@ -86,6 +86,7 @@ pub fn setParent(self: *Paned, parent: Parent) void {
|
|||||||
pub fn focusSurfaceInPosition(self: *Paned, position: Position) void {
|
pub fn focusSurfaceInPosition(self: *Paned, position: Position) void {
|
||||||
const surface: *Surface = self.surfaceInPosition(position) orelse return;
|
const surface: *Surface = self.surfaceInPosition(position) orelse return;
|
||||||
const widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
const widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
||||||
|
surface.tab.focus_child = surface;
|
||||||
_ = c.gtk_widget_grab_focus(widget);
|
_ = c.gtk_widget_grab_focus(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,6 +836,7 @@ fn gtkMouseDown(
|
|||||||
// If we don't have focus, grab it.
|
// If we don't have focus, grab it.
|
||||||
const gl_widget = @as(*c.GtkWidget, @ptrCast(self.gl_area));
|
const gl_widget = @as(*c.GtkWidget, @ptrCast(self.gl_area));
|
||||||
if (c.gtk_widget_has_focus(gl_widget) == 0) {
|
if (c.gtk_widget_has_focus(gl_widget) == 0) {
|
||||||
|
self.tab.focus_child = self;
|
||||||
_ = c.gtk_widget_grab_focus(gl_widget);
|
_ = c.gtk_widget_grab_focus(gl_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,8 +93,6 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
|||||||
errdefer surface.deinit();
|
errdefer surface.deinit();
|
||||||
|
|
||||||
self.child = Child{ .surface = surface };
|
self.child = Child{ .surface = surface };
|
||||||
// // TODO: this needs to change
|
|
||||||
self.focus_child = surface;
|
|
||||||
|
|
||||||
// Add Surface to the Tab
|
// Add Surface to the Tab
|
||||||
const gl_area_widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
const gl_area_widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
||||||
@ -122,6 +120,9 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
|||||||
c.gtk_notebook_set_show_tabs(window.notebook, 1);
|
c.gtk_notebook_set_show_tabs(window.notebook, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This needs to happen before we show the page
|
||||||
|
self.focus_child = surface;
|
||||||
|
|
||||||
// Set the userdata of the box to point to this tab.
|
// Set the userdata of the box to point to this tab.
|
||||||
c.g_object_set_data(@ptrCast(box_widget), GHOSTTY_TAB, self);
|
c.g_object_set_data(@ptrCast(box_widget), GHOSTTY_TAB, self);
|
||||||
|
|
||||||
|
@ -313,6 +313,10 @@ fn closeSurfaceInPaned(self: *Window, surface: *Surface, paned: *Paned, position
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (sibling_child) {
|
||||||
|
.surface => |s| s.tab.focus_child = s,
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
const widget = @as(*c.GtkWidget, @ptrCast(sibling_widget));
|
const widget = @as(*c.GtkWidget, @ptrCast(sibling_widget));
|
||||||
_ = c.gtk_widget_grab_focus(widget);
|
_ = c.gtk_widget_grab_focus(widget);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user