public Boolean run() { boolean loadSuccess = false; if (X11GraphicsEnvironment.isXRenderAvailable()) { try { System.loadLibrary("jules"); loadSuccess = true; if (X11GraphicsEnvironment.isXRenderVerbose()) { System.out.println( "Xrender: INFO: Jules library loaded"); } } catch (UnsatisfiedLinkError ex) { loadSuccess = false; if (X11GraphicsEnvironment.isXRenderVerbose()) { System.out.println( "Xrender: INFO: Jules library not installed."); } } } return Boolean.valueOf(loadSuccess); }
/** * Xinerama-aware version of XlibWrapper.RootWindow method. */ public static long getRootWindow(int screenNumber) { XToolkit.awtLock(); try { X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment(); if (x11ge.runningXinerama()) { // all the Xinerama windows share the same root window return XlibWrapper.RootWindow(XToolkit.getDisplay(), 0); } else { return XlibWrapper.RootWindow(XToolkit.getDisplay(), screenNumber); } } finally { XToolkit.awtUnlock(); } }
public static GLXGraphicsConfig getConfig(X11GraphicsDevice device, int visualnum) { if (!X11GraphicsEnvironment.isGLXAvailable()) { return null; } long cfginfo = 0; final String ids[] = new String[1]; OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); try { // getGLXConfigInfo() creates and destroys temporary // surfaces/contexts, so we should first invalidate the current // Java-level context and flush the queue... OGLContext.invalidateCurrentContext(); GLXGetConfigInfo action = new GLXGetConfigInfo(device.getScreen(), visualnum); rq.flushAndInvokeNow(action); cfginfo = action.getConfigInfo(); if (cfginfo != 0L) { OGLContext.setScratchSurface(cfginfo); rq.flushAndInvokeNow(new Runnable() { public void run() { ids[0] = OGLContext.getOGLIdString(); } }); } } finally { rq.unlock(); } if (cfginfo == 0) { return null; } int oglCaps = getOGLCapabilities(cfginfo); ContextCapabilities caps = new OGLContextCaps(oglCaps, ids[0]); return new GLXGraphicsConfig(device, visualnum, cfginfo, caps); }
static Vector<XWindowPeer> collectJavaToplevels() { Vector<XWindowPeer> javaToplevels = new Vector<XWindowPeer>(); Vector<Long> v = new Vector<Long>(); X11GraphicsEnvironment ge = (X11GraphicsEnvironment)GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); if (!ge.runningXinerama() && (gds.length > 1)) { for (GraphicsDevice gd : gds) { int screen = ((X11GraphicsDevice)gd).getScreen(); long rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen); v.add(rootWindow); } } else { v.add(XToolkit.getDefaultRootWindow()); } final int windowsCount = windows.size(); while ((v.size() > 0) && (javaToplevels.size() < windowsCount)) { long win = v.remove(0); XQueryTree qt = new XQueryTree(win); try { if (qt.execute() != 0) { int nchildren = qt.get_nchildren(); long children = qt.get_children(); // XQueryTree returns window children ordered by z-order for (int i = 0; i < nchildren; i++) { long child = Native.getWindow(children, i); XBaseWindow childWindow = XToolkit.windowToXWindow(child); // filter out Java non-toplevels if ((childWindow != null) && !(childWindow instanceof XWindowPeer)) { continue; } else { v.add(child); } if (childWindow instanceof XWindowPeer) { XWindowPeer np = (XWindowPeer)childWindow; javaToplevels.add(np); // XQueryTree returns windows sorted by their z-order. However, // if WM has not handled transient for hint for a child window, // it may appear in javaToplevels before its owner. Move such // children after their owners. int k = 0; XWindowPeer toCheck = javaToplevels.get(k); while (toCheck != np) { XWindowPeer toCheckOwnerPeer = toCheck.getOwnerPeer(); if (toCheckOwnerPeer == np) { javaToplevels.remove(k); javaToplevels.add(toCheck); } else { k++; } toCheck = javaToplevels.get(k); } } } } } finally { qt.dispose(); } } return javaToplevels; }
@Override public void mouseMove(int x, int y) { X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment) GraphicsEnvironment.getLocalGraphicsEnvironment(); if(x11ge.runningXinerama()) { Rectangle sb = xgc.getBounds(); mouseMoveImpl(xgc, xgc.scaleUp(x + sb.x), xgc.scaleUp(y + sb.y)); } else { mouseMoveImpl(xgc, xgc.scaleUp(x), xgc.scaleUp(y)); } }
@Override public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; getRGBPixelsImpl(xgc, x, y, 1, 1, pixelArray, isGtkSupported, X11GraphicsEnvironment.isWayland()); return pixelArray[0]; }
@Override public int [] getRGBPixels(Rectangle bounds) { int pixelArray[] = new int[bounds.width*bounds.height]; getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, pixelArray, isGtkSupported, X11GraphicsEnvironment.isWayland()); return pixelArray; }