src/solaris/classes/sun/awt/X11/XWindowPeer.java

Print this page




 600         return getContentWindow();
 601     }
 602 
 603     /**
 604      * Returns whether or not this window peer has native X window
 605      * configured as non-focusable window. It might happen if:
 606      * - Java window is non-focusable
 607      * - Java window is simple Window(not Frame or Dialog)
 608      */
 609     boolean isNativelyNonFocusableWindow() {
 610         if (XToolkit.isToolkitThread() || SunToolkit.isAWTLockHeldByCurrentThread())
 611         {
 612             return isSimpleWindow() || !cachedFocusableWindow;
 613         } else {
 614             return isSimpleWindow() || !(((Window)target).isFocusableWindow());
 615         }
 616     }
 617 
 618     public void handleWindowFocusIn_Dispatch() {
 619         if (EventQueue.isDispatchThread()) {
 620             XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
 621             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 622             SunToolkit.setSystemGenerated(we);
 623             target.dispatchEvent(we);
 624         }
 625     }
 626 
 627     public void handleWindowFocusInSync(long serial) {
 628         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 629         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
 630         sendEvent(we);
 631     }
 632     // NOTE: This method may be called by privileged threads.
 633     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 634     public void handleWindowFocusIn(long serial) {
 635         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 636         /* wrap in Sequenced, then post*/
 637         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
 638         postEvent(wrapInSequenced((AWTEvent) we));
 639     }
 640 
 641     // NOTE: This method may be called by privileged threads.
 642     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 643     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
 644         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
 645         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
 646         XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
 647         /* wrap in Sequenced, then post*/
 648         postEvent(wrapInSequenced((AWTEvent) we));
 649     }
 650     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
 651         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
 652         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
 653         XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
 654         sendEvent(we);
 655     }
 656 
 657 /* --- DisplayChangedListener Stuff --- */
 658 
 659     /* Xinerama
 660      * called to check if we've been moved onto a different screen
 661      * Based on checkNewXineramaScreen() in awt_GraphicsEnv.c
 662      */
 663     public void checkIfOnNewScreen(Rectangle newBounds) {
 664         if (!XToolkit.localEnv.runningXinerama()) {
 665             return;
 666         }
 667 
 668         if (log.isLoggable(PlatformLogger.FINEST)) {
 669             log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode");
 670         }
 671 
 672         int area = newBounds.width * newBounds.height;
 673         int intAmt, vertAmt, horizAmt;


1121         updateSecurityWarningVisibility();
1122     }
1123 
1124     public void updateSecurityWarningVisibility() {
1125         if (warningWindow == null) {
1126             return;
1127         }
1128 
1129         if (!isVisible()) {
1130             return; // The warning window should already be hidden.
1131         }
1132 
1133         boolean show = false;
1134 
1135         if (!isFullScreenExclusiveMode()) {
1136             int state = getWMState();
1137 
1138             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
1139             // we ignore the state for such windows.
1140             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
1141                 if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
1142                         getTarget())
1143                 {
1144                     show = true;
1145                 }
1146 
1147                 if (isMouseAbove() || warningWindow.isMouseAbove())
1148                 {
1149                     show = true;
1150                 }
1151             }
1152         }
1153 
1154         warningWindow.setSecurityWarningVisible(show, true);
1155     }
1156 
1157     boolean isOverrideRedirect() {
1158         return XWM.getWMID() == XWM.OPENLOOK_WM ||
1159             Window.Type.POPUP.equals(getWindowType());
1160     }
1161 


