5879N/A * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A // should be synchronized on awtLock 0N/A // used for modal blocking to keep existing z-order 0N/A // value of WM_TRANSIENT_FOR hint set on this window 0N/A private boolean grab =
false;
// Whether to do a grab during showing 0N/A private boolean isMapped =
false;
// Is this window mapped or not 0N/A * Focus related flags 0N/A // setVisible(true) & handleMapNotify(). 1971N/A * The type is supposed to be immutable while the peer object exists. 1971N/A * The value gets initialized in the preInit() method. 0N/A // It need to be accessed from XFramePeer. 0N/A * This constant defines icon size recommended for using. 0N/A * Apparently, we should use XGetIconSizes which should 0N/A * return icon sizes would be most appreciated by the WM. 0N/A * However, XGetIconSizes always returns 0 for some reason. 0N/A * So the constant has been introduced. 0N/A * Sometimes XChangeProperty(_NET_WM_ICON) doesn't work if 0N/A * image buffer is too large. This constant holds maximum 0N/A * length of buffer which can be used with _NET_WM_ICON hint. 0N/A * It holds int's value. 0N/A // we should not call setFont because it will call a repaint 0N/A // which the peer may not be ready to do yet. 0N/A // we should not call setBackGround because it will call a repaint 0N/A // which the peer may not be ready to do yet. 0N/A // we should not call setForeGround because it will call a repaint 0N/A // which the peer may not be ready to do yet. 0N/A // Init WM_PROTOCOLS atom 4514N/A // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM 0N/A // Set WM_TRANSIENT_FOR and group_leader 0N/A // as owner window may be an embedded window, we must get a toplevel window 0N/A // to set as TRANSIENT_FOR hint 0N/A // Set WM_TRANSIENT_FOR 0N/A // Init warning window(for applets) 0N/A // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip 0N/A // and TrayIcon balloon windows without a warning window. 1045N/A // no need in updateOpaque() as it is no-op 0N/A //read icon images from target 0N/A log.
finest(
"XWindowPeer.updateIconImages: Skipping the image passed into Java because it's null.");
0N/A log.
finest(
"XWindowPeer.updateIconImages: Perhaps the image passed into Java is broken. Skipping this icon.");
0N/A // Fix for CR#6425089 0N/A //target.icons is empty or all icon images are broken 0N/A //icon is inherited from parent 0N/A //default icon is used 0N/A * Sometimes XChangeProperty(_NET_WM_ICON) doesn't work if 0N/A * image buffer is too large. This function help us accommodate 0N/A * initial list of the icon images to certainly-acceptable. 0N/A * It does scale some of these icons to appropriate size 0N/A * if it's necessary. 0N/A * Dumps each icon from the list 0N/A for (
int i =
0; i <
cnt; i++) {
0N/A //This does nothing for XWindowPeer, 0N/A //It's overriden in XDecoratedPeer 1045N/A // Shape shape = ((Window)target).getShape(); 1045N/A // float opacity = ((Window)target).getOpacity(); 0N/A //This function only saves minimumSize value in XWindowPeer 0N/A //Setting WMSizeHints is implemented in XDecoratedPeer 0N/A //Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges 0N/A //the window but fails to revalidate, Sol-CDE 0N/A //This bug is regression for 0N/A //5025858: Resizing a decorated frame triggers componentResized event twice. 0N/A //Since events are not posted from Component.setBounds we need to send them here. 0N/A //Note that this function is overriden in XDecoratedPeer so event 0N/A //posting is not changing for decorated peers 0N/A // NOTE: This method may be called by privileged threads. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A // NOTE: This method may be called by privileged threads. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A // NOTE: This method may be called by privileged threads. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A * DEPRECATED: Replaced by getInsets(). 219N/A * Retrives real native focused window and converts it into Java peer. 219N/A * Retrives real native focused window and converts it into Java window. 0N/A /* WARNING: don't call client code in this method! */ 0N/A * Returns whether or not this window peer has native X window 0N/A * configured as non-focusable window. It might happen if: 0N/A * - Java window is non-focusable 0N/A * - Java window is simple Window(not Frame or Dialog) 0N/A // NOTE: This method may be called by privileged threads. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A /* wrap in Sequenced, then post*/ 0N/A // NOTE: This method may be called by privileged threads. 0N/A // DO NOT INVOKE CLIENT CODE ON THIS THREAD! 0N/A /* wrap in Sequenced, then post*/ 0N/A/* --- DisplayChangedListener Stuff --- */ 0N/A * called to check if we've been moved onto a different screen 0N/A * Based on checkNewXineramaScreen() in awt_GraphicsEnv.c 0N/A log.
finest(
"XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode");
0N/A // Completely on this screen - done! 0N/A * Helper method that executes the displayChanged(screen) method on 0N/A * the event dispatch thread. This method is used in the Xinerama case 0N/A * and after display mode change events. 0N/A * From the DisplayChangedListener interface; called from 0N/A * X11GraphicsDevice when the display mode has been changed. 0N/A * From the DisplayChangedListener interface; top-levels do not need 0N/A * to react to this event. 0N/A * Added for 4934052. 0N/A // TODO: We create an XConfigureEvent every time we override 0N/A // handleConfigureNotify() - too many! 0N/A // Don't call super until we've handled a screen change. Otherwise 0N/A // there could be a race condition in which a ComponentListener could 0N/A // see the old screen. 0N/A * Requests focus to this top-level. Descendants should override to provide 0N/A * implementations based on a class of top-level. 0N/A // Since in XAWT focus is synthetic and all basic Windows are 0N/A // override_redirect all we can do is check whether our parent 0N/A // is active. If it is - we can freely synthesize focus transfer. 0N/A // Luckily, this logic is already implemented in requestWindowFocus. 0N/A Window target = (Window)this.target; 0N/A if (!target.isVisible() || 0N/A !target.isEnabled() || 0N/A !target.isFocusable()) 0N/A // If this window is non-focusable don't post any java focus event 0N/A // If this window is non-focusable don't post any java focus event 0N/A // Check if opposite window is non-focusable. In that case we don't want to 0N/A // make new hash of toplevels of all windows from 'windows' hash. 0N/A // FIXME: do not call them "toplevel" as it is misleading. 0N/A // find in the root's tree: 0N/A // (1) my toplevel, (2) lowest java toplevel, (3) desktop 0N/A // We must enforce (3), (1), (2) order, upward; 0N/A // note that nautilus on the next restacking will do (1),(3),(2). 0N/A // we need topmost desktop of them all. 0N/A return;
// no action necessary 0N/A // add root window property listener: 0N/A // somebody (eg nautilus desktop) may obscure us 0N/A Get XID of closest to root window in a given window hierarchy. 0N/A FIXME: do not call it "toplevel" as it is misleading. 0N/A * It's easier and safer to temporary suppress WM_TAKE_FOCUS 0N/A * protocol itself than to ignore WM_TAKE_FOCUS client message. 0N/A * Because we will have to make the difference between 0N/A * the message come after showing and the message come after 0N/A * activation. Also, on Metacity, for some reason, we have _two_ 0N/A // ICCCM, 4.1.4. Changing Window State: 0N/A // "Iconic -> Withdrawn - The client should unmap the window and follow it 0N/A // with a synthetic UnmapNotify event as described later in this section." 0N/A // The same is true for Normal -> Withdrawn 0N/A // method called somewhere in parent does not generate configure-notify 0N/A // event for override-redirect. 0N/A // Ergo, no reshape and bugs like 5085647 in case setBounds was 0N/A // called before setVisible. 0N/A // The height of menu bar window 1066N/A // Called when shell changes its size and requires children windows 1066N/A // to update their sizes appropriately 1066N/A // the Java window may be swinging while it's being moved. 1066N/A // This doesn't make the application unusable though looks quite ugly. 1066N/A // Probobly we need to find some hint to assign to our Security 1066N/A // Warning window in order to exclude it from the snapping option. 1066N/A // We are not currently aware of existance of such a property. 1066N/A // We can't use the coordinates stored in the XBaseWindow since 1066N/A // they are zeros for decorated frames. 1066N/A return;
// The warning window should already be hidden. 1890N/A // getWMState() always returns 0 (Withdrawn) for simple windows. Hence 1890N/A // we ignore the state for such windows. 5315N/A grabLog.
fine(
"Generating UngrabEvent on {0} because of the window disposal",
this);
0N/A * When disposing an owned Window we should implicitly 0N/A * return focus to its decorated owner because it won't 0N/A * receive WM_TAKE_FOCUS. 0N/A// if (ve.get_state() == XlibWrapper.VisibilityUnobscured) { 0N/A// // raiseInputMethodWindow 0N/A // As of now, don't use any generic machinery: just 0N/A // do toBack() again. 0N/A * without WM_TAKE_FOCUS protocol doesn't get moved to the front. 0N/A * So, we do it evidently. 0N/A // On Metacity UnmapNotify comes before PropertyNotify (for _NET_WM_STATE_HIDDEN). 0N/A // So we also check for the property later in MapNotify. See 6480534. 0N/A * Override this methods to get notifications when top-level window state changes. The state is 0N/A * meant in terms of ICCCM: WithdrawnState, IconicState, NormalState 0N/A // Fix for 6401700, 6412803 0N/A // If this window is modal blocked, it is put into the transient_for 0N/A // chain using prevTransientFor and nextTransientFor hints. However, 0N/A // the real WM_TRANSIENT_FOR hint shouldn't be set for windows in 0N/A // different WM states (except for owner-window relationship), so 0N/A // if the window changes its state, its real WM_TRANSIENT_FOR hint 0N/A // should be updated accordingly. 0N/A * Returns a Vector of all Java top-level windows, 0N/A * sorted by their current Z-order 0N/A // XQueryTree returns window children ordered by z-order 0N/A // filter out Java non-toplevels 0N/A // XQueryTree returns windows sorted by their z-order. However, 0N/A // if WM has not handled transient for hint for a child window, 0N/A // it may appear in javaToplevels before its owner. Move such 0N/A // children after their owners. 0N/A // State lock should always be after awtLock 0N/A * Sets the TRANSIENT_FOR hint to the given top-level window. This 0N/A * If window or transientForWindow are embedded frames, the containing 0N/A * top-level windows are used. 0N/A * @param window specifies the top-level window that the hint 0N/A * @param transientForWindow the top-level window 0N/A * @param allStates if set to <code>true</code> then TRANSIENT_FOR hint 0N/A * is set regardless of the state of window and transientForWindow, 0N/A * otherwise it is set only if both are in the same state 0N/A * This method does nothing if this window is not blocked by any modal dialog. 0N/A * For modal blocked windows this method looks up for the nearest 0N/A * as this one and makes this window transient for it. The same operation is 0N/A * performed for nextTransientFor window. 0N/A * Values of prevTransientFor and nextTransientFor fields are not changed. 0N/A * Removes the TRANSIENT_FOR hint from the given top-level window. 0N/A * If window or transientForWindow are embedded frames, the containing 0N/A * top-level windows are used. 0N/A * @param window specifies the top-level window that the hint 0N/A * is to be removed from 0N/A * When a modal dialog is shown, all its blocked windows are lined up into 0N/A * a chain in such a way that each window is a transient_for window for 0N/A * the next one. That allows us to keep the modal dialog above all its 0N/A * blocked windows (even if there are some another modal dialogs between 0N/A * This method adds this top-level window to the chain of the given modal 0N/A * dialog. To keep the current relative z-order, we should use the 0N/A * XQueryTree to find the place to insert this window to. As each window 0N/A * can be blocked by only one modal dialog (such checks are performed in 0N/A * shared code), both this and blockerPeer are on the top of their chains 0N/A * (chains may be empty). 0N/A * If this window is a modal dialog and has its own chain, these chains are 0N/A * merged according to the current z-order (XQueryTree is used again). 0N/A * Below are some simple examples (z-order is from left to right, -- is 0N/A * T (current chain of this, no windows are blocked by this) 0N/A * W1---B (current chain of blockerPeer, W2 is blocked by blockerPeer) 0N/A * W1-T-B (merged chain, all the windows are blocked by blockerPeer) 0N/A * W1-T (current chain of this, W1 is blocked by this) 0N/A * W2-B (current chain of blockerPeer, W2 is blocked by blockerPeer) 0N/A * W1-T-W2-B (merged chain, all the windows are blocked by blockerPeer) 0N/A * W1----T (current chain of this, W1 is blocked by this) 0N/A * W2---B (current chain of blockerPeer, W2 is blocked by blockerPeer) 0N/A * W1-W2-T-B (merged chain, all the windows are blocked by blockerPeer) 0N/A * This method should be called under the AWT lock. 0N/A * @see #removeFromTransientFors 0N/A * @see #setModalBlocked 0N/A // blockerPeer chain iterator 0N/A // this window chain iterator 0N/A // each window can be blocked no more than once, so this window 0N/A // is on top of its chain 0N/A // if there are no windows blocked by modalBlocker, simply add this window 0N/A // and its chain to blocker's chain 0N/A // Collect all the Java top-levels, if required 0N/A // merged chain tail 0N/A * When a window is modally unblocked, it should be removed from its blocker 0N/A * chain, see {@link #addToTransientFor addToTransientFors} method for the 0N/A * The problem is that we cannot simply restore window's original 0N/A * TRANSIENT_FOR hint (if any) and link prevTransientFor and 0N/A * nextTransientFor together as the whole chain could be created as a merge 0N/A * of two other chains in addToTransientFors. In that case, if this window is 0N/A * a modal dialog, it would lost all its own chain, if we simply exclude it 0N/A * The correct behaviour of this method should be to split the chain, this 0N/A * window is currently in, into two chains. First chain is this window own 0N/A * chain (i. e. all the windows blocked by this one, directly or indirectly), 0N/A * if any, and the rest windows from the current chain. 0N/A * W1-B1 (window W1 is blocked by B1) 0N/A * W2-B2 (window W2 is blocked by B2) 0N/A * B3 is shown and blocks B1 and B2: 0N/A * W1-W2-B1-B2-B3 (a single chain after B1.addToTransientFors() and B2.addToTransientFors()) 0N/A * If we then unblock B1, the state should be: 0N/A * W1-B1 (window W1 is blocked by B1) 0N/A * W2-B2-B3 (window W2 is blocked by B2 and B2 is blocked by B3) 0N/A * This method should be called under the AWT lock. 0N/A * @see #addToTransientFors 0N/A * @see #setModalBlocked 0N/A // the head of the chain of this window 0N/A // the head of the current chain 0N/A // nextTransientFor is always not null as this window is in the chain 0N/A // the set of blockers in this chain: if this dialog blocks some other 0N/A // modal dialogs, their blocked windows should stay in this dialog's chain 0N/A // current chain iterator in the order from next to prev 0N/A // add to this dialog's chain 0N/A // leave in the current chain 0N/A // If this is Frame or Dialog we can't assure focus request success - but we still can try 0N/A // If this is Window and its owner Frame is active we can be sure request succedded. 0N/A focusLog.
fine(
"Parent window is active - generating focus for this window");
219N/A focusLog.
fine(
"Parent window accepted focus request - generating focus for this window");
0N/A focusLog.
fine(
"Denied - parent window is not active and didn't accept focus request");
0N/A // This method is to be overriden in XDecoratedPeer. 1971N/A * Applies the current window type. 1888N/A // should be synchronized on awtLock 0N/A // When window is grabbed, all events are dispatched to 0N/A // it. Retarget them to the corresponding windows (notice 0N/A // that XBaseWindow.dispatchEvent does the opposite 0N/A // Note that we need to retarget XCrossingEvents to content window 0N/A // (fix for 6390326) 870N/A // here is the bug in WM: extra buttons doesn't have state!=0 as they should. 870N/A if ((i !=
4) && (i !=
5)){
0N/A // When window is grabbed, all events are dispatched to 0N/A // it. Retarget them to the corresponding windows (notice 0N/A // that XBaseWindow.dispatchEvent does the opposite 0N/A // for some reasons if we grab input MotionNotify for drag is reported with target 0N/A // to underlying window, not to window on which we have initiated drag 0N/A // so we need to retarget them. Here I use simplified logic which retarget all 0N/A // such events to source of mouse press (or the grabber). It helps with fix for 6390326. 0N/A // So, I do not want to implement complicated logic for better retargeting. 0N/A // note that we need to pass dragging events to the grabber (6390326) 0N/A // see comment above for more inforamtion. 0N/A // we use it to retarget mouse drag and mouse release during grab. 1224N/A * Ignore the buttons above 20 due to the bit limit for 1224N/A * InputEvent.BUTTON_DOWN_MASK. 1224N/A * One more bit is reserved for FIRST_HIGH_BIT. 0N/A // When window is grabbed, all events are dispatched to 0N/A // it. Retarget them to the corresponding windows (notice 0N/A // that XBaseWindow.dispatchEvent does the opposite 0N/A // need to keep it to retarget mouse release 0N/A // during grab we do receive mouse release on different component (not on the source 0N/A // of mouse press). So we need to retarget it. 0N/A // see 6390326 for more information. 0N/A // Target is either us or our content window - 0N/A // check that event is inside. 'Us' in case of 0N/A // shell will mean that this will also filter out press on title 0N/A // Outside this toplevel hierarchy 0N/A // According to the specification of UngrabEvent, post it 0N/A // when press occurs outside of the window and not on its owned windows 0N/A // First, get the toplevel 0N/A // toplevel == null - outside of 0N/A // hierarchy, toplevel is Dialog - should 0N/A // send ungrab (but shouldn't for Window) 0N/A // toplevel is null - outside of hierarchy 0N/A // target doesn't map to XAWT window - outside of hierarchy 1045N/A // We assume we print the whole frame, 1045N/A // so we expect no clip was set previously