150 } else {
151 // first we check if user provided alpha for background. This is
152 // similar to what Apple's Java do.
153 // Since JDK7 we should rely on setOpacity() only.
154 // this.opacity = c.getAlpha();
155 // System.out.println("Delegate assigns alpha (we ignore setOpacity()):"
156 // +this.opacity);
157 }
158
159 if (!target.isForegroundSet()) {
160 target.setForeground(SystemColor.windowText);
161 // we should not call setForeground because it will call a repaint
162 // which the peer may not be ready to do yet.
163 }
164
165 platformWindow.initialize(target, this, ownerDelegate);
166 }
167
168 @Override
169 public void initialize() {
170 super.initialize();
171
172 updateInsets(platformWindow.getInsets());
173
174 if (getTarget() instanceof Frame) {
175 setTitle(((Frame)getTarget()).getTitle());
176 setState(((Frame)getTarget()).getExtendedState());
177 } else if (getTarget() instanceof Dialog) {
178 setTitle(((Dialog)getTarget()).getTitle());
179 }
180
181 setAlwaysOnTop(getTarget().isAlwaysOnTop());
182 updateMinimumSize();
183
184 cachedFocusableWindow = getTarget().isFocusableWindow();
185
186 setOpacity(getTarget().getOpacity());
187 setOpaque(getTarget().isOpaque());
188
189 // Create surface data and back buffer
190 replaceSurfaceData(1, null);
191 }
192
193 // Just a helper method
194 public PlatformWindow getPlatformWindow() {
195 return platformWindow;
196 }
197
198 @Override
199 protected LWWindowPeer getWindowPeerOrSelf() {
200 return this;
201 }
202
203 @Override
204 protected void initializeContainerPeer() {
205 // No-op as LWWindowPeer doesn't have any containerPeer
206 }
207
208 // ---- PEER METHODS ---- //
209
210 @Override
422 @Override
423 public void updateMinimumSize() {
424 Dimension d = null;
425 if (getTarget().isMinimumSizeSet()) {
426 d = getTarget().getMinimumSize();
427 }
428 if (d == null) {
429 d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
430 }
431 platformWindow.setMinimumSize(d.width, d.height);
432 }
433
434 @Override
435 public void updateIconImages() {
436 getPlatformWindow().updateIconImages();
437 }
438
439 @Override
440 public void setOpacity(float opacity) {
441 getPlatformWindow().setOpacity(opacity);
442 }
443
444 @Override
445 public void setOpaque(boolean isOpaque) {
446 if (this.isOpaque != isOpaque) {
447 this.isOpaque = isOpaque;
448 getPlatformWindow().setOpaque(isOpaque);
449 replaceSurfaceData();
450 }
451 }
452
453 public boolean isOpaque() {
454 return isOpaque;
455 }
456
457 @Override
458 public void updateWindow() {
459 flushOffscreenGraphics();
460 }
461
462 @Override
463 public void repositionSecurityWarning() {
464 throw new RuntimeException("not implemented");
465 }
466
467 // ---- FRAME PEER METHODS ---- //
468
469 @Override // FramePeer and DialogPeer
470 public void setTitle(String title) {
471 platformWindow.setTitle(title == null ? "" : title);
472 }
473
1037 return backBufferCaps;
1038 }
1039
1040 /*
1041 * Request the window insets from the delegate and compares it
1042 * with the current one. This method is mostly called by the
1043 * delegate, e.g. when the window state is changed and insets
1044 * should be recalculated.
1045 *
1046 * This method may be called on the toolkit thread.
1047 */
1048 public boolean updateInsets(Insets newInsets) {
1049 boolean changed = false;
1050 synchronized (getStateLock()) {
1051 changed = (insets.equals(newInsets));
1052 insets = newInsets;
1053 }
1054
1055 if (changed) {
1056 replaceSurfaceData();
1057 }
1058
1059 return changed;
1060 }
1061
1062 public static LWWindowPeer getWindowUnderCursor() {
1063 return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
1064 }
1065
1066 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
1067 if (focusLog.isLoggable(PlatformLogger.FINE)) {
1068 focusLog.fine("requesting native focus to " + this);
1069 }
1070
1071 if (!focusAllowedFor()) {
1072 focusLog.fine("focus is not allowed");
1073 return false;
1074 }
1075
1076 // Cross-app activation requests are not allowed.
|
150 } else {
151 // first we check if user provided alpha for background. This is
152 // similar to what Apple's Java do.
153 // Since JDK7 we should rely on setOpacity() only.
154 // this.opacity = c.getAlpha();
155 // System.out.println("Delegate assigns alpha (we ignore setOpacity()):"
156 // +this.opacity);
157 }
158
159 if (!target.isForegroundSet()) {
160 target.setForeground(SystemColor.windowText);
161 // we should not call setForeground because it will call a repaint
162 // which the peer may not be ready to do yet.
163 }
164
165 platformWindow.initialize(target, this, ownerDelegate);
166 }
167
168 @Override
169 public void initialize() {
170 if (getTarget() instanceof Frame) {
171 setTitle(((Frame)getTarget()).getTitle());
172 setState(((Frame)getTarget()).getExtendedState());
173 } else if (getTarget() instanceof Dialog) {
174 setTitle(((Dialog)getTarget()).getTitle());
175 }
176
177 setAlwaysOnTop(getTarget().isAlwaysOnTop());
178 updateMinimumSize();
179
180 cachedFocusableWindow = getTarget().isFocusableWindow();
181
182 setOpacity(getTarget().getOpacity());
183 setOpaque(getTarget().isOpaque());
184
185 super.initialize();
186
187 updateInsets(platformWindow.getInsets());
188 }
189
190 // Just a helper method
191 public PlatformWindow getPlatformWindow() {
192 return platformWindow;
193 }
194
195 @Override
196 protected LWWindowPeer getWindowPeerOrSelf() {
197 return this;
198 }
199
200 @Override
201 protected void initializeContainerPeer() {
202 // No-op as LWWindowPeer doesn't have any containerPeer
203 }
204
205 // ---- PEER METHODS ---- //
206
207 @Override
419 @Override
420 public void updateMinimumSize() {
421 Dimension d = null;
422 if (getTarget().isMinimumSizeSet()) {
423 d = getTarget().getMinimumSize();
424 }
425 if (d == null) {
426 d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
427 }
428 platformWindow.setMinimumSize(d.width, d.height);
429 }
430
431 @Override
432 public void updateIconImages() {
433 getPlatformWindow().updateIconImages();
434 }
435
436 @Override
437 public void setOpacity(float opacity) {
438 getPlatformWindow().setOpacity(opacity);
439 repaintPeer();
440 }
441
442 @Override
443 public final void setOpaque(final boolean isOpaque) {
444 if (this.isOpaque != isOpaque) {
445 this.isOpaque = isOpaque;
446 getPlatformWindow().setOpaque(isOpaque);
447 replaceSurfaceData();
448 repaintPeer();
449 }
450 }
451
452 public final boolean isOpaque() {
453 return isOpaque;
454 }
455
456 @Override
457 public void updateWindow() {
458 flushOffscreenGraphics();
459 }
460
461 @Override
462 public void repositionSecurityWarning() {
463 throw new RuntimeException("not implemented");
464 }
465
466 // ---- FRAME PEER METHODS ---- //
467
468 @Override // FramePeer and DialogPeer
469 public void setTitle(String title) {
470 platformWindow.setTitle(title == null ? "" : title);
471 }
472
1036 return backBufferCaps;
1037 }
1038
1039 /*
1040 * Request the window insets from the delegate and compares it
1041 * with the current one. This method is mostly called by the
1042 * delegate, e.g. when the window state is changed and insets
1043 * should be recalculated.
1044 *
1045 * This method may be called on the toolkit thread.
1046 */
1047 public boolean updateInsets(Insets newInsets) {
1048 boolean changed = false;
1049 synchronized (getStateLock()) {
1050 changed = (insets.equals(newInsets));
1051 insets = newInsets;
1052 }
1053
1054 if (changed) {
1055 replaceSurfaceData();
1056 repaintPeer();
1057 }
1058
1059 return changed;
1060 }
1061
1062 public static LWWindowPeer getWindowUnderCursor() {
1063 return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
1064 }
1065
1066 public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
1067 if (focusLog.isLoggable(PlatformLogger.FINE)) {
1068 focusLog.fine("requesting native focus to " + this);
1069 }
1070
1071 if (!focusAllowedFor()) {
1072 focusLog.fine("focus is not allowed");
1073 return false;
1074 }
1075
1076 // Cross-app activation requests are not allowed.
|