jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
changeset 13648 90effcfc064f
parent 11659 2cc8db870a68
child 13649 ac4f162d1f35
equal deleted inserted replaced
13647:de61414bbcf2 13648:90effcfc064f
   615         }
   615         }
   616     }
   616     }
   617 
   617 
   618     public void handleWindowFocusIn_Dispatch() {
   618     public void handleWindowFocusIn_Dispatch() {
   619         if (EventQueue.isDispatchThread()) {
   619         if (EventQueue.isDispatchThread()) {
   620             XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
   620             XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
   621             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   621             WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   622             SunToolkit.setSystemGenerated(we);
   622             SunToolkit.setSystemGenerated(we);
   623             target.dispatchEvent(we);
   623             target.dispatchEvent(we);
   624         }
   624         }
   625     }
   625     }
   626 
   626 
   627     public void handleWindowFocusInSync(long serial) {
   627     public void handleWindowFocusInSync(long serial) {
   628         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   628         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   629         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
   629         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
   630         sendEvent(we);
   630         sendEvent(we);
   631     }
   631     }
   632     // NOTE: This method may be called by privileged threads.
   632     // NOTE: This method may be called by privileged threads.
   633     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   633     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   634     public void handleWindowFocusIn(long serial) {
   634     public void handleWindowFocusIn(long serial) {
   635         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   635         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_GAINED_FOCUS);
   636         /* wrap in Sequenced, then post*/
   636         /* wrap in Sequenced, then post*/
   637         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow((Window) target);
   637         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow((Window) target);
   638         postEvent(wrapInSequenced((AWTEvent) we));
   638         postEvent(wrapInSequenced((AWTEvent) we));
   639     }
   639     }
   640 
   640 
   641     // NOTE: This method may be called by privileged threads.
   641     // NOTE: This method may be called by privileged threads.
   642     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   642     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   643     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
   643     public void handleWindowFocusOut(Window oppositeWindow, long serial) {
   644         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
   644         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
   645         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
   645         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
   646         XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
   646         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
   647         /* wrap in Sequenced, then post*/
   647         /* wrap in Sequenced, then post*/
   648         postEvent(wrapInSequenced((AWTEvent) we));
   648         postEvent(wrapInSequenced((AWTEvent) we));
   649     }
   649     }
   650     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
   650     public void handleWindowFocusOutSync(Window oppositeWindow, long serial) {
   651         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
   651         WindowEvent we = new WindowEvent((Window)target, WindowEvent.WINDOW_LOST_FOCUS, oppositeWindow);
   652         XKeyboardFocusManagerPeer.setCurrentNativeFocusedWindow(null);
   652         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusedWindow(null);
   653         XKeyboardFocusManagerPeer.setCurrentNativeFocusOwner(null);
   653         XKeyboardFocusManagerPeer.getInstance().setCurrentFocusOwner(null);
   654         sendEvent(we);
   654         sendEvent(we);
   655     }
   655     }
   656 
   656 
   657 /* --- DisplayChangedListener Stuff --- */
   657 /* --- DisplayChangedListener Stuff --- */
   658 
   658 
  1136             int state = getWMState();
  1136             int state = getWMState();
  1137 
  1137 
  1138             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
  1138             // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
  1139             // we ignore the state for such windows.
  1139             // we ignore the state for such windows.
  1140             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
  1140             if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
  1141                 if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
  1141                 if (XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() ==
  1142                         getTarget())
  1142                         getTarget())
  1143                 {
  1143                 {
  1144                     show = true;
  1144                     show = true;
  1145                 }
  1145                 }
  1146 
  1146 
  1183          * When disposing an owned Window we should implicitly
  1183          * When disposing an owned Window we should implicitly
  1184          * return focus to its decorated owner because it won't
  1184          * return focus to its decorated owner because it won't
  1185          * receive WM_TAKE_FOCUS.
  1185          * receive WM_TAKE_FOCUS.
  1186          */
  1186          */
  1187         if (isSimpleWindow()) {
  1187         if (isSimpleWindow()) {
  1188             if (target == XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow()) {
  1188             if (target == XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow()) {
  1189                 Window owner = getDecoratedOwner((Window)target);
  1189                 Window owner = getDecoratedOwner((Window)target);
  1190                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
  1190                 ((XWindowPeer)AWTAccessor.getComponentAccessor().getPeer(owner)).requestWindowFocus();
  1191             }
  1191             }
  1192         }
  1192         }
  1193     }
  1193     }
  1823     public boolean requestWindowFocus(long time, boolean timeProvided) {
  1823     public boolean requestWindowFocus(long time, boolean timeProvided) {
  1824         focusLog.fine("Request for window focus");
  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
  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.
  1826         // If this is Window and its owner Frame is active we can be sure request succedded.
  1827         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
  1827         Window ownerWindow  = XWindowPeer.getDecoratedOwner((Window)target);
  1828         Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
  1828         Window focusedWindow = XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();
  1829         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
  1829         Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);
  1830 
  1830 
  1831         if (isWMStateNetHidden()) {
  1831         if (isWMStateNetHidden()) {
  1832             focusLog.fine("The window is unmapped, so rejecting the request");
  1832             focusLog.fine("The window is unmapped, so rejecting the request");
  1833             return false;
  1833             return false;