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
42 public class WWindowPeer extends WPanelPeer implements WindowPeer,
43 DisplayChangedListener
44 {
45
46 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
47 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
48
49 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
50 // extends WWindowPeer, not WDialogPeer
51 private WWindowPeer modalBlocker = null;
52
53 private boolean isOpaque;
54
55 private TranslucentWindowPainter painter;
56
57 /*
58 * A key used for storing a list of active windows in AppContext. The value
59 * is a list of windows, sorted by the time of activation: later a window is
60 * activated, greater its index is in the list.
613 }
614
615 // These are the peer bounds. They get updated at:
616 // 1. the WWindowPeer.setBounds() method.
617 // 2. the native code (on WM_SIZE/WM_MOVE)
618 private volatile int sysX = 0;
619 private volatile int sysY = 0;
620 private volatile int sysW = 0;
621 private volatile int sysH = 0;
622
623 @Override
624 public native void repositionSecurityWarning();
625
626 @Override
627 public void setBounds(int x, int y, int width, int height, int op) {
628 sysX = x;
629 sysY = y;
630 sysW = width;
631 sysH = height;
632
633 super.setBounds(x, y, width, height, op);
634 }
635
636 @Override
637 public void print(Graphics g) {
638 // We assume we print the whole frame,
639 // so we expect no clip was set previously
640 Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
641 if (shape != null) {
642 g.setClip(shape);
643 }
644 super.print(g);
645 }
646
647 private void replaceSurfaceDataRecursively(Component c) {
648 if (c instanceof Container) {
649 for (Component child : ((Container)c).getComponents()) {
650 replaceSurfaceDataRecursively(child);
651 }
652 }
653 final Object cp = AWTAccessor.getComponentAccessor().getPeer(c);
654 if (cp instanceof WComponentPeer) {
|
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.
614 }
615
616 // These are the peer bounds. They get updated at:
617 // 1. the WWindowPeer.setBounds() method.
618 // 2. the native code (on WM_SIZE/WM_MOVE)
619 private volatile int sysX = 0;
620 private volatile int sysY = 0;
621 private volatile int sysW = 0;
622 private volatile int sysH = 0;
623
624 @Override
625 public native void repositionSecurityWarning();
626
627 @Override
628 public void setBounds(int x, int y, int width, int height, int op) {
629 sysX = x;
630 sysY = y;
631 sysW = width;
632 sysH = height;
633
634 int cx = x + width / 2;
635 int cy = y + height / 2;
636 GraphicsConfiguration current = getGraphicsConfiguration();
637 GraphicsConfiguration other = SwingUtilities2.getGraphicsConfigurationAtPoint(current, cx, cy);
638 if (!current.equals(other)) {
639 AffineTransform tx = other.getDefaultTransform();
640 double otherScaleX = tx.getScaleX();
641 double otherScaleY = tx.getScaleY();
642 initScales();
643 if (scaleX != otherScaleX || scaleY != otherScaleY) {
644 x = sysX = (int) Math.floor(x * otherScaleX / scaleX);
645 y = sysY = (int) Math.floor(y * otherScaleY / scaleY);
646 }
647 }
648
649 super.setBounds(x, y, width, height, op);
650 }
651
652 private final void initScales() {
653
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) {
|