mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
@ -3504,6 +3504,12 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
|
|||||||
} else log.warn("runtime doesn't implement toggleFullscreen", .{});
|
} else log.warn("runtime doesn't implement toggleFullscreen", .{});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.toggle_window_decorations => {
|
||||||
|
if (@hasDecl(apprt.Surface, "toggleWindowDecorations")) {
|
||||||
|
self.rt_surface.toggleWindowDecorations();
|
||||||
|
} else log.warn("runtime doesn't implement toggleWindowDecorations", .{});
|
||||||
|
},
|
||||||
|
|
||||||
.select_all => {
|
.select_all => {
|
||||||
const sel = self.io.terminal.screen.selectAll();
|
const sel = self.io.terminal.screen.selectAll();
|
||||||
if (sel) |s| {
|
if (sel) |s| {
|
||||||
|
@ -721,6 +721,18 @@ pub fn toggleFullscreen(self: *Surface, mac_non_native: configpkg.NonNativeFulls
|
|||||||
window.toggleFullscreen(mac_non_native);
|
window.toggleFullscreen(mac_non_native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggleWindowDecorations(self: *Surface) void {
|
||||||
|
const window = self.container.window() orelse {
|
||||||
|
log.info(
|
||||||
|
"toggleWindowDecorations invalid for container={s}",
|
||||||
|
.{@tagName(self.container)},
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
window.toggleWindowDecorations();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn getTitleLabel(self: *Surface) ?*c.GtkWidget {
|
pub fn getTitleLabel(self: *Surface) ?*c.GtkWidget {
|
||||||
switch (self.title) {
|
switch (self.title) {
|
||||||
.none => return null,
|
.none => return null,
|
||||||
|
@ -77,11 +77,10 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
const display = c.gdk_display_get_default();
|
const display = c.gdk_display_get_default();
|
||||||
c.gtk_style_context_add_provider_for_display(display, @ptrCast(app.css_provider), c.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
c.gtk_style_context_add_provider_for_display(display, @ptrCast(app.css_provider), c.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
// Use the new GTK4 header bar. We only create a header bar if we have
|
// gtk-titlebar can be used to disable the header bar (but keep
|
||||||
// window decorations.
|
// the window manager's decorations). We create this no matter if we
|
||||||
if (app.config.@"window-decoration") {
|
// are decorated or not because we can have a keybind to toggle the
|
||||||
// gtk-titlebar can also be used to disable the header bar (but keep
|
// decorations.
|
||||||
// the window manager's decorations).
|
|
||||||
if (app.config.@"gtk-titlebar") {
|
if (app.config.@"gtk-titlebar") {
|
||||||
const header = c.gtk_header_bar_new();
|
const header = c.gtk_header_bar_new();
|
||||||
c.gtk_window_set_titlebar(gtk_window, header);
|
c.gtk_window_set_titlebar(gtk_window, header);
|
||||||
@ -99,9 +98,9 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
_ = c.g_signal_connect_data(btn, "clicked", c.G_CALLBACK(>kTabNewClick), self, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(btn, "clicked", c.G_CALLBACK(>kTabNewClick), self, null, c.G_CONNECT_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Hide window decoration if configured. This has to happen before
|
// If we are disabling decorations then disable them right away.
|
||||||
// `gtk_widget_show`.
|
if (!app.config.@"window-decoration") {
|
||||||
c.gtk_window_set_decorated(gtk_window, 0);
|
c.gtk_window_set_decorated(gtk_window, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,6 +295,15 @@ pub fn toggleFullscreen(self: *Window, _: configpkg.NonNativeFullscreen) void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Toggle the window decorations for this window.
|
||||||
|
pub fn toggleWindowDecorations(self: *Window) void {
|
||||||
|
if (c.gtk_window_get_decorated(self.window) == 0) {
|
||||||
|
c.gtk_window_set_decorated(self.window, 1);
|
||||||
|
} else {
|
||||||
|
c.gtk_window_set_decorated(self.window, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Grabs focus on the currently selected tab.
|
/// Grabs focus on the currently selected tab.
|
||||||
fn focusCurrentTab(self: *Window) void {
|
fn focusCurrentTab(self: *Window) void {
|
||||||
const page_idx = c.gtk_notebook_get_current_page(self.notebook);
|
const page_idx = c.gtk_notebook_get_current_page(self.notebook);
|
||||||
|
@ -571,6 +571,11 @@ class: ?[:0]const u8 = null,
|
|||||||
///
|
///
|
||||||
/// * only a single key input is allowed, `ctrl+a+b` is invalid.
|
/// * only a single key input is allowed, `ctrl+a+b` is invalid.
|
||||||
///
|
///
|
||||||
|
/// * the key input can be prefixed with `physical:` to specify a
|
||||||
|
/// physical key mapping rather than a logical one. A physical key
|
||||||
|
/// mapping responds to the hardware keycode and not the keycode
|
||||||
|
/// translated by any system keyboard layouts. Example: "ctrl+physical:a"
|
||||||
|
///
|
||||||
/// Valid modifiers are `shift`, `ctrl` (alias: `control`), `alt` (alias: `opt`,
|
/// Valid modifiers are `shift`, `ctrl` (alias: `control`), `alt` (alias: `opt`,
|
||||||
/// `option`), and `super` (alias: `cmd`, `command`). You may use the modifier
|
/// `option`), and `super` (alias: `cmd`, `command`). You may use the modifier
|
||||||
/// or the alias. When debugging keybinds, the non-aliased modifier will always
|
/// or the alias. When debugging keybinds, the non-aliased modifier will always
|
||||||
@ -608,6 +613,12 @@ class: ?[:0]const u8 = null,
|
|||||||
/// * `keybind=clear` will clear all set keybindings. Warning: this
|
/// * `keybind=clear` will clear all set keybindings. Warning: this
|
||||||
/// removes ALL keybindings up to this point, including the default
|
/// removes ALL keybindings up to this point, including the default
|
||||||
/// keybindings.
|
/// keybindings.
|
||||||
|
///
|
||||||
|
/// A keybind by default causes the input to be consumed. This means that the
|
||||||
|
/// associated encoding (if any) will not be sent to the running program
|
||||||
|
/// in the terminal. If you wish to send the encoded value to the program,
|
||||||
|
/// specify the "unconsumed:" prefix before the entire keybind. For example:
|
||||||
|
/// "unconsumed:ctrl+a=reload_config"
|
||||||
keybind: Keybinds = .{},
|
keybind: Keybinds = .{},
|
||||||
|
|
||||||
/// Window padding. This applies padding between the terminal cells and the
|
/// Window padding. This applies padding between the terminal cells and the
|
||||||
@ -669,7 +680,12 @@ keybind: Keybinds = .{},
|
|||||||
/// * `true`
|
/// * `true`
|
||||||
/// * `false` - windows won't have native decorations, i.e. titlebar and
|
/// * `false` - windows won't have native decorations, i.e. titlebar and
|
||||||
/// borders. On MacOS this also disables tabs and tab overview.
|
/// borders. On MacOS this also disables tabs and tab overview.
|
||||||
|
///
|
||||||
|
/// The "toggle_window_decoration" keybind action can be used to create
|
||||||
|
/// a keybinding to toggle this setting at runtime.
|
||||||
|
///
|
||||||
|
/// Changing this configuration in your configuration and reloading will
|
||||||
|
/// only affect new windows. Existing windows will not be affected.
|
||||||
@"window-decoration": bool = true,
|
@"window-decoration": bool = true,
|
||||||
|
|
||||||
/// The font that will be used for the application's window and tab titles.
|
/// The font that will be used for the application's window and tab titles.
|
||||||
@ -781,17 +797,6 @@ keybind: Keybinds = .{},
|
|||||||
// Default is false.
|
// Default is false.
|
||||||
@"focus-follows-mouse": bool = false,
|
@"focus-follows-mouse": bool = false,
|
||||||
|
|
||||||
/// When enabled, the full GTK titlebar is displayed instead of your window
|
|
||||||
/// manager's simple titlebar. The behavior of this option will vary with your
|
|
||||||
/// window manager.
|
|
||||||
///
|
|
||||||
/// This option does nothing when `window-decoration` is false or when running
|
|
||||||
/// under macOS.
|
|
||||||
///
|
|
||||||
/// Changing this value at runtime and reloading the configuration will only
|
|
||||||
/// affect new windows.
|
|
||||||
@"gtk-titlebar": bool = true,
|
|
||||||
|
|
||||||
/// Whether to allow programs running in the terminal to read/write to the
|
/// Whether to allow programs running in the terminal to read/write to the
|
||||||
/// system clipboard (OSC 52, for googling). The default is to allow clipboard
|
/// system clipboard (OSC 52, for googling). The default is to allow clipboard
|
||||||
/// reading after prompting the user and allow writing unconditionally.
|
/// reading after prompting the user and allow writing unconditionally.
|
||||||
@ -1102,6 +1107,17 @@ keybind: Keybinds = .{},
|
|||||||
/// so you can test single instance without conflicting with release builds.
|
/// so you can test single instance without conflicting with release builds.
|
||||||
@"gtk-single-instance": GtkSingleInstance = .desktop,
|
@"gtk-single-instance": GtkSingleInstance = .desktop,
|
||||||
|
|
||||||
|
/// When enabled, the full GTK titlebar is displayed instead of your window
|
||||||
|
/// manager's simple titlebar. The behavior of this option will vary with your
|
||||||
|
/// window manager.
|
||||||
|
///
|
||||||
|
/// This option does nothing when `window-decoration` is false or when running
|
||||||
|
/// under macOS.
|
||||||
|
///
|
||||||
|
/// Changing this value at runtime and reloading the configuration will only
|
||||||
|
/// affect new windows.
|
||||||
|
@"gtk-titlebar": bool = true,
|
||||||
|
|
||||||
/// Determines the side of the screen that the GTK tab bar will stick to.
|
/// Determines the side of the screen that the GTK tab bar will stick to.
|
||||||
/// Top, bottom, left, and right are supported. The default is top.
|
/// Top, bottom, left, and right are supported. The default is top.
|
||||||
@"gtk-tabs-location": GtkTabsLocation = .top,
|
@"gtk-tabs-location": GtkTabsLocation = .top,
|
||||||
|
@ -266,6 +266,9 @@ pub const Action = union(enum) {
|
|||||||
/// Toggle fullscreen mode of window.
|
/// Toggle fullscreen mode of window.
|
||||||
toggle_fullscreen: void,
|
toggle_fullscreen: void,
|
||||||
|
|
||||||
|
/// Toggle window decorations on and off. This only works on Linux.
|
||||||
|
toggle_window_decorations: void,
|
||||||
|
|
||||||
/// Quit ghostty.
|
/// Quit ghostty.
|
||||||
quit: void,
|
quit: void,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user