9060861
--- openjdk/jdk/make/lib/Awt2dLibraries.gmk	2016-02-29 17:11:00.497484904 +0100
9060861
+++ openjdk/jdk/make/lib/Awt2dLibraries.gmk	2016-02-29 17:11:00.402486574 +0100
9060861
@@ -618,7 +618,7 @@
9060861
         XRSurfaceData.c \
9060861
         XRBackendNative.c
9060861
 
9060861
-    LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc
9060861
+    LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender -lXcomposite $(LIBDL) -lXtst -lXi -ljava -ljvm -lc
9060861
 
9060861
     ifeq ($(OPENJDK_TARGET_OS), linux)
9060861
       # To match old build, add this to LDFLAGS instead of suffix.
9060861
--- openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c	2016-02-29 17:11:00.777479982 +0100
9060861
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c	2016-02-29 17:11:00.677481740 +0100
9060861
@@ -38,6 +38,7 @@
9060861
 #include <X11/extensions/XTest.h>
9060861
 #include <X11/extensions/XInput.h>
9060861
 #include <X11/extensions/XI.h>
9060861
+#include <X11/extensions/Xcomposite.h>
9060861
 #include <jni.h>
9060861
 #include <sizecalc.h>
9060861
 #include "robot_common.h"
9060861
@@ -88,6 +89,32 @@
9060861
     return isXTestAvailable;
9060861
 }
9060861
 
9060861
+static Bool hasXCompositeOverlayExtension(Display *display) {
9060861
+
9060861
+    int xoverlay = False;
9060861
+    int eventBase, errorBase;
9060861
+    if (XCompositeQueryExtension(display, &eventBase, &errorBase)) {
9060861
+        int major = 0;
9060861
+        int minor = 0;
9060861
+
9060861
+        XCompositeQueryVersion(display, &major, &minor);
9060861
+        if (major > 0 || minor >= 3)
9060861
+            xoverlay = True;
9060861
+    }
9060861
+
9060861
+    return xoverlay;
9060861
+}
9060861
+
9060861
+static jboolean isXCompositeDisplay(Display *display, int screenNumber) {
9060861
+
9060861
+    char NET_WM_CM_Sn[25];
9060861
+    snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber);
9060861
+
9060861
+    Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0);
9060861
+    Window owner = XGetSelectionOwner(display, managerSelection);
9060861
+
9060861
+    return owner != 0;
9060861
+}
9060861
 
9060861
 static XImage *getWindowImage(Display * display, Window window,
9060861
                               int32_t x, int32_t y,
9060861
@@ -232,6 +259,12 @@
9060861
     DASSERT(adata != NULL);
9060861
 
9060861
     rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen);
9060861
+    if (isXCompositeDisplay(awt_display, adata->awt_visInfo.screen) &&
9060861
+        hasXCompositeOverlayExtension(awt_display))
9060861
+    {
9060861
+        rootWindow = XCompositeGetOverlayWindow(awt_display, rootWindow);
9060861
+    }
9060861
+
9060861
     image = getWindowImage(awt_display, rootWindow, x, y, width, height);
9060861
 
9060861
     /* Array to use to crunch around the pixel values */