← Back to Pull requests

appearance in wayland: Support changing theme, icon theme, and font #749

Closed
lukefromdc closed this pull request without merging on May 26, 2024 18:02 UTC
View on GitHub
lukefromdc lukefromdc commented on Mar 28, 2024 00:45 UTC
Author

If we are in a wayland session, write the gtk theme and icon theme to both org.mate and org.gnome This changes wayland and xwayland themes simultaniously *startup with x11 backend, if we are under wayland without xwayland we don't have mate-settings-daemon anyway

Diff: 143 lines (+137 / -6) across 5 files Reviewer: zhuyaliang Review duration: 85997m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.39) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 143 lines diff across 5 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.75 · 5 substantive comment(s)
0.75
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
81%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.297
Real PR Conversation Timeline
52 items
zhuyaliang zhuyaliang commented on code on Mar 28, 2024 01:16 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +49,22 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  int ret;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  ret = system ("killall -0 -e Xwayland");

Suggest replacing ``system` with `g_spawn_command_line_async``

lukefromdc lukefromdc commented on code on Mar 28, 2024 06:53 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +49,22 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  int ret;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  ret = system ("killall -0 -e Xwayland");

I just tested that change, and unfortunately I could not get it to work. The reason is that with system() we get the return value of the program being run, and that's what we are using to distinguish the wayland session from an x11 session while running under Xwayland.

With g_spawn_command_line_async() we don't. Since finding nothing on running killall -0 -e <anything> does not seem to be considered an error, using GError doesn't seem to give a way of distinguishing this either. While this function is a gboolean returning TRUE or FALSE, it seems to return TRUE unconditionally when running
g_spawn_command_line_async("killall -0 -e Xwayland", NULL);
I tested that by comparing behavior in both wayland and x11 sessions

A different issue cropped up trying to use g_spawn_command_line_async() to start mate-appearance-properties from caja in https://github.com/mate-desktop/caja/pull/1771
if using mate-control-center 1.28.0 or current git master, we cannot open mate-appearance-properties without passing GDK_BACKEND=x11 as an environmental variable. We can get by without it entirely in caja if this PR is applied to mate-control-center, but that would cause caja to have different behavior in wayland depending on which version of m-c-c is installed, shortly after a major release. Not a hard dependency due to the fallback, but something that might generate bug reports.

g_spawn_command_line_async() does not seem to be able to pass environmental variables, and neither do the similar commands such as those that underlie caja_launch_application_from_command. That one can be made to work by setting it to open a command in terminal, but then we have that showing on the desktop plus all the code to run a totally unneeded terminal. Three things worked there: g_spawn_command_line_async() or caja_launch_application_from_command() with this PR applied to m-c-c and not trying to pass any environmental variables, or caja_launch_application_from_command() setting terminal usabe to TRUE, which allowed GDK_BACKEND=x11 to be passed and the background page of this capplet to open.

I agree that it would be good to avoid system() as it is heavy, but this seems to be hard to avoid here. In this case, an alternative mode of detecting that we are in a wayland session from an app running in Xwayland might be able get us around using system() which is rather heavy for this job. In the caja case by comparison, the fork etc should be less of a concern as mate-appearance-properties being launched from there is a whole new toplevel program anyway. There too though we have to run two checks, there too I tested g_spawn_command_line_async() and the checks didn't work.

Thoughts?

lukefromdc lukefromdc commented on Mar 28, 2024 07:28 UTC
Author

Latest force-push adds control of cursor theme, note however that cursor theme setting in wayland has been reported to be buggy no matter how it's done.

lukefromdc lukefromdc commented on code on Mar 29, 2024 18:33 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +49,22 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  int ret;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  ret = system ("killall -0 -e Xwayland");

Since https://github.com/mate-desktop/mate-control-center/pull/749/commits/3835297e5add6c2d3327d5813b861939e41d1713 the appearance capplet can now run under native wayland. That means we no longer need that system call to detect the session so
https://github.com/mate-desktop/mate-control-center/pull/749/commits/4832386262c8fbadf6cce5bacb0b571b15b99338

