Skip to content

Missing default name if gdk_monitor_get_model(monitor) fails

In the (already closed) issue #380 (closed) I added details about a failure that I initially thought would be the same as that issue - but in the end it was something different.

I have a monitor where gdk_monitor_get_model(monitor) fails (returns a NULL pointer) and this causes inconsitencies between `build_property_prefix() and xfdesktop_settings_generate_per_workspace_binding_string().

This causes display of the default background no matter what changes I make in the xfdesktop-settings app.

This patch seems to fix it for me:

diff --git a/common/xfdesktop-common.c b/common/xfdesktop-common.c
index c846c05e..78cf048c 100644
--- a/common/xfdesktop-common.c
+++ b/common/xfdesktop-common.c
@@ -114,12 +114,16 @@ xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget, gint monitor_num)
     GdkWindow     *window = NULL;
     GdkDisplay    *display = NULL;
     GdkMonitor    *monitor = NULL;
+    const gchar   *monitor_name = NULL;
 
     window = gtk_widget_get_window(widget);
     display = gdk_window_get_display(window);
     monitor = gdk_display_get_monitor(display, monitor_num);
 
-    return g_strdup(gdk_monitor_get_model(monitor));
+    monitor_name = gdk_monitor_get_model(monitor);
+    if (monitor_name == NULL)
+        monitor_name = "default";
+    return g_strdup(monitor_name);
 }
 
 gint