mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
inherit font size works again
This commit is contained in:
33
src/App.zig
33
src/App.zig
@ -152,10 +152,7 @@ fn drainMailbox(self: *App, rt_app: *apprt.runtime.App) !void {
|
|||||||
while (self.mailbox.pop()) |message| {
|
while (self.mailbox.pop()) |message| {
|
||||||
log.debug("mailbox message={s}", .{@tagName(message)});
|
log.debug("mailbox message={s}", .{@tagName(message)});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.new_window => |msg| {
|
.new_window => |msg| try self.newWindow(rt_app, msg),
|
||||||
_ = msg; // TODO
|
|
||||||
_ = try rt_app.newWindow();
|
|
||||||
},
|
|
||||||
.new_tab => |msg| try self.newTab(rt_app, msg),
|
.new_tab => |msg| try self.newTab(rt_app, msg),
|
||||||
.quit => try self.setQuit(),
|
.quit => try self.setQuit(),
|
||||||
.surface_message => |msg| try self.surfaceMessage(msg.surface, msg.message),
|
.surface_message => |msg| try self.surfaceMessage(msg.surface, msg.message),
|
||||||
@ -163,8 +160,20 @@ fn drainMailbox(self: *App, rt_app: *apprt.runtime.App) !void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a new window
|
||||||
|
fn newWindow(self: *App, rt_app: *apprt.runtime.App, msg: Message.NewWindow) !void {
|
||||||
|
const window = try rt_app.newWindow();
|
||||||
|
if (self.config.@"window-inherit-font-size") {
|
||||||
|
if (msg.parent) |parent| {
|
||||||
|
if (self.hasSurface(parent)) {
|
||||||
|
window.core_surface.setFontSize(parent.font_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new tab in the parent window
|
/// Create a new tab in the parent window
|
||||||
fn newTab(self: *App, rt_app: *apprt.runtime.App, msg: Message.NewWindow) !void {
|
fn newTab(self: *App, rt_app: *apprt.runtime.App, msg: Message.NewTab) !void {
|
||||||
const parent = msg.parent orelse {
|
const parent = msg.parent orelse {
|
||||||
log.warn("parent must be set in new_tab message", .{});
|
log.warn("parent must be set in new_tab message", .{});
|
||||||
return;
|
return;
|
||||||
@ -176,7 +185,8 @@ fn newTab(self: *App, rt_app: *apprt.runtime.App, msg: Message.NewWindow) !void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try rt_app.newTab(parent);
|
const window = try rt_app.newTab(parent);
|
||||||
|
if (self.config.@"window-inherit-font-size") window.core_surface.setFontSize(parent.font_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start quitting
|
/// Start quitting
|
||||||
@ -219,7 +229,7 @@ pub const Message = union(enum) {
|
|||||||
/// Create a new tab within the tab group of the focused window.
|
/// Create a new tab within the tab group of the focused window.
|
||||||
/// This does nothing if we're on a platform or using a window
|
/// This does nothing if we're on a platform or using a window
|
||||||
/// environment that doesn't support tabs.
|
/// environment that doesn't support tabs.
|
||||||
new_tab: NewWindow,
|
new_tab: NewTab,
|
||||||
|
|
||||||
/// Quit
|
/// Quit
|
||||||
quit: void,
|
quit: void,
|
||||||
@ -234,12 +244,13 @@ pub const Message = union(enum) {
|
|||||||
/// Runtime-specific window options.
|
/// Runtime-specific window options.
|
||||||
runtime: apprt.runtime.Surface.Options = .{},
|
runtime: apprt.runtime.Surface.Options = .{},
|
||||||
|
|
||||||
/// The parent surface, only used for new tabs.
|
/// The parent surface
|
||||||
parent: ?*Surface = null,
|
parent: ?*Surface = null,
|
||||||
|
};
|
||||||
|
|
||||||
/// The font size to create the window with or null to default to
|
const NewTab = struct {
|
||||||
/// the configuration amount.
|
/// The parent surface
|
||||||
font_size: ?font.face.DesiredSize = null,
|
parent: ?*Surface = null,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -904,10 +904,7 @@ pub fn keyCallback(
|
|||||||
.new_window => {
|
.new_window => {
|
||||||
_ = self.app.mailbox.push(.{
|
_ = self.app.mailbox.push(.{
|
||||||
.new_window = .{
|
.new_window = .{
|
||||||
.font_size = if (self.config.@"window-inherit-font-size")
|
.parent = self,
|
||||||
self.font_size
|
|
||||||
else
|
|
||||||
null,
|
|
||||||
},
|
},
|
||||||
}, .{ .instant = {} });
|
}, .{ .instant = {} });
|
||||||
self.app.wakeup();
|
self.app.wakeup();
|
||||||
@ -917,11 +914,6 @@ pub fn keyCallback(
|
|||||||
_ = self.app.mailbox.push(.{
|
_ = self.app.mailbox.push(.{
|
||||||
.new_tab = .{
|
.new_tab = .{
|
||||||
.parent = self,
|
.parent = self,
|
||||||
|
|
||||||
.font_size = if (self.config.@"window-inherit-font-size")
|
|
||||||
self.font_size
|
|
||||||
else
|
|
||||||
null,
|
|
||||||
},
|
},
|
||||||
}, .{ .instant = {} });
|
}, .{ .instant = {} });
|
||||||
self.app.wakeup();
|
self.app.wakeup();
|
||||||
|
@ -89,10 +89,10 @@ pub const App = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new tab in the parent surface.
|
/// Create a new tab in the parent surface.
|
||||||
pub fn newTab(self: *App, parent: *CoreSurface) !void {
|
pub fn newTab(self: *App, parent: *CoreSurface) !*Surface {
|
||||||
if (!Darwin.enabled) {
|
if (!Darwin.enabled) {
|
||||||
log.warn("tabbing is not supported on this platform", .{});
|
log.warn("tabbing is not supported on this platform", .{});
|
||||||
return;
|
return error.TabbingNotSupported;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the new window
|
// Create the new window
|
||||||
@ -120,6 +120,8 @@ pub const App = struct {
|
|||||||
log.err("error in size callback from new tab err={}", .{err});
|
log.err("error in size callback from new tab err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close the given surface.
|
/// Close the given surface.
|
||||||
|
Reference in New Issue
Block a user