removes it, and this should make lighter code

lukefromdc lukefromdc commented on Mar 29, 2024 19:02 UTC
Author

https://github.com/mate-desktop/caja/pull/1771 updated to take advantage of this without depending on it.

Still a draft as I am hoping to get theme customization to apply in wayland. we have fonts, theme, and icon theme now but customization of a theme is only applying on closing and reopening m-c-c.

lukefromdc lukefromdc commented on Mar 29, 2024 19:05 UTC
Author

We also need to suppress the "settings manager is not running" error dialog in wayland, since the settings manager is used only to control Xwayland. Alternately the dialog could be modified under wayland to indicate specifically that settings won't be applied in Xwayland, and suppress it when the appearance capplet is opened to the background page

lukefromdc lukefromdc commented on Apr 04, 2024 05:41 UTC
Author

Since a caja PR takes advantage of this, customized theme support can be included with this if I can find what is needed to apply customization in this timeframe, or it can wait for a followup.

This gives a lot of new functionality in a wayland session as matters stand now,partially resolving one of the biggest user hassles: how to set the theme and font.

Rebased against current master after the 1.29 version bump

zhuyaliang zhuyaliang commented on code on May 08, 2024 02:16 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

Why is it ``0`` here? If multiple monitors are connected, will there be a problem here? I'm not sure

zhuyaliang zhuyaliang commented on code on May 08, 2024 02:35 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,26 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;
+

Extra spaces

lukefromdc lukefromdc commented on code on May 08, 2024 19:52 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

We are setting the font here, and right now I have yet to figure out how to do this on a per-monitor basis. First priority on that would be showing the caja desktop on all monitors. Monitor 0 (leftmost or only monitor on single monitor setup) is always present, and in the wayland session it's where caja's desktop goes unless manually started from a terminal on another monitor.

If you know a better way I am definately interested in it

lukefromdc lukefromdc commented on code on May 08, 2024 19:58 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,26 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;
+

This file was converted some time ago to GNOME style 2 space indents. That is the indent under the if statement, same under the else statement. If this makes the file hard to read, I can use brackets instead if you or anyone else prefers.

zhuyaliang zhuyaliang commented on code on May 09, 2024 01:21 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

Would it be better to use ``gdk_display_get_primary_monitor`` ?

lukefromdc lukefromdc commented on May 09, 2024 22:18 UTC
Author

Not sure it would alwaya work

https://docs.gtk.org/gdk3/method.Display.get_primary_monitor.html

Says this can return NULL when no primary monitor is configured, and in Wayland the concept of a primary monitor seems to have not been implemented.

zhuyaliang zhuyaliang commented on code on May 10, 2024 01:23 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

Would it be better to use ``gdk_display_get_monitor_at_window`` instead

lukefromdc lukefromdc commented on May 10, 2024 04:33 UTC
Author

That might work, will try it when I get home

lukefromdc lukefromdc commented on code on May 10, 2024 18:19 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

We don't have the window the capplet is using within get_dpi_from_x_server_or_monitor, and we don't have it in the calling function either. Thus we'd have to pass the window through a lot of other functions to get it here it seems.

In an ideal multimonitor case, an argument could be made for using the monitor the capplet is on, or for using the monitor the desktop is on. Setting a different font for each monitor would require a lot of other changes, notable additional gsettings values to store additional values in, we'd have to show each possible monitor in the capplet at well

zhuyaliang zhuyaliang commented on code on May 11, 2024 06:28 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -421,20 +421,40 @@ dpi_from_pixels_and_mm (int pixels, int mm)
 }
 
 static double
