summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKosmiK2001 <[email protected]>2026-10-27 08:10:30 +0300
committerLuke from DC <[email protected]>2026-10-27 07:52:51 +0000
commit3ba51cb0642c8c52c15a4f61fecf34f8c41cf3d6 (patch)
tree3ed7b41f1f2268875c011bd035f023e278eb98a4 /src
parentcd1baeb643af8025e300c6b78f722ee2e2e7322f (diff)
downloadmate-terminal-master.tar.bz2
mate-terminal-master.tar.xz
terminal-window: don't paint the CSD shadow margins when transparentHEADmaster
With a transparent profile background the toplevel becomes app-paintable and terminal_window_draw() fills the whole window. GTK reserves margins on such a toplevel for the client-side window shadow and the titlebar, so the fill paints those margins too: the shadow disappears and the margins show up as a band of the terminal background around the window (it was the theme background before, which read as a second, lighter window). Fill only the content rectangle (the child allocation) and leave the margins to the shadow, exactly as the non-paintable path does. The opaque path is unchanged. The band only appears when the toplevel really has CSD margins - measured on a Wayland session as toplevel 708x523 with child 656x434+26+60 - which is why it is not visible everywhere.
Diffstat (limited to 'src')
-rw-r--r--src/terminal-window.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/terminal-window.c b/src/terminal-window.c
index b3830495..8cdede45 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -1776,6 +1776,7 @@ terminal_window_draw (GtkWidget *widget,
int width;
int height;
GtkWidget *child;
+ TerminalWindow *window = TERMINAL_WINDOW (widget);
/* Get the *child* allocation, so we don't overwrite window borders */
child = gtk_bin_get_child (GTK_BIN (widget));
@@ -1784,8 +1785,62 @@ terminal_window_draw (GtkWidget *widget,
context = gtk_widget_get_style_context (widget);
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
- gtk_render_background (context, cr, 0, 0, width, height);
- gtk_render_frame (context, cr, 0, 0, width, height);
+
+ /* A transparent profile background makes the toplevel app-paintable,
+ * and GTK then reserves margins on it for the client-side window
+ * shadow and the titlebar. Filling the whole toplevel paints those
+ * margins as well: the shadow is gone and the margins show up as a
+ * band of the terminal background around the window. Fill only the
+ * content rectangle and leave the margins to the shadow. */
+ if (window->priv->active_screen != NULL)
+ {
+ TerminalProfile *profile = terminal_screen_get_profile (window->priv->active_screen);
+ const GdkRGBA *bg_rgba;
+ GdkRGBA bg;
+ GdkRGBA *theme_bg = NULL;
+
+ bg_rgba = (const GdkRGBA *) terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BACKGROUND_COLOR);
+ if (bg_rgba != NULL)
+ {
+ bg = *bg_rgba;
+ }
+ else
+ {
+ gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
+ GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
+ &theme_bg, NULL);
+ if (theme_bg != NULL)
+ {
+ bg = *theme_bg;
+ gdk_rgba_free (theme_bg);
+ }
+ else
+ {
+ bg.red = bg.green = bg.blue = 0.0;
+ bg.alpha = 1.0;
+ }
+ }
+
+ if (terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE)
+ == TERMINAL_BACKGROUND_TRANSPARENT)
+ {
+ bg.alpha = terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS);
+ }
+
+ cairo_save (cr);
+ cairo_rectangle (cr,
+ child_allocation.x, child_allocation.y,
+ child_allocation.width, child_allocation.height);
+ cairo_clip (cr);
+ gdk_cairo_set_source_rgba (cr, &bg);
+ cairo_paint (cr);
+ cairo_restore (cr);
+ }
+ else
+ {
+ gtk_render_background (context, cr, 0, 0, width, height);
+ gtk_render_frame (context, cr, 0, 0, width, height);
+ }
gtk_render_background (context, cr,
child_allocation.x, child_allocation.y,