1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 }
117
118 protected void getCursorPos(Point p) {
119
120 if (!((XToolkit)Toolkit.getDefaultToolkit()).getLastCursorPos(p)) {
121 XToolkit.awtLock();
122 try {
123 long display = XToolkit.getDisplay();
124 long root_window = XlibWrapper.RootWindow(display,
125 XlibWrapper.DefaultScreen(display));
126
127 XlibWrapper.XQueryPointer(display, root_window,
128 XlibWrapper.larg1,
129 XlibWrapper.larg2,
130 XlibWrapper.larg3,
131 XlibWrapper.larg4,
132 XlibWrapper.larg5,
133 XlibWrapper.larg6,
134 XlibWrapper.larg7);
135
136 p.x = (int) XlibWrapper.unsafe.getInt(XlibWrapper.larg3);
137 p.y = (int) XlibWrapper.unsafe.getInt(XlibWrapper.larg4);
138 } finally {
139 XToolkit.awtUnlock();
140 }
141 }
142 }
143 protected Component findHeavyweightUnderCursor() {
144 return XAwtState.getComponentMouseEntered();
145 }
146
147 /*
148 * native method to call corresponding methods in Component
149 */
150 protected Point getLocationOnScreen(Component c) {
151 return c.getLocationOnScreen();
152 }
153
154 protected Component findHeavyweightUnderCursor(boolean useCache) {
155 return findHeavyweightUnderCursor();
156 }
157
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 }
117
118 protected void getCursorPos(Point p) {
119
120 if (!((XToolkit)Toolkit.getDefaultToolkit()).getLastCursorPos(p)) {
121 XToolkit.awtLock();
122 try {
123 long display = XToolkit.getDisplay();
124 long root_window = XlibWrapper.RootWindow(display,
125 XlibWrapper.DefaultScreen(display));
126
127 XlibWrapper.XQueryPointer(display, root_window,
128 XlibWrapper.larg1,
129 XlibWrapper.larg2,
130 XlibWrapper.larg3,
131 XlibWrapper.larg4,
132 XlibWrapper.larg5,
133 XlibWrapper.larg6,
134 XlibWrapper.larg7);
135
136 p.x = XlibWrapper.unsafe.getInt(XlibWrapper.larg3);
137 p.y = XlibWrapper.unsafe.getInt(XlibWrapper.larg4);
138 } finally {
139 XToolkit.awtUnlock();
140 }
141 }
142 }
143 protected Component findHeavyweightUnderCursor() {
144 return XAwtState.getComponentMouseEntered();
145 }
146
147 /*
148 * native method to call corresponding methods in Component
149 */
150 protected Point getLocationOnScreen(Component c) {
151 return c.getLocationOnScreen();
152 }
153
154 protected Component findHeavyweightUnderCursor(boolean useCache) {
155 return findHeavyweightUnderCursor();
156 }
157
|