[console/wip/exalm/transparency: 4/4] Remove terminal transparency




commit dbd3541acbf6e4a64e7f1f248f9cdc1e182b81d1
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Aug 4 21:37:40 2022 +0400

    Remove terminal transparency
    
    Fixes https://gitlab.gnome.org/GNOME/console/-/issues/170

 src/kgx-pages.c    | 23 --------------------
 src/kgx-tab.c      | 32 ---------------------------
 src/kgx-terminal.c | 49 +++++++----------------------------------
 src/kgx-terminal.h |  2 --
 src/kgx-window.c   | 64 ++----------------------------------------------------
 src/kgx-window.h   |  1 -
 src/kgx-window.ui  |  2 ++
 src/style-dark.css |  8 -------
 8 files changed, 12 insertions(+), 169 deletions(-)
---
diff --git a/src/kgx-pages.c b/src/kgx-pages.c
index 8137fee..4f94aee 100644
--- a/src/kgx-pages.c
+++ b/src/kgx-pages.c
@@ -66,7 +66,6 @@ struct _KgxPagesPrivate {
   PangoFontDescription *font;
   double                zoom;
   KgxTheme              theme;
-  gboolean              opaque;
   gint64                scrollback_lines;
 
   AdwTabPage           *action_page;
@@ -83,7 +82,6 @@ enum {
   PROP_TITLE,
   PROP_PATH,
   PROP_THEME,
-  PROP_OPAQUE,
   PROP_FONT,
   PROP_ZOOM,
   PROP_IS_ACTIVE,
@@ -148,9 +146,6 @@ kgx_pages_get_property (GObject    *object,
     case PROP_THEME:
       g_value_set_enum (value, priv->theme);
       break;
-    case PROP_OPAQUE:
-      g_value_set_boolean (value, priv->opaque);
-      break;
     case PROP_FONT:
       g_value_set_boxed (value, priv->font);
       break;
@@ -197,9 +192,6 @@ kgx_pages_set_property (GObject      *object,
     case PROP_THEME:
       priv->theme = g_value_get_enum (value);
       break;
-    case PROP_OPAQUE:
-      priv->opaque = g_value_get_boolean (value);
-      break;
     case PROP_FONT:
       if (priv->font) {
         g_boxed_free (PANGO_TYPE_FONT_DESCRIPTION, priv->font);
@@ -619,20 +611,6 @@ kgx_pages_class_init (KgxPagesClass *klass)
                        KGX_THEME_NIGHT,
                        G_PARAM_READWRITE);
 
-  /**
-   * KgxPages:opaque:
-   *
-   * Whether to disable transparency
-   *
-   * Bound to #GtkWindow:is-maximized on the #KgxWindow
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_OPAQUE] =
-    g_param_spec_boolean ("opaque", "Opaque", "Terminal opaqueness",
-                          FALSE,
-                          G_PARAM_READWRITE);
-
   pspecs[PROP_FONT] =
     g_param_spec_boxed ("font", "Font", "Monospace font",
                          PANGO_TYPE_FONT_DESCRIPTION,
@@ -713,7 +691,6 @@ kgx_pages_init (KgxPages *self)
   priv->font = NULL;
   priv->zoom = KGX_FONT_SCALE_DEFAULT;
   priv->theme = KGX_THEME_NIGHT;
-  priv->opaque = FALSE;
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
diff --git a/src/kgx-tab.c b/src/kgx-tab.c
index 16d0ec5..cc3345c 100644
--- a/src/kgx-tab.c
+++ b/src/kgx-tab.c
@@ -47,7 +47,6 @@ struct _KgxTabPrivate {
   double                zoom;
   KgxStatus             status;
   KgxTheme              theme;
-  gboolean              opaque;
   gint64                scrollback_lines;
 
   gboolean              is_active;
@@ -61,13 +60,11 @@ struct _KgxTabPrivate {
   GBinding             *term_font_bind;
   GBinding             *term_zoom_bind;
   GBinding             *term_theme_bind;
-  GBinding             *term_opaque_bind;
   GBinding             *term_scrollback_bind;
 
   GBinding             *pages_font_bind;
   GBinding             *pages_zoom_bind;
   GBinding             *pages_theme_bind;
-  GBinding             *pages_opaque_bind;
   GBinding             *pages_scrollback_bind;
 
   GtkWidget            *stack;
@@ -109,7 +106,6 @@ enum {
   PROP_ZOOM,
   PROP_THEME,
   PROP_IS_ACTIVE,
-  PROP_OPAQUE,
   PROP_CLOSE_ON_QUIT,
   PROP_NEEDS_ATTENTION,
   PROP_SEARCH_MODE_ENABLED,
@@ -355,9 +351,6 @@ kgx_tab_get_property (GObject    *object,
     case PROP_THEME:
       g_value_set_enum (value, priv->theme);
       break;
-    case PROP_OPAQUE:
-      g_value_set_boolean (value, priv->opaque);
-      break;
     case PROP_CLOSE_ON_QUIT:
       g_value_set_boolean (value, priv->close_on_quit);
       break;
@@ -451,9 +444,6 @@ kgx_tab_set_property (GObject      *object,
     case PROP_THEME:
       priv->theme = g_value_get_enum (value);
       break;
-    case PROP_OPAQUE:
-      priv->opaque = g_value_get_boolean (value);
-      break;
     case PROP_CLOSE_ON_QUIT:
       priv->close_on_quit = g_value_get_boolean (value);
       break;
@@ -625,20 +615,6 @@ kgx_tab_class_init (KgxTabClass *klass)
                        KGX_THEME_NIGHT,
                        G_PARAM_READWRITE);
 
-  /**
-   * KgxTab:opaque:
-   *
-   * Whether to disable transparency
-   *
-   * Bound to #GtkWindow:is-maximized on the #KgxWindow
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_OPAQUE] =
-    g_param_spec_boolean ("opaque", "Opaque", "Terminal opaqueness",
-                          FALSE,
-                          G_PARAM_READWRITE);
-
   pspecs[PROP_CLOSE_ON_QUIT] =
     g_param_spec_boolean ("close-on-quit", "Close on quit",
                           "Should the tab close when dead",
@@ -836,7 +812,6 @@ kgx_tab_connect_terminal (KgxTab      *self,
   g_clear_object (&priv->term_font_bind);
   g_clear_object (&priv->term_zoom_bind);
   g_clear_object (&priv->term_theme_bind);
-  g_clear_object (&priv->term_opaque_bind);
   g_clear_object (&priv->term_scrollback_bind);
 
   g_set_object (&priv->terminal, term);
@@ -862,9 +837,6 @@ kgx_tab_connect_terminal (KgxTab      *self,
   priv->term_theme_bind = g_object_bind_property (self, "theme",
                                                   term, "theme",
                                                   G_BINDING_SYNC_CREATE);
-  priv->term_opaque_bind = g_object_bind_property (self, "opaque",
-                                                   term, "opaque",
-                                                   G_BINDING_SYNC_CREATE);
   priv->term_scrollback_bind = g_object_bind_property (self, "scrollback-lines",
                                                        term, "scrollback-lines",
                                                        G_BINDING_SYNC_CREATE);
@@ -1209,7 +1181,6 @@ kgx_tab_set_pages (KgxTab   *self,
   g_clear_object (&priv->pages_font_bind);
   g_clear_object (&priv->pages_zoom_bind);
   g_clear_object (&priv->pages_theme_bind);
-  g_clear_object (&priv->pages_opaque_bind);
   g_clear_object (&priv->pages_scrollback_bind);
 
   if (pages == NULL) {
@@ -1225,9 +1196,6 @@ kgx_tab_set_pages (KgxTab   *self,
   priv->pages_theme_bind = g_object_bind_property (pages, "theme",
                                                    self, "theme",
                                                    G_BINDING_SYNC_CREATE);
-  priv->pages_opaque_bind = g_object_bind_property (pages, "opaque",
-                                                    self, "opaque",
-                                                    G_BINDING_SYNC_CREATE);
   priv->pages_scrollback_bind = g_object_bind_property (pages, "scrollback-lines",
                                                         self, "scrollback-lines",
                                                         G_BINDING_SYNC_CREATE);
diff --git a/src/kgx-terminal.c b/src/kgx-terminal.c
index 848f2ae..33956e6 100644
--- a/src/kgx-terminal.c
+++ b/src/kgx-terminal.c
@@ -69,7 +69,6 @@ G_DEFINE_TYPE (KgxTerminal, kgx_terminal, VTE_TYPE_TERMINAL)
 enum {
   PROP_0,
   PROP_THEME,
-  PROP_OPAQUE,
   PROP_PATH,
   LAST_PROP
 };
@@ -137,7 +136,7 @@ update_terminal_colors (KgxTerminal *self)
   switch (resolved_theme) {
     case KGX_THEME_HACKER:
       fg = (GdkRGBA) { 0.1, 1.0, 0.1, 1.0};
-      bg = (GdkRGBA) { 0.05, 0.05, 0.05, 0.96 };
+      bg = (GdkRGBA) { 0.05, 0.05, 0.05, 1.0 };
       break;
     case KGX_THEME_DAY:
       fg = (GdkRGBA) { 0.0, 0.0, 0.0, 0.0 };
@@ -147,38 +146,26 @@ update_terminal_colors (KgxTerminal *self)
     case KGX_THEME_AUTO:
     default:
       fg = (GdkRGBA) { 1.0, 1.0, 1.0, 1.0};
-      bg = (GdkRGBA) { 0.12, 0.12, 0.12, 0.96 };
+      bg = (GdkRGBA) { 0.12, 0.12, 0.12, 1.0 };
       break;
   }
 
-  if (self->opaque) {
-    bg.alpha = 1.0;
-  }
-
   vte_terminal_set_colors (VTE_TERMINAL (self), &fg, &bg, palette, 16);
 }
 
 
 static void
 kgx_terminal_set_theme (KgxTerminal *self,
-                        KgxTheme     theme,
-                        gboolean     opaque)
+                        KgxTheme     theme)
 {
-  if (self->theme == theme && self->opaque == opaque) {
+  if (self->theme == theme) {
     return;
   }
 
-  if (self->theme != theme) {
-    self->theme = theme;
-    g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_THEME]);
-  }
-
-  if (self->opaque != opaque) {
-    self->opaque = opaque;
-    g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_OPAQUE]);
-  }
-
+  self->theme = theme;
   update_terminal_colors (self);
+
+  g_object_notify_by_pspec (G_OBJECT (self), pspecs[PROP_THEME]);
 }
 
 
@@ -192,10 +179,7 @@ kgx_terminal_set_property (GObject      *object,
 
   switch (property_id) {
     case PROP_THEME:
-      kgx_terminal_set_theme (self, g_value_get_enum (value), self->opaque);
-      break;
-    case PROP_OPAQUE:
-      kgx_terminal_set_theme (self, self->theme, g_value_get_boolean (value));
+      kgx_terminal_set_theme (self, g_value_get_enum (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -217,9 +201,6 @@ kgx_terminal_get_property (GObject    *object,
     case PROP_THEME:
       g_value_set_enum (value, self->theme);
       break;
-    case PROP_OPAQUE:
-      g_value_set_boolean (value, self->opaque);
-      break;
     case PROP_PATH:
       if ((uri = vte_terminal_get_current_file_uri (VTE_TERMINAL (self)))) {
         path = g_file_new_for_uri (uri);
@@ -520,20 +501,6 @@ kgx_terminal_class_init (KgxTerminalClass *klass)
                        KGX_TYPE_THEME, KGX_THEME_NIGHT,
                        G_PARAM_READWRITE);
 
-  /**
-   * KgxTerminal:opaque:
-   *
-   * Whether to disable transparency
-   *
-   * Bound to #GtkWindow:is-maximized on the #KgxWindow
-   *
-   * Stability: Private
-   */
-  pspecs[PROP_OPAQUE] =
-    g_param_spec_boolean ("opaque", "Opaque", "Terminal opaqueness",
-                          FALSE,
-                          G_PARAM_READWRITE);
-
   /**
    * KgxTerminal:path:
    *
diff --git a/src/kgx-terminal.h b/src/kgx-terminal.h
index c6878a0..6c689d4 100644
--- a/src/kgx-terminal.h
+++ b/src/kgx-terminal.h
@@ -86,7 +86,6 @@ typedef enum /*< enum,prefix=KGX >*/
 /**
  * KgxTerminal:
  * @theme: the palette to use, see #KgxTerminal:theme
- * @opaque: is transparency enabled, see #KgxTerminal:opaque
  * @actions: action map for the context menu
  * @current_url: the address under the cursor
  * @match_id: regex ids for finding hyperlinks
@@ -99,7 +98,6 @@ struct _KgxTerminal {
 
   /*< public >*/
   KgxTheme    theme;
-  gboolean    opaque;
   GtkWidget  *popup_menu;
 
   /* Hyperlinks */
diff --git a/src/kgx-window.c b/src/kgx-window.c
index 264b201..5086afe 100644
--- a/src/kgx-window.c
+++ b/src/kgx-window.c
@@ -224,28 +224,8 @@ active_changed (GObject *object, GParamSpec *pspec, gpointer data)
 
 
 static void
-state_or_size_changed (KgxWindow  *self)
+size_changed (KgxWindow  *self)
 {
-  GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (self));
-  GdkToplevelState state = gdk_toplevel_get_state (GDK_TOPLEVEL (surface));
-
-  self->is_maximized_or_tiled =
-    (state & (GDK_TOPLEVEL_STATE_FULLSCREEN |
-              GDK_TOPLEVEL_STATE_MAXIMIZED |
-              GDK_TOPLEVEL_STATE_TILED |
-              GDK_TOPLEVEL_STATE_TOP_TILED |
-              GDK_TOPLEVEL_STATE_RIGHT_TILED |
-              GDK_TOPLEVEL_STATE_BOTTOM_TILED |
-              GDK_TOPLEVEL_STATE_LEFT_TILED)) > 0;
-
-  g_object_set (self->pages, "opaque", self->is_maximized_or_tiled, NULL);
-
-  if (self->is_maximized_or_tiled) {
-    gtk_widget_add_css_class (GTK_WIDGET (self), "opaque");
-  } else {
-    gtk_widget_remove_css_class (GTK_WIDGET (self), "opaque");
-  }
-
   gtk_window_get_default_size (GTK_WINDOW (self),
                                &self->current_width,
                                &self->current_height);
@@ -321,44 +301,6 @@ new_tab_cb (KgxTabSwitcher *switcher,
 }
 
 
-static void
-kgx_window_realize (GtkWidget *widget)
-{
-  KgxWindow *self = KGX_WINDOW (widget);
-  GdkSurface *surface;
-
-  GTK_WIDGET_CLASS (kgx_window_parent_class)->realize (widget);
-
-  surface = gtk_native_get_surface (GTK_NATIVE (self));
-
-  g_signal_connect_swapped (surface, "notify::state",
-                            G_CALLBACK (state_or_size_changed), self);
-  g_signal_connect_swapped (self, "notify::default-width",
-                            G_CALLBACK (state_or_size_changed), self);
-  g_signal_connect_swapped (self, "notify::default-height",
-                            G_CALLBACK (state_or_size_changed), self);
-
-  state_or_size_changed (self);
-}
-
-
-static void
-kgx_window_unrealize (GtkWidget *widget)
-{
-  KgxWindow *self = KGX_WINDOW (widget);
-  GdkSurface *surface = gtk_native_get_surface (GTK_NATIVE (self));
-
-  g_signal_handlers_disconnect_by_func (surface,
-                                        G_CALLBACK (state_or_size_changed),
-                                        self);
-  g_signal_handlers_disconnect_by_func (self,
-                                        G_CALLBACK (state_or_size_changed),
-                                        self);
-
-  GTK_WIDGET_CLASS (kgx_window_parent_class)->unrealize (widget);
-}
-
-
 static void
 kgx_window_class_init (KgxWindowClass *klass)
 {
@@ -371,9 +313,6 @@ kgx_window_class_init (KgxWindowClass *klass)
   object_class->set_property = kgx_window_set_property;
   object_class->get_property = kgx_window_get_property;
 
-  widget_class->realize = kgx_window_realize;
-  widget_class->unrealize = kgx_window_unrealize;
-
   window_class->close_request = kgx_window_close_request;
 
   /**
@@ -405,6 +344,7 @@ kgx_window_class_init (KgxWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, KgxWindow, primary_menu);
 
   gtk_widget_class_bind_template_callback (widget_class, active_changed);
+  gtk_widget_class_bind_template_callback (widget_class, size_changed);
 
   gtk_widget_class_bind_template_callback (widget_class, zoom);
   gtk_widget_class_bind_template_callback (widget_class, status_changed);
diff --git a/src/kgx-window.h b/src/kgx-window.h
index 94bff51..2b364d2 100644
--- a/src/kgx-window.h
+++ b/src/kgx-window.h
@@ -99,7 +99,6 @@ struct _KgxWindow
 
   int                   current_width;
   int                   current_height;
-  gboolean              is_maximized_or_tiled;
 
   GActionMap           *tab_actions;
 };
diff --git a/src/kgx-window.ui b/src/kgx-window.ui
index 9c44f25..32e904c 100644
--- a/src/kgx-window.ui
+++ b/src/kgx-window.ui
@@ -31,6 +31,8 @@
   </menu>
   <template class="KgxWindow" parent="AdwApplicationWindow">
     <signal name="notify::is-active" handler="active_changed" swapped="no"/>
+    <signal name="notify::default-width" handler="size_changed" swapped="no"/>
+    <signal name="notify::default-height" handler="size_changed" swapped="no"/>
     <property name="content">
       <object class="KgxTabSwitcher" id="tab_switcher">
         <signal name="new-tab" handler="new_tab_cb" swapped="no"/>
diff --git a/src/style-dark.css b/src/style-dark.css
index e6ec435..01dd760 100644
--- a/src/style-dark.css
+++ b/src/style-dark.css
@@ -3,11 +3,3 @@
 
 @define-color remote_headerbar_bg_color       shade(@purple_5, 0.6);
 @define-color remote_headerbar_backdrop_color shade(@purple_5, 0.45);
-
-.empty-state {
-  background: alpha(@view_bg_color, 0.96);
-}
-
-window.opaque .empty-state {
-  background: @view_bg_color;
-}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]