-get_dpi_from_x_server (void)
+get_dpi_from_x_server_or_monitor (void)
 {
   GdkScreen  *screen;
+  GdkDisplay *display;
   double dpi;
 
   screen = gdk_screen_get_default ();
+  display = gdk_display_get_default();
 
   if (screen) {
     double width_dpi, height_dpi;
 
-    Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
+    if (GDK_IS_X11_DISPLAY (display))
+    {
+      Screen *xscreen = gdk_x11_screen_get_xscreen (screen);
 
-    width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
-    height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+      width_dpi = dpi_from_pixels_and_mm (WidthOfScreen (xscreen), WidthMMOfScreen (xscreen));
+      height_dpi = dpi_from_pixels_and_mm (HeightOfScreen (xscreen), HeightMMOfScreen (xscreen));
+    }
+    else
+    {
+      GdkMonitor *monitor;
+      GdkRectangle geometry = {0};
+
+      /*FIXME: we have to use the main monitor for this
+       *which may not always be the leftmost monitor
+       *Separate per-monitor settings for this would be ideal
+       */
+      monitor = gdk_display_get_monitor (display, 0);

I personally think there's no problem. Let others take a look too

zhuyaliang zhuyaliang approved these changes on May 11, 2024 06:29 UTC
Approved Reviewer

Not validated in the Wayland environment, there are no issues with the code logic

lukefromdc lukefromdc commented on May 11, 2024 07:16 UTC
Author

Hoping we can get a review by another who has the wayland session set up

lukefromdc lukefromdc commented on May 22, 2024 00:04 UTC
Author

Is anyone else able to test this in a wayland session, should I merge it, or something else?

cwendling cwendling commented on code on May 22, 2024 09:24 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");

That's a bit… meh. Can't we just check whether the app's display is a Wayland one? The only probable issue is if the app is run under Xwayland, but maybe it's only fair that it might not control the Wayland session in that case?

cwendling cwendling commented on code on May 22, 2024 09:25 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

how does this interact if one of the settings change (either the GNOME or MATE one) from outside? does it sync both, or does this goes crazy? I would think it would just sync both but better safe than sorry

cwendling cwendling commented on code on May 22, 2024 09:26 UTC
Code Review
capplets/appearance/appearance.h:1
@@ -58,6 +58,7 @@
 #define GTK_THEME_KEY                "gtk-theme"
 #define ICON_THEME_KEY               "icon-theme"
 #define INTERFACE_SCHEMA             "org.mate.interface"
+#define INTERFACE_GNOME_SCHEMA       "org.gnome.desktop.interface"

does this add a strong dependency on GNOME desktop schemas?

cwendling cwendling commented on code on May 22, 2024 09:27 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,26 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;

The comment seems out of sync.
But I like the check better than the system call :)

cwendling cwendling commented on code on May 22, 2024 09:28 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

BTW if it works, maybe we could just bind the two regardless of Wayland? Does it cause any issue on X11? It's just that MCC would partially control the GNOME settings as well, but given some apps use those maybe it's only fair?

cwendling cwendling commented on code on May 22, 2024 09:41 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

(BTW IMO we should at some point have MSD work under Wayland, but I get that it's very far from trivial, so maybe it's not realistic, at least not for now…)

lukefromdc lukefromdc commented on code on May 22, 2024 17:33 UTC
Code Review
capplets/appearance/appearance.h:1
@@ -58,6 +58,7 @@
 #define GTK_THEME_KEY                "gtk-theme"
 #define ICON_THEME_KEY               "icon-theme"
 #define INTERFACE_SCHEMA             "org.mate.interface"
+#define INTERFACE_GNOME_SCHEMA       "org.gnome.desktop.interface"

Not a new one, pretty sure gtk3 itself depends on that, correct me if I am wrong.

lukefromdc lukefromdc commented on code on May 22, 2024 17:34 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,26 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;

Thanks for catching this, looks like two code blocks I wrote at two different times used two different methods

lukefromdc lukefromdc commented on code on May 22, 2024 18:08 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

All the code does here is write to gsettings. I just checked, having this and dconf-editor open at the same time. If you change it in either one it is applied and immediately reflected in the other.

Binding the GNOME settings when under x11 would probably get complaints from users and even distros, as no doubt some want to have both sessions installed and with different settings. This is no problem under x11 but is impossible under wayland at this time unless we maintain our own compositor (probably a fork of wayfire but with really very few changes). Probably we should submit a PR for wayfire to allow use of MATE or other gsettings for these values.

Another approach might be to add a slider in the control center for something like "Set GNOME values too (needed for wayland session)" and let users decide what to do.

lukefromdc lukefromdc commented on code on May 22, 2024 18:10 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,26 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out if we are running under wayland and have xwayland
+   *Sending signal 0 with killall doesn't kill the process but
+   *the return value tells us whether the process exists
+   */
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;

That is fixed, I missed it in the previous commit that removed the same system call elsewhere. Thanks again for finding it.

lukefromdc lukefromdc commented on May 22, 2024 18:45 UTC
Author

Last force-push just updates a comment to reflect that in native wayland we no longer have to resort to the system call

lukefromdc lukefromdc commented on code on May 22, 2024 18:50 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

Also note that we DO in fact need to run mate-settings-daemon in the x11 session or we don't apply nondefault theme/font/icon theme values in Xwayland apps. It controls only settings of apps running under x11 or xwayland, but without it we can no longer sync the theme etc between a wayland session and apps running under xwayland. Therefore, we run m-s-d under the current wayland session for that purpose

lukefromdc lukefromdc commented on code on May 22, 2024 18:54 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");

The original reason for this was that at first I had this whole capplet running under xwayland. Once I got past that and got it running under native wayland, there was no more need for this roundabout approach. One of today's updates removed the leftover instance of this,

cwendling cwendling commented on code on May 23, 2024 07:45 UTC
Code Review
capplets/appearance/appearance-font.c:1
@@ -781,6 +802,40 @@ void font_init(AppearanceData* data)
 			  G_CALLBACK (marco_changed),
 			  data);
 
+	/*In a wayland session we must manage MATE font settings for xwayland
+	 *and also manage GNOME font settings for native wayland applications
+	 *
+	 *First find out if we are running under a wayland session
+	 */
+
+	ret = system ("killall -0 -e Xwayland");
+	/*If we are, set the GNOME interface keys too*/
+	if (ret == 0)
+	{
+		widget = appearance_capplet_get_widget(data, "application_font");
+		g_settings_bind (data->interface_gnome_settings,
+				 GTK_FONT_KEY,
+				 G_OBJECT (widget),
+				 "font-name",
+				 G_SETTINGS_BIND_DEFAULT);

Probably we should submit a PR for wayfire to allow use of MATE or other gsettings for these values.

Yeah I don't know how wayfire works yet, but possibly a plugin similar to Compiz's MATE integration? Anyway yes if it's at this level that it has to be modified it'd make sense to do so there. But I guess that can be delayed if you prefer.

cwendling cwendling commented on code on May 23, 2024 07:58 UTC
Code Review
capplets/appearance/appearance.h:1
@@ -58,6 +58,7 @@
 #define GTK_THEME_KEY                "gtk-theme"
 #define ICON_THEME_KEY               "icon-theme"
 #define INTERFACE_SCHEMA             "org.mate.interface"
+#define INTERFACE_GNOME_SCHEMA       "org.gnome.desktop.interface"

Apparently it does use it for the Wayland backend indeed. Though, if I read the code properly it's a soft-dependency, and a fallback one at that, and it uses the DBus org.freedesktop.portal.Settings interface on the org.freedesktop.portal.Desktop session bus (plus something for the fontconfig settings). So either that's what Wayfire provides, or we'd just have to provide that instead of an XSettings backend in MSD.

cwendling cwendling commented on code on May 23, 2024 08:03 UTC
Code Review
capplets/appearance/appearance.h:1
@@ -58,6 +58,7 @@
 #define GTK_THEME_KEY                "gtk-theme"
 #define ICON_THEME_KEY               "icon-theme"
 #define INTERFACE_SCHEMA             "org.mate.interface"
+#define INTERFACE_GNOME_SCHEMA       "org.gnome.desktop.interface"

So what I mean is that this does make MCC depend on the GNOME desktop schemas. Whether another component needed for the Wayland session already does or not is yet to be determined.

cwendling cwendling commented on code on May 23, 2024 08:09 UTC
Code Review
capplets/appearance/appearance-main.c:1
@@ -56,6 +56,8 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context)
 
   data->filechooser_settings = g_settings_new (FILECHOOSER_SCHEMA);
   data->interface_settings = g_settings_new (INTERFACE_SCHEMA);
+  /*Loading this unconditionally may be cheaper than another system() call*/
+  data->interface_gnome_settings = g_settings_new (INTERFACE_GNOME_SCHEMA);

you could remove the comment or guard with a ! GDK_IS_X11_DISDPLAY() call

cwendling cwendling commented on code on May 23, 2024 08:14 UTC
Code Review
capplets/appearance/appearance-main.c:1
@@ -56,6 +56,8 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context)
 
   data->filechooser_settings = g_settings_new (FILECHOOSER_SCHEMA);
   data->interface_settings = g_settings_new (INTERFACE_SCHEMA);
