author | serb |
Thu, 17 May 2018 14:41:23 -0700 | |
changeset 50343 | 80a5ff734fcd |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
12047 | 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.lwawt; |
|
27 |
||
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
28 |
import java.awt.AlphaComposite; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
29 |
import java.awt.Color; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
30 |
import java.awt.Component; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
31 |
import java.awt.Dialog; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
32 |
import java.awt.Dimension; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
33 |
import java.awt.Font; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
34 |
import java.awt.FontMetrics; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
35 |
import java.awt.Frame; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
36 |
import java.awt.Graphics; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
37 |
import java.awt.Graphics2D; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
38 |
import java.awt.GraphicsConfiguration; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
39 |
import java.awt.GraphicsDevice; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
40 |
import java.awt.GraphicsEnvironment; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
41 |
import java.awt.Insets; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
42 |
import java.awt.KeyboardFocusManager; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
43 |
import java.awt.MenuBar; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
44 |
import java.awt.Point; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
45 |
import java.awt.Rectangle; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
46 |
import java.awt.Shape; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
47 |
import java.awt.SystemColor; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
48 |
import java.awt.Toolkit; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
49 |
import java.awt.Window; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
50 |
import java.awt.event.FocusEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
51 |
import java.awt.event.KeyEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
52 |
import java.awt.event.MouseEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
53 |
import java.awt.event.MouseWheelEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
54 |
import java.awt.event.WindowEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
55 |
import java.awt.peer.ComponentPeer; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
56 |
import java.awt.peer.DialogPeer; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
57 |
import java.awt.peer.FramePeer; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
58 |
import java.awt.peer.KeyboardFocusManagerPeer; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
59 |
import java.awt.peer.WindowPeer; |
12047 | 60 |
import java.util.List; |
61 |
||
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
62 |
import javax.swing.JComponent; |
12047 | 63 |
|
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
64 |
import sun.awt.AWTAccessor; |
30469 | 65 |
import sun.awt.AWTAccessor.ComponentAccessor; |
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
66 |
import sun.awt.AppContext; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
67 |
import sun.awt.CGraphicsDevice; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
68 |
import sun.awt.DisplayChangedListener; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
69 |
import sun.awt.ExtendedKeyCodes; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
70 |
import sun.awt.FullScreenCapable; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
71 |
import sun.awt.SunToolkit; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
72 |
import sun.awt.TimedWindowEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
73 |
import sun.awt.UngrabEvent; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
74 |
import sun.java2d.NullSurfaceData; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
75 |
import sun.java2d.SunGraphics2D; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
76 |
import sun.java2d.SunGraphicsEnvironment; |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
77 |
import sun.java2d.SurfaceData; |
12047 | 78 |
import sun.java2d.loops.Blit; |
79 |
import sun.java2d.loops.CompositeType; |
|
13233 | 80 |
import sun.java2d.pipe.Region; |
12047 | 81 |
import sun.util.logging.PlatformLogger; |
82 |
||
83 |
public class LWWindowPeer |
|
84 |
extends LWContainerPeer<Window, JComponent> |
|
18249 | 85 |
implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener, PlatformEventNotifier |
12047 | 86 |
{ |
20153 | 87 |
public enum PeerType { |
12047 | 88 |
SIMPLEWINDOW, |
89 |
FRAME, |
|
90 |
DIALOG, |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
91 |
EMBEDDED_FRAME, |
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
92 |
VIEW_EMBEDDED_FRAME, |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
93 |
LW_FRAME |
12047 | 94 |
} |
95 |
||
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
96 |
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer"); |
12047 | 97 |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
98 |
private final PlatformWindow platformWindow; |
12047 | 99 |
|
100 |
private static final int MINIMUM_WIDTH = 1; |
|
101 |
private static final int MINIMUM_HEIGHT = 1; |
|
102 |
||
103 |
private Insets insets = new Insets(0, 0, 0, 0); |
|
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
104 |
private Rectangle maximizedBounds; |
12047 | 105 |
|
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
106 |
private GraphicsDevice graphicsDevice; |
12047 | 107 |
private GraphicsConfiguration graphicsConfig; |
108 |
||
109 |
private SurfaceData surfaceData; |
|
110 |
private final Object surfaceDataLock = new Object(); |
|
111 |
||
112 |
private volatile int windowState = Frame.NORMAL; |
|
113 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
114 |
// check that the mouse is over the window |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
115 |
private volatile boolean isMouseOver = false; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
116 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
117 |
// A peer where the last mouse event came to. Used by cursor manager to |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
118 |
// find the component under cursor |
20153 | 119 |
private static volatile LWComponentPeer<?, ?> lastCommonMouseEventPeer; |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
120 |
|
12047 | 121 |
// A peer where the last mouse event came to. Used to generate |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
122 |
// MOUSE_ENTERED/EXITED notifications |
20153 | 123 |
private volatile LWComponentPeer<?, ?> lastMouseEventPeer; |
12047 | 124 |
|
125 |
// Peers where all dragged/released events should come to, |
|
126 |
// depending on what mouse button is being dragged according to Cocoa |
|
20153 | 127 |
private static final LWComponentPeer<?, ?>[] mouseDownTarget = new LWComponentPeer<?, ?>[3]; |
12047 | 128 |
|
129 |
// A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events |
|
130 |
// on MOUSE_RELEASE. Click events are only generated if there were no drag |
|
131 |
// events between MOUSE_PRESSED and MOUSE_RELEASED for particular button |
|
132 |
private static int mouseClickButtons = 0; |
|
133 |
||
134 |
private volatile boolean isOpaque = true; |
|
135 |
||
136 |
private static final Font DEFAULT_FONT = new Font("Lucida Grande", Font.PLAIN, 13); |
|
137 |
||
138 |
private static LWWindowPeer grabbingWindow; |
|
139 |
||
140 |
private volatile boolean skipNextFocusChange; |
|
141 |
||
13233 | 142 |
private static final Color nonOpaqueBackground = new Color(0, 0, 0, 0); |
143 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
144 |
private volatile boolean textured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
145 |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
146 |
private final PeerType peerType; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
147 |
|
18241 | 148 |
private final SecurityWarningWindow warningWindow; |
149 |
||
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
150 |
private volatile boolean targetFocusable; |
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
151 |
|
12047 | 152 |
/** |
153 |
* Current modal blocker or null. |
|
154 |
* |
|
155 |
* Synchronization: peerTreeLock. |
|
156 |
*/ |
|
157 |
private LWWindowPeer blocker; |
|
158 |
||
159 |
public LWWindowPeer(Window target, PlatformComponent platformComponent, |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
160 |
PlatformWindow platformWindow, PeerType peerType) |
12047 | 161 |
{ |
162 |
super(target, platformComponent); |
|
163 |
this.platformWindow = platformWindow; |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
164 |
this.peerType = peerType; |
12047 | 165 |
|
166 |
Window owner = target.getOwner(); |
|
20153 | 167 |
LWWindowPeer ownerPeer = owner == null ? null : |
168 |
(LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner); |
|
12047 | 169 |
PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null; |
170 |
||
171 |
// The delegate.initialize() needs a non-null GC on X11. |
|
172 |
GraphicsConfiguration gc = getTarget().getGraphicsConfiguration(); |
|
173 |
synchronized (getStateLock()) { |
|
174 |
// graphicsConfig should be updated according to the real window |
|
175 |
// bounds when the window is shown, see 4868278 |
|
176 |
this.graphicsConfig = gc; |
|
177 |
} |
|
178 |
||
179 |
if (!target.isFontSet()) { |
|
180 |
target.setFont(DEFAULT_FONT); |
|
181 |
} |
|
182 |
||
183 |
if (!target.isBackgroundSet()) { |
|
184 |
target.setBackground(SystemColor.window); |
|
185 |
} else { |
|
186 |
// first we check if user provided alpha for background. This is |
|
187 |
// similar to what Apple's Java do. |
|
188 |
// Since JDK7 we should rely on setOpacity() only. |
|
189 |
// this.opacity = c.getAlpha(); |
|
190 |
} |
|
191 |
||
192 |
if (!target.isForegroundSet()) { |
|
193 |
target.setForeground(SystemColor.windowText); |
|
194 |
// we should not call setForeground because it will call a repaint |
|
195 |
// which the peer may not be ready to do yet. |
|
196 |
} |
|
197 |
||
198 |
platformWindow.initialize(target, this, ownerDelegate); |
|
18241 | 199 |
|
200 |
// Init warning window(for applets) |
|
201 |
SecurityWarningWindow warn = null; |
|
20153 | 202 |
if (target.getWarningString() != null) { |
18241 | 203 |
// accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip |
204 |
// and TrayIcon balloon windows without a warning window. |
|
20153 | 205 |
if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) { |
18241 | 206 |
LWToolkit toolkit = (LWToolkit)Toolkit.getDefaultToolkit(); |
207 |
warn = toolkit.createSecurityWarning(target, this); |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
warningWindow = warn; |
|
12047 | 212 |
} |
213 |
||
214 |
@Override |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
215 |
void initializeImpl() { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
216 |
super.initializeImpl(); |
18241 | 217 |
|
218 |
||
12047 | 219 |
if (getTarget() instanceof Frame) { |
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
220 |
Frame frame = (Frame) getTarget(); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
221 |
setTitle(frame.getTitle()); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
222 |
setState(frame.getExtendedState()); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
223 |
setMaximizedBounds(frame.getMaximizedBounds()); |
12047 | 224 |
} else if (getTarget() instanceof Dialog) { |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
225 |
setTitle(((Dialog) getTarget()).getTitle()); |
12047 | 226 |
} |
227 |
||
16892 | 228 |
updateAlwaysOnTopState(); |
12047 | 229 |
updateMinimumSize(); |
41005
75033e345d45
8160570: [macosx] modal dialog can skip the activation/focus events
ant
parents:
37700
diff
changeset
|
230 |
updateFocusableWindowState(); |
12047 | 231 |
|
13233 | 232 |
final Shape shape = getTarget().getShape(); |
233 |
if (shape != null) { |
|
234 |
applyShape(Region.getInstance(shape, null)); |
|
235 |
} |
|
236 |
||
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
237 |
final float opacity = getTarget().getOpacity(); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
238 |
if (opacity < 1.0f) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
239 |
setOpacity(opacity); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
240 |
} |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
241 |
|
12047 | 242 |
setOpaque(getTarget().isOpaque()); |
243 |
||
244 |
updateInsets(platformWindow.getInsets()); |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
245 |
if (getSurfaceData() == null) { |
13233 | 246 |
replaceSurfaceData(false); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
247 |
} |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
248 |
activateDisplayListener(); |
12047 | 249 |
} |
250 |
||
251 |
// Just a helper method |
|
20153 | 252 |
@Override |
12047 | 253 |
public PlatformWindow getPlatformWindow() { |
254 |
return platformWindow; |
|
255 |
} |
|
256 |
||
257 |
@Override |
|
258 |
protected LWWindowPeer getWindowPeerOrSelf() { |
|
259 |
return this; |
|
260 |
} |
|
261 |
||
262 |
// ---- PEER METHODS ---- // |
|
263 |
||
264 |
@Override |
|
265 |
protected void disposeImpl() { |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
266 |
deactivateDisplayListener(); |
12047 | 267 |
SurfaceData oldData = getSurfaceData(); |
268 |
synchronized (surfaceDataLock){ |
|
269 |
surfaceData = null; |
|
270 |
} |
|
271 |
if (oldData != null) { |
|
272 |
oldData.invalidate(); |
|
273 |
} |
|
274 |
if (isGrabbing()) { |
|
275 |
ungrab(); |
|
276 |
} |
|
18241 | 277 |
if (warningWindow != null) { |
278 |
warningWindow.dispose(); |
|
279 |
} |
|
280 |
||
12047 | 281 |
platformWindow.dispose(); |
282 |
super.disposeImpl(); |
|
283 |
} |
|
284 |
||
285 |
@Override |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
286 |
protected void setVisibleImpl(final boolean visible) { |
18241 | 287 |
if (!visible && warningWindow != null) { |
288 |
warningWindow.setVisible(false, false); |
|
289 |
} |
|
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
290 |
updateFocusableWindowState(); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
291 |
super.setVisibleImpl(visible); |
12047 | 292 |
// TODO: update graphicsConfig, see 4868278 |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
293 |
platformWindow.setVisible(visible); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
294 |
if (isSimpleWindow()) { |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
295 |
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
296 |
if (visible) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
297 |
if (!getTarget().isAutoRequestFocus()) { |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
298 |
return; |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
299 |
} else { |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
34394
diff
changeset
|
300 |
requestWindowFocus(FocusEvent.Cause.ACTIVATION); |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
301 |
} |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
302 |
// Focus the owner in case this window is focused. |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
303 |
} else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) { |
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
304 |
// Transfer focus to the owner. |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
305 |
LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this); |
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
306 |
if (owner != null) { |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
34394
diff
changeset
|
307 |
owner.requestWindowFocus(FocusEvent.Cause.ACTIVATION); |
12047 | 308 |
} |
309 |
} |
|
13143
31c70a66a053
7142091: [macosx] RFE: Refactoring of peer initialization/disposing
serb
parents:
12816
diff
changeset
|
310 |
} |
12047 | 311 |
} |
312 |
||
313 |
@Override |
|
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
314 |
public final GraphicsConfiguration getGraphicsConfiguration() { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
315 |
synchronized (getStateLock()) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
316 |
return graphicsConfig; |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
317 |
} |
12047 | 318 |
} |
319 |
||
320 |
@Override |
|
321 |
public boolean updateGraphicsData(GraphicsConfiguration gc) { |
|
322 |
setGraphicsConfig(gc); |
|
323 |
return false; |
|
324 |
} |
|
325 |
||
326 |
protected final Graphics getOnscreenGraphics(Color fg, Color bg, Font f) { |
|
327 |
if (getSurfaceData() == null) { |
|
328 |
return null; |
|
329 |
} |
|
330 |
if (fg == null) { |
|
331 |
fg = SystemColor.windowText; |
|
332 |
} |
|
333 |
if (bg == null) { |
|
334 |
bg = SystemColor.window; |
|
335 |
} |
|
336 |
if (f == null) { |
|
337 |
f = DEFAULT_FONT; |
|
338 |
} |
|
37700 | 339 |
return new SunGraphics2D(getSurfaceData(), fg, bg, f); |
12047 | 340 |
} |
341 |
||
342 |
@Override |
|
343 |
public void setBounds(int x, int y, int w, int h, int op) { |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
344 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
345 |
if((op & NO_EMBEDDED_CHECK) == 0 && getPeerType() == PeerType.VIEW_EMBEDDED_FRAME) { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
346 |
return; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
347 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
348 |
|
12047 | 349 |
if ((op & SET_CLIENT_SIZE) != 0) { |
350 |
// SET_CLIENT_SIZE is only applicable to window peers, so handle it here |
|
351 |
// instead of pulling 'insets' field up to LWComponentPeer |
|
352 |
// no need to add insets since Window's notion of width and height includes insets. |
|
353 |
op &= ~SET_CLIENT_SIZE; |
|
354 |
op |= SET_SIZE; |
|
355 |
} |
|
356 |
||
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
357 |
// Don't post ComponentMoved/Resized and Paint events |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
358 |
// until we've got a notification from the delegate |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
359 |
Rectangle cb = constrainBounds(x, y, w, h); |
21247
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
360 |
|
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
361 |
Rectangle newBounds = new Rectangle(getBounds()); |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
362 |
if ((op & (SET_LOCATION | SET_BOUNDS)) != 0) { |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
363 |
newBounds.x = cb.x; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
364 |
newBounds.y = cb.y; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
365 |
} |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
366 |
if ((op & (SET_SIZE | SET_BOUNDS)) != 0) { |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
367 |
newBounds.width = cb.width; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
368 |
newBounds.height = cb.height; |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
369 |
} |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
370 |
// Native system could constraint bounds, so the peer wold be updated in the callback |
40e9d768d8e2
8024864: [macosx] Problems with rendering of controls
pchelko
parents:
20457
diff
changeset
|
371 |
platformWindow.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height); |
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
372 |
} |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
373 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
374 |
public Rectangle constrainBounds(Rectangle bounds) { |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
375 |
return constrainBounds(bounds.x, bounds.y, bounds.width, bounds.height); |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
376 |
} |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
377 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
378 |
public Rectangle constrainBounds(int x, int y, int w, int h) { |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
379 |
|
12047 | 380 |
if (w < MINIMUM_WIDTH) { |
381 |
w = MINIMUM_WIDTH; |
|
382 |
} |
|
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
383 |
|
12047 | 384 |
if (h < MINIMUM_HEIGHT) { |
385 |
h = MINIMUM_HEIGHT; |
|
386 |
} |
|
387 |
||
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
388 |
final int maxW = getLWGC().getMaxTextureWidth(); |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
389 |
final int maxH = getLWGC().getMaxTextureHeight(); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
390 |
|
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
391 |
if (w > maxW) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
392 |
w = maxW; |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
393 |
} |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
394 |
if (h > maxH) { |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
395 |
h = maxH; |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
396 |
} |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
397 |
|
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
20448
diff
changeset
|
398 |
return new Rectangle(x, y, w, h); |
12047 | 399 |
} |
400 |
||
401 |
@Override |
|
402 |
public Point getLocationOnScreen() { |
|
403 |
return platformWindow.getLocationOnScreen(); |
|
404 |
} |
|
405 |
||
406 |
/** |
|
407 |
* Overridden from LWContainerPeer to return the correct insets. |
|
408 |
* Insets are queried from the delegate and are kept up to date by |
|
409 |
* requiering when needed (i.e. when the window geometry is changed). |
|
410 |
*/ |
|
411 |
@Override |
|
412 |
public Insets getInsets() { |
|
413 |
synchronized (getStateLock()) { |
|
414 |
return insets; |
|
415 |
} |
|
416 |
} |
|
417 |
||
418 |
@Override |
|
419 |
public FontMetrics getFontMetrics(Font f) { |
|
420 |
// TODO: check for "use platform metrics" settings |
|
421 |
return platformWindow.getFontMetrics(f); |
|
422 |
} |
|
423 |
||
424 |
@Override |
|
425 |
public void toFront() { |
|
426 |
platformWindow.toFront(); |
|
427 |
} |
|
428 |
||
429 |
@Override |
|
430 |
public void toBack() { |
|
431 |
platformWindow.toBack(); |
|
432 |
} |
|
433 |
||
434 |
@Override |
|
435 |
public void setZOrder(ComponentPeer above) { |
|
436 |
throw new RuntimeException("not implemented"); |
|
437 |
} |
|
438 |
||
439 |
@Override |
|
16892 | 440 |
public void updateAlwaysOnTopState() { |
441 |
platformWindow.setAlwaysOnTop(getTarget().isAlwaysOnTop()); |
|
12047 | 442 |
} |
443 |
||
444 |
@Override |
|
445 |
public void updateFocusableWindowState() { |
|
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
446 |
targetFocusable = getTarget().isFocusableWindow(); |
12047 | 447 |
platformWindow.updateFocusableWindowState(); |
448 |
} |
|
449 |
||
450 |
@Override |
|
451 |
public void setModalBlocked(Dialog blocker, boolean blocked) { |
|
452 |
synchronized (getPeerTreeLock()) { |
|
20445
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
453 |
ComponentPeer peer = AWTAccessor.getComponentAccessor().getPeer(blocker); |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
454 |
if (blocked && (peer instanceof LWWindowPeer)) { |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
455 |
this.blocker = (LWWindowPeer) peer; |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
456 |
} else { |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
457 |
this.blocker = null; |
9440dd9e78d1
7124363: [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
pchelko
parents:
20153
diff
changeset
|
458 |
} |
12047 | 459 |
} |
12640 | 460 |
|
461 |
platformWindow.setModalBlocked(blocked); |
|
12047 | 462 |
} |
463 |
||
464 |
@Override |
|
465 |
public void updateMinimumSize() { |
|
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
466 |
final Dimension min; |
12047 | 467 |
if (getTarget().isMinimumSizeSet()) { |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
468 |
min = getTarget().getMinimumSize(); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
469 |
min.width = Math.max(min.width, MINIMUM_WIDTH); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
470 |
min.height = Math.max(min.height, MINIMUM_HEIGHT); |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
471 |
} else { |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
472 |
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT); |
12047 | 473 |
} |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
474 |
|
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
475 |
final Dimension max; |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
476 |
if (getTarget().isMaximumSizeSet()) { |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
477 |
max = getTarget().getMaximumSize(); |
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
478 |
max.width = Math.min(max.width, getLWGC().getMaxTextureWidth()); |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
479 |
max.height = Math.min(max.height, getLWGC().getMaxTextureHeight()); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
480 |
} else { |
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
481 |
max = new Dimension(getLWGC().getMaxTextureWidth(), |
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
482 |
getLWGC().getMaxTextureHeight()); |
13550
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
483 |
} |
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
484 |
|
648dd6fa0dee
7160609: [macosx] JDK crash in libjvm.dylib ( C [GeForceGLDriver+0x675a] gldAttachDrawable+0x941)
anthony
parents:
13234
diff
changeset
|
485 |
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height); |
12047 | 486 |
} |
487 |
||
488 |
@Override |
|
489 |
public void updateIconImages() { |
|
490 |
getPlatformWindow().updateIconImages(); |
|
491 |
} |
|
492 |
||
493 |
@Override |
|
25196
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
494 |
public void setBackground(final Color c) { |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
495 |
super.setBackground(c); |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
496 |
updateOpaque(); |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
497 |
} |
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
498 |
|
48d9cfe3f138
8033786: White flashing when opening Dialogs and Menus using Nimbus with dark background
serb
parents:
23627
diff
changeset
|
499 |
@Override |
12047 | 500 |
public void setOpacity(float opacity) { |
501 |
getPlatformWindow().setOpacity(opacity); |
|
502 |
repaintPeer(); |
|
503 |
} |
|
504 |
||
505 |
@Override |
|
506 |
public final void setOpaque(final boolean isOpaque) { |
|
507 |
if (this.isOpaque != isOpaque) { |
|
508 |
this.isOpaque = isOpaque; |
|
13233 | 509 |
updateOpaque(); |
12047 | 510 |
} |
511 |
} |
|
512 |
||
13233 | 513 |
private void updateOpaque() { |
514 |
getPlatformWindow().setOpaque(!isTranslucent()); |
|
515 |
replaceSurfaceData(false); |
|
516 |
repaintPeer(); |
|
12047 | 517 |
} |
518 |
||
519 |
@Override |
|
520 |
public void updateWindow() { |
|
13233 | 521 |
} |
522 |
||
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
523 |
public final boolean isTextured() { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
524 |
return textured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
525 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
526 |
|
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
527 |
public final void setTextured(final boolean isTextured) { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
528 |
textured = isTextured; |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
529 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
530 |
|
20153 | 531 |
@Override |
13233 | 532 |
public final boolean isTranslucent() { |
533 |
synchronized (getStateLock()) { |
|
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
534 |
/* |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
535 |
* Textured window is a special case of translucent window. |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
536 |
* The difference is only in nswindow background. So when we set |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
537 |
* texture property our peer became fully translucent. It doesn't |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
538 |
* fill background, create non opaque backbuffers and layer etc. |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
539 |
*/ |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
540 |
return !isOpaque || isShaped() || isTextured(); |
13233 | 541 |
} |
542 |
} |
|
543 |
||
544 |
@Override |
|
545 |
final void applyShapeImpl(final Region shape) { |
|
546 |
super.applyShapeImpl(shape); |
|
547 |
updateOpaque(); |
|
12047 | 548 |
} |
549 |
||
550 |
@Override |
|
551 |
public void repositionSecurityWarning() { |
|
18241 | 552 |
if (warningWindow != null) { |
30469 | 553 |
ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor(); |
18241 | 554 |
Window target = getTarget(); |
555 |
int x = compAccessor.getX(target); |
|
556 |
int y = compAccessor.getY(target); |
|
557 |
int width = compAccessor.getWidth(target); |
|
558 |
int height = compAccessor.getHeight(target); |
|
559 |
warningWindow.reposition(x, y, width, height); |
|
560 |
} |
|
12047 | 561 |
} |
562 |
||
563 |
// ---- FRAME PEER METHODS ---- // |
|
564 |
||
565 |
@Override // FramePeer and DialogPeer |
|
566 |
public void setTitle(String title) { |
|
567 |
platformWindow.setTitle(title == null ? "" : title); |
|
568 |
} |
|
569 |
||
570 |
@Override |
|
571 |
public void setMenuBar(MenuBar mb) { |
|
572 |
platformWindow.setMenuBar(mb); |
|
573 |
} |
|
574 |
||
575 |
@Override // FramePeer and DialogPeer |
|
576 |
public void setResizable(boolean resizable) { |
|
577 |
platformWindow.setResizable(resizable); |
|
578 |
} |
|
579 |
||
580 |
@Override |
|
581 |
public void setState(int state) { |
|
582 |
platformWindow.setWindowState(state); |
|
583 |
} |
|
584 |
||
585 |
@Override |
|
586 |
public int getState() { |
|
587 |
return windowState; |
|
588 |
} |
|
589 |
||
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
590 |
private boolean isMaximizedBoundsSet() { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
591 |
synchronized (getStateLock()) { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
592 |
return maximizedBounds != null; |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
593 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
594 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
595 |
|
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
596 |
private Rectangle getDefaultMaximizedBounds() { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
597 |
GraphicsConfiguration config = getGraphicsConfiguration(); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
598 |
Insets screenInsets = ((CGraphicsDevice) config.getDevice()) |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
599 |
.getScreenInsets(); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
600 |
Rectangle gcBounds = config.getBounds(); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
601 |
return new Rectangle( |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
602 |
gcBounds.x + screenInsets.left, |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
603 |
gcBounds.y + screenInsets.top, |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
604 |
gcBounds.width - screenInsets.left - screenInsets.right, |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
605 |
gcBounds.height - screenInsets.top - screenInsets.bottom); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
606 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
607 |
|
12047 | 608 |
@Override |
609 |
public void setMaximizedBounds(Rectangle bounds) { |
|
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
610 |
boolean isMaximizedBoundsSet; |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
611 |
synchronized (getStateLock()) { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
612 |
this.maximizedBounds = (isMaximizedBoundsSet = (bounds != null)) |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
613 |
? constrainBounds(bounds) : null; |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
614 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
615 |
|
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
616 |
setPlatformMaximizedBounds(isMaximizedBoundsSet ? maximizedBounds |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
617 |
: getDefaultMaximizedBounds()); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
618 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
619 |
|
32480
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
620 |
public Rectangle getMaximizedBounds() { |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
621 |
synchronized (getStateLock()) { |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
622 |
return (maximizedBounds == null) |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
623 |
? getDefaultMaximizedBounds() |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
624 |
: maximizedBounds; |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
625 |
} |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
626 |
} |
6d72f6be8202
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
alexsch
parents:
32295
diff
changeset
|
627 |
|
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
628 |
private void setPlatformMaximizedBounds(Rectangle bounds) { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
629 |
platformWindow.setMaximizedBounds( |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
630 |
bounds.x, bounds.y, |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
631 |
bounds.width, bounds.height); |
12047 | 632 |
} |
633 |
||
634 |
@Override |
|
635 |
public void setBoundsPrivate(int x, int y, int width, int height) { |
|
636 |
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK); |
|
637 |
} |
|
638 |
||
639 |
@Override |
|
640 |
public Rectangle getBoundsPrivate() { |
|
641 |
throw new RuntimeException("not implemented"); |
|
642 |
} |
|
643 |
||
644 |
// ---- DIALOG PEER METHODS ---- // |
|
645 |
||
646 |
@Override |
|
647 |
public void blockWindows(List<Window> windows) { |
|
648 |
//TODO: LWX will probably need some collectJavaToplevels to speed this up |
|
649 |
for (Window w : windows) { |
|
30469 | 650 |
WindowPeer wp = AWTAccessor.getComponentAccessor().getPeer(w); |
12047 | 651 |
if (wp != null) { |
652 |
wp.setModalBlocked((Dialog)getTarget(), true); |
|
653 |
} |
|
654 |
} |
|
655 |
} |
|
656 |
||
657 |
// ---- PEER NOTIFICATIONS ---- // |
|
658 |
||
18241 | 659 |
@Override |
12047 | 660 |
public void notifyIconify(boolean iconify) { |
661 |
//The toplevel target is Frame and states are applicable to it. |
|
662 |
//Otherwise, the target is Window and it don't have state property. |
|
663 |
//Hopefully, no such events are posted in the queue so consider the |
|
664 |
//target as Frame in all cases. |
|
665 |
||
666 |
// REMIND: should we send it anyway if the state not changed since last |
|
667 |
// time? |
|
668 |
WindowEvent iconifyEvent = new WindowEvent(getTarget(), |
|
669 |
iconify ? WindowEvent.WINDOW_ICONIFIED |
|
670 |
: WindowEvent.WINDOW_DEICONIFIED); |
|
671 |
postEvent(iconifyEvent); |
|
672 |
||
673 |
int newWindowState = iconify ? Frame.ICONIFIED : Frame.NORMAL; |
|
674 |
postWindowStateChangedEvent(newWindowState); |
|
675 |
||
676 |
// REMIND: RepaintManager doesn't repaint iconified windows and |
|
677 |
// hence ignores any repaint request during deiconification. |
|
678 |
// So, we need to repaint window explicitly when it becomes normal. |
|
679 |
if (!iconify) { |
|
680 |
repaintPeer(); |
|
681 |
} |
|
682 |
} |
|
683 |
||
18241 | 684 |
@Override |
12047 | 685 |
public void notifyZoom(boolean isZoomed) { |
686 |
int newWindowState = isZoomed ? Frame.MAXIMIZED_BOTH : Frame.NORMAL; |
|
687 |
postWindowStateChangedEvent(newWindowState); |
|
688 |
} |
|
689 |
||
690 |
/** |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
691 |
* Called by the {@code PlatformWindow} when any part of the window should |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
692 |
* be repainted. |
12047 | 693 |
*/ |
18241 | 694 |
@Override |
695 |
public void notifyExpose(final Rectangle r) { |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
696 |
repaintPeer(r); |
12047 | 697 |
} |
698 |
||
699 |
/** |
|
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
700 |
* Called by the {@code PlatformWindow} when this window is moved/resized by |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
701 |
* user or window insets are changed. There's no notifyReshape() in |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
702 |
* LWComponentPeer as the only components which could be resized by user are |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
703 |
* top-level windows. |
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
704 |
* <p> |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
705 |
* We need to update the target and post the events, if the peer was moved |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
706 |
* or resized, or if the target is out of sync with this peer. |
12047 | 707 |
*/ |
18241 | 708 |
@Override |
709 |
public void notifyReshape(int x, int y, int w, int h) { |
|
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
710 |
final Rectangle pBounds = getBounds(); |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
711 |
final boolean invalid = updateInsets(platformWindow.getInsets()); |
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
712 |
final boolean pMoved = (x != pBounds.x) || (y != pBounds.y); |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
713 |
final boolean pResized = (w != pBounds.width) || (h != pBounds.height); |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
714 |
|
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
715 |
final ComponentAccessor accessor = AWTAccessor.getComponentAccessor(); |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
716 |
final Rectangle tBounds = accessor.getBounds(getTarget()); |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
717 |
final boolean tMoved = (x != tBounds.x) || (y != tBounds.y); |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
718 |
final boolean tResized = (w != tBounds.width) || (h != tBounds.height); |
12047 | 719 |
|
720 |
// Check if anything changed |
|
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
721 |
if (!tMoved && !tResized && !pMoved && !pResized && !invalid) { |
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
722 |
// Native window(NSWindow)/LWWindowPeer/Target are in sync |
12047 | 723 |
return; |
724 |
} |
|
725 |
// First, update peer's bounds |
|
726 |
setBounds(x, y, w, h, SET_BOUNDS, false, false); |
|
727 |
||
728 |
// Second, update the graphics config and surface data |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
729 |
final boolean isNewDevice = updateGraphicsDevice(); |
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
730 |
if (isNewDevice && !isMaximizedBoundsSet()) { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
731 |
setPlatformMaximizedBounds(getDefaultMaximizedBounds()); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
732 |
} |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
733 |
|
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
734 |
if (pResized || isNewDevice) { |
12047 | 735 |
replaceSurfaceData(); |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
736 |
updateMinimumSize(); |
12047 | 737 |
} |
738 |
||
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
739 |
// Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events |
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
740 |
if (tMoved || pMoved || invalid) { |
12047 | 741 |
handleMove(x, y, true); |
742 |
} |
|
50343
80a5ff734fcd
8201364: [macosx] Component.getLocation() gives inconsistent coordinate for a component at (0,0)
serb
parents:
47216
diff
changeset
|
743 |
if (tResized || pResized || invalid || isNewDevice) { |
14306
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
744 |
handleResize(w, h, true); |
8d823e84507a
7198229: Painting during resizing of the frame should be more smooth
serb
parents:
13652
diff
changeset
|
745 |
repaintPeer(); |
12047 | 746 |
} |
18241 | 747 |
|
748 |
repositionSecurityWarning(); |
|
12047 | 749 |
} |
750 |
||
751 |
private void clearBackground(final int w, final int h) { |
|
752 |
final Graphics g = getOnscreenGraphics(getForeground(), getBackground(), |
|
753 |
getFont()); |
|
754 |
if (g != null) { |
|
755 |
try { |
|
13233 | 756 |
if (g instanceof Graphics2D) { |
757 |
((Graphics2D) g).setComposite(AlphaComposite.Src); |
|
758 |
} |
|
759 |
if (isTranslucent()) { |
|
760 |
g.setColor(nonOpaqueBackground); |
|
761 |
g.fillRect(0, 0, w, h); |
|
762 |
} |
|
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
763 |
if (!isTextured()) { |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
764 |
if (g instanceof SunGraphics2D) { |
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
765 |
((SunGraphics2D) g).constrain(0, 0, w, h, getRegion()); |
13234
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
766 |
} |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
767 |
g.setColor(getBackground()); |
9437e5985d73
7124513: [macosx] Support NSTexturedBackgroundWindowMask/different titlebar styles to create unified toolbar
serb
parents:
13233
diff
changeset
|
768 |
g.fillRect(0, 0, w, h); |
13233 | 769 |
} |
12047 | 770 |
} finally { |
771 |
g.dispose(); |
|
772 |
} |
|
773 |
} |
|
774 |
} |
|
775 |
||
18241 | 776 |
@Override |
12047 | 777 |
public void notifyUpdateCursor() { |
778 |
getLWToolkit().getCursorManager().updateCursorLater(this); |
|
779 |
} |
|
780 |
||
18241 | 781 |
@Override |
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
782 |
public void notifyActivation(boolean activation, LWWindowPeer opposite) { |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
783 |
Window oppositeWindow = (opposite == null)? null : opposite.getTarget(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
784 |
changeFocusedWindow(activation, oppositeWindow); |
12047 | 785 |
} |
786 |
||
787 |
// MouseDown in non-client area |
|
18241 | 788 |
@Override |
12047 | 789 |
public void notifyNCMouseDown() { |
790 |
// Ungrab except for a click on a Dialog with the grabbing owner |
|
791 |
if (grabbingWindow != null && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
792 |
!grabbingWindow.isOneOfOwnersOf(this)) |
12047 | 793 |
{ |
794 |
grabbingWindow.ungrab(); |
|
795 |
} |
|
796 |
} |
|
797 |
||
798 |
// ---- EVENTS ---- // |
|
799 |
||
800 |
/* |
|
801 |
* Called by the delegate to dispatch the event to Java. Event |
|
802 |
* coordinates are relative to non-client window are, i.e. the top-left |
|
803 |
* point of the client area is (insets.top, insets.left). |
|
804 |
*/ |
|
18241 | 805 |
@Override |
806 |
public void notifyMouseEvent(int id, long when, int button, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
807 |
int x, int y, int absX, int absY, |
18241 | 808 |
int modifiers, int clickCount, boolean popupTrigger, |
809 |
byte[] bdata) |
|
12047 | 810 |
{ |
811 |
// TODO: fill "bdata" member of AWTEvent |
|
812 |
Rectangle r = getBounds(); |
|
813 |
// findPeerAt() expects parent coordinates |
|
20153 | 814 |
LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y); |
12047 | 815 |
|
816 |
if (id == MouseEvent.MOUSE_EXITED) { |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
817 |
isMouseOver = false; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
818 |
if (lastMouseEventPeer != null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
819 |
if (lastMouseEventPeer.isEnabled()) { |
12047 | 820 |
Point lp = lastMouseEventPeer.windowToLocal(x, y, |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
821 |
this); |
18241 | 822 |
Component target = lastMouseEventPeer.getTarget(); |
823 |
postMouseExitedEvent(target, when, modifiers, lp, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
824 |
absX, absY, clickCount, popupTrigger, button); |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
825 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
826 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
827 |
// Sometimes we may get MOUSE_EXITED after lastCommonMouseEventPeer is switched |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
828 |
// to a peer from another window. So we must first check if this peer is |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
829 |
// the same as lastWindowPeer |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
830 |
if (lastCommonMouseEventPeer != null && lastCommonMouseEventPeer.getWindowPeerOrSelf() == this) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
831 |
lastCommonMouseEventPeer = null; |
12047 | 832 |
} |
833 |
lastMouseEventPeer = null; |
|
834 |
} |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
835 |
} else if(id == MouseEvent.MOUSE_ENTERED) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
836 |
isMouseOver = true; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
837 |
if (targetPeer != null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
838 |
if (targetPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
839 |
Point lp = targetPeer.windowToLocal(x, y, this); |
18241 | 840 |
Component target = targetPeer.getTarget(); |
841 |
postMouseEnteredEvent(target, when, modifiers, lp, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
842 |
absX, absY, clickCount, popupTrigger, button); |
12047 | 843 |
} |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
844 |
lastCommonMouseEventPeer = targetPeer; |
12047 | 845 |
lastMouseEventPeer = targetPeer; |
846 |
} |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
847 |
} else { |
30924 | 848 |
PlatformWindow topmostPlatformWindow = LWToolkit.getLWToolkit().getPlatformWindowUnderMouse(); |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
849 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
850 |
LWWindowPeer topmostWindowPeer = |
30924 | 851 |
topmostPlatformWindow != null ? topmostPlatformWindow.getPeer() : null; |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
852 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
853 |
// topmostWindowPeer == null condition is added for the backward |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
854 |
// compatibility with applets. It can be removed when the |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
855 |
// getTopmostPlatformWindowUnderMouse() method will be properly |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
856 |
// implemented in CPlatformEmbeddedFrame class |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
857 |
if (topmostWindowPeer == this || topmostWindowPeer == null) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
858 |
generateMouseEnterExitEventsForComponents(when, button, x, y, |
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
859 |
absX, absY, modifiers, clickCount, popupTrigger, |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
860 |
targetPeer); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
861 |
} else { |
30924 | 862 |
LWComponentPeer<?, ?> topmostTargetPeer = topmostWindowPeer.findPeerAt(r.x + x, r.y + y); |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
863 |
topmostWindowPeer.generateMouseEnterExitEventsForComponents(when, button, x, y, |
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
864 |
absX, absY, modifiers, clickCount, popupTrigger, |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
865 |
topmostTargetPeer); |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
866 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
867 |
|
12047 | 868 |
// TODO: fill "bdata" member of AWTEvent |
869 |
||
870 |
int eventButtonMask = (button > 0)? MouseEvent.getMaskForButton(button) : 0; |
|
871 |
int otherButtonsPressed = modifiers & ~eventButtonMask; |
|
872 |
||
873 |
// For pressed/dragged/released events OS X treats other |
|
874 |
// mouse buttons as if they were BUTTON2, so we do the same |
|
875 |
int targetIdx = (button > 3) ? MouseEvent.BUTTON2 - 1 : button - 1; |
|
876 |
||
877 |
// MOUSE_ENTERED/EXITED are generated for the components strictly under |
|
878 |
// mouse even when dragging. That's why we first update lastMouseEventPeer |
|
879 |
// based on initial targetPeer value and only then recalculate targetPeer |
|
880 |
// for MOUSE_DRAGGED/RELEASED events |
|
881 |
if (id == MouseEvent.MOUSE_PRESSED) { |
|
882 |
||
883 |
// Ungrab only if this window is not an owned window of the grabbing one. |
|
884 |
if (!isGrabbing() && grabbingWindow != null && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
885 |
!grabbingWindow.isOneOfOwnersOf(this)) |
12047 | 886 |
{ |
887 |
grabbingWindow.ungrab(); |
|
888 |
} |
|
889 |
if (otherButtonsPressed == 0) { |
|
890 |
mouseClickButtons = eventButtonMask; |
|
891 |
} else { |
|
892 |
mouseClickButtons |= eventButtonMask; |
|
893 |
} |
|
894 |
||
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
895 |
// The window should be focused on mouse click. If it gets activated by the native platform, |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
896 |
// this request will be no op. It will take effect when: |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
897 |
// 1. A simple not focused window is clicked. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
898 |
// 2. An active but not focused owner frame/dialog is clicked. |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
899 |
// The mouse event then will trigger a focus request "in window" to the component, so the window |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
900 |
// should gain focus before. |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
34394
diff
changeset
|
901 |
requestWindowFocus(FocusEvent.Cause.MOUSE_EVENT); |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
902 |
|
12047 | 903 |
mouseDownTarget[targetIdx] = targetPeer; |
904 |
} else if (id == MouseEvent.MOUSE_DRAGGED) { |
|
905 |
// Cocoa dragged event has the information about which mouse |
|
906 |
// button is being dragged. Use it to determine the peer that |
|
907 |
// should receive the dragged event. |
|
908 |
targetPeer = mouseDownTarget[targetIdx]; |
|
909 |
mouseClickButtons &= ~modifiers; |
|
910 |
} else if (id == MouseEvent.MOUSE_RELEASED) { |
|
911 |
// TODO: currently, mouse released event goes to the same component |
|
912 |
// that received corresponding mouse pressed event. For most cases, |
|
913 |
// it's OK, however, we need to make sure that our behavior is consistent |
|
914 |
// with 1.6 for cases where component in question have been |
|
915 |
// hidden/removed in between of mouse pressed/released events. |
|
916 |
targetPeer = mouseDownTarget[targetIdx]; |
|
917 |
||
918 |
if ((modifiers & eventButtonMask) == 0) { |
|
919 |
mouseDownTarget[targetIdx] = null; |
|
920 |
} |
|
921 |
||
922 |
// mouseClickButtons is updated below, after MOUSE_CLICK is sent |
|
923 |
} |
|
924 |
||
925 |
if (targetPeer == null) { |
|
926 |
//TODO This can happen if this window is invisible. this is correct behavior in this case? |
|
927 |
targetPeer = this; |
|
928 |
} |
|
929 |
||
930 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
931 |
Point lp = targetPeer.windowToLocal(x, y, this); |
12047 | 932 |
if (targetPeer.isEnabled()) { |
933 |
MouseEvent event = new MouseEvent(targetPeer.getTarget(), id, |
|
934 |
when, modifiers, lp.x, lp.y, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
935 |
absX, absY, clickCount, |
12047 | 936 |
popupTrigger, button); |
937 |
postEvent(event); |
|
938 |
} |
|
939 |
||
940 |
if (id == MouseEvent.MOUSE_RELEASED) { |
|
941 |
if ((mouseClickButtons & eventButtonMask) != 0 |
|
942 |
&& targetPeer.isEnabled()) { |
|
943 |
postEvent(new MouseEvent(targetPeer.getTarget(), |
|
944 |
MouseEvent.MOUSE_CLICKED, |
|
945 |
when, modifiers, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
946 |
lp.x, lp.y, absX, absY, |
12047 | 947 |
clickCount, popupTrigger, button)); |
948 |
} |
|
949 |
mouseClickButtons &= ~eventButtonMask; |
|
950 |
} |
|
951 |
} |
|
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
952 |
notifyUpdateCursor(); |
12047 | 953 |
} |
954 |
||
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
955 |
private void generateMouseEnterExitEventsForComponents(long when, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
956 |
int button, int x, int y, int screenX, int screenY, |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
957 |
int modifiers, int clickCount, boolean popupTrigger, |
20153 | 958 |
final LWComponentPeer<?, ?> targetPeer) { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
959 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
960 |
if (!isMouseOver || targetPeer == lastMouseEventPeer) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
961 |
return; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
962 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
963 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
964 |
// Generate Mouse Exit for components |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
965 |
if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
966 |
Point oldp = lastMouseEventPeer.windowToLocal(x, y, this); |
18241 | 967 |
Component target = lastMouseEventPeer.getTarget(); |
968 |
postMouseExitedEvent(target, when, modifiers, oldp, screenX, screenY, |
|
969 |
clickCount, popupTrigger, button); |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
970 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
971 |
lastCommonMouseEventPeer = targetPeer; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
972 |
lastMouseEventPeer = targetPeer; |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
973 |
|
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
974 |
// Generate Mouse Enter for components |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
975 |
if (targetPeer != null && targetPeer.isEnabled()) { |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
976 |
Point newp = targetPeer.windowToLocal(x, y, this); |
18241 | 977 |
Component target = targetPeer.getTarget(); |
978 |
postMouseEnteredEvent(target, when, modifiers, newp, screenX, screenY, clickCount, popupTrigger, button); |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
979 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
980 |
} |
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
981 |
|
18241 | 982 |
private void postMouseEnteredEvent(Component target, long when, int modifiers, |
983 |
Point loc, int xAbs, int yAbs, |
|
984 |
int clickCount, boolean popupTrigger, int button) { |
|
985 |
||
986 |
updateSecurityWarningVisibility(); |
|
987 |
||
988 |
postEvent(new MouseEvent(target, |
|
989 |
MouseEvent.MOUSE_ENTERED, |
|
990 |
when, modifiers, |
|
991 |
loc.x, loc.y, xAbs, yAbs, |
|
992 |
clickCount, popupTrigger, button)); |
|
993 |
} |
|
994 |
||
995 |
private void postMouseExitedEvent(Component target, long when, int modifiers, |
|
996 |
Point loc, int xAbs, int yAbs, |
|
997 |
int clickCount, boolean popupTrigger, int button) { |
|
998 |
||
999 |
updateSecurityWarningVisibility(); |
|
1000 |
||
1001 |
postEvent(new MouseEvent(target, |
|
1002 |
MouseEvent.MOUSE_EXITED, |
|
1003 |
when, modifiers, |
|
1004 |
loc.x, loc.y, xAbs, yAbs, |
|
1005 |
clickCount, popupTrigger, button)); |
|
1006 |
} |
|
1007 |
||
1008 |
@Override |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
1009 |
public void notifyMouseWheelEvent(long when, int x, int y, int absX, |
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
1010 |
int absY, int modifiers, int scrollType, |
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
1011 |
int scrollAmount, int wheelRotation, |
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
1012 |
double preciseWheelRotation, byte[] bdata) |
12047 | 1013 |
{ |
1014 |
// TODO: could we just use the last mouse event target here? |
|
1015 |
Rectangle r = getBounds(); |
|
1016 |
// findPeerAt() expects parent coordinates |
|
20153 | 1017 |
final LWComponentPeer<?, ?> targetPeer = findPeerAt(r.x + x, r.y + y); |
12047 | 1018 |
if (targetPeer == null || !targetPeer.isEnabled()) { |
1019 |
return; |
|
1020 |
} |
|
1021 |
||
1022 |
Point lp = targetPeer.windowToLocal(x, y, this); |
|
1023 |
// TODO: fill "bdata" member of AWTEvent |
|
1024 |
postEvent(new MouseWheelEvent(targetPeer.getTarget(), |
|
1025 |
MouseEvent.MOUSE_WHEEL, |
|
1026 |
when, modifiers, |
|
1027 |
lp.x, lp.y, |
|
32295
5ba453554637
6778087: getLocationOnScreen() always returns (0, 0) for mouse wheel events
serb
parents:
30944
diff
changeset
|
1028 |
absX, absY, /* absX, absY */ |
12047 | 1029 |
0 /* clickCount */, false /* popupTrigger */, |
1030 |
scrollType, scrollAmount, |
|
1031 |
wheelRotation, preciseWheelRotation)); |
|
1032 |
} |
|
1033 |
||
1034 |
/* |
|
1035 |
* Called by the delegate when a key is pressed. |
|
1036 |
*/ |
|
18241 | 1037 |
@Override |
1038 |
public void notifyKeyEvent(int id, long when, int modifiers, |
|
1039 |
int keyCode, char keyChar, int keyLocation) |
|
12047 | 1040 |
{ |
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1041 |
LWKeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
1042 |
Component focusOwner = kfmPeer.getCurrentFocusOwner(); |
12047 | 1043 |
|
13652
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1044 |
if (focusOwner == null) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1045 |
focusOwner = kfmPeer.getCurrentFocusedWindow(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1046 |
if (focusOwner == null) { |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1047 |
focusOwner = this.getTarget(); |
42544e68dc39
6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents:
13648
diff
changeset
|
1048 |
} |
12047 | 1049 |
} |
20109
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
1050 |
|
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
1051 |
KeyEvent keyEvent = new KeyEvent(focusOwner, id, when, modifiers, |
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
1052 |
keyCode, keyChar, keyLocation); |
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
1053 |
AWTAccessor.getKeyEventAccessor().setExtendedKeyCode(keyEvent, |
21783
a3863a1446bf
8025126: [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X
alexsch
parents:
21247
diff
changeset
|
1054 |
(keyChar == KeyEvent.CHAR_UNDEFINED) ? keyCode |
a3863a1446bf
8025126: [macosx] Invalid calls to setValueAt() within JTable in Java 7 on Mac OS X
alexsch
parents:
21247
diff
changeset
|
1055 |
: ExtendedKeyCodes.getExtendedKeyCodeForChar(keyChar)); |
20109
e568ad7e1bf3
8007156: [macosx] Wrong events in processKeyBinding of JTable Submit Date
alexsch
parents:
18275
diff
changeset
|
1056 |
postEvent(keyEvent); |
12047 | 1057 |
} |
1058 |
||
1059 |
// ---- UTILITY METHODS ---- // |
|
1060 |
||
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1061 |
private void activateDisplayListener() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1062 |
final GraphicsEnvironment ge = |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1063 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1064 |
((SunGraphicsEnvironment) ge).addDisplayChangedListener(this); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1065 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1066 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1067 |
private void deactivateDisplayListener() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1068 |
final GraphicsEnvironment ge = |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1069 |
GraphicsEnvironment.getLocalGraphicsEnvironment(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1070 |
((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1071 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1072 |
|
12047 | 1073 |
private void postWindowStateChangedEvent(int newWindowState) { |
1074 |
if (getTarget() instanceof Frame) { |
|
1075 |
AWTAccessor.getFrameAccessor().setExtendedState( |
|
1076 |
(Frame)getTarget(), newWindowState); |
|
1077 |
} |
|
18241 | 1078 |
|
12047 | 1079 |
WindowEvent stateChangedEvent = new WindowEvent(getTarget(), |
1080 |
WindowEvent.WINDOW_STATE_CHANGED, |
|
1081 |
windowState, newWindowState); |
|
1082 |
postEvent(stateChangedEvent); |
|
1083 |
windowState = newWindowState; |
|
18241 | 1084 |
|
1085 |
updateSecurityWarningVisibility(); |
|
12047 | 1086 |
} |
1087 |
||
1088 |
private static int getGraphicsConfigScreen(GraphicsConfiguration gc) { |
|
1089 |
// TODO: this method can be implemented in a more |
|
1090 |
// efficient way by forwarding to the delegate |
|
1091 |
GraphicsDevice gd = gc.getDevice(); |
|
1092 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
|
1093 |
GraphicsDevice[] gds = ge.getScreenDevices(); |
|
1094 |
for (int i = 0; i < gds.length; i++) { |
|
1095 |
if (gds[i] == gd) { |
|
1096 |
return i; |
|
1097 |
} |
|
1098 |
} |
|
1099 |
// Should never happen if gc is a screen device config |
|
1100 |
return 0; |
|
1101 |
} |
|
1102 |
||
1103 |
/* |
|
1104 |
* This method is called when window's graphics config is changed from |
|
1105 |
* the app code (e.g. when the window is made non-opaque) or when |
|
1106 |
* the window is moved to another screen by user. |
|
1107 |
* |
|
1108 |
* Returns true if the graphics config has been changed, false otherwise. |
|
1109 |
*/ |
|
1110 |
private boolean setGraphicsConfig(GraphicsConfiguration gc) { |
|
1111 |
synchronized (getStateLock()) { |
|
1112 |
if (graphicsConfig == gc) { |
|
1113 |
return false; |
|
1114 |
} |
|
1115 |
// If window's graphics config is changed from the app code, the |
|
1116 |
// config correspond to the same device as before; when the window |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1117 |
// is moved by user, graphicsDevice is updated in notifyReshape(). |
12047 | 1118 |
// In either case, there's nothing to do with screenOn here |
1119 |
graphicsConfig = gc; |
|
1120 |
} |
|
1121 |
// SurfaceData is replaced later in updateGraphicsData() |
|
1122 |
return true; |
|
1123 |
} |
|
1124 |
||
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1125 |
/** |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1126 |
* Returns true if the GraphicsDevice has been changed, false otherwise. |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1127 |
*/ |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1128 |
public boolean updateGraphicsDevice() { |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1129 |
GraphicsDevice newGraphicsDevice = platformWindow.getGraphicsDevice(); |
12047 | 1130 |
synchronized (getStateLock()) { |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1131 |
if (graphicsDevice == newGraphicsDevice) { |
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1132 |
return false; |
12047 | 1133 |
} |
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1134 |
graphicsDevice = newGraphicsDevice; |
12047 | 1135 |
} |
1136 |
||
12816
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1137 |
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration(); |
b4cabffcb0de
7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents:
12663
diff
changeset
|
1138 |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1139 |
if (!setGraphicsConfig(newGC)) return false; |
12047 | 1140 |
|
1141 |
SunToolkit.executeOnEventHandlerThread(getTarget(), new Runnable() { |
|
1142 |
public void run() { |
|
1143 |
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(getTarget(), newGC); |
|
1144 |
} |
|
1145 |
}); |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1146 |
return true; |
12047 | 1147 |
} |
1148 |
||
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1149 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1150 |
public final void displayChanged() { |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1151 |
if (updateGraphicsDevice()) { |
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1152 |
updateMinimumSize(); |
30944
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
1153 |
if (!isMaximizedBoundsSet()) { |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
1154 |
setPlatformMaximizedBounds(getDefaultMaximizedBounds()); |
b24bdcb53f5a
8065739: [macosx] Frame warps to lower left of screen when
alexsch
parents:
30924
diff
changeset
|
1155 |
} |
23325
4c3942938b0d
8027778: [macosx] Full screen not working properly on 7u45 and jdk8
serb
parents:
21783
diff
changeset
|
1156 |
} |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1157 |
// Replace surface unconditionally, because internal state of the |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1158 |
// GraphicsDevice could be changed. |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1159 |
replaceSurfaceData(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1160 |
repaintPeer(); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1161 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1162 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1163 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1164 |
public final void paletteChanged() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1165 |
// components do not need to react to this event. |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1166 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
17150
diff
changeset
|
1167 |
|
12047 | 1168 |
/* |
1169 |
* May be called by delegate to provide SD to Java2D code. |
|
1170 |
*/ |
|
1171 |
public SurfaceData getSurfaceData() { |
|
1172 |
synchronized (surfaceDataLock) { |
|
1173 |
return surfaceData; |
|
1174 |
} |
|
1175 |
} |
|
1176 |
||
1177 |
private void replaceSurfaceData() { |
|
13233 | 1178 |
replaceSurfaceData(true); |
1179 |
} |
|
1180 |
||
14647
bacc2d4f4b27
7124552: [macosx] NullPointerException in getBufferStrategy()
serb
parents:
14311
diff
changeset
|
1181 |
private void replaceSurfaceData(final boolean blit) { |
12047 | 1182 |
synchronized (surfaceDataLock) { |
1183 |
final SurfaceData oldData = getSurfaceData(); |
|
1184 |
surfaceData = platformWindow.replaceSurfaceData(); |
|
1185 |
final Rectangle size = getSize(); |
|
1186 |
if (getSurfaceData() != null && oldData != getSurfaceData()) { |
|
1187 |
clearBackground(size.width, size.height); |
|
1188 |
} |
|
13233 | 1189 |
|
1190 |
if (blit) { |
|
1191 |
blitSurfaceData(oldData, getSurfaceData()); |
|
1192 |
} |
|
12047 | 1193 |
|
1194 |
if (oldData != null && oldData != getSurfaceData()) { |
|
1195 |
// TODO: drop oldData for D3D/WGL pipelines |
|
1196 |
// This can only happen when this peer is being created |
|
1197 |
oldData.flush(); |
|
1198 |
} |
|
1199 |
} |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1200 |
flushOnscreenGraphics(); |
12047 | 1201 |
} |
1202 |
||
1203 |
private void blitSurfaceData(final SurfaceData src, final SurfaceData dst) { |
|
1204 |
//TODO blit. proof-of-concept |
|
1205 |
if (src != dst && src != null && dst != null |
|
1206 |
&& !(dst instanceof NullSurfaceData) |
|
1207 |
&& !(src instanceof NullSurfaceData) |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1208 |
&& src.getSurfaceType().equals(dst.getSurfaceType()) |
34394 | 1209 |
&& src.getDefaultScaleX() == dst.getDefaultScaleX() |
1210 |
&& src.getDefaultScaleY() == dst.getDefaultScaleY()) |
|
1211 |
{ |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1212 |
final Rectangle size = src.getBounds(); |
12047 | 1213 |
final Blit blit = Blit.locate(src.getSurfaceType(), |
1214 |
CompositeType.Src, |
|
1215 |
dst.getSurfaceType()); |
|
1216 |
if (blit != null) { |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1217 |
blit.Blit(src, dst, AlphaComposite.Src, null, 0, 0, 0, 0, |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
16839
diff
changeset
|
1218 |
size.width, size.height); |
12047 | 1219 |
} |
1220 |
} |
|
1221 |
} |
|
1222 |
||
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1223 |
/** |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1224 |
* Request the window insets from the delegate and compares it with the |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1225 |
* current one. This method is mostly called by the delegate, e.g. when the |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1226 |
* window state is changed and insets should be recalculated. |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1227 |
* <p/> |
12047 | 1228 |
* This method may be called on the toolkit thread. |
1229 |
*/ |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1230 |
public final boolean updateInsets(final Insets newInsets) { |
12047 | 1231 |
synchronized (getStateLock()) { |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1232 |
if (insets.equals(newInsets)) { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1233 |
return false; |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1234 |
} |
12047 | 1235 |
insets = newInsets; |
1236 |
} |
|
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
15323
diff
changeset
|
1237 |
return true; |
12047 | 1238 |
} |
1239 |
||
1240 |
public static LWWindowPeer getWindowUnderCursor() { |
|
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
1241 |
return lastCommonMouseEventPeer != null ? lastCommonMouseEventPeer.getWindowPeerOrSelf() : null; |
12047 | 1242 |
} |
1243 |
||
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1244 |
public static LWComponentPeer<?, ?> getPeerUnderCursor() { |
13647
de61414bbcf2
7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents:
13550
diff
changeset
|
1245 |
return lastCommonMouseEventPeer; |
12396
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1246 |
} |
79c64c6eb61e
7150105: [macosx] four scroll-buttons don't display. scroll-sliders cursors are TextCursor.
serb
parents:
12176
diff
changeset
|
1247 |
|
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1248 |
/* |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1249 |
* Requests platform to set native focus on a frame/dialog. |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1250 |
* In case of a simple window, triggers appropriate java focus change. |
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1251 |
*/ |
37694
c064aefc5a2f
8080395: consider making sun.awt.CausedFocusEvent functionality public
ssadetsky
parents:
34394
diff
changeset
|
1252 |
public boolean requestWindowFocus(FocusEvent.Cause cause) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1253 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1254 |
focusLog.fine("requesting native focus to " + this); |
1255 |
} |
|
1256 |
||
1257 |
if (!focusAllowedFor()) { |
|
1258 |
focusLog.fine("focus is not allowed"); |
|
1259 |
return false; |
|
1260 |
} |
|
1261 |
||
12176 | 1262 |
if (platformWindow.rejectFocusRequest(cause)) { |
12047 | 1263 |
return false; |
1264 |
} |
|
1265 |
||
20448
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1266 |
AppContext targetAppContext = AWTAccessor.getComponentAccessor().getAppContext(getTarget()); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1267 |
KeyboardFocusManager kfm = AWTAccessor.getKeyboardFocusManagerAccessor() |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1268 |
.getCurrentKeyboardFocusManager(targetAppContext); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1269 |
Window currentActive = kfm.getActiveWindow(); |
0eef03207781
8024158: [macosx] java/awt/EventDispatchThread/LoopRobustness/LoopRobustness still failed after fix JDK-8022247; since jdk8b96
pchelko
parents:
20445
diff
changeset
|
1270 |
|
12047 | 1271 |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1272 |
Window opposite = LWKeyboardFocusManagerPeer.getInstance(). |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1273 |
getCurrentFocusedWindow(); |
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1274 |
|
12047 | 1275 |
// Make the owner active window. |
1276 |
if (isSimpleWindow()) { |
|
1277 |
LWWindowPeer owner = getOwnerFrameDialog(this); |
|
1278 |
||
1279 |
// If owner is not natively active, request native |
|
1280 |
// activation on it w/o sending events up to java. |
|
1281 |
if (owner != null && !owner.platformWindow.isActive()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1282 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1283 |
focusLog.fine("requesting native focus to the owner " + owner); |
1284 |
} |
|
20153 | 1285 |
LWWindowPeer currentActivePeer = currentActive == null ? null : |
1286 |
(LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer( |
|
1287 |
currentActive); |
|
12047 | 1288 |
|
1289 |
// Ensure the opposite is natively active and suppress sending events. |
|
1290 |
if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1291 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1292 |
focusLog.fine("the opposite is " + currentActivePeer); |
1293 |
} |
|
1294 |
currentActivePeer.skipNextFocusChange = true; |
|
1295 |
} |
|
1296 |
owner.skipNextFocusChange = true; |
|
1297 |
||
1298 |
owner.platformWindow.requestWindowFocus(); |
|
1299 |
} |
|
1300 |
||
1301 |
// DKFM will synthesize all the focus/activation events correctly. |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1302 |
changeFocusedWindow(true, opposite); |
12047 | 1303 |
return true; |
1304 |
||
1305 |
// In case the toplevel is active but not focused, change focus directly, |
|
1306 |
// as requesting native focus on it will not have effect. |
|
1307 |
} else if (getTarget() == currentActive && !getTarget().hasFocus()) { |
|
1308 |
||
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1309 |
changeFocusedWindow(true, opposite); |
12047 | 1310 |
return true; |
1311 |
} |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1312 |
|
12047 | 1313 |
return platformWindow.requestWindowFocus(); |
1314 |
} |
|
1315 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1316 |
protected boolean focusAllowedFor() { |
12047 | 1317 |
Window window = getTarget(); |
1318 |
// TODO: check if modal blocked |
|
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1319 |
return window.isVisible() && window.isEnabled() && isFocusableWindow(); |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1320 |
} |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1321 |
|
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1322 |
private boolean isFocusableWindow() { |
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
1323 |
boolean focusable = targetFocusable; |
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1324 |
if (isSimpleWindow()) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1325 |
LWWindowPeer ownerPeer = getOwnerFrameDialog(this); |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1326 |
if (ownerPeer == null) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1327 |
return false; |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1328 |
} |
26008
ccab11700f07
8047288: Fixes endless loop on mac caused by invoking Windows.isFocusable() on Appkit thread.
mcherkas
parents:
25196
diff
changeset
|
1329 |
return focusable && ownerPeer.targetFocusable; |
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1330 |
} |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1331 |
return focusable; |
12047 | 1332 |
} |
1333 |
||
1334 |
public boolean isSimpleWindow() { |
|
1335 |
Window window = getTarget(); |
|
1336 |
return !(window instanceof Dialog || window instanceof Frame); |
|
1337 |
} |
|
1338 |
||
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1339 |
@Override |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1340 |
public void emulateActivation(boolean activate) { |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1341 |
changeFocusedWindow(activate, null); |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1342 |
} |
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1343 |
|
28235
0dfebfcb9f8a
8067086: Suppress mac-specific deprecation warnings in the java.desktop module
darcy
parents:
26037
diff
changeset
|
1344 |
@SuppressWarnings("deprecation") |
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1345 |
private boolean isOneOfOwnersOf(LWWindowPeer peer) { |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1346 |
Window owner = (peer != null ? peer.getTarget().getOwner() : null); |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1347 |
while (owner != null) { |
30469 | 1348 |
final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
1349 |
if (acc.getPeer(owner) == this) { |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1350 |
return true; |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1351 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1352 |
owner = owner.getOwner(); |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1353 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1354 |
return false; |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1355 |
} |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1356 |
|
12047 | 1357 |
/* |
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1358 |
* Changes focused window on java level. |
12047 | 1359 |
*/ |
15983
26a673dec5b2
8006406: lightweight embedding in other Java UI toolkits
ant
parents:
15331
diff
changeset
|
1360 |
protected void changeFocusedWindow(boolean becomesFocused, Window opposite) { |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1361 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
12047 | 1362 |
focusLog.fine((becomesFocused?"gaining":"loosing") + " focus window: " + this); |
1363 |
} |
|
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1364 |
if (skipNextFocusChange) { |
12047 | 1365 |
focusLog.fine("skipping focus change"); |
1366 |
skipNextFocusChange = false; |
|
1367 |
return; |
|
1368 |
} |
|
12663
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1369 |
if (!isFocusableWindow() && becomesFocused) { |
58d40d4a87b3
7145827: [macosx] JCK failure in b11: FocusableWindow3
ant
parents:
12662
diff
changeset
|
1370 |
focusLog.fine("the window is not focusable"); |
12047 | 1371 |
return; |
1372 |
} |
|
1373 |
if (becomesFocused) { |
|
1374 |
synchronized (getPeerTreeLock()) { |
|
1375 |
if (blocker != null) { |
|
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1376 |
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) { |
12047 | 1377 |
focusLog.finest("the window is blocked by " + blocker); |
1378 |
} |
|
1379 |
return; |
|
1380 |
} |
|
1381 |
} |
|
1382 |
} |
|
1383 |
||
1384 |
// Note, the method is not called: |
|
1385 |
// - when the opposite (gaining focus) window is an owned/owner window. |
|
1386 |
// - for a simple window in any case. |
|
1387 |
if (!becomesFocused && |
|
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1388 |
(isGrabbing() || this.isOneOfOwnersOf(grabbingWindow))) |
12047 | 1389 |
{ |
18178
ee71c923891d
8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents:
17151
diff
changeset
|
1390 |
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) { |
16839
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
15983
diff
changeset
|
1391 |
focusLog.fine("ungrabbing on " + grabbingWindow); |
d0f2e97b7359
8010297: Missing isLoggable() checks in logging code
anthony
parents:
15983
diff
changeset
|
1392 |
} |
12047 | 1393 |
// ungrab a simple window if its owner looses activation. |
1394 |
grabbingWindow.ungrab(); |
|
1395 |
} |
|
1396 |
||
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1397 |
KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); |
29884
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1398 |
|
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1399 |
if (!becomesFocused && kfmPeer.getCurrentFocusedWindow() != getTarget()) { |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1400 |
// late window focus lost event - ingoring |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1401 |
return; |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1402 |
} |
013dd351eb8a
8074481: [macosx] Menu items are appearing on top of other windows
anashaty
parents:
28235
diff
changeset
|
1403 |
|
13648
90effcfc064f
7124375: [macosx] Focus isn't transfered as expected between components
leonidr
parents:
13647
diff
changeset
|
1404 |
kfmPeer.setCurrentFocusedWindow(becomesFocused ? getTarget() : null); |
12047 | 1405 |
|
1406 |
int eventID = becomesFocused ? WindowEvent.WINDOW_GAINED_FOCUS : WindowEvent.WINDOW_LOST_FOCUS; |
|
14311
b2492ea8d08e
7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents:
14306
diff
changeset
|
1407 |
WindowEvent windowEvent = new TimedWindowEvent(getTarget(), eventID, opposite, System.currentTimeMillis()); |
12047 | 1408 |
|
1409 |
// TODO: wrap in SequencedEvent |
|
1410 |
postEvent(windowEvent); |
|
1411 |
} |
|
1412 |
||
23627
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1413 |
/* |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1414 |
* Retrieves the owner of the peer. |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1415 |
* Note: this method returns the owner which can be activated, (i.e. the instance |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1416 |
* of Frame or Dialog may be returned). |
f578c6ea3c8d
8032872: [macosx] Cannot select from JComboBox in a JWindow
dmarkov
parents:
23325
diff
changeset
|
1417 |
*/ |
12662
184d8d3b7fff
7145768: [macosx] Regression: failure in b11 of ModalDialogInFocusEventTest
ant
parents:
12640
diff
changeset
|
1418 |
static LWWindowPeer getOwnerFrameDialog(LWWindowPeer peer) { |
12047 | 1419 |
Window owner = (peer != null ? peer.getTarget().getOwner() : null); |
1420 |
while (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { |
|
1421 |
owner = owner.getOwner(); |
|
1422 |
} |
|
30469 | 1423 |
return owner == null ? null : AWTAccessor.getComponentAccessor() |
1424 |
.getPeer(owner); |
|
12047 | 1425 |
} |
1426 |
||
1427 |
/** |
|
1428 |
* Returns the foremost modal blocker of this window, or null. |
|
1429 |
*/ |
|
1430 |
public LWWindowPeer getBlocker() { |
|
1431 |
synchronized (getPeerTreeLock()) { |
|
1432 |
LWWindowPeer blocker = this.blocker; |
|
1433 |
if (blocker == null) { |
|
1434 |
return null; |
|
1435 |
} |
|
1436 |
while (blocker.blocker != null) { |
|
1437 |
blocker = blocker.blocker; |
|
1438 |
} |
|
1439 |
return blocker; |
|
1440 |
} |
|
1441 |
} |
|
1442 |
||
20153 | 1443 |
@Override |
12047 | 1444 |
public void enterFullScreenMode() { |
1445 |
platformWindow.enterFullScreenMode(); |
|
18241 | 1446 |
updateSecurityWarningVisibility(); |
12047 | 1447 |
} |
1448 |
||
20153 | 1449 |
@Override |
12047 | 1450 |
public void exitFullScreenMode() { |
1451 |
platformWindow.exitFullScreenMode(); |
|
18241 | 1452 |
updateSecurityWarningVisibility(); |
12047 | 1453 |
} |
1454 |
||
1455 |
public long getLayerPtr() { |
|
1456 |
return getPlatformWindow().getLayerPtr(); |
|
1457 |
} |
|
1458 |
||
1459 |
void grab() { |
|
1460 |
if (grabbingWindow != null && !isGrabbing()) { |
|
1461 |
grabbingWindow.ungrab(); |
|
1462 |
} |
|
1463 |
grabbingWindow = this; |
|
1464 |
} |
|
1465 |
||
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1466 |
final void ungrab(boolean doPost) { |
12047 | 1467 |
if (isGrabbing()) { |
1468 |
grabbingWindow = null; |
|
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1469 |
if (doPost) { |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1470 |
postEvent(new UngrabEvent(getTarget())); |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1471 |
} |
12047 | 1472 |
} |
1473 |
} |
|
1474 |
||
15323
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1475 |
void ungrab() { |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1476 |
ungrab(true); |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1477 |
} |
9087838098e6
8006417: JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X
alitvinov
parents:
14753
diff
changeset
|
1478 |
|
12047 | 1479 |
private boolean isGrabbing() { |
1480 |
return this == grabbingWindow; |
|
1481 |
} |
|
1482 |
||
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1483 |
public PeerType getPeerType() { |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1484 |
return peerType; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1485 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
14647
diff
changeset
|
1486 |
|
18241 | 1487 |
public void updateSecurityWarningVisibility() { |
1488 |
if (warningWindow == null) { |
|
1489 |
return; |
|
1490 |
} |
|
1491 |
||
1492 |
if (!isVisible()) { |
|
1493 |
return; // The warning window should already be hidden. |
|
1494 |
} |
|
1495 |
||
1496 |
boolean show = false; |
|
1497 |
||
1498 |
if (!platformWindow.isFullScreenMode()) { |
|
1499 |
if (isVisible()) { |
|
1500 |
if (LWKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() == |
|
1501 |
getTarget()) { |
|
1502 |
show = true; |
|
1503 |
} |
|
1504 |
||
1505 |
if (platformWindow.isUnderMouse() || warningWindow.isUnderMouse()) { |
|
1506 |
show = true; |
|
1507 |
} |
|
1508 |
} |
|
1509 |
} |
|
1510 |
||
1511 |
warningWindow.setVisible(show, true); |
|
1512 |
} |
|
1513 |
||
12047 | 1514 |
@Override |
1515 |
public String toString() { |
|
1516 |
return super.toString() + " [target is " + getTarget() + "]"; |
|
1517 |
} |
|
1518 |
} |