< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c

Print this page

        

*** 35,44 **** --- 35,45 ---- #include <X11/Xmd.h> #include <X11/extensions/xtestext1.h> #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" #include "canvas.h" #include "wsutils.h"
*** 87,96 **** --- 88,123 ---- } 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, int32_t w, int32_t h) { XImage *image;
*** 236,245 **** --- 263,280 ---- jint swidth = jwidth * scale; jint sheight = jheight * scale; 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 || sy + sheight <= attr.y || attr.y + attr.height <= sy) {
< prev index next >