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