Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 11678:139ec635c8ba
8150954, PR2866, RH1176206: AWT Robot not compatible with GNOME Shell
Summary: Use the overlay window rather than the root window when on a composite display.
author | neugens |
---|---|
date | Fri, 01 Apr 2016 04:32:30 +0100 |
parents | 2ebaea63abb4 |
children | 6b81fd2227d1 |
files | make/lib/Awt2dLibraries.gmk src/solaris/native/sun/awt/awt_Robot.c |
diffstat | 2 files changed, 34 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/make/lib/Awt2dLibraries.gmk Fri Jan 29 13:35:06 2016 +0100 +++ b/make/lib/Awt2dLibraries.gmk Fri Apr 01 04:32:30 2016 +0100 @@ -618,7 +618,7 @@ XRSurfaceData.c \ XRBackendNative.c - LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc + LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender -lXcomposite $(LIBDL) -lXtst -lXi -ljava -ljvm -lc ifeq ($(OPENJDK_TARGET_OS), linux) # To match old build, add this to LDFLAGS instead of suffix.
--- a/src/solaris/native/sun/awt/awt_Robot.c Fri Jan 29 13:35:06 2016 +0100 +++ b/src/solaris/native/sun/awt/awt_Robot.c Fri Apr 01 04:32:30 2016 +0100 @@ -38,6 +38,7 @@ #include <X11/extensions/XTest.h> #include <X11/extensions/XInput.h> #include <X11/extensions/XI.h> +#include <X11/extensions/Xcomposite.h> #include <jni.h> #include <sizecalc.h> #include "robot_common.h" @@ -88,6 +89,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, @@ -232,6 +259,12 @@ DASSERT(adata != NULL); rootWindow = XRootWindow(awt_display, adata->awt_visInfo.screen); + if (isXCompositeDisplay(awt_display, adata->awt_visInfo.screen) && + hasXCompositeOverlayExtension(awt_display)) + { + rootWindow = XCompositeGetOverlayWindow(awt_display, rootWindow); + } + image = getWindowImage(awt_display, rootWindow, x, y, width, height); /* Array to use to crunch around the pixel values */