[totem] screensaver: Only try to inhibit once



commit 537f1f0db59438a22e69e4314bafb00c660e7e64
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 7 10:53:48 2014 +0100

    screensaver: Only try to inhibit once
    
    This stops plenty of warnings appearing on the command-line when
    gtk_application_inhibit() fails. It can fail for a number of reasons,
    but the documentation's only hint is:
    If the platform does not support inhibiting or the request failed for
    some reason, 0 is returned.
    
    So only try to disable the screensaver once.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721054

 src/plugins/screensaver/totem-screensaver.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/screensaver/totem-screensaver.c b/src/plugins/screensaver/totem-screensaver.c
index 06d6241..c376f7b 100644
--- a/src/plugins/screensaver/totem-screensaver.c
+++ b/src/plugins/screensaver/totem-screensaver.c
@@ -51,6 +51,7 @@ typedef struct {
        BaconVideoWidget *bvw;
        GSettings *settings;
 
+       gboolean       inhibit_available;
        guint          handler_id_playing;
        guint          handler_id_metadata;
        guint          inhibit_cookie;
@@ -87,7 +88,8 @@ totem_screensaver_update_from_state (TotemObject *totem,
 
        if ((totem_object_is_playing (totem) != FALSE && has_video_frames) ||
            (totem_object_is_playing (totem) != FALSE && !lock_screensaver_on_audio)) {
-               if (pi->priv->inhibit_cookie == 0) {
+               if (pi->priv->inhibit_cookie == 0 &&
+                   pi->priv->inhibit_available) {
                        GtkWindow *window;
 
                        window = totem_object_get_main_window (totem);
@@ -95,6 +97,8 @@ totem_screensaver_update_from_state (TotemObject *totem,
                                                                                window,
                                                                                GTK_APPLICATION_INHIBIT_IDLE,
                                                                                _("Playing a movie"));
+                       if (pi->priv->inhibit_cookie == 0)
+                               pi->priv->inhibit_available = FALSE;
                        g_object_unref (window);
                }
        } else {
@@ -131,6 +135,8 @@ impl_activate (PeasActivatable *plugin)
        TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
        TotemObject *totem;
 
+       pi->priv->inhibit_available = TRUE;
+
        totem = g_object_get_data (G_OBJECT (plugin), "object");
        pi->priv->bvw = BACON_VIDEO_WIDGET (totem_object_get_video_widget (totem));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]