From d9a9765a61e9d0844f8ad10a9bef3053ed3b6798 Mon Sep 17 00:00:00 2001 From: numeral Date: Mon, 17 Jun 2013 12:04:58 -0400 Subject: [PATCH] Make Pseudo Transparency Work! Added pseudo_transparency bool in info_config struct, and changed set_opacity to use it for vte_set_background_transparent(). --- termite.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/termite.cc b/termite.cc index 101323d..51e0e08 100644 --- a/termite.cc +++ b/termite.cc @@ -88,7 +88,7 @@ struct hint_info { struct config_info { hint_info hints; char *browser; - gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set; + gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set, pseudo_transparency; int tag; char *config_file; }; @@ -105,7 +105,7 @@ struct draw_cb_info { }; static void launch_browser(char *browser, char *url); -static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity); +static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity, gboolean pseudo); static void window_title_cb(VteTerminal *vte, gboolean *dynamic_title); static gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info); static gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *info); @@ -130,9 +130,9 @@ void launch_browser(char *browser, char *url) { g_spawn_async(nullptr, browser_cmd, nullptr, G_SPAWN_SEARCH_PATH, nullptr, nullptr, nullptr, nullptr); } -static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity) { +static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity, gboolean psuedo) { vte_terminal_set_background_saturation(vte, opacity); - vte_terminal_set_background_transparent(vte, false); + vte_terminal_set_background_transparent(vte, psuedo); GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(window)); GdkVisual *visual; @@ -1168,6 +1168,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info, info->dynamic_title = cfg_bool("dynamic_title", TRUE); info->urgent_on_bell = cfg_bool("urgent_on_bell", TRUE); info->clickable_url = cfg_bool("clickable_url", TRUE); + info->pseudo_transparency = cfg_bool("pseudo_transparency", FALSE); if (info->clickable_url) { info->tag = @@ -1234,7 +1235,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info, if (auto opacity = get_config_double(config, "options", "transparency")) { if (!info->opacity_set) { - set_opacity(GTK_WIDGET(window), vte, *opacity); + set_opacity(GTK_WIDGET(window), vte, *opacity, info->pseudo_transparency); } } @@ -1337,7 +1338,7 @@ int main(int argc, char **argv) { nullptr}, {vi_mode::insert, 0, 0, 0, 0}, {{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, 0, 0}, - nullptr, FALSE, FALSE, FALSE, FALSE, -1, config_file} + nullptr, FALSE, FALSE, FALSE, FALSE, FALSE, -1, config_file} }; load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry); @@ -1401,7 +1402,7 @@ int main(int argc, char **argv) { if (trans > 0.0) { info.config.opacity_set = true; - set_opacity(GTK_WIDGET(window), vte, trans); + set_opacity(GTK_WIDGET(window), vte, trans, info.config.pseudo_transparency); } gtk_widget_grab_focus(vte_widget);