1168         SunToolkit.awtLock();
1169         try {
1170             windows.remove(this);
1171         } finally {
1172             SunToolkit.awtUnlock();
1173         }
1174         if (warningWindow != null) {
1175             warningWindow.destroy();
1176         }
1177         removeRootPropertyEventDispatcher();
1178         mustControlStackPosition = false;
1179         super.dispose();
1180 
1181         /*
1182          * Fix for 6457980.
1183          * When disposing an owned Window we should implicitly
1184          * return focus to its decorated owner because it won't
1185          * receive WM_TAKE_FOCUS.
1186          */
1187         if (isSimpleWindow()) {
1188             if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) {
1189                 Window owner = getDecoratedOwner((Window)target);
1190                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
1191             }
1192         }
1193     }
1194     boolean isResizable() {
1195         return winAttr.isResizable;
1196     }
1197 
1198     public void handleVisibilityEvent(XEvent xev) {
1199         super.handleVisibilityEvent(xev);
1200         XVisibilityEvent ve = xev.get_xvisibility();
1201         winAttr.visibilityState = ve.get_state();
1202 //         if (ve.get_state() == XlibWrapper.VisibilityUnobscured) {
1203 //             // raiseInputMethodWindow
1204 //         }
1205         repositionSecurityWarning();
1206     }
1207 
1208     void handleRootPropertyNotify(XEvent xev) {


1808         while ((null != window) && !(window instanceof Frame || window instanceof Dialog)) {
1809             window = (Window) AWTAccessor.getComponentAccessor().getParent(window);
1810         }
1811         return window;
1812     }
1813 
1814     public boolean requestWindowFocus(XWindowPeer actualFocusedWindow) {
1815         setActualFocusedWindow(actualFocusedWindow);
1816         return requestWindowFocus();
1817     }
1818 
1819     public boolean requestWindowFocus() {
1820         return requestWindowFocus(0, false);
1821     }
1822 
1823     public boolean requestWindowFocus(long time, boolean timeProvided) {
1824         focusLog.fine("Request for window focus");
1825         // If this is Frame or Dialog we can't assure focus request success - but we still can try
1826         // If this is Window and its owner Frame is active we can be sure request succedded.
1827         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
1828         Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
1829         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
1830 
1831         if (isWMStateNetHidden()) {
1832             focusLog.fine("The window is unmapped, so rejecting the request");
1833             return false;
1834         }
1835         if (activeWindow == ownerWindow) {
1836             focusLog.fine("Parent window is active - generating focus for this window");
1837             handleWindowFocusInSync(-1);
1838             return true;
1839         }
1840         focusLog.fine("Parent window is not active");
1841 
1842         XDecoratedPeer wpeer = (XDecoratedPeer)AWTAccessor.getComponentAccessor().getPeer(ownerWindow);
1843         if (wpeer != null && wpeer.requestWindowFocus(this, time, timeProvided)) {
1844             focusLog.fine("Parent window accepted focus request - generating focus for this window");
1845             return true;
1846         }
1847         focusLog.fine("Denied - parent window is not active and didn't accept focus request");
1848         return false;




 600         return getContentWindow();
 601     }
 602 
 603     /**
 604      * Returns whether or not this window peer has native X window
 605      * configured as non-focusable window. It might happen if:
 606      * - Java window is non-focusable
 607      * - Java window is simple Window(not Frame or Dialog)
 608      */
 609     boolean isNativelyNonFocusableWindow() {
 610         if (XToolkit.isToolkitThread() || SunToolkit.isAWTLockHeldByCurrentThread())
 611         {
 612             return isSimpleWindow() || !cachedFocusableWindow;
 613         } else {
 614             return isSimpleWindow() || !(((Window)target).isFocusableWindow());
 615         }
 616     }
 617 
 618     public void handleWindowFocusIn_Dispatch() {
 619         if (EventQueue.isDispatchThread()) {
 620             XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
 621             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 622             SunToolkit.setSystemGenerated(we);
 623             target.dispatchEvent(we);
 624         }
 625     }
 626 
 627     public void handleWindowFocusInSync(long serial) {
 628         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 629         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
 630         sendEvent(we);
 631     }
 632     // NOTE: This method may be called by privileged threads.
 633     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 634     public void handleWindowFocusIn(long serial) {
 635         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
 636         /* wrap in Sequenced, then post*/
 637         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
 638         postEvent(wrapInSequenced((AWTEvent) we));
 639     }
 640 
 641     // NOTE: This method may be called by privileged threads.
 642     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 643     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
 644         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
 645         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
 646         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
 647         /* wrap in Sequenced, then post*/
 648         postEvent(wrapInSequenced((AWTEvent) we));
 649     }
 650     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
 651         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
 652         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
 653         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
 654         sendEvent(we);
 655     }
 656 
 657 /* --- DisplayChangedListener Stuff --- */
 658 
 659     /* Xinerama
 660      * called to check if we've been moved onto a different screen
 661      * Based on checkNewXineramaScreen() in awt_GraphicsEnv.c
 662      */
 663     public void checkIfOnNewScreen(Rectangle newBounds) {
 664         if (!XToolkit.localEnv.runningXinerama()) {
 665             return;
 666         }
 667 
 668         if (log.isLoggable(PlatformLogger.FINEST)) {
 669             log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode");
 670         }
 671 
 672         int area = newBounds.width * newBounds.height;
 673         int intAmt, vertAmt, horizAmt;


1121         updateSecurityWarningVisibility();
1122     }
1123 
1124     public void updateSecurityWarningVisibility() {
1125         if (warningWindow == null) {
1126             return;
1127         }
1128 
1129         if (!isVisible()) {
1130             return; // The warning window should already be hidden.
1131         }
1132 
1133         boolean show = false;
1134 
1135         if (!isFullScreenExclusiveMode()) {
1136             int state = getWMState();
1137 
1138             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
1139             // we ignore the state for such windows.
1140             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
1141                 if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
1142                         getTarget())
1143                 {
1144                     show = true;
1145                 }
1146 
1147                 if (isMouseAbove() || warningWindow.isMouseAbove())
1148                 {
1149                     show = true;
1150                 }
1151             }
1152         }
1153 
1154         warningWindow.setSecurityWarningVisible(show, true);
1155     }
1156 
1157     boolean isOverrideRedirect() {
1158         return XWM.getWMID() == XWM.OPENLOOK_WM ||
1159             Window.Type.POPUP.equals(getWindowType());
1160     }
1161 


