[Xfce4-commits] [xfce/xfce4-power-manager] 01/01: Add support of xfce4-screensaver

noreply at xfce.org noreply at xfce.org
Mon Jul 22 02:34:09 CEST 2019


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

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-power-manager.

commit c06710f6ab925678b9130e680aa8c7014e9e75b4
Author: Olivier Duchateau <duchateau.olivier at gmail.com>
Date:   Tue Jun 25 18:31:02 2019 +0200

    Add support of xfce4-screensaver
    
    Signed-off-by: Sean Davis <smd.seandavis at gmail.com>
---
 src/xfce-screensaver.c | 125 +++++++++++++++++++++++++++++--------------------
 1 file changed, 74 insertions(+), 51 deletions(-)

diff --git a/src/xfce-screensaver.c b/src/xfce-screensaver.c
index 63ba6e7..6d8d98a 100644
--- a/src/xfce-screensaver.c
+++ b/src/xfce-screensaver.c
@@ -69,6 +69,7 @@ typedef enum
     SCREENSAVER_TYPE_CINNAMON,
     SCREENSAVER_TYPE_MATE,
     SCREENSAVER_TYPE_GNOME,
+    SCREENSAVER_TYPE_XFCE,
     SCREENSAVER_TYPE_OTHER,
     N_SCREENSAVER_TYPE
 } ScreenSaverType;
@@ -257,6 +258,13 @@ xfce_screensaver_setup(XfceScreenSaver *saver)
     {
         DBG ("using gnome screensaver daemon");
         saver->priv->screensaver_type = SCREENSAVER_TYPE_GNOME;
+    } else if (screen_saver_proxy_setup (saver,
+                                         "org.xfce.ScreenSaver",
+                                         "/org.xfce/ScreenSaver",
+                                         "org.xfce.ScreenSaver"))
+    {
+        DBG ("using Xfce screensaver daemon");
+        saver->priv->screensaver_type = SCREENSAVER_TYPE_XFCE;
     }
     else
     {
@@ -402,63 +410,77 @@ void
 xfce_screensaver_inhibit (XfceScreenSaver *saver,
                           gboolean inhibit)
 {
-    if (saver->priv->screensaver_type != SCREENSAVER_TYPE_FREEDESKTOP &&
-        saver->priv->screensaver_type != SCREENSAVER_TYPE_MATE)
-    {
-        /* remove any existing keepalive */
-        if (saver->priv->screensaver_id != 0)
-        {
-            g_source_remove (saver->priv->screensaver_id);
-            saver->priv->screensaver_id = 0;
-        }
-
-        if (inhibit)
-        {
-            /* Reset the screensaver timers every so often so they don't activate */
-            saver->priv->screensaver_id = g_timeout_add_seconds (20,
-                                                                 (GSourceFunc)xfce_reset_screen_saver,
-                                                                 saver);
-        }
-        return;
-    }
-
-    /* SCREENSAVER_TYPE_FREEDESKTOP & SCREENSAVER_TYPE_MATE
+    /* SCREENSAVER_TYPE_FREEDESKTOP, SCREENSAVER_TYPE_MATE,
+     * SCREENSAVER_TYPE_GNOME and SCREENSAVER_TYPE_XFCE
      * don't need a periodic timer because they have an actual
      * inhibit/uninhibit setup */
-    if (inhibit)
-    {
-        GVariant *response = NULL;
-        response = g_dbus_proxy_call_sync (saver->priv->proxy,
-                                           "Inhibit",
-                                           g_variant_new ("(ss)",
-                                                          PACKAGE_NAME,
-                                                          "Inhibit requested"),
-                                           G_DBUS_CALL_FLAGS_NONE,
-                                           -1,
-                                           NULL,
-                                           NULL);
-        if (response != NULL)
+    switch (saver->priv->screensaver_type) {
+        case SCREENSAVER_TYPE_FREEDESKTOP:
+        case SCREENSAVER_TYPE_MATE:
+        case SCREENSAVER_TYPE_GNOME:
+        case SCREENSAVER_TYPE_XFCE:
         {
-            g_variant_get (response, "(u)", &saver->priv->cookie);
-            g_variant_unref (response);
+            if (inhibit)
+            {
+                GVariant *response = NULL;
+                response = g_dbus_proxy_call_sync (saver->priv->proxy,
+                                                   "Inhibit",
+                                                   g_variant_new ("(ss)",
+                                                                  PACKAGE_NAME,
+                                                                  "Inhibit requested"),
+                                                   G_DBUS_CALL_FLAGS_NONE,
+                                                   -1,
+                                                   NULL, NULL);
+                if (response != NULL)
+                {
+                    g_variant_get (response, "(u)",
+                                   &saver->priv->cookie);
+                    g_variant_unref (response);
+                }
+            }
+            else
+            {
+                GVariant *response = NULL;
+                response = g_dbus_proxy_call_sync (saver->priv->proxy,
+                                                   "UnInhibit",
+                                                   g_variant_new ("(u)",
+                                                                  saver->priv->cookie),
+                                                   G_DBUS_CALL_FLAGS_NONE,
+                                                   -1,
+                                                   NULL, NULL);
+
+                saver->priv->cookie = 0;
+                if (response != NULL)
+                {
+                    g_variant_unref (response);
+                }
+            }
+            break;
         }
-    }
-    else
-    {
-        GVariant *response = NULL;
-        response = g_dbus_proxy_call_sync (saver->priv->proxy,
-                                           "UnInhibit",
-                                           g_variant_new ("(u)",
-                                                          saver->priv->cookie),
-                                           G_DBUS_CALL_FLAGS_NONE,
-                                           -1,
-                                           NULL,
-                                           NULL);
+        case SCREENSAVER_TYPE_OTHER:
+        case SCREENSAVER_TYPE_CINNAMON:
+        {
+            /* remove any existing keepalive */
+            if (saver->priv->screensaver_id != 0)
+            {
+                g_source_remove (saver->priv->screensaver_id);
+                saver->priv->screensaver_id = 0;
+            }
 
-        saver->priv->cookie = 0;
-        if (response != NULL)
+            if (inhibit)
+            {
+                /* Reset the screensaver timers every so often
+                 * so they don't activate */
+                saver->priv->screensaver_id = g_timeout_add_seconds (20,
+                                                                     (GSourceFunc)xfce_reset_screen_saver,
+                                                                     saver);
+            }
+            break;
+        }
+        default:
         {
-            g_variant_unref (response);
+            g_warning("Not able to inhibit or uninhibit screensaver");
+            break;
         }
     }
 }
@@ -480,6 +502,7 @@ xfce_screensaver_lock (XfceScreenSaver *saver)
         case SCREENSAVER_TYPE_FREEDESKTOP:
         case SCREENSAVER_TYPE_MATE:
         case SCREENSAVER_TYPE_GNOME:
+        case SCREENSAVER_TYPE_XFCE:
         {
             GVariant *response = NULL;
             response = g_dbus_proxy_call_sync (saver->priv->proxy,

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


More information about the Xfce4-commits mailing list