64
65 /*
66 * Listener for 'activeWindow' KFM property changes. It is added to each
67 * AppContext KFM. See ActiveWindowListener inner class below.
68 */
69 private static PropertyChangeListener activeWindowListener =
70 new ActiveWindowListener();
71
72 /*
73 * The object is a listener for the AppContext.GUI_DISPOSED property.
74 */
75 private static final PropertyChangeListener guiDisposedListener =
76 new GuiDisposedListener();
77
78 /*
79 * Called (on the Toolkit thread) before the appropriate
80 * WindowStateEvent is posted to the EventQueue.
81 */
82 private WindowListener windowListener;
83
84 /**
85 * Initialize JNI field IDs
86 */
87 private static native void initIDs();
88 static {
89 initIDs();
90 }
91
92 // WComponentPeer overrides
93 @Override
94 @SuppressWarnings("unchecked")
95 protected void disposeImpl() {
96 AppContext appContext = SunToolkit.targetToAppContext(target);
97 synchronized (appContext) {
98 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
99 if (l != null) {
100 l.remove(this);
101 }
102 }
103
168 // Toolkit & peer internals
169
170 WWindowPeer(Window target) {
171 super(target);
172 }
173
174 @Override
175 void initialize() {
176 super.initialize();
177
178 updateInsets(insets_);
179
180 Font f = ((Window)target).getFont();
181 if (f == null) {
182 f = defaultFont;
183 ((Window)target).setFont(f);
184 setFont(f);
185 }
186 // Express our interest in display changes
187 GraphicsConfiguration gc = getGraphicsConfiguration();
188 ((Win32GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this);
189
190 initActiveWindowsTracking((Window)target);
191
192 updateIconImages();
193
194 Shape shape = ((Window)target).getShape();
195 if (shape != null) {
196 applyShape(Region.getInstance(shape, null));
197 }
198
199 float opacity = ((Window)target).getOpacity();
200 if (opacity < 1.0f) {
201 setOpacity(opacity);
202 }
203
204 synchronized (getStateLock()) {
205 // default value of a boolean field is 'false', so set isOpaque to
206 // true here explicitly
207 this.isOpaque = true;
208 setOpaque(((Window)target).isOpaque());
512 }
513
514 // Set winGraphicsConfig to the default GC for the monitor this Window
515 // is now mostly on.
516 winGraphicsConfig = (Win32GraphicsConfig)newDev
517 .getDefaultConfiguration();
518 if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
519 if (winGraphicsConfig == null) {
520 screenLog.fine("Assertion (winGraphicsConfig != null) failed");
521 }
522 }
523
524 // if on a different display, take off old GD and put on new GD
525 if (oldDev != newDev) {
526 oldDev.removeDisplayChangedListener(this);
527 newDev.addDisplayChangedListener(this);
528 }
529
530 AWTAccessor.getComponentAccessor().
531 setGraphicsConfiguration((Component)target, winGraphicsConfig);
532 }
533
534 /**
535 * From the DisplayChangedListener interface.
536 *
537 * This method handles a display change - either when the display settings
538 * are changed, or when the window has been dragged onto a different
539 * display.
540 * Called after a change in the display mode. This event
541 * triggers replacing the surfaceData object (since that object
542 * reflects the current display depth information, which has
543 * just changed).
544 */
545 @Override
546 public void displayChanged() {
547 updateGC();
548 }
549
550 /**
551 * Part of the DisplayChangedListener interface: components
552 * do not need to react to this event
553 */
|
64
65 /*
66 * Listener for 'activeWindow' KFM property changes. It is added to each
67 * AppContext KFM. See ActiveWindowListener inner class below.
68 */
69 private static PropertyChangeListener activeWindowListener =
70 new ActiveWindowListener();
71
72 /*
73 * The object is a listener for the AppContext.GUI_DISPOSED property.
74 */
75 private static final PropertyChangeListener guiDisposedListener =
76 new GuiDisposedListener();
77
78 /*
79 * Called (on the Toolkit thread) before the appropriate
80 * WindowStateEvent is posted to the EventQueue.
81 */
82 private WindowListener windowListener;
83
84 private float scaleX;
85 private float scaleY;
86
87 /**
88 * Initialize JNI field IDs
89 */
90 private static native void initIDs();
91 static {
92 initIDs();
93 }
94
95 // WComponentPeer overrides
96 @Override
97 @SuppressWarnings("unchecked")
98 protected void disposeImpl() {
99 AppContext appContext = SunToolkit.targetToAppContext(target);
100 synchronized (appContext) {
101 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
102 if (l != null) {
103 l.remove(this);
104 }
105 }
106
171 // Toolkit & peer internals
172
173 WWindowPeer(Window target) {
174 super(target);
175 }
176
177 @Override
178 void initialize() {
179 super.initialize();
180
181 updateInsets(insets_);
182
183 Font f = ((Window)target).getFont();
184 if (f == null) {
185 f = defaultFont;
186 ((Window)target).setFont(f);
187 setFont(f);
188 }
189 // Express our interest in display changes
190 GraphicsConfiguration gc = getGraphicsConfiguration();
191 Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
192 (gd).addDisplayChangedListener(this);
193 scaleX = gd.getDefaultScaleX();
194 scaleY = gd.getDefaultScaleY();
195
196 initActiveWindowsTracking((Window)target);
197
198 updateIconImages();
199
200 Shape shape = ((Window)target).getShape();
201 if (shape != null) {
202 applyShape(Region.getInstance(shape, null));
203 }
204
205 float opacity = ((Window)target).getOpacity();
206 if (opacity < 1.0f) {
207 setOpacity(opacity);
208 }
209
210 synchronized (getStateLock()) {
211 // default value of a boolean field is 'false', so set isOpaque to
212 // true here explicitly
213 this.isOpaque = true;
214 setOpaque(((Window)target).isOpaque());
518 }
519
520 // Set winGraphicsConfig to the default GC for the monitor this Window
521 // is now mostly on.
522 winGraphicsConfig = (Win32GraphicsConfig)newDev
523 .getDefaultConfiguration();
524 if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
525 if (winGraphicsConfig == null) {
526 screenLog.fine("Assertion (winGraphicsConfig != null) failed");
527 }
528 }
529
530 // if on a different display, take off old GD and put on new GD
531 if (oldDev != newDev) {
532 oldDev.removeDisplayChangedListener(this);
533 newDev.addDisplayChangedListener(this);
534 }
535
536 AWTAccessor.getComponentAccessor().
537 setGraphicsConfiguration((Component)target, winGraphicsConfig);
538
539 float newScaleX = newDev.getDefaultScaleX();
540 float newScaleY = newDev.getDefaultScaleY();
541
542 if (scaleX != newScaleX || scaleY != newScaleY) {
543 setBounds(rescale(sysX, scaleX, newScaleX),
544 rescale(sysY, scaleY, newScaleY),
545 sysW, sysH, SET_BOUNDS);
546 scaleX = newScaleX;
547 scaleY = newScaleY;
548 }
549 }
550
551 private static int rescale(int position, float oldScale, float newScale) {
552 return Math.round(position * oldScale / newScale);
553 }
554 /**
555 * From the DisplayChangedListener interface.
556 *
557 * This method handles a display change - either when the display settings
558 * are changed, or when the window has been dragged onto a different
559 * display.
560 * Called after a change in the display mode. This event
561 * triggers replacing the surfaceData object (since that object
562 * reflects the current display depth information, which has
563 * just changed).
564 */
565 @Override
566 public void displayChanged() {
567 updateGC();
568 }
569
570 /**
571 * Part of the DisplayChangedListener interface: components
572 * do not need to react to this event
573 */
|