From fb2a59dcdc87be6abcd67acf4c4028c921b607ae Mon Sep 17 00:00:00 2001
From: Clement Lefebvre <clement.lefebvre@linuxmint.com>
Date: Fri, 4 Sep 2015 21:51:14 +0100
Subject: Switch to org.gnome.SessionManager

---
 libcaja-private/caja-file-utilities.c |  8 +++----
 src/caja-application.c                | 43 ++++++++++++++++-------------------
 src/file-manager/fm-icon-view.c       | 19 ----------------
 3 files changed, 23 insertions(+), 47 deletions(-)

diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c
index 51083122..ca946a00 100644
--- a/libcaja-private/caja-file-utilities.c
+++ b/libcaja-private/caja-file-utilities.c
@@ -1117,12 +1117,12 @@ caja_is_engrampa_installed (void)
     return installed > 0 ? TRUE : FALSE;
 }
 
-#define GSM_NAME  "org.mate.SessionManager"
-#define GSM_PATH "/org/mate/SessionManager"
-#define GSM_INTERFACE "org.mate.SessionManager"
+#define GSM_NAME  "org.gnome.SessionManager"
+#define GSM_PATH "/org/gnome/SessionManager"
+#define GSM_INTERFACE "org.gnome.SessionManager"
 
 /* The following values come from
- * http://www.gnome.org/~mccann/mate-session/docs/mate-session.html#org.mate.SessionManager.Inhibit
+ * http://www.gnome.org/~mccann/mate-session/docs/mate-session.html#org.gnome.SessionManager.Inhibit
  */
 #define INHIBIT_LOGOUT (1U)
 #define INHIBIT_SUSPEND (4U)
diff --git a/src/caja-application.c b/src/caja-application.c
index e4d2d973..557ae7e5 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -1107,7 +1107,8 @@ caja_application_startup (CajaApplication *application,
             {
                 open_windows (application, NULL,
                               urls,
-                              gdk_screen_get_default (),
+                              gdk_display_get_default_screen (gdk_display_get_default()),
+                              // gdk_screen_get_default (),
                               geometry,
                               browser_window);
             }
@@ -1138,14 +1139,14 @@ selection_get_cb (GtkWidget          *widget,
 }
 
 static GtkWidget *
-get_desktop_manager_selection (GdkDisplay *display, int screen)
+get_desktop_manager_selection (GdkDisplay *display)
 {
     char selection_name[32];
     GdkAtom selection_atom;
     Window selection_owner;
     GtkWidget *selection_widget;
 
-    g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S%d", screen);
+    g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0");
     selection_atom = gdk_atom_intern (selection_name, FALSE);
 
     selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
@@ -1156,7 +1157,7 @@ get_desktop_manager_selection (GdkDisplay *display, int screen)
         return NULL;
     }
 
-    selection_widget = gtk_invisible_new_for_screen (gdk_display_get_screen (display, screen));
+    selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
     /* We need this for gdk_x11_get_server_time() */
     gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
 
@@ -1203,7 +1204,6 @@ caja_application_create_desktop_windows (CajaApplication *application)
     GdkDisplay *display;
     CajaDesktopWindow *window;
     GtkWidget *selection_widget;
-    int screens, i;
 
     g_return_if_fail (caja_application_desktop_windows == NULL);
     g_return_if_fail (CAJA_IS_APPLICATION (application));
@@ -1216,32 +1216,27 @@ caja_application_create_desktop_windows (CajaApplication *application)
     create_in_progress = TRUE;
 
     display = gdk_display_get_default ();
-    screens = gdk_display_get_n_screens (display);
 
-    for (i = 0; i < screens; i++)
+    selection_widget = get_desktop_manager_selection (display);
+    if (selection_widget != NULL)
     {
-        selection_widget = get_desktop_manager_selection (display, i);
-        if (selection_widget != NULL)
-        {
-            window = caja_desktop_window_new (application,
-                                              gdk_display_get_screen (display, i));
+        window = caja_desktop_window_new (application, gdk_display_get_default_screen (display));
 
-            g_signal_connect (selection_widget, "selection_clear_event",
-                              G_CALLBACK (selection_clear_event_cb), window);
+        g_signal_connect (selection_widget, "selection_clear_event",
+                          G_CALLBACK (selection_clear_event_cb), window);
 
-            g_signal_connect (window, "unrealize",
-                              G_CALLBACK (desktop_unrealize_cb), selection_widget);
+        g_signal_connect (window, "unrealize",
+                          G_CALLBACK (desktop_unrealize_cb), selection_widget);
 
-            /* We realize it immediately so that the CAJA_DESKTOP_WINDOW_ID
-               property is set so mate-settings-daemon doesn't try to set the
-               background. And we do a gdk_flush() to be sure X gets it. */
-            gtk_widget_realize (GTK_WIDGET (window));
-            gdk_flush ();
+        /* We realize it immediately so that the CAJA_DESKTOP_WINDOW_ID
+           property is set so mate-settings-daemon doesn't try to set the
+           background. And we do a gdk_flush() to be sure X gets it. */
+        gtk_widget_realize (GTK_WIDGET (window));
+        gdk_flush ();
 
 
-            caja_application_desktop_windows =
-                g_list_prepend (caja_application_desktop_windows, window);
-        }
+        caja_application_desktop_windows =
+            g_list_prepend (caja_application_desktop_windows, window);
     }
 
     create_in_progress = FALSE;
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 3d29bead..21e2cc5c 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -108,7 +108,6 @@ struct FMIconViewDetails
     GPid audio_preview_child_pid;
 
     gboolean filter_by_screen;
-    int num_screens;
 
     gboolean compact;
 
@@ -541,10 +540,7 @@ fm_icon_view_clear (FMDirectoryView *view)
 static gboolean
 should_show_file_on_screen (FMDirectoryView *view, CajaFile *file)
 {
-    char *screen_string;
-    int screen_num;
     FMIconView *icon_view;
-    GdkScreen *screen;
 
     icon_view = FM_ICON_VIEW (view);
 
@@ -553,20 +549,6 @@ should_show_file_on_screen (FMDirectoryView *view, CajaFile *file)
         return FALSE;
     }
 
-    /* Get the screen for this icon from the metadata. */
-    screen_string = caja_file_get_metadata
-                    (file, CAJA_METADATA_KEY_SCREEN, "0");
-    screen_num = atoi (screen_string);
-    g_free (screen_string);
-    screen = gtk_widget_get_screen (GTK_WIDGET (view));
-
-    if (screen_num != gdk_screen_get_number (screen) &&
-            (screen_num < icon_view->details->num_screens ||
-             gdk_screen_get_number (screen) > 0))
-    {
-        return FALSE;
-    }
-
     return TRUE;
 }
 
@@ -2447,7 +2429,6 @@ fm_icon_view_filter_by_screen (FMIconView *icon_view,
                                gboolean filter)
 {
     icon_view->details->filter_by_screen = filter;
-    icon_view->details->num_screens = gdk_display_get_n_screens (gtk_widget_get_display (GTK_WIDGET (icon_view)));
 }
 
 static void
-- 
cgit v1.2.1