From 5884366b39182fdc84dd1565d1727dde03606897 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 1 Aug 2011 20:18:28 +0200 Subject: AWT/X11 Reduce XQueryExtension 'hang' ; Impl. use XineramaIsActive() instead of XineramaQueryScreens() - Reenable creating own XDisplay for AWT components, which reduces/removes hang in subsequent XQueryExtension call (fetchScreens .. XineramaEnabled()) - Impl. use XineramaIsActive() instead of XineramaQueryScreens() Reducing memory allocation, XFree call (which was missing anyways) --- .../awt/X11AWTGLXGraphicsConfigurationFactory.java | 20 +++++++++++--------- src/nativewindow/native/x11/XineramaHelper.c | 17 +++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java index ee7dd280e..5fcc8e4d1 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/awt/X11AWTGLXGraphicsConfigurationFactory.java @@ -89,19 +89,21 @@ public class X11AWTGLXGraphicsConfigurationFactory extends GLGraphicsConfigurati displayHandle = X11Util.createDisplay(null); owner = true; if(DEBUG) { - System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: using a thread local X11 display"); + System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: create local X11 display"); } } else { - if(DEBUG) { - System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: using AWT X11 display 0x"+Long.toHexString(displayHandle)); - } /** - * Using the AWT display handle works fine with NVidia and AMD drivers today 2011-02-22, - * hence no need for our own display instance anymore. - String name = X11Util.XDisplayString(displayHandle); - displayHandle = X11Util.createDisplay(name); - owner = true; + * Using the AWT display handle works fine with NVidia. + * However we experienced different results w/ AMD drivers, + * some work, but some behave erratic. + * I.e. hangs in XQueryExtension(..) via X11GraphicsScreen. */ + final String displayName = X11Util.XDisplayString(displayHandle); + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - X11AWTGLXGraphicsConfigurationFactory: create X11 display @ "+displayName+" / 0x"+Long.toHexString(displayHandle)); + } + displayHandle = X11Util.createDisplay(displayName); + owner = true; } ((AWTGraphicsDevice)awtScreen.getDevice()).setSubType(NativeWindowFactory.TYPE_X11, displayHandle); X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT); diff --git a/src/nativewindow/native/x11/XineramaHelper.c b/src/nativewindow/native/x11/XineramaHelper.c index 25a79645b..a4d380e13 100644 --- a/src/nativewindow/native/x11/XineramaHelper.c +++ b/src/nativewindow/native/x11/XineramaHelper.c @@ -37,6 +37,7 @@ #include #include +#include #ifdef __sun @@ -98,23 +99,23 @@ Bool XineramaEnabled(Display* display) { #else - char* XinExtName = "XINERAMA"; + static const char* XinExtName = "XINERAMA"; int32_t major_opcode, first_event, first_error; Bool gotXinExt = False; - int32_t locNumScr = 0; + Bool isXinActive = False; - XineramaScreenInfo *xinInfo; + // fprintf(stderr, "XineramaEnabled: p0\n"); fflush(stderr); gotXinExt = XQueryExtension(display, XinExtName, &major_opcode, &first_event, &first_error); + // fprintf(stderr, "XineramaEnabled: p1 gotXinExt %d\n",gotXinExt); fflush(stderr); if (gotXinExt) { - xinInfo = XineramaQueryScreens(display, &locNumScr); - if (xinInfo != NULL) { - return True; - } + isXinActive = XineramaIsActive(display); } - return False; + // fprintf(stderr, "XineramaEnabled: p2 XineramaIsActive %d\n", isXinActive); fflush(stderr); + + return isXinActive; #endif } -- cgit v1.2.3