[mutter/wayland] xrandr: ignore the error if setting the primary output fails



commit 643645938141e8564d9c1a0e728c7b1be6b57876
Author: Alberto Milone <alberto milone canonical com>
Date:   Tue Dec 3 18:16:22 2013 +0100

    xrandr: ignore the error if setting the primary output fails
    
    Some drivers which support RandR 1.4 may not support setting
    or getting the primary output, therefore mutter should trap
    and ignore any relevant errors.
    
    The modesetting driver exposes this problem when used in
    combination with the nvidia binary driver using RandR 1.4
    offloading.
    
    Also use a local display variable instead of calling
    meta_get_display () every time.

 src/core/monitor-xrandr.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/core/monitor-xrandr.c b/src/core/monitor-xrandr.c
index e723c1c..167b94c 100644
--- a/src/core/monitor-xrandr.c
+++ b/src/core/monitor-xrandr.c
@@ -453,8 +453,10 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager)
       XRRFreeCrtcInfo (crtc);
     }
 
+  meta_error_trap_push (meta_get_display ());
   primary_output = XRRGetOutputPrimary (manager_xrandr->xdisplay,
                                        DefaultRootWindow (manager_xrandr->xdisplay));
+  meta_error_trap_pop (meta_get_display ());
 
   n_actual_outputs = 0;
   for (i = 0; i < (unsigned)resources->noutput; i++)
@@ -691,10 +693,11 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
                                                 unsigned int         n_outputs)
 {
   MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager);
+  MetaDisplay *display = meta_get_display ();
   unsigned i;
   int width, height, width_mm, height_mm;
 
-  meta_display_grab (meta_get_display ());
+  meta_display_grab (display);
 
   /* First compute the new size of the screen (framebuffer) */
   width = 0; height = 0;
@@ -788,10 +791,10 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
    */
   width_mm = (width / DPI_FALLBACK) * 25.4 + 0.5;
   height_mm = (height / DPI_FALLBACK) * 25.4 + 0.5;
-  meta_error_trap_push (meta_get_display ());
+  meta_error_trap_push (display);
   XRRSetScreenSize (manager_xrandr->xdisplay, DefaultRootWindow (manager_xrandr->xdisplay),
                     width, height, width_mm, height_mm);
-  meta_error_trap_pop (meta_get_display ());
+  meta_error_trap_pop (display);
 
   for (i = 0; i < n_crtcs; i++)
     {
@@ -848,7 +851,7 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
               goto next;
             }
 
-          meta_error_trap_push (meta_get_display ());
+          meta_error_trap_push (display);
           ok = XRRSetCrtcConfig (manager_xrandr->xdisplay,
                                  manager_xrandr->resources,
                                  (XID)crtc->crtc_id,
@@ -857,7 +860,7 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
                                  (XID)mode->mode_id,
                                  wl_transform_to_xrandr (crtc_info->transform),
                                  outputs, n_outputs);
-          meta_error_trap_pop (meta_get_display ());
+          meta_error_trap_pop (display);
 
           if (ok != Success)
             {
@@ -898,9 +901,11 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
 
       if (output_info->is_primary)
         {
+          meta_error_trap_push (display);
           XRRSetOutputPrimary (manager_xrandr->xdisplay,
                                DefaultRootWindow (manager_xrandr->xdisplay),
                                (XID)output_info->output->output_id);
+          meta_error_trap_pop (display);
         }
 
       output_set_presentation_xrandr (manager_xrandr,
@@ -926,7 +931,7 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
       output->is_primary = FALSE;
     }
 
-  meta_display_ungrab (meta_get_display ());
+  meta_display_ungrab (display);
 }
 
 static void


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