1168         SunToolkit.awtLock();
1169         try {
1170             windows.remove(this);
1171         } finally {
1172             SunToolkit.awtUnlock();
1173         }
1174         if (warningWindow != null) {
1175             warningWindow.destroy();
1176         }
1177         removeRootPropertyEventDispatcher();
1178         mustControlStackPosition = false;
1179         super.dispose();
1180 
1181         /*
1182          * Fix for 6457980.
1183          * When disposing an owned Window we should implicitly
1184          * return focus to its decorated owner because it won't
1185          * receive WM_TAKE_FOCUS.
1186          */
1187         if (isSimpleWindow()) {
1188             if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
1189                 Window owner = getDecoratedOwner((Window)target);
1190                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
1191             }
1192         }
1193     }
1194     boolean isResizable() {
1195         return winAttr.isResizable;
1196     }
1197 
1198     public void handleVisibilityEvent(XEvent xev) {
1199         super.handleVisibilityEvent(xev);
1200         XVisibilityEvent ve = xev.get_xvisibility();
1201         winAttr.visibilityState = ve.get_state();
1202 //         if (ve.get_state() == XlibWrapper.VisibilityUnobscured) {
1203 //             // raiseInputMethodWindow
1204 //         }
1205         repositionSecurityWarning();
1206     }
1207 
1208     void handleRootPropertyNotify(XEvent xev) {


1808         while ((null != window) && !(window instanceof Frame || window instanceof Dialog)) {
1809             window = (Window) AWTAccessor.getComponentAccessor().getParent(window);
1810         }
1811         return window;
1812     }
1813 
1814     public boolean requestWindowFocus(XWindowPeer actualFocusedWindow) {
1815         setActualFocusedWindow(actualFocusedWindow);
1816         return requestWindowFocus();
1817     }
1818 
1819     public boolean requestWindowFocus() {
1820         return requestWindowFocus(0, false);
1821     }
1822 
1823     public boolean requestWindowFocus(long time, boolean timeProvided) {
1824         focusLog.fine("Request for window focus");
1825         // If this is Frame or Dialog we can't assure focus request success - but we still can try
1826         // If this is Window and its owner Frame is active we can be sure request succedded.
1827         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
1828         Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
1829         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
1830 
1831         if (isWMStateNetHidden()) {
1832             focusLog.fine("The window is unmapped, so rejecting the request");
1833             return false;
1834         }
1835         if (activeWindow == ownerWindow) {
1836             focusLog.fine("Parent window is active - generating focus for this window");
1837             handleWindowFocusInSync(-1);
1838             return true;
1839         }
1840         focusLog.fine("Parent window is not active");
1841 
1842         XDecoratedPeer wpeer = (XDecoratedPeer)AWTAccessor.getComponentAccessor().getPeer(ownerWindow);
1843         if (wpeer != null && wpeer.requestWindowFocus(this, time, timeProvided)) {
1844             focusLog.fine("Parent window accepted focus request - generating focus for this window");
1845             return true;
1846         }
1847         focusLog.fine("Denied - parent window is not active and didn't accept focus request");
1848         return false;