+  /*Loading this unconditionally may be cheaper than another system() call*/
+  data->interface_gnome_settings = g_settings_new (INTERFACE_GNOME_SCHEMA);

BTW if you wanted this schema to be optional (in case it makes any sense to have it optional), you could do something like this:

  GSettingsSchemaSource *source = g_settings_schema_source_get_default ();

  if (source)
  {
    GSettingsSchema *schema = g_settings_schema_source_lookup (source, INTERFACE_GNOME_SCHEMA, TRUE);

    if (schema)
      data->interface_gnome_settings = g_settings_new_full (schema, NULL, NULL);
  }

Again, not saying you should do that, as there's no point if we have to have this schema for things to work.

cwendling cwendling commented on code on May 23, 2024 08:20 UTC
Code Review
capplets/common/mate-theme-apply.c:1
@@ -48,13 +50,24 @@ void
 mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
 {
   GSettings *interface_settings;
+  GSettings *interface_gnome_settings;
   GSettings *marco_settings;
   GSettings *mouse_settings;
   GSettings *notification_settings = NULL;
   gchar *old_key;
   gint old_key_int;
+  gboolean wayland;
+
+  /*Find out whether we are running under wayland or x11 */
+
+  if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
+    wayland = FALSE;
+
+  else
+    wayland = TRUE;

What about doing something like this instead?

    if (GDK_IS_X11_DISPLAY ((gdk_display_get_default())))
        interface_gnome_settings = g_settings_new (INTERFACE_GNOME_SCHEMA);
    else
        interface_gnome_settings = NULL;

/* … */

    if (interface_gnome_settings)
        g_settings_set_string (interface_gnome_settings, 
                               GTK_THEME_KEY, meta_theme_info->gtk_theme_name);

Just to avoid coupling wayland and interface_gnome_settings.

Just an idea, feel free to scrap it :)

