Blame SOURCES/rh1176206-jdk.patch

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