[Xfce4-commits] [xfce/xfwm4] 04/05: compositor: Disable XPresent in case of error

noreply at xfce.org noreply at xfce.org
Thu Jan 19 09:33:59 CET 2017


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

olivier pushed a commit to branch master
in repository xfce/xfwm4.

commit 222e2c8af29b69fbdddf6d400aaa45acb4c6a850
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Wed Jan 11 09:31:01 2017 +0100

    compositor: Disable XPresent in case of error
    
    Bug: 13257
    
    If for some reason XPresentPixmap() fails, we might end up waiting
    forever for a present complete notification that will never arrive.
    
    Check for possible errors after XPresentPixmap() and disable XPresent in
    case of error.
    
    Signed-off-by: Olivier Fourdan <fourdan at xfce.org>
---
 src/compositor.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index 015030f..cf67264 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -99,6 +99,10 @@
 #define MONITOR_ROOT_PIXMAP   1
 #endif /* MONITOR_ROOT_PIXMAP */
 
+#ifdef HAVE_PRESENT_EXTENSION
+static int (*default_error_handler) (Display *, XErrorEvent *);
+#endif /* HAVE_PRESENT_EXTENSION */
+
 typedef struct _CWindow CWindow;
 struct _CWindow
 {
@@ -1615,6 +1619,37 @@ redraw_glx_texture (ScreenInfo *screen_info)
 #endif /* HAVE_EPOXY */
 
 #ifdef HAVE_PRESENT_EXTENSION
+static int
+present_error_handler (Display * dpy, XErrorEvent * err)
+{
+    DisplayInfo *display_info;
+
+    display_info = myDisplayGetDefault ();
+    g_return_val_if_fail (display_info, 0);
+
+    /* XPresentPixmap() can trigger a BadWindow rather than a BadMatch */
+    if (err->request_code == display_info->present_opcode && err->error_code == BadWindow)
+    {
+        ScreenInfo *screen_info;
+        screen_info = myDisplayGetScreenFromOutput (display_info, err->resourceid);
+
+        if (screen_info != NULL)
+        {
+            g_warning ("Disabling XPresent, error %d on window 0x%lx for request %d",
+                       err->error_code, err->resourceid, err->request_code);
+            screen_info->present_pending = FALSE;
+            screen_info->use_present = FALSE;
+        }
+    }
+
+    /* Chain with our default error handler if available */
+    if (default_error_handler)
+    {
+        return (default_error_handler (dpy, err));
+    }
+    return 0;
+}
+
 static void
 present_flip (ScreenInfo *screen_info, XserverRegion region, Pixmap pixmap)
 {
@@ -4167,7 +4202,7 @@ compositorInitDisplay (DisplayInfo *display_info)
     else
     {
         display_info->have_present = TRUE;
-
+        default_error_handler = XSetErrorHandler (present_error_handler);
         DBG ("present opcode:  %i", display_info->present_opcode);
         DBG ("present event base: %i", display_info->present_event_base);
         DBG ("present error base: %i", display_info->present_error_base);

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


More information about the Xfce4-commits mailing list