1 /*
2 * Copyright (c) 2006, 2008, 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
134 }
135 }
136
137 /**
138 * Translates the given point from one window to another. Returns
139 * null if the translation is failed
140 */
141 static Point translateCoordinates(long src, long dst, Point p)
142 {
143 Point translated = null;
144
145 XToolkit.awtLock();
146 try
147 {
148 XTranslateCoordinates xtc =
149 new XTranslateCoordinates(src, dst, p.x, p.y);
150 try
151 {
152 int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
153 if ((status != 0) &&
154 ((XToolkit.saved_error == null) ||
155 (XToolkit.saved_error.get_error_code() == XConstants.Success)))
156 {
157 translated = new Point(xtc.get_dest_x(), xtc.get_dest_y());
158 }
159 }
160 finally
161 {
162 xtc.dispose();
163 }
164 }
165 finally
166 {
167 XToolkit.awtUnlock();
168 }
169
170 return translated;
171 }
172
173 /**
174 * Translates the given rectangle from one window to another.
175 * Returns null if the translation is failed
328 /**
329 * The same as isToplevelWindow(window), but doesn't treat
330 * XEmbeddedFramePeer as toplevel.
331 */
332 static boolean isTrueToplevelWindow(long window)
333 {
334 if (XToolkit.windowToXWindow(window) instanceof XEmbeddedFramePeer)
335 {
336 return false;
337 }
338
339 return isToplevelWindow(window);
340 }
341
342 static int getWindowMapState(long window)
343 {
344 XToolkit.awtLock();
345 XWindowAttributes wattr = new XWindowAttributes();
346 try
347 {
348 XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
349 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
350 window, wattr.pData);
351 XToolkit.RESTORE_XERROR_HANDLER();
352 if ((status != 0) &&
353 ((XToolkit.saved_error == null) ||
354 (XToolkit.saved_error.get_error_code() == XConstants.Success)))
355 {
356 return wattr.get_map_state();
357 }
358 }
359 finally
360 {
361 wattr.dispose();
362 XToolkit.awtUnlock();
363 }
364
365 return XConstants.IsUnmapped;
366 }
367
368 /**
369 * XSHAPE extension support.
370 */
371
372 // The variable is declared static as the XSHAPE extension cannot
373 // be disabled at run-time, and thus is available all the time
374 // once the check is passed.
|
1 /*
2 * Copyright (c) 2006, 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
134 }
135 }
136
137 /**
138 * Translates the given point from one window to another. Returns
139 * null if the translation is failed
140 */
141 static Point translateCoordinates(long src, long dst, Point p)
142 {
143 Point translated = null;
144
145 XToolkit.awtLock();
146 try
147 {
148 XTranslateCoordinates xtc =
149 new XTranslateCoordinates(src, dst, p.x, p.y);
150 try
151 {
152 int status = xtc.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
153 if ((status != 0) &&
154 ((XErrorHandlerUtil.saved_error == null) ||
155 (XErrorHandlerUtil.saved_error.get_error_code() == XConstants.Success)))
156 {
157 translated = new Point(xtc.get_dest_x(), xtc.get_dest_y());
158 }
159 }
160 finally
161 {
162 xtc.dispose();
163 }
164 }
165 finally
166 {
167 XToolkit.awtUnlock();
168 }
169
170 return translated;
171 }
172
173 /**
174 * Translates the given rectangle from one window to another.
175 * Returns null if the translation is failed
328 /**
329 * The same as isToplevelWindow(window), but doesn't treat
330 * XEmbeddedFramePeer as toplevel.
331 */
332 static boolean isTrueToplevelWindow(long window)
333 {
334 if (XToolkit.windowToXWindow(window) instanceof XEmbeddedFramePeer)
335 {
336 return false;
337 }
338
339 return isToplevelWindow(window);
340 }
341
342 static int getWindowMapState(long window)
343 {
344 XToolkit.awtLock();
345 XWindowAttributes wattr = new XWindowAttributes();
346 try
347 {
348 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
349 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
350 window, wattr.pData);
351 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
352 if ((status != 0) &&
353 ((XErrorHandlerUtil.saved_error == null) ||
354 (XErrorHandlerUtil.saved_error.get_error_code() == XConstants.Success)))
355 {
356 return wattr.get_map_state();
357 }
358 }
359 finally
360 {
361 wattr.dispose();
362 XToolkit.awtUnlock();
363 }
364
365 return XConstants.IsUnmapped;
366 }
367
368 /**
369 * XSHAPE extension support.
370 */
371
372 // The variable is declared static as the XSHAPE extension cannot
373 // be disabled at run-time, and thus is available all the time
374 // once the check is passed.
|