1 /*
2 * Copyright (c) 1996, 2016, 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 package sun.awt.windows;
26
27 import java.awt.*;
28 import java.awt.event.*;
29 import java.awt.image.*;
30 import java.awt.peer.*;
31
32 import java.beans.*;
33
34 import java.util.*;
35 import java.util.List;
36 import sun.util.logging.PlatformLogger;
37 import java.awt.geom.AffineTransform;
38 import sun.awt.*;
39
40 import sun.java2d.pipe.Region;
41 import sun.swing.SwingUtilities2;
42
43 public class WWindowPeer extends WPanelPeer implements WindowPeer,
44 DisplayChangedListener
45 {
46
47 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
48 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
49
50 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
51 // extends WWindowPeer, not WDialogPeer
52 private WWindowPeer modalBlocker = null;
53
54 private boolean isOpaque;
55
56 private TranslucentWindowPainter painter;
57
58 /*
59 * A key used for storing a list of active windows in AppContext. The value
60 * is a list of windows, sorted by the time of activation: later a window is
61 * activated, greater its index is in the list.
654 if (scaleX >= 1 && scaleY >= 1) {
655 return;
656 }
657
658 GraphicsConfiguration gc = getGraphicsConfiguration();
659 if (gc instanceof Win32GraphicsConfig) {
660 Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice();
661 scaleX = gd.getDefaultScaleX();
662 scaleY = gd.getDefaultScaleY();
663 } else {
664 AffineTransform tx = gc.getDefaultTransform();
665 scaleX = (float) tx.getScaleX();
666 scaleY = (float) tx.getScaleY();
667 }
668 }
669
670 @Override
671 public void print(Graphics g) {
672 // We assume we print the whole frame,
673 // so we expect no clip was set previously
674 Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
675 if (shape != null) {
676 g.setClip(shape);
677 }
678 super.print(g);
679 }
680
681 private void replaceSurfaceDataRecursively(Component c) {
682 if (c instanceof Container) {
683 for (Component child : ((Container)c).getComponents()) {
684 replaceSurfaceDataRecursively(child);
685 }
686 }
687 final Object cp = AWTAccessor.getComponentAccessor().getPeer(c);
688 if (cp instanceof WComponentPeer) {
689 ((WComponentPeer)cp).replaceSurfaceDataLater();
690 }
691 }
692
693 public final Graphics getTranslucentGraphics() {
694 synchronized (getStateLock()) {
|
1 /*
2 * Copyright (c) 1996, 2017, 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.windows;
27
28 import java.awt.AWTEvent;
29 import java.awt.AWTEventMulticaster;
30 import java.awt.Color;
31 import java.awt.Component;
32 import java.awt.Container;
33 import java.awt.Dialog;
34 import java.awt.Dimension;
35 import java.awt.Graphics;
36 import java.awt.GraphicsConfiguration;
37 import java.awt.GraphicsDevice;
38 import java.awt.GraphicsEnvironment;
39 import java.awt.Image;
40 import java.awt.Insets;
41 import java.awt.KeyboardFocusManager;
42 import java.awt.Rectangle;
43 import java.awt.Shape;
44 import java.awt.SystemColor;
45 import java.awt.Window;
46 import java.awt.event.FocusEvent;
47 import java.awt.event.WindowEvent;
48 import java.awt.event.WindowListener;
49 import java.awt.geom.AffineTransform;
50 import java.awt.image.DataBufferInt;
51 import java.awt.peer.WindowPeer;
52 import java.beans.PropertyChangeEvent;
53 import java.beans.PropertyChangeListener;
54 import java.util.LinkedList;
55 import java.util.List;
56
57 import sun.awt.AWTAccessor;
58 import sun.awt.AppContext;
59 import sun.awt.DisplayChangedListener;
60 import sun.awt.SunToolkit;
61 import sun.awt.Win32GraphicsConfig;
62 import sun.awt.Win32GraphicsDevice;
63 import sun.awt.Win32GraphicsEnvironment;
64 import sun.java2d.pipe.Region;
65 import sun.swing.SwingUtilities2;
66 import sun.util.logging.PlatformLogger;
67
68 public class WWindowPeer extends WPanelPeer implements WindowPeer,
69 DisplayChangedListener
70 {
71
72 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
73 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
74
75 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
76 // extends WWindowPeer, not WDialogPeer
77 private WWindowPeer modalBlocker = null;
78
79 private boolean isOpaque;
80
81 private TranslucentWindowPainter painter;
82
83 /*
84 * A key used for storing a list of active windows in AppContext. The value
85 * is a list of windows, sorted by the time of activation: later a window is
86 * activated, greater its index is in the list.
679 if (scaleX >= 1 && scaleY >= 1) {
680 return;
681 }
682
683 GraphicsConfiguration gc = getGraphicsConfiguration();
684 if (gc instanceof Win32GraphicsConfig) {
685 Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice();
686 scaleX = gd.getDefaultScaleX();
687 scaleY = gd.getDefaultScaleY();
688 } else {
689 AffineTransform tx = gc.getDefaultTransform();
690 scaleX = (float) tx.getScaleX();
691 scaleY = (float) tx.getScaleY();
692 }
693 }
694
695 @Override
696 public void print(Graphics g) {
697 // We assume we print the whole frame,
698 // so we expect no clip was set previously
699 Shape shape = ((Window)target).getShape();
700 if (shape != null) {
701 g.setClip(shape);
702 }
703 super.print(g);
704 }
705
706 private void replaceSurfaceDataRecursively(Component c) {
707 if (c instanceof Container) {
708 for (Component child : ((Container)c).getComponents()) {
709 replaceSurfaceDataRecursively(child);
710 }
711 }
712 final Object cp = AWTAccessor.getComponentAccessor().getPeer(c);
713 if (cp instanceof WComponentPeer) {
714 ((WComponentPeer)cp).replaceSurfaceDataLater();
715 }
716 }
717
718 public final Graphics getTranslucentGraphics() {
719 synchronized (getStateLock()) {
|