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
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
642 // 1. the WWindowPeer.setBounds() method.
643 // 2. the native code (on WM_SIZE/WM_MOVE)
644 private volatile int sysX = 0;
645 private volatile int sysY = 0;
646 private volatile int sysW = 0;
647 private volatile int sysH = 0;
648
649 @Override
650 public native void repositionSecurityWarning();
651
652 @Override
653 public void setBounds(int x, int y, int width, int height, int op) {
654 sysX = x;
655 sysY = y;
656 sysW = width;
657 sysH = height;
658
659 int cx = x + width / 2;
660 int cy = y + height / 2;
661 GraphicsConfiguration current = getGraphicsConfiguration();
662 GraphicsConfiguration other = SwingUtilities2.getGraphicsConfigurationAtPoint(current, cx, cy);
663 if (!current.equals(other)) {
664 AffineTransform tx = other.getDefaultTransform();
665 double otherScaleX = tx.getScaleX();
666 double otherScaleY = tx.getScaleY();
667 initScales();
668 if (scaleX != otherScaleX || scaleY != otherScaleY) {
669 x = (int) Math.floor(x * otherScaleX / scaleX);
670 y = (int) Math.floor(y * otherScaleY / scaleY);
671 }
672 }
673
674 super.setBounds(x, y, width, height, op);
675 }
676
677 private void initScales() {
678
679 if (scaleX >= 1 && scaleY >= 1) {
680 return;
681 }
682
|
1 /*
2 * Copyright (c) 1996, 2018, 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
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.SunGraphicsEnvironment;
65 import sun.java2d.pipe.Region;
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
642 // 1. the WWindowPeer.setBounds() method.
643 // 2. the native code (on WM_SIZE/WM_MOVE)
644 private volatile int sysX = 0;
645 private volatile int sysY = 0;
646 private volatile int sysW = 0;
647 private volatile int sysH = 0;
648
649 @Override
650 public native void repositionSecurityWarning();
651
652 @Override
653 public void setBounds(int x, int y, int width, int height, int op) {
654 sysX = x;
655 sysY = y;
656 sysW = width;
657 sysH = height;
658
659 int cx = x + width / 2;
660 int cy = y + height / 2;
661 GraphicsConfiguration current = getGraphicsConfiguration();
662 GraphicsConfiguration other = SunGraphicsEnvironment
663 .getGraphicsConfigurationAtPoint(current, cx, cy);
664 if (!current.equals(other)) {
665 AffineTransform tx = other.getDefaultTransform();
666 double otherScaleX = tx.getScaleX();
667 double otherScaleY = tx.getScaleY();
668 initScales();
669 if (scaleX != otherScaleX || scaleY != otherScaleY) {
670 x = (int) Math.floor(x * otherScaleX / scaleX);
671 y = (int) Math.floor(y * otherScaleY / scaleY);
672 }
673 }
674
675 super.setBounds(x, y, width, height, op);
676 }
677
678 private void initScales() {
679
680 if (scaleX >= 1 && scaleY >= 1) {
681 return;
682 }
683
|