39 |
39 |
40 import sun.awt.*; |
40 import sun.awt.*; |
41 |
41 |
42 import sun.java2d.pipe.Region; |
42 import sun.java2d.pipe.Region; |
43 |
43 |
44 public class WWindowPeer extends WPanelPeer implements WindowPeer { |
44 public class WWindowPeer extends WPanelPeer implements WindowPeer, |
|
45 DisplayChangedListener |
|
46 { |
45 |
47 |
46 private static final Logger log = Logger.getLogger("sun.awt.windows.WWindowPeer"); |
48 private static final Logger log = Logger.getLogger("sun.awt.windows.WWindowPeer"); |
47 private static final Logger screenLog = Logger.getLogger("sun.awt.windows.screen.WWindowPeer"); |
49 private static final Logger screenLog = Logger.getLogger("sun.awt.windows.screen.WWindowPeer"); |
48 |
50 |
49 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that |
51 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that |
196 // then calling Window.getGraphicsConfig() returns wrong config. That may lead |
198 // then calling Window.getGraphicsConfig() returns wrong config. That may lead |
197 // to some problems like wrong-placed tooltips. It is caused by calling |
199 // to some problems like wrong-placed tooltips. It is caused by calling |
198 // super.displayChanged() in WWindowPeer.displayChanged() regardless of whether |
200 // super.displayChanged() in WWindowPeer.displayChanged() regardless of whether |
199 // GraphicsDevice was really changed, or not. So we need to track it here. |
201 // GraphicsDevice was really changed, or not. So we need to track it here. |
200 updateGC(); |
202 updateGC(); |
201 resetTargetGC(); |
|
202 |
203 |
203 realShow(); |
204 realShow(); |
204 updateMinimumSize(); |
205 updateMinimumSize(); |
205 |
206 |
206 if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) { |
207 if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) { |
398 displayChanged(); |
399 displayChanged(); |
399 } |
400 } |
400 }); |
401 }); |
401 } |
402 } |
402 |
403 |
403 |
|
404 /* |
|
405 * Called from WCanvasPeer.displayChanged(). |
|
406 * Override to do nothing - Window and WWindowPeer GC must never be set to |
|
407 * null! |
|
408 */ |
|
409 void clearLocalGC() {} |
|
410 |
|
411 public void updateGC() { |
404 public void updateGC() { |
412 int scrn = getScreenImOn(); |
405 int scrn = getScreenImOn(); |
413 if (screenLog.isLoggable(Level.FINER)) { |
406 if (screenLog.isLoggable(Level.FINER)) { |
414 log.log(Level.FINER, "Screen number: " + scrn); |
407 log.log(Level.FINER, "Screen number: " + scrn); |
415 } |
408 } |
444 // if on a different display, take off old GD and put on new GD |
437 // if on a different display, take off old GD and put on new GD |
445 if (oldDev != newDev) { |
438 if (oldDev != newDev) { |
446 oldDev.removeDisplayChangedListener(this); |
439 oldDev.removeDisplayChangedListener(this); |
447 newDev.addDisplayChangedListener(this); |
440 newDev.addDisplayChangedListener(this); |
448 } |
441 } |
449 } |
442 |
450 |
443 SunToolkit.executeOnEventHandlerThread((Component)target, |
451 /* |
444 new Runnable() { |
452 * From the DisplayChangedListener interface |
445 public void run() { |
|
446 AWTAccessor.getComponentAccessor(). |
|
447 setGraphicsConfiguration((Component)target, winGraphicsConfig); |
|
448 } |
|
449 }); |
|
450 } |
|
451 |
|
452 /** |
|
453 * From the DisplayChangedListener interface. |
453 * |
454 * |
454 * This method handles a display change - either when the display settings |
455 * This method handles a display change - either when the display settings |
455 * are changed, or when the window has been dragged onto a different |
456 * are changed, or when the window has been dragged onto a different |
456 * display. |
457 * display. |
|
458 * Called after a change in the display mode. This event |
|
459 * triggers replacing the surfaceData object (since that object |
|
460 * reflects the current display depth information, which has |
|
461 * just changed). |
457 */ |
462 */ |
458 public void displayChanged() { |
463 public void displayChanged() { |
459 updateGC(); |
464 updateGC(); |
460 super.displayChanged(); |
465 } |
|
466 |
|
467 /** |
|
468 * Part of the DisplayChangedListener interface: components |
|
469 * do not need to react to this event |
|
470 */ |
|
471 public void paletteChanged() { |
461 } |
472 } |
462 |
473 |
463 private native int getScreenImOn(); |
474 private native int getScreenImOn(); |
464 |
475 |
465 /* |
476 /* |