44 import java.awt.SystemColor;
45 import java.awt.Window;
46 import java.awt.event.FocusEvent;
47 import java.awt.event.WindowEvent;
48 import java.awt.event.WindowListener;
49 import java.awt.geom.AffineTransform;
50 import java.awt.image.DataBufferInt;
51 import java.awt.peer.WindowPeer;
52 import java.beans.PropertyChangeEvent;
53 import java.beans.PropertyChangeListener;
54 import java.util.LinkedList;
55 import java.util.List;
56
57 import sun.awt.AWTAccessor;
58 import sun.awt.AppContext;
59 import sun.awt.DisplayChangedListener;
60 import sun.awt.SunToolkit;
61 import sun.awt.Win32GraphicsConfig;
62 import sun.awt.Win32GraphicsDevice;
63 import sun.awt.Win32GraphicsEnvironment;
64 import sun.java2d.SunGraphicsEnvironment;
65 import sun.java2d.pipe.Region;
66 import sun.util.logging.PlatformLogger;
67
68 public class WWindowPeer extends WPanelPeer implements WindowPeer,
69 DisplayChangedListener
70 {
71
72 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
73 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
74
75 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
76 // extends WWindowPeer, not WDialogPeer
77 private WWindowPeer modalBlocker = null;
78
79 private boolean isOpaque;
80
81 private TranslucentWindowPainter painter;
82
83 /*
84 * A key used for storing a list of active windows in AppContext. The value
85 * is a list of windows, sorted by the time of activation: later a window is
86 * activated, greater its index is in the list.
87 */
89 new StringBuffer("active_windows_list");
90
91 /*
92 * Listener for 'activeWindow' KFM property changes. It is added to each
93 * AppContext KFM. See ActiveWindowListener inner class below.
94 */
95 private static PropertyChangeListener activeWindowListener =
96 new ActiveWindowListener();
97
98 /*
99 * The object is a listener for the AppContext.GUI_DISPOSED property.
100 */
101 private static final PropertyChangeListener guiDisposedListener =
102 new GuiDisposedListener();
103
104 /*
105 * Called (on the Toolkit thread) before the appropriate
106 * WindowStateEvent is posted to the EventQueue.
107 */
108 private WindowListener windowListener;
109 private float scaleX;
110 private float scaleY;
111
112 /**
113 * Initialize JNI field IDs
114 */
115 private static native void initIDs();
116 static {
117 initIDs();
118 }
119
120 // WComponentPeer overrides
121 @Override
122 @SuppressWarnings("unchecked")
123 protected void disposeImpl() {
124 AppContext appContext = SunToolkit.targetToAppContext(target);
125 synchronized (appContext) {
126 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
127 if (l != null) {
128 l.remove(this);
129 }
130 }
203 void initialize() {
204 super.initialize();
205
206 updateInsets(insets_);
207
208 if (!((Window) target).isFontSet()) {
209 ((Window) target).setFont(defaultFont);
210 setFont(defaultFont);
211 }
212 if (!((Window) target).isForegroundSet()) {
213 ((Window) target).setForeground(SystemColor.windowText);
214 }
215 if (!((Window) target).isBackgroundSet()) {
216 ((Window) target).setBackground(SystemColor.window);
217 }
218
219 // Express our interest in display changes
220 GraphicsConfiguration gc = getGraphicsConfiguration();
221 Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
222 gd.addDisplayChangedListener(this);
223 scaleX = gd.getDefaultScaleX();
224 scaleY = gd.getDefaultScaleY();
225
226 initActiveWindowsTracking((Window)target);
227
228 updateIconImages();
229
230 Shape shape = ((Window)target).getShape();
231 if (shape != null) {
232 applyShape(Region.getInstance(shape, null));
233 }
234
235 float opacity = ((Window)target).getOpacity();
236 if (opacity < 1.0f) {
237 setOpacity(opacity);
238 }
239
240 synchronized (getStateLock()) {
241 // default value of a boolean field is 'false', so set isOpaque to
242 // true here explicitly
243 this.isOpaque = true;
244 setOpaque(((Window)target).isOpaque());
291 updateMinimumSize();
292
293 if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) {
294 setAlwaysOnTop(alwaysOnTop);
295 }
296
297 synchronized (getStateLock()) {
298 if (!isOpaque) {
299 updateWindow(true);
300 }
301 }
302
303 // See https://javafx-jira.kenai.com/browse/RT-32570
304 WComponentPeer owner = getNativeParent();
305 if (owner != null && owner.isLightweightFramePeer()) {
306 Rectangle b = getBounds();
307 handleExpose(0, 0, b.width, b.height);
308 }
309 }
310
311 // Synchronize the insets members (here & in helper) with actual window
312 // state.
313 native void updateInsets(Insets i);
314
315 static native int getSysMinWidth();
316 static native int getSysMinHeight();
317 static native int getSysIconWidth();
318 static native int getSysIconHeight();
319 static native int getSysSmIconWidth();
320 static native int getSysSmIconHeight();
321 /**windows/classes/sun/awt/windows/
322 * Creates native icon from specified raster data and updates
323 * icon for window and all descendant windows that inherit icon.
324 * Raster data should be passed in the ARGB form.
325 * Note that raster data format was changed to provide support
326 * for XP icons with alpha-channel
327 */
328 native void setIconImagesData(int[] iconRaster, int w, int h,
329 int[] smallIconRaster, int smw, int smh);
330
385 }
386 }
387 }
388 }
389
390 synchronized void addWindowListener(WindowListener l) {
391 windowListener = AWTEventMulticaster.add(windowListener, l);
392 }
393
394 synchronized void removeWindowListener(WindowListener l) {
395 windowListener = AWTEventMulticaster.remove(windowListener, l);
396 }
397
398 @Override
399 public void updateMinimumSize() {
400 Dimension minimumSize = null;
401 if (((Component)target).isMinimumSizeSet()) {
402 minimumSize = ((Component)target).getMinimumSize();
403 }
404 if (minimumSize != null) {
405 int w = Math.max(minimumSize.width, scaleDownX(getSysMinWidth()));
406 int h = Math.max(minimumSize.height, scaleDownY(getSysMinHeight()));
407 setMinSize(w, h);
408 } else {
409 setMinSize(0, 0);
410 }
411 }
412
413 @Override
414 public void updateIconImages() {
415 java.util.List<Image> imageList = ((Window)target).getIconImages();
416 if (imageList == null || imageList.size() == 0) {
417 setIconImagesData(null, 0, 0, null, 0, 0);
418 } else {
419 int w = getSysIconWidth();
420 int h = getSysIconHeight();
421 int smw = getSysSmIconWidth();
422 int smh = getSysSmIconHeight();
423 AffineTransform tx = getGraphicsConfiguration().getDefaultTransform();
424 w = Region.clipScale(w, tx.getScaleX());
425 h = Region.clipScale(h, tx.getScaleY());
426 smw = Region.clipScale(smw, tx.getScaleX());
427 smh = Region.clipScale(smh, tx.getScaleY());
545 }
546
547 // Set winGraphicsConfig to the default GC for the monitor this Window
548 // is now mostly on.
549 winGraphicsConfig = (Win32GraphicsConfig)newDev
550 .getDefaultConfiguration();
551 if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
552 if (winGraphicsConfig == null) {
553 screenLog.fine("Assertion (winGraphicsConfig != null) failed");
554 }
555 }
556
557 // if on a different display, take off old GD and put on new GD
558 if (oldDev != newDev) {
559 oldDev.removeDisplayChangedListener(this);
560 newDev.addDisplayChangedListener(this);
561 }
562
563 AWTAccessor.getComponentAccessor().
564 setGraphicsConfiguration((Component)target, winGraphicsConfig);
565
566 checkDPIChange(oldDev, newDev);
567 }
568
569 private void checkDPIChange(Win32GraphicsDevice oldDev,
570 Win32GraphicsDevice newDev) {
571 float newScaleX = newDev.getDefaultScaleX();
572 float newScaleY = newDev.getDefaultScaleY();
573
574 if (scaleX != newScaleX || scaleY != newScaleY) {
575 windowDPIChange(oldDev.getScreen(), scaleX, scaleY,
576 newDev.getScreen(), newScaleX, newScaleY);
577 scaleX = newScaleX;
578 scaleY = newScaleY;
579 }
580 }
581
582 /**
583 * From the DisplayChangedListener interface.
584 *
585 * This method handles a display change - either when the display settings
586 * are changed, or when the window has been dragged onto a different
587 * display.
588 * Called after a change in the display mode. This event
589 * triggers replacing the surfaceData object (since that object
590 * reflects the current display depth information, which has
591 * just changed).
592 */
593 @Override
594 public void displayChanged() {
595 SunToolkit.executeOnEventHandlerThread(target, this::updateGC);
596 }
597
598 /**
599 * Part of the DisplayChangedListener interface: components
613 */
614
615 public void grab() {
616 nativeGrab();
617 }
618
619 public void ungrab() {
620 nativeUngrab();
621 }
622 private native void nativeGrab();
623 private native void nativeUngrab();
624
625 private boolean hasWarningWindow() {
626 return ((Window)target).getWarningString() != null;
627 }
628
629 boolean isTargetUndecorated() {
630 return true;
631 }
632
633 // These are the peer bounds. They get updated at:
634 // 1. the WWindowPeer.setBounds() method.
635 // 2. the native code (on WM_SIZE/WM_MOVE)
636 private volatile int sysX = 0;
637 private volatile int sysY = 0;
638 private volatile int sysW = 0;
639 private volatile int sysH = 0;
640
641 @Override
642 public native void repositionSecurityWarning();
643
644 @Override
645 public void setBounds(int x, int y, int width, int height, int op) {
646 sysX = x;
647 sysY = y;
648 sysW = width;
649 sysH = height;
650
651 int cx = x + width / 2;
652 int cy = y + height / 2;
653 GraphicsConfiguration current = getGraphicsConfiguration();
654 GraphicsConfiguration other = SunGraphicsEnvironment
655 .getGraphicsConfigurationAtPoint(current, cx, cy);
656 if (!current.equals(other)) {
657 AffineTransform tx = other.getDefaultTransform();
658 double otherScaleX = tx.getScaleX();
659 double otherScaleY = tx.getScaleY();
660 initScales();
661 if (scaleX != otherScaleX || scaleY != otherScaleY) {
662 x = (int) Math.floor(x * otherScaleX / scaleX);
663 y = (int) Math.floor(y * otherScaleY / scaleY);
664 }
665 }
666
667 super.setBounds(x, y, width, height, op);
668 }
669
670 private void initScales() {
671
672 if (scaleX >= 1 && scaleY >= 1) {
673 return;
674 }
675
676 GraphicsConfiguration gc = getGraphicsConfiguration();
677 if (gc instanceof Win32GraphicsConfig) {
678 Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice();
679 scaleX = gd.getDefaultScaleX();
680 scaleY = gd.getDefaultScaleY();
681 } else {
682 AffineTransform tx = gc.getDefaultTransform();
683 scaleX = (float) tx.getScaleX();
684 scaleY = (float) tx.getScaleY();
685 }
686 }
687
688 final int scaleUpX(int x) {
689 return Region.clipRound(x * scaleX);
690 }
691
692 final int scaleUpY(int y) {
693 return Region.clipRound(y * scaleY);
694 }
695
696 final int scaleDownX(int x) {
697 return Region.clipRound(x / scaleX);
698 }
699
700 final int scaleDownY(int y) {
701 return Region.clipRound(y / scaleY);
702 }
703
704 @Override
705 public void print(Graphics g) {
706 // We assume we print the whole frame,
707 // so we expect no clip was set previously
708 Shape shape = ((Window)target).getShape();
709 if (shape != null) {
710 g.setClip(shape);
711 }
712 super.print(g);
713 }
714
715 private void replaceSurfaceDataRecursively(Component c) {
716 if (c instanceof Container) {
717 for (Component child : ((Container)c).getComponents()) {
718 replaceSurfaceDataRecursively(child);
719 }
720 }
721 final Object cp = AWTAccessor.getComponentAccessor().getPeer(c);
722 if (cp instanceof WComponentPeer) {
723 ((WComponentPeer)cp).replaceSurfaceDataLater();
724 }
851 public void updateWindow() {
852 updateWindow(false);
853 }
854
855 private void updateWindow(boolean repaint) {
856 Window w = (Window)target;
857 synchronized (getStateLock()) {
858 if (isOpaque || !w.isVisible() ||
859 (w.getWidth() <= 0) || (w.getHeight() <= 0))
860 {
861 return;
862 }
863 TranslucentWindowPainter currentPainter = painter;
864 if (currentPainter != null) {
865 currentPainter.updateWindow(repaint);
866 } else if (log.isLoggable(PlatformLogger.Level.FINER)) {
867 log.finer("Translucent window painter is null in updateWindow");
868 }
869 }
870 }
871
872 native void windowDPIChange(int prevScreen, float prevScaleX, float prevScaleY,
873 int newScreen, float newScaleX, float newScaleY);
874
875 /*
876 * The method maps the list of the active windows to the window's AppContext,
877 * then the method registers ActiveWindowListener, GuiDisposedListener listeners;
878 * it executes the initilialization only once per AppContext.
879 */
880 @SuppressWarnings("unchecked")
881 private static void initActiveWindowsTracking(Window w) {
882 AppContext appContext = AppContext.getAppContext();
883 synchronized (appContext) {
884 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
885 if (l == null) {
886 l = new LinkedList<WWindowPeer>();
887 appContext.put(ACTIVE_WINDOWS_KEY, l);
888 appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener);
889
890 KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
891 kfm.addPropertyChangeListener("activeWindow", activeWindowListener);
892 }
893 }
|
44 import java.awt.SystemColor;
45 import java.awt.Window;
46 import java.awt.event.FocusEvent;
47 import java.awt.event.WindowEvent;
48 import java.awt.event.WindowListener;
49 import java.awt.geom.AffineTransform;
50 import java.awt.image.DataBufferInt;
51 import java.awt.peer.WindowPeer;
52 import java.beans.PropertyChangeEvent;
53 import java.beans.PropertyChangeListener;
54 import java.util.LinkedList;
55 import java.util.List;
56
57 import sun.awt.AWTAccessor;
58 import sun.awt.AppContext;
59 import sun.awt.DisplayChangedListener;
60 import sun.awt.SunToolkit;
61 import sun.awt.Win32GraphicsConfig;
62 import sun.awt.Win32GraphicsDevice;
63 import sun.awt.Win32GraphicsEnvironment;
64 import sun.java2d.pipe.Region;
65 import sun.util.logging.PlatformLogger;
66
67 import static sun.java2d.SunGraphicsEnvironment.toUserSpace;
68
69 public class WWindowPeer extends WPanelPeer implements WindowPeer,
70 DisplayChangedListener
71 {
72
73 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WWindowPeer");
74 private static final PlatformLogger screenLog = PlatformLogger.getLogger("sun.awt.windows.screen.WWindowPeer");
75
76 // we can't use WDialogPeer as blocker may be an instance of WPrintDialogPeer that
77 // extends WWindowPeer, not WDialogPeer
78 private WWindowPeer modalBlocker = null;
79
80 private boolean isOpaque;
81
82 private TranslucentWindowPainter painter;
83
84 /*
85 * A key used for storing a list of active windows in AppContext. The value
86 * is a list of windows, sorted by the time of activation: later a window is
87 * activated, greater its index is in the list.
88 */
90 new StringBuffer("active_windows_list");
91
92 /*
93 * Listener for 'activeWindow' KFM property changes. It is added to each
94 * AppContext KFM. See ActiveWindowListener inner class below.
95 */
96 private static PropertyChangeListener activeWindowListener =
97 new ActiveWindowListener();
98
99 /*
100 * The object is a listener for the AppContext.GUI_DISPOSED property.
101 */
102 private static final PropertyChangeListener guiDisposedListener =
103 new GuiDisposedListener();
104
105 /*
106 * Called (on the Toolkit thread) before the appropriate
107 * WindowStateEvent is posted to the EventQueue.
108 */
109 private WindowListener windowListener;
110
111 /**
112 * Initialize JNI field IDs
113 */
114 private static native void initIDs();
115 static {
116 initIDs();
117 }
118
119 // WComponentPeer overrides
120 @Override
121 @SuppressWarnings("unchecked")
122 protected void disposeImpl() {
123 AppContext appContext = SunToolkit.targetToAppContext(target);
124 synchronized (appContext) {
125 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
126 if (l != null) {
127 l.remove(this);
128 }
129 }
202 void initialize() {
203 super.initialize();
204
205 updateInsets(insets_);
206
207 if (!((Window) target).isFontSet()) {
208 ((Window) target).setFont(defaultFont);
209 setFont(defaultFont);
210 }
211 if (!((Window) target).isForegroundSet()) {
212 ((Window) target).setForeground(SystemColor.windowText);
213 }
214 if (!((Window) target).isBackgroundSet()) {
215 ((Window) target).setBackground(SystemColor.window);
216 }
217
218 // Express our interest in display changes
219 GraphicsConfiguration gc = getGraphicsConfiguration();
220 Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
221 gd.addDisplayChangedListener(this);
222
223 initActiveWindowsTracking((Window)target);
224
225 updateIconImages();
226
227 Shape shape = ((Window)target).getShape();
228 if (shape != null) {
229 applyShape(Region.getInstance(shape, null));
230 }
231
232 float opacity = ((Window)target).getOpacity();
233 if (opacity < 1.0f) {
234 setOpacity(opacity);
235 }
236
237 synchronized (getStateLock()) {
238 // default value of a boolean field is 'false', so set isOpaque to
239 // true here explicitly
240 this.isOpaque = true;
241 setOpaque(((Window)target).isOpaque());
288 updateMinimumSize();
289
290 if (((Window)target).isAlwaysOnTopSupported() && alwaysOnTop) {
291 setAlwaysOnTop(alwaysOnTop);
292 }
293
294 synchronized (getStateLock()) {
295 if (!isOpaque) {
296 updateWindow(true);
297 }
298 }
299
300 // See https://javafx-jira.kenai.com/browse/RT-32570
301 WComponentPeer owner = getNativeParent();
302 if (owner != null && owner.isLightweightFramePeer()) {
303 Rectangle b = getBounds();
304 handleExpose(0, 0, b.width, b.height);
305 }
306 }
307
308 final void syncBounds(){
309 // The Windows will take care of the top-level window/frame/dialog,
310 // and update the location/size when DPI changes.
311 }
312
313 // Synchronize the insets members (here & in helper) with actual window
314 // state.
315 native void updateInsets(Insets i);
316
317 static native int getSysMinWidth();
318 static native int getSysMinHeight();
319 static native int getSysIconWidth();
320 static native int getSysIconHeight();
321 static native int getSysSmIconWidth();
322 static native int getSysSmIconHeight();
323 /**windows/classes/sun/awt/windows/
324 * Creates native icon from specified raster data and updates
325 * icon for window and all descendant windows that inherit icon.
326 * Raster data should be passed in the ARGB form.
327 * Note that raster data format was changed to provide support
328 * for XP icons with alpha-channel
329 */
330 native void setIconImagesData(int[] iconRaster, int w, int h,
331 int[] smallIconRaster, int smw, int smh);
332
387 }
388 }
389 }
390 }
391
392 synchronized void addWindowListener(WindowListener l) {
393 windowListener = AWTEventMulticaster.add(windowListener, l);
394 }
395
396 synchronized void removeWindowListener(WindowListener l) {
397 windowListener = AWTEventMulticaster.remove(windowListener, l);
398 }
399
400 @Override
401 public void updateMinimumSize() {
402 Dimension minimumSize = null;
403 if (((Component)target).isMinimumSizeSet()) {
404 minimumSize = ((Component)target).getMinimumSize();
405 }
406 if (minimumSize != null) {
407 Dimension sysMin = toUserSpace(getGraphicsConfiguration(),
408 getSysMinWidth(), getSysMinHeight());
409 setMinSize(Math.max(minimumSize.width, sysMin.width),
410 Math.max(minimumSize.height, sysMin.height));
411 } else {
412 setMinSize(0, 0);
413 }
414 }
415
416 @Override
417 public void updateIconImages() {
418 java.util.List<Image> imageList = ((Window)target).getIconImages();
419 if (imageList == null || imageList.size() == 0) {
420 setIconImagesData(null, 0, 0, null, 0, 0);
421 } else {
422 int w = getSysIconWidth();
423 int h = getSysIconHeight();
424 int smw = getSysSmIconWidth();
425 int smh = getSysSmIconHeight();
426 AffineTransform tx = getGraphicsConfiguration().getDefaultTransform();
427 w = Region.clipScale(w, tx.getScaleX());
428 h = Region.clipScale(h, tx.getScaleY());
429 smw = Region.clipScale(smw, tx.getScaleX());
430 smh = Region.clipScale(smh, tx.getScaleY());
548 }
549
550 // Set winGraphicsConfig to the default GC for the monitor this Window
551 // is now mostly on.
552 winGraphicsConfig = (Win32GraphicsConfig)newDev
553 .getDefaultConfiguration();
554 if (screenLog.isLoggable(PlatformLogger.Level.FINE)) {
555 if (winGraphicsConfig == null) {
556 screenLog.fine("Assertion (winGraphicsConfig != null) failed");
557 }
558 }
559
560 // if on a different display, take off old GD and put on new GD
561 if (oldDev != newDev) {
562 oldDev.removeDisplayChangedListener(this);
563 newDev.addDisplayChangedListener(this);
564 }
565
566 AWTAccessor.getComponentAccessor().
567 setGraphicsConfiguration((Component)target, winGraphicsConfig);
568 }
569
570 /**
571 * From the DisplayChangedListener interface.
572 *
573 * This method handles a display change - either when the display settings
574 * are changed, or when the window has been dragged onto a different
575 * display.
576 * Called after a change in the display mode. This event
577 * triggers replacing the surfaceData object (since that object
578 * reflects the current display depth information, which has
579 * just changed).
580 */
581 @Override
582 public void displayChanged() {
583 SunToolkit.executeOnEventHandlerThread(target, this::updateGC);
584 }
585
586 /**
587 * Part of the DisplayChangedListener interface: components
601 */
602
603 public void grab() {
604 nativeGrab();
605 }
606
607 public void ungrab() {
608 nativeUngrab();
609 }
610 private native void nativeGrab();
611 private native void nativeUngrab();
612
613 private boolean hasWarningWindow() {
614 return ((Window)target).getWarningString() != null;
615 }
616
617 boolean isTargetUndecorated() {
618 return true;
619 }
620
621 @Override
622 public native void repositionSecurityWarning();
623
624 @Override
625 public void print(Graphics g) {
626 // We assume we print the whole frame,
627 // so we expect no clip was set previously
628 Shape shape = ((Window)target).getShape();
629 if (shape != null) {
630 g.setClip(shape);
631 }
632 super.print(g);
633 }
634
635 private void replaceSurfaceDataRecursively(Component c) {
636 if (c instanceof Container) {
637 for (Component child : ((Container)c).getComponents()) {
638 replaceSurfaceDataRecursively(child);
639 }
640 }
641 final Object cp = AWTAccessor.getComponentAccessor().getPeer(c);
642 if (cp instanceof WComponentPeer) {
643 ((WComponentPeer)cp).replaceSurfaceDataLater();
644 }
771 public void updateWindow() {
772 updateWindow(false);
773 }
774
775 private void updateWindow(boolean repaint) {
776 Window w = (Window)target;
777 synchronized (getStateLock()) {
778 if (isOpaque || !w.isVisible() ||
779 (w.getWidth() <= 0) || (w.getHeight() <= 0))
780 {
781 return;
782 }
783 TranslucentWindowPainter currentPainter = painter;
784 if (currentPainter != null) {
785 currentPainter.updateWindow(repaint);
786 } else if (log.isLoggable(PlatformLogger.Level.FINER)) {
787 log.finer("Translucent window painter is null in updateWindow");
788 }
789 }
790 }
791
792 /*
793 * The method maps the list of the active windows to the window's AppContext,
794 * then the method registers ActiveWindowListener, GuiDisposedListener listeners;
795 * it executes the initilialization only once per AppContext.
796 */
797 @SuppressWarnings("unchecked")
798 private static void initActiveWindowsTracking(Window w) {
799 AppContext appContext = AppContext.getAppContext();
800 synchronized (appContext) {
801 List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
802 if (l == null) {
803 l = new LinkedList<WWindowPeer>();
804 appContext.put(ACTIVE_WINDOWS_KEY, l);
805 appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener);
806
807 KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
808 kfm.addPropertyChangeListener("activeWindow", activeWindowListener);
809 }
810 }
|