1 /*
2 * Copyright (c) 2002, 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
23 * questions.
24 */
25
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.ComponentPeer;
31 import java.awt.image.ColorModel;
32
33 import java.lang.ref.WeakReference;
34
35 import java.lang.reflect.Method;
36
37 import sun.util.logging.PlatformLogger;
38
39 import sun.awt.*;
40
41 import sun.awt.image.PixelConverter;
42
43 import sun.java2d.SunGraphics2D;
44 import sun.java2d.SurfaceData;
45
46 class XWindow extends XBaseWindow implements X11ComponentPeer {
47 private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
48 private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
49 private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
50 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
51 private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
52 /* If a motion comes in while a multi-click is pending,
53 * allow a smudge factor so that moving the mouse by a small
54 * amount does not wipe out the multi-click state variables.
55 */
56 private final static int AWT_MULTICLICK_SMUDGE = 4;
265
266 public AwtGraphicsConfigData getGraphicsConfigurationData() {
267 if (graphicsConfigData == null) {
268 initGraphicsConfiguration();
269 }
270 return graphicsConfigData;
271 }
272
273 protected String[] getWMClass() {
274 return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
275 }
276
277 void setReparented(boolean newValue) {
278 reparented = newValue;
279 }
280
281 boolean isReparented() {
282 return reparented;
283 }
284
285 @SuppressWarnings("deprecation")
286 static long getParentWindowID(Component target) {
287
288 ComponentPeer peer = target.getParent().getPeer();
289 Component temp = target.getParent();
290 while (!(peer instanceof XWindow))
291 {
292 temp = temp.getParent();
293 peer = temp.getPeer();
294 }
295
296 if (peer != null && peer instanceof XWindow)
297 return ((XWindow)peer).getContentWindow();
298 else return 0;
299 }
300
301
302 @SuppressWarnings("deprecation")
303 static XWindow getParentXWindowObject(Component target) {
304 if (target == null) return null;
305 Component temp = target.getParent();
306 if (temp == null) return null;
307 ComponentPeer peer = temp.getPeer();
308 if (peer == null) return null;
309 while ((peer != null) && !(peer instanceof XWindow))
310 {
311 temp = temp.getParent();
312 peer = temp.getPeer();
313 }
314 if (peer != null && peer instanceof XWindow)
315 return (XWindow) peer;
316 else return null;
317 }
318
319
320 boolean isParentOf(XWindow win) {
321 if (!(target instanceof Container) || win == null || win.getTarget() == null) {
322 return false;
323 }
324 Container parent = AWTAccessor.getComponentAccessor().getParent(win.target);
325 while (parent != null && parent != target) {
326 parent = AWTAccessor.getComponentAccessor().getParent(parent);
327 }
328 return (parent == target);
329 }
330
331 public Object getTarget() {
332 return target;
535 }
536 }
537
538 public void popup(int x, int y, int width, int height) {
539 // TBD: grab the pointer
540 xSetBounds(x, y, width, height);
541 }
542
543 public void handleExposeEvent(XEvent xev) {
544 super.handleExposeEvent(xev);
545 XExposeEvent xe = xev.get_xexpose();
546 if (isEventDisabled(xev)) {
547 return;
548 }
549 int x = xe.get_x();
550 int y = xe.get_y();
551 int w = xe.get_width();
552 int h = xe.get_height();
553
554 Component target = getEventSource();
555 AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
556
557 if (!compAccessor.getIgnoreRepaint(target)
558 && compAccessor.getWidth(target) != 0
559 && compAccessor.getHeight(target) != 0)
560 {
561 postPaintEvent(target, x, y, w, h);
562 }
563 }
564
565 public void postPaintEvent(Component target, int x, int y, int w, int h) {
566 PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
567 createPaintEvent(target, x, y, w, h);
568 if (event != null) {
569 postEventToEventQueue(event);
570 }
571 }
572
573 static int getModifiers(int state, int button, int keyCode) {
574 return getModifiers(state, button, keyCode, 0, false);
575 }
|
1 /*
2 * Copyright (c) 2002, 2015, 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
23 * questions.
24 */
25
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.ComponentPeer;
31 import java.awt.image.ColorModel;
32
33 import java.lang.ref.WeakReference;
34
35 import java.lang.reflect.Method;
36
37 import sun.awt.AWTAccessor.ComponentAccessor;
38 import sun.util.logging.PlatformLogger;
39
40 import sun.awt.*;
41
42 import sun.awt.image.PixelConverter;
43
44 import sun.java2d.SunGraphics2D;
45 import sun.java2d.SurfaceData;
46
47 class XWindow extends XBaseWindow implements X11ComponentPeer {
48 private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
49 private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
50 private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
51 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
52 private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
53 /* If a motion comes in while a multi-click is pending,
54 * allow a smudge factor so that moving the mouse by a small
55 * amount does not wipe out the multi-click state variables.
56 */
57 private final static int AWT_MULTICLICK_SMUDGE = 4;
266
267 public AwtGraphicsConfigData getGraphicsConfigurationData() {
268 if (graphicsConfigData == null) {
269 initGraphicsConfiguration();
270 }
271 return graphicsConfigData;
272 }
273
274 protected String[] getWMClass() {
275 return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
276 }
277
278 void setReparented(boolean newValue) {
279 reparented = newValue;
280 }
281
282 boolean isReparented() {
283 return reparented;
284 }
285
286 static long getParentWindowID(Component target) {
287
288 Component temp = target.getParent();
289 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
290 ComponentPeer peer = acc.getPeer(temp);
291 while (!(peer instanceof XWindow))
292 {
293 temp = temp.getParent();
294 peer = acc.getPeer(temp);
295 }
296
297 if (peer != null && peer instanceof XWindow)
298 return ((XWindow)peer).getContentWindow();
299 else return 0;
300 }
301
302
303 static XWindow getParentXWindowObject(Component target) {
304 if (target == null) return null;
305 Component temp = target.getParent();
306 if (temp == null) return null;
307 final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
308 ComponentPeer peer = acc.getPeer(temp);
309 if (peer == null) return null;
310 while ((peer != null) && !(peer instanceof XWindow))
311 {
312 temp = temp.getParent();
313 peer = acc.getPeer(temp);
314 }
315 if (peer != null && peer instanceof XWindow)
316 return (XWindow) peer;
317 else return null;
318 }
319
320
321 boolean isParentOf(XWindow win) {
322 if (!(target instanceof Container) || win == null || win.getTarget() == null) {
323 return false;
324 }
325 Container parent = AWTAccessor.getComponentAccessor().getParent(win.target);
326 while (parent != null && parent != target) {
327 parent = AWTAccessor.getComponentAccessor().getParent(parent);
328 }
329 return (parent == target);
330 }
331
332 public Object getTarget() {
333 return target;
536 }
537 }
538
539 public void popup(int x, int y, int width, int height) {
540 // TBD: grab the pointer
541 xSetBounds(x, y, width, height);
542 }
543
544 public void handleExposeEvent(XEvent xev) {
545 super.handleExposeEvent(xev);
546 XExposeEvent xe = xev.get_xexpose();
547 if (isEventDisabled(xev)) {
548 return;
549 }
550 int x = xe.get_x();
551 int y = xe.get_y();
552 int w = xe.get_width();
553 int h = xe.get_height();
554
555 Component target = getEventSource();
556 ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
557
558 if (!compAccessor.getIgnoreRepaint(target)
559 && compAccessor.getWidth(target) != 0
560 && compAccessor.getHeight(target) != 0)
561 {
562 postPaintEvent(target, x, y, w, h);
563 }
564 }
565
566 public void postPaintEvent(Component target, int x, int y, int w, int h) {
567 PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
568 createPaintEvent(target, x, y, w, h);
569 if (event != null) {
570 postEventToEventQueue(event);
571 }
572 }
573
574 static int getModifiers(int state, int button, int keyCode) {
575 return getModifiers(state, button, keyCode, 0, false);
576 }
|