// WComponentPeer overrides @SuppressWarnings("unchecked") protected void disposeImpl() { AppContext appContext = SunToolkit.targetToAppContext(target); synchronized (appContext) { List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY); if (l != null) { l.remove(this); } } // Remove ourself from the Map of DisplayChangeListeners GraphicsConfiguration gc = getGraphicsConfiguration(); ((Win32GraphicsDevice) gc.getDevice()).removeDisplayChangedListener(this); synchronized (getStateLock()) { TranslucentWindowPainter currentPainter = painter; if (currentPainter != null) { currentPainter.flush(); // don't set the current one to null here; reduces the chances of // MT issues (like NPEs) } } super.disposeImpl(); }
/* * The method maps the list of the active windows to the window's AppContext, * then the method registers ActiveWindowListener, GuiDisposedListener listeners; * it executes the initilialization only once per AppContext. */ @SuppressWarnings("unchecked") private static void initActiveWindowsTracking(Window w) { AppContext appContext = AppContext.getAppContext(); synchronized (appContext) { List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY); if (l == null) { l = new LinkedList<WWindowPeer>(); appContext.put(ACTIVE_WINDOWS_KEY, l); appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener); KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); kfm.addPropertyChangeListener("activeWindow", activeWindowListener); } } }
/* * Returns all the ever active windows from the current AppContext. * The list is sorted by the time of activation, so the latest * active window is always at the end. */ @SuppressWarnings("unchecked") public static long[] getActiveWindowHandles() { AppContext appContext = AppContext.getAppContext(); synchronized (appContext) { List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY); if (l == null) { return null; } long[] result = new long[l.size()]; for (int j = 0; j < l.size(); j++) { result[j] = l.get(j).getHWnd(); } return result; } }
public void propertyChange(PropertyChangeEvent e) { Window w = (Window) e.getNewValue(); if (w == null) { return; } AppContext appContext = SunToolkit.targetToAppContext(w); synchronized (appContext) { WWindowPeer wp = (WWindowPeer) w.getPeer(); // add/move wp to the end of the list List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY); if (l != null) { l.remove(wp); l.add(wp); } } }