lukefromdc lukefromdc commented on code on May 23, 2024 16:59 UTC
Code Review
capplets/appearance/appearance-main.c:1
@@ -56,6 +56,8 @@ init_appearance_data (int *argc, char ***argv, GOptionContext *context)
 
   data->filechooser_settings = g_settings_new (FILECHOOSER_SCHEMA);
   data->interface_settings = g_settings_new (INTERFACE_SCHEMA);
+  /*Loading this unconditionally may be cheaper than another system() call*/
+  data->interface_gnome_settings = g_settings_new (INTERFACE_GNOME_SCHEMA);

Since we no longer use system() to tell if we are under wayland or x11, we no longer have to deal unconditionally with that schema. Wayfire btw does indeed depend on it as wayfire (and probably a lot of other non-GNOME/non-KDE compositors) use the GNOME gsettings values.

lukefromdc lukefromdc commented on May 23, 2024 18:29 UTC
Author

Wayfire's Debian package itself does NOT depend on gsettings-desktop-schemas(debian packaging names here), not sure how it handles settings themes etc (maybe using Adwaita unconditionally?) when this is not installed.

Anyway, I can add checking for the existance of the GNOME interface schema so this will not crash if some distro is shipping GTK without it and assuming that works. Debian's GTK 3 builds at least used to depend on it, I've never tested anything without that package as it would break so much of my system

