mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Reapply "Merge pull request #1690 from TheOnlyMrCat/gtk_opacity"
This reverts commit 57bf0b08ffe04578feb087fab739a48543c0ac75.
This commit is contained in:
@ -82,9 +82,9 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
|
|
||||||
c.gtk_window_set_icon_name(gtk_window, "com.mitchellh.ghostty");
|
c.gtk_window_set_icon_name(gtk_window, "com.mitchellh.ghostty");
|
||||||
|
|
||||||
// Apply background opacity if we have it
|
// Remove the window's background if any of the widgets need to be transparent
|
||||||
if (app.config.@"background-opacity" < 1) {
|
if (app.config.@"background-opacity" < 1) {
|
||||||
c.gtk_widget_set_opacity(@ptrCast(window), app.config.@"background-opacity");
|
c.gtk_widget_remove_css_class(@ptrCast(window), "background");
|
||||||
}
|
}
|
||||||
|
|
||||||
var header: ?*c.GtkHeaderBar = null;
|
var header: ?*c.GtkHeaderBar = null;
|
||||||
@ -126,6 +126,7 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
// In debug we show a warning and apply the 'devel' class to the window.
|
// In debug we show a warning and apply the 'devel' class to the window.
|
||||||
// This is a really common issue where people build from source in debug and performance is really bad.
|
// This is a really common issue where people build from source in debug and performance is really bad.
|
||||||
if (comptime std.debug.runtime_safety) {
|
if (comptime std.debug.runtime_safety) {
|
||||||
|
const warning_box = c.gtk_box_new(c.GTK_ORIENTATION_VERTICAL, 0);
|
||||||
const warning_text = "⚠️ You're running a debug build of Ghostty! Performance will be degraded.";
|
const warning_text = "⚠️ You're running a debug build of Ghostty! Performance will be degraded.";
|
||||||
if ((comptime adwaita.versionAtLeast(1, 3, 0)) and
|
if ((comptime adwaita.versionAtLeast(1, 3, 0)) and
|
||||||
adwaita.enabled(&app.config) and
|
adwaita.enabled(&app.config) and
|
||||||
@ -133,14 +134,16 @@ pub fn init(self: *Window, app: *App) !void {
|
|||||||
{
|
{
|
||||||
const banner = c.adw_banner_new(warning_text);
|
const banner = c.adw_banner_new(warning_text);
|
||||||
c.adw_banner_set_revealed(@ptrCast(banner), 1);
|
c.adw_banner_set_revealed(@ptrCast(banner), 1);
|
||||||
c.gtk_box_append(@ptrCast(box), @ptrCast(banner));
|
c.gtk_box_append(@ptrCast(warning_box), @ptrCast(banner));
|
||||||
} else {
|
} else {
|
||||||
const warning = c.gtk_label_new(warning_text);
|
const warning = c.gtk_label_new(warning_text);
|
||||||
c.gtk_widget_set_margin_top(warning, 10);
|
c.gtk_widget_set_margin_top(warning, 10);
|
||||||
c.gtk_widget_set_margin_bottom(warning, 10);
|
c.gtk_widget_set_margin_bottom(warning, 10);
|
||||||
c.gtk_box_append(@ptrCast(box), warning);
|
c.gtk_box_append(@ptrCast(warning_box), warning);
|
||||||
}
|
}
|
||||||
c.gtk_widget_add_css_class(@ptrCast(gtk_window), "devel");
|
c.gtk_widget_add_css_class(@ptrCast(gtk_window), "devel");
|
||||||
|
c.gtk_widget_add_css_class(@ptrCast(warning_box), "background");
|
||||||
|
c.gtk_box_append(@ptrCast(box), warning_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.notebook = Notebook.create(self, box);
|
self.notebook = Notebook.create(self, box);
|
||||||
|
@ -47,6 +47,10 @@ pub const Notebook = union(enum) {
|
|||||||
c.gtk_widget_set_vexpand(notebook_widget, 1);
|
c.gtk_widget_set_vexpand(notebook_widget, 1);
|
||||||
c.gtk_widget_set_hexpand(notebook_widget, 1);
|
c.gtk_widget_set_hexpand(notebook_widget, 1);
|
||||||
|
|
||||||
|
// Remove the background from the stack widget
|
||||||
|
const stack = c.gtk_widget_get_last_child(notebook_widget);
|
||||||
|
c.gtk_widget_add_css_class(stack, "transparent");
|
||||||
|
|
||||||
// All of our events
|
// All of our events
|
||||||
_ = c.g_signal_connect_data(notebook, "page-added", c.G_CALLBACK(>kPageAdded), window, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(notebook, "page-added", c.G_CALLBACK(>kPageAdded), window, null, c.G_CONNECT_DEFAULT);
|
||||||
_ = c.g_signal_connect_data(notebook, "page-removed", c.G_CALLBACK(>kPageRemoved), window, null, c.G_CONNECT_DEFAULT);
|
_ = c.g_signal_connect_data(notebook, "page-removed", c.G_CALLBACK(>kPageRemoved), window, null, c.G_CONNECT_DEFAULT);
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
.transparent {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
.transparent {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
.transparent {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
@ -32,3 +32,7 @@ label.size-overlay {
|
|||||||
label.size-overlay.hidden {
|
label.size-overlay.hidden {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.transparent {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user