summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-06-02 14:57:52 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-06-02 14:57:52 +0000
commit80c33ca2ddea9116b869302e9375de75e2dca0d9 (patch)
tree0200887c11b4de4b86765c13d19ba82a3e8c24d5
parent7307c6fdfbb2b48435f1783df2213bd0b3a7922c (diff)
parent5af6c37f8c407ea1e7c12956b1bab21758fb1f22 (diff)
downloadgtk+-80c33ca2ddea9116b869302e9375de75e2dca0d9.tar.gz
Merge branch 'wip/otte/for-master' into 'master'
x11: Be more careful with NVIDIA workaround See merge request GNOME/gtk!3620
-rw-r--r--gdk/x11/gdkglcontext-glx.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/gdk/x11/gdkglcontext-glx.c b/gdk/x11/gdkglcontext-glx.c
index 83006eb51c..eece4ce360 100644
--- a/gdk/x11/gdkglcontext-glx.c
+++ b/gdk/x11/gdkglcontext-glx.c
@@ -1271,6 +1271,12 @@ gdk_x11_screen_init_glx (GdkX11Screen *screen)
if (g_strcmp0 (glXGetClientString (dpy, GLX_VENDOR), "NVIDIA Corporation") == 0)
{
+ Atom type;
+ int format;
+ gulong nitems;
+ gulong bytes_after;
+ guchar *data = NULL;
+
/* With the mesa based drivers, we can safely assume the compositor can
* access the updated surface texture immediately after glXSwapBuffers is
* run, because the kernel ensures there is an implicit synchronization
@@ -1280,8 +1286,24 @@ gdk_x11_screen_init_glx (GdkX11Screen *screen)
* in that case, to defer telling the compositor our latest frame is
* ready until after the GPU has completed all issued commands related
* to the frame, and that the X server says the frame has been drawn.
+ *
+ * As this can cause deadlocks, we want to make sure to only enable it for Xorg,
+ * but not for XWayland, Xnest or whatever other X servers exist.
*/
- display_x11->has_async_glx_swap_buffers = TRUE;
+
+ gdk_x11_display_error_trap_push (display);
+ if (XGetWindowProperty (dpy, DefaultRootWindow (dpy),
+ gdk_x11_get_xatom_by_name_for_display (display, "XFree86_VT"),
+ 0, 1, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &data) == Success)
+ {
+ if (type != None)
+ display_x11->has_async_glx_swap_buffers = TRUE;
+ }
+ gdk_x11_display_error_trap_pop_ignored (display);
+
+ if (data)
+ XFree (data);
}
GDK_DISPLAY_NOTE (display, OPENGL,