cwendling cwendling commented on May 23, 2024 20:06 UTC
Contributor

Wayfire's Debian package itself does NOT depend on gsettings-desktop-schemas(debian packaging names here), not sure how it handles settings themes etc (maybe using Adwaita unconditionally?) when this is not installed.

I don't know either but as said it seems that on the GTK side a specific DBus name can provide the data, so they could also potentially get the info from some place else (be it a conffile or whatever) and present it that way. No idea. And the Debian package could be missing a dep as well if nobody noticed, this happens even in Debian :slightly_smiling_face:

Anyway, I can add checking for the existance of the GNOME interface schema so this will not crash if some distro is shipping GTK without it and assuming that works. Debian's GTK 3 builds at least used to depend on it, I've never tested anything without that package as it would break so much of my system

I don't know if it's actually worth it if it looks unlikely anybody is gonna have such a setup, so you can do whichever you prefer I think. And if you don't do it and somebody happen to find a setup where it's a problem, we can always add it…
OTOH if we depend on it we might want to make that explicit. :shrug:

lukefromdc lukefromdc commented on May 23, 2024 21:02 UTC
Author

Latest changes simplify the logic for detecting x11 vs wayland, looking for x11 once, loading the gnome schema if we are not under x11, then looking for the settings object it is loaded into. That also paves the way to not depending on the schema at all, just not setting the GNOME preferences (thus not theming anything running under wayfire at least) rather than say, crashing.

lukefromdc lukefromdc commented on May 23, 2024 21:14 UTC
Author

last force-push is just a rebase against master

lukefromdc lukefromdc commented on May 23, 2024 21:55 UTC
Author

Above commit allows installation when the GNOME schemas are not present, we just lose the ability to actually apply the chosen theme to non-xwayland apps when running under wayland with the GNOME schemas absent. No idea if that will ever be used of course

lukefromdc lukefromdc commented on May 24, 2024 21:40 UTC
Author

Thanks, we can keep that definition than

cwendling cwendling commented on May 24, 2024 21:44 UTC
Contributor

OK, I didn't test this yet, but code looks OK to me :+1:

lukefromdc lukefromdc commented on May 25, 2024 01:42 UTC
Author

Last commit just moves initializating of interface_gnome_settings to where it is declared, thus removing one line of code.

cwendling cwendling commented on May 25, 2024 21:37 UTC
Contributor

Looks good :+1:

lukefromdc lukefromdc commented on May 26, 2024 18:02 UTC
Author

Squashed and merged from the command line with https://github.com/mate-desktop/mate-control-center/commit/1e8c08e51ea38d5faec5f352ea5d00c565a0a63d to allow editing the commit message

lukefromdc lukefromdc commented on May 26, 2024 18:05 UTC
Author

Thanks everyone for reviewing!
We also have the related caja PR
https://github.com/mate-desktop/caja/pull/1771
which allows setting caja's background from the control center in wayland whenever mate-settings-daemon (as needed for xwayland apps) is running, falls back to the standalone wayland background dialog if it is not running or not installed

Reviewers
Assignees
lukefromdc lukefromdc
Labels
risk: low confidence: 81.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 38.6% (MEDIUM) · Higher = larger blast radius
38.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 81.1% · Lower = rushed or shallow review
81.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 7.3% · Safe to merge
7.3%