From 686f9b46070cd8fd257bd367f2a1e0595ddc50dd Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 11 Aug 2014 21:29:00 +0100 Subject: [PATCH] x11: Update GL viewport on ConfigureNotify On X11, by virtue of the asynchronous nature of the protocol, we have to wait until the ConfigureNotify event to resize the GL viewport. If the GdkWindow is a top-level one, then we'll get a GDK_CONFIGURE event, but if we're using a GDK_WINDOW_CHILD the event will be dropped on the floor. --- gdk/x11/gdkdisplay-x11.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 1837347b61..f6ba01ab9b 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -782,11 +782,27 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator, } #endif - if (!window || - xevent->xconfigure.event != xevent->xconfigure.window || - GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD || + if (!window || + xevent->xconfigure.event != xevent->xconfigure.window || GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT) - return_val = FALSE; + { + return_val = FALSE; + } + else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) + { + /* on X11 we need to wait until a ConfigureNotify before + * updating the GL viewport, otherwise the GLX drawable + * and the X drawable will go out of sync. + */ + if (gdk_window_has_gl_context (window)) + { + GdkGLContext *context = gdk_window_get_gl_context (window); + + gdk_gl_context_update (context); + } + + return_val = FALSE; + } else { event->configure.type = GDK_CONFIGURE;