[gnome-desktop] Ignore DPMSSetTimeouts() and DPMSForceLevel() return value



commit 0328984c4a61b26e3bc2c382fbb2aac2e8e66221
Author: Alexandre Rostovtsev <tetromino gmail com>
Date:   Wed Oct 5 02:27:48 2011 -0400

    Ignore DPMSSetTimeouts() and DPMSForceLevel() return value
    
    At least with nvidia binary drivers, DPMSSetTimeouts() and DPMSForceLevel()
    always return BadRequest, even if they succeed. On a machine with intel
    graphics, DPMSForceLevel() was also observed to return BadRequest despite
    successfully changing the DPMS level. So we should just ignore the return
    value from these functions, like xset does.
    
    Also, there's no need to clear the timeouts twice if the mode has indeed
    changed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660962
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 libgnome-desktop/gnome-rr.c |   40 ++++++++--------------------------------
 1 files changed, 8 insertions(+), 32 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index d2cfe7b..243d2d0 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -1181,24 +1181,17 @@ static gboolean
 gnome_rr_screen_clear_dpms_timeouts (GnomeRRScreen *screen,
                                      GError **error)
 {
-    gboolean ret = TRUE;
-    gint rc;
-
     gdk_error_trap_push ();
-    rc = DPMSSetTimeouts (screen->priv->xdisplay, 0, 0, 0);
-    if (gdk_error_trap_pop ())
-        ret = FALSE;
-
-    if (!ret || rc != Success) {
-        ret = FALSE;
+    /* DPMSSetTimeouts() return value is often a lie, so ignore it */
+    DPMSSetTimeouts (screen->priv->xdisplay, 0, 0, 0);
+    if (gdk_error_trap_pop ()) {
         g_set_error_literal (error,
                              GNOME_RR_ERROR,
                              GNOME_RR_ERROR_UNKNOWN,
                              "Could not set DPMS timeouts");
-        goto out;
+        return FALSE;
     }
-out:
-    return ret;
+    return TRUE;
 }
 
 /**
@@ -1213,7 +1206,6 @@ gnome_rr_screen_set_dpms_mode (GnomeRRScreen *screen,
 {
     CARD16 state = 0;
     gboolean ret;
-    gint rc;
     GnomeRRDpmsMode current_mode;
 
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1246,11 +1238,9 @@ gnome_rr_screen_set_dpms_mode (GnomeRRScreen *screen,
     }
 
     gdk_error_trap_push ();
-    rc = DPMSForceLevel (screen->priv->xdisplay, state);
-    if (gdk_error_trap_pop ())
-        ret = FALSE;
-
-    if (!ret || rc != Success) {
+    /* DPMSForceLevel() return value is often a lie, so ignore it */
+    DPMSForceLevel (screen->priv->xdisplay, state);
+    if (gdk_error_trap_pop ()) {
         ret = FALSE;
         g_set_error_literal (error,
                              GNOME_RR_ERROR,
@@ -1259,20 +1249,6 @@ gnome_rr_screen_set_dpms_mode (GnomeRRScreen *screen,
         goto out;
     }
 
-    gdk_error_trap_push ();
-    rc = DPMSSetTimeouts (screen->priv->xdisplay, 0, 0, 0);
-    if (gdk_error_trap_pop ())
-        ret = FALSE;
-
-    if (!ret || rc != Success) {
-        ret = FALSE;
-        g_set_error_literal (error,
-                             GNOME_RR_ERROR,
-                             GNOME_RR_ERROR_UNKNOWN,
-                             "Could not set DPMS timeouts");
-        goto out;
-    }
-
     ret = gnome_rr_screen_clear_dpms_timeouts (screen, error);
     if (!ret)
         goto out;



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