--- old/make/lib/Awt2dLibraries.gmk 2016-05-31 12:31:43.241478363 +0200 +++ new/make/lib/Awt2dLibraries.gmk 2016-05-31 12:31:43.128480011 +0200 @@ -337,7 +337,7 @@ endif endif - LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc + LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender -lXcomposite $(LIBDL) -lXtst -lXi -ljava -ljvm -lc ifeq ($(OPENJDK_TARGET_OS), linux) LIBAWT_XAWT_LIBS += -lpthread --- old/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java 2016-05-31 12:31:43.546473915 +0200 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XRobotPeer.java 2016-05-31 12:31:43.430475607 +0200 @@ -35,8 +35,14 @@ class XRobotPeer implements RobotPeer { - private static volatile boolean isGtkSupported; + static final boolean tryGtk; + static { + tryGtk = Boolean.getBoolean("awt.robot.gtk"); + } + + private static volatile boolean useGtk; private X11GraphicsConfig xgc = null; + /* * native implementation uses some static shared data (pipes, processes) * so use a class lock to synchronize native method calls @@ -49,13 +55,14 @@ setup(tk.getNumberOfButtons(), AWTAccessor.getInputEventAccessor().getButtonDownMasks()); - Toolkit toolkit = Toolkit.getDefaultToolkit(); - if (!isGtkSupported) { - if (toolkit instanceof UNIXToolkit - && ((UNIXToolkit) toolkit).loadGTK()) { + boolean isGtkSupported = false; + if (tryGtk && !isGtkSupported) { + if (tk instanceof UNIXToolkit && ((UNIXToolkit) tk).loadGTK()) { isGtkSupported = true; } } + + useGtk = (tryGtk && isGtkSupported); } @Override @@ -104,7 +111,7 @@ public int getRGBPixel(int x, int y) { int pixelArray[] = new int[1]; getRGBPixelsImpl(xgc, x, y, 1, 1, xgc.getScale(), pixelArray, - isGtkSupported); + useGtk); return pixelArray[0]; } @@ -112,7 +119,7 @@ public int [] getRGBPixels(Rectangle bounds) { int pixelArray[] = new int[bounds.width*bounds.height]; getRGBPixelsImpl(xgc, bounds.x, bounds.y, bounds.width, bounds.height, - xgc.getScale(), pixelArray, isGtkSupported); + xgc.getScale(), pixelArray, useGtk); return pixelArray; } --- old/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c 2016-05-31 12:31:43.834469715 +0200 +++ new/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c 2016-05-31 12:31:43.718471407 +0200 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include "robot_common.h" @@ -89,6 +90,32 @@ return isXTestAvailable; } +static Bool hasXCompositeOverlayExtension(Display *display) { + int xoverlay = False; + int eventBase, errorBase; + if (XCompositeQueryExtension(display, &eventBase, &errorBase)) { + int major = 0; + int minor = 0; + + XCompositeQueryVersion(display, &major, &minor); + if (major > 0 || minor >= 3) { + xoverlay = True; + } + } + + return xoverlay; +} + +static jboolean isXCompositeDisplay(Display *display, int screenNumber) { + + char NET_WM_CM_Sn[25]; + snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber); + + Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0); + Window owner = XGetSelectionOwner(display, managerSelection); + + return owner != 0; +} static XImage *getWindowImage(Display * display, Window window, int32_t x, int32_t y, @@ -238,6 +265,14 @@ rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); + if (!isGtkSupported) { + if (isXCompositeDisplay(awt_display, adata->awt_visInfo.screen) && + hasXCompositeOverlayExtension(awt_display)) + { + rootWindow = XCompositeGetOverlayWindow(awt_display, rootWindow); + } + } + if (!XGetWindowAttributes(awt_display, rootWindow, &attr) || sx + swidth <= attr.x || attr.x + attr.width <= sx