0N/A/*
2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.awt.X11;
0N/A
0N/Aimport java.awt.Point;
0N/Aimport java.awt.Window;
0N/Aimport java.awt.GraphicsEnvironment;
0N/Aimport java.awt.GraphicsConfiguration;
0N/Aimport java.awt.GraphicsDevice;
0N/Aimport java.awt.peer.MouseInfoPeer;
0N/A
0N/Apublic class XMouseInfoPeer implements MouseInfoPeer {
0N/A
0N/A /**
0N/A * Package-private constructor to prevent instantiation.
0N/A */
0N/A XMouseInfoPeer() {
0N/A }
0N/A
0N/A public int fillPointWithCoords(Point point) {
0N/A long display = XToolkit.getDisplay();
0N/A GraphicsEnvironment ge = GraphicsEnvironment.
0N/A getLocalGraphicsEnvironment();
0N/A GraphicsDevice[] gds = ge.getScreenDevices();
0N/A int gdslen = gds.length;
0N/A
0N/A XToolkit.awtLock();
0N/A try {
0N/A for (int i = 0; i < gdslen; i++) {
0N/A long screenRoot = XlibWrapper.RootWindow(display, i);
0N/A boolean pointerFound = XlibWrapper.XQueryPointer(
0N/A display, screenRoot,
0N/A XlibWrapper.larg1, // root_return
0N/A XlibWrapper.larg2, // child_return
0N/A XlibWrapper.larg3, // xr_return
0N/A XlibWrapper.larg4, // yr_return
0N/A XlibWrapper.larg5, // xw_return
0N/A XlibWrapper.larg6, // yw_return
0N/A XlibWrapper.larg7); // mask_return
0N/A if (pointerFound) {
0N/A point.x = Native.getInt(XlibWrapper.larg3);
0N/A point.y = Native.getInt(XlibWrapper.larg4);
0N/A return i;
0N/A }
0N/A }
0N/A } finally {
0N/A XToolkit.awtUnlock();
0N/A }
0N/A
0N/A // this should never happen
0N/A assert false : "No pointer found in the system.";
0N/A return 0;
0N/A }
0N/A
0N/A public boolean isWindowUnderMouse(Window w) {
0N/A
0N/A long display = XToolkit.getDisplay();
0N/A
0N/A // java.awt.Component.findUnderMouseInWindow checks that
0N/A // the peer is non-null by checking that the component
0N/A // is showing.
0N/A
0N/A long contentWindow = ((XWindow)w.getPeer()).getContentWindow();
0N/A long parent = XlibUtil.getParentWindow(contentWindow);
0N/A
0N/A XToolkit.awtLock();
0N/A try
0N/A {
0N/A boolean windowOnTheSameScreen = XlibWrapper.XQueryPointer(display, parent,
0N/A XlibWrapper.larg1, // root_return
0N/A XlibWrapper.larg8, // child_return
0N/A XlibWrapper.larg3, // root_x_return
0N/A XlibWrapper.larg4, // root_y_return
0N/A XlibWrapper.larg5, // win_x_return
0N/A XlibWrapper.larg6, // win_y_return
0N/A XlibWrapper.larg7); // mask_return
0N/A long siblingWindow = Native.getWindow(XlibWrapper.larg8);
0N/A return (siblingWindow == contentWindow && windowOnTheSameScreen);
0N/A }
0N/A finally
0N/A {
0N/A XToolkit.awtUnlock();
0N/A }
0N/A }
0N/A}