mate-desktop / mate-terminal

The MATE Terminal Emulator
http://www.mate-desktop.org
GNU General Public License v3.0
135 stars 73 forks source link

Fix screen widget artifacts with Mutter-based WMs when transparent terminal background is enabled #434

Closed marcxjo closed 1 year ago

marcxjo commented 1 year ago

Addresses #432 and borrows liberally from the transparency patch in the AUR gnome-terminal-transparency package. Credit to the developers and patch collectors for that particular changeset.

A fix for this invoking gtk_widget_set_app_paintable was pushed up in e1b834a but rolled back due to the side effect of producing a transparent menu bar in Compiz (see #240). The current fix produces expected behavior in Marco, but produces visual composited artifacts in Mutter and Muffin.

This PR adds restores the invocation of gtk_widget_set_app_paintable while adding handling to explicitly draw the frame and background of the terminal window to prevent them from rendering as transparent. It also adds handling to update transparency on anchored state change.

Tested and compared outcomes with 8896efd. Artifacting persists in 8896efd when run in GNOME Shell. With these changes applied, artifacting behavior is no longer observed.

lukefromdc commented 1 year ago

Got these build warnings concerning gsettings handling starting at terminal-screen.c: line 1085:

../src/terminal-screen.c: In function ‘update_toplevel_transparency’:
../src/terminal-screen.c:1085:30: warning: initialization of ‘GSettings *’ {aka ‘struct _GSettings *’} from incompatible pointer type ‘TerminalProfile *’ {aka ‘struct _TerminalProfile *’} [-Wincompatible-pointer-types]
 1085 |         GSettings *profile = priv->profile;
      |                              ^~~~
../src/terminal-screen.c:1086:78: warning: passing argument 1 of ‘terminal_profile_get_property_enum’ from incompatible pointer type [-Wincompatible-pointer-types]
 1086 |         TerminalBackgroundType bg_type = terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE);
      |                                                                              ^~~~~~~
      |                                                                              |
      |                                                                              GSettings * {aka struct _GSettings *}
In file included from ../src/terminal-screen.h:27:
../src/terminal-profile.h:166:77: note: expected ‘TerminalProfile *’ {aka ‘struct _TerminalProfile *’} but argument is of type ‘GSettings *’ {aka ‘struct _GSettings *’}
  166 | int               terminal_profile_get_property_enum      (TerminalProfile *profile,
marcxjo commented 1 year ago

@lukefromdc thanks for the catch - cargo-culted the pointer type from the gnome-terminal patch. :grimacing:

Fixed now.

lukefromdc commented 1 year ago

While gtk_widget_set_app_paintable was removed from GTK4 WITHOUT ever being deprecated in GTK3, we have no plans to support GTK4 as too much was removed from it. While only two widgets in GTK3 use this flag, one of them is GtkWindow. Using CSS would be needed to set it transparent if we ever ported to GTK4 but we'd have to re-implement a heck of a lot of stuff to do that.

Will merge as this is a portover from GNOME-terminal and works