[Xfce4-commits] [xfce/xfdesktop] 33/34: Replace gdk_screen_get_monitor_plug_name

noreply at xfce.org noreply at xfce.org
Sun Apr 16 07:07:07 CEST 2017


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 43777f2c6914659bb57bebc71f8303932a4580f9
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Sun Apr 16 07:11:53 2017 +0300

    Replace gdk_screen_get_monitor_plug_name
    
    Using either gdk_monitor_get_model or a new helper function,
    xfdesktop_get_monitor_name_from_gtk_widget
---
 common/xfdesktop-common.c | 14 ++++++++++++++
 common/xfdesktop-common.h |  2 ++
 settings/main.c           |  4 ++--
 src/xfce-workspace.c      | 18 +++++++++++-------
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/common/xfdesktop-common.c b/common/xfdesktop-common.c
index 4b06f73..acadd26 100644
--- a/common/xfdesktop-common.c
+++ b/common/xfdesktop-common.c
@@ -53,6 +53,20 @@
 #include "xfdesktop-common.h"
 #include "xfce-backdrop.h" /* for XfceBackdropImageStyle */
 
+/* Free the string whe done using it */
+gchar*
+xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget)
+{
+    GdkWindow     *window = NULL;
+    GdkDisplay    *display = NULL;
+    GdkMonitor    *monitor = NULL;
+
+    window = gtk_widget_get_window(widget);
+    display = gdk_window_get_display(window);
+    monitor = gdk_display_get_monitor_at_window(display, window);
+
+    return g_strdup(gdk_monitor_get_model(monitor));
+}
 
 gint
 xfdesktop_compare_paths(GFile *a, GFile *b)
diff --git a/common/xfdesktop-common.h b/common/xfdesktop-common.h
index 2310441..7a46089 100644
--- a/common/xfdesktop-common.h
+++ b/common/xfdesktop-common.h
@@ -89,6 +89,8 @@
 
 G_BEGIN_DECLS
 
+gchar* xfdesktop_get_monitor_name_from_gtk_widget(GtkWidget *widget);
+
 gint xfdesktop_compare_paths(GFile *a, GFile *b);
 
 gboolean xfdesktop_image_file_is_valid(const gchar *filename);
diff --git a/settings/main.c b/settings/main.c
index 2f5139d..043fc8b 100644
--- a/settings/main.c
+++ b/settings/main.c
@@ -1523,7 +1523,7 @@ cb_update_background_tab(WnckWindow *wnck_window,
     display = gdk_window_get_display(window);
     monitor = gdk_display_get_monitor_at_window(display, window);
     monitor_num = display_get_monitor_num(display, monitor);
-    monitor_name = g_strdup(gdk_monitor_get_model(monitor));
+    monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview);
 
     /* Most of the time we won't change monitor, screen, or workspace so try
      * to bail out now if we can */
@@ -1557,7 +1557,7 @@ cb_update_background_tab(WnckWindow *wnck_window,
     panel->workspace = workspace_num;
     panel->screen = screen_num;
     panel->monitor = monitor_num;
-    panel->monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor_at_window(gdk_window_get_display(window), window)));
+    panel->monitor_name = xfdesktop_get_monitor_name_from_gtk_widget(panel->image_iconview);
 
     /* The first monitor has the option of doing the "spanning screens" style,
      * but only if there's multiple monitors attached. Remove it in all other cases.
diff --git a/src/xfce-workspace.c b/src/xfce-workspace.c
index 3c4518f..c3f9e20 100644
--- a/src/xfce-workspace.c
+++ b/src/xfce-workspace.c
@@ -144,12 +144,13 @@ xfce_workspace_set_xfconf_property_string(XfceWorkspace *workspace,
 {
     XfconfChannel *channel = workspace->priv->channel;
     char buf[1024];
+    GdkDisplay *display;
     gchar *monitor_name = NULL;
 
     TRACE("entering");
 
-    monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen,
-                                                    monitor_num);
+    display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+    monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor_num)));
 
     /* Get the backdrop's image property */
     if(monitor_name == NULL) {
@@ -176,14 +177,15 @@ xfce_workspace_set_xfconf_property_value(XfceWorkspace *workspace,
     XfconfChannel *channel = workspace->priv->channel;
     char buf[1024];
     gchar *monitor_name = NULL;
+    GdkDisplay *display;
 #ifdef G_ENABLE_DEBUG
     gchar *contents = NULL;
 #endif
 
     TRACE("entering");
 
-    monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen,
-                                                    monitor_num);
+    display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+    monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor_num)));
 
     /* Get the backdrop's image property */
     if(monitor_name == NULL) {
@@ -305,7 +307,7 @@ xfce_workspace_monitors_changed(XfceWorkspace *workspace,
         /* When spanning screens we only need one backdrop */
         n_monitors = 1;
     } else {
-        n_monitors = gdk_screen_get_n_monitors(gscreen);
+        n_monitors = gdk_display_get_n_monitors(gdk_screen_get_display(workspace->priv->gscreen));
     }
 
     /* Remove all backdrops so that the correct monitor is added/removed and
@@ -610,11 +612,13 @@ xfce_workspace_connect_backdrop_settings(XfceWorkspace *workspace,
     XfconfChannel *channel = workspace->priv->channel;
     char buf[1024];
     gint pp_len;
+    GdkDisplay *display;
     gchar *monitor_name = NULL;
 
     TRACE("entering");
 
-    monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen, monitor);
+    display = gdk_display_manager_get_default_display(gdk_display_manager_get());
+    monitor_name = g_strdup(gdk_monitor_get_model(gdk_display_get_monitor(display, monitor)));
 
     if(monitor_name == NULL) {
         g_snprintf(buf, sizeof(buf), "%smonitor%d/workspace%d/",
@@ -714,7 +718,7 @@ xfce_workspace_remove_backdrops(XfceWorkspace *workspace)
 
     g_return_if_fail(XFCE_IS_WORKSPACE(workspace));
 
-    n_monitors = gdk_screen_get_n_monitors(workspace->priv->gscreen);
+    n_monitors = gdk_display_get_n_monitors(gdk_screen_get_display(workspace->priv->gscreen));
 
     for(i = 0; i < n_monitors && i < workspace->priv->nbackdrops; ++i) {
         xfce_workspace_disconnect_backdrop_settings(workspace,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list