src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page




 882         }
 883         return size;
 884     }
 885 
 886     @Override
 887     public void updateCursorImmediately() {
 888         getLWToolkit().getCursorManager().updateCursor();
 889     }
 890 
 891     @Override
 892     public boolean isFocusable() {
 893         // Overridden in focusable subclasses like buttons
 894         return false;
 895     }
 896 
 897     @Override
 898     public boolean requestFocus(Component lightweightChild, boolean temporary,
 899                                 boolean focusedWindowChangeAllowed, long time,
 900                                 CausedFocusEvent.Cause cause)
 901     {
 902         if (focusLog.isLoggable(PlatformLogger.FINEST)) {
 903             focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
 904                             ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
 905                             ", time= " + time + ", cause=" + cause);
 906         }
 907         if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
 908                 getTarget(), lightweightChild, temporary,
 909                 focusedWindowChangeAllowed, time)) {
 910             return true;
 911         }
 912 
 913         int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
 914                 getTarget(), lightweightChild, temporary,
 915                 focusedWindowChangeAllowed, time, cause);
 916         switch (result) {
 917             case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
 918                 return false;
 919             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
 920                 Window parentWindow = SunToolkit.getContainingWindow(getTarget());
 921                 if (parentWindow == null) {
 922                     focusLog.fine("request rejected, parentWindow is null");
 923                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 924                     return false;
 925                 }
 926                 LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer();
 927                 if (parentPeer == null) {
 928                     focusLog.fine("request rejected, parentPeer is null");
 929                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 930                     return false;
 931                 }
 932 
 933                 // A fix for 7145768. Ensure the parent window is currently natively focused.
 934                 // The more evident place to perform this check is in KFM.shouldNativelyFocusHeavyweight,
 935                 // however that is the shared code and this particular problem's reproducibility has
 936                 // platform specifics. So, it was decided to narrow down the fix to lwawt (OSX) in
 937                 // current release. TODO: consider fixing it in the shared code.
 938                 if (!focusedWindowChangeAllowed) {
 939                     LWWindowPeer decoratedPeer = parentPeer.isSimpleWindow() ?
 940                         LWWindowPeer.getOwnerFrameDialog(parentPeer) : parentPeer;
 941 
 942                     if (decoratedPeer == null || !decoratedPeer.getPlatformWindow().isActive()) {
 943                         if (focusLog.isLoggable(PlatformLogger.FINE)) {
 944                             focusLog.fine("request rejected, focusedWindowChangeAllowed==false, " +
 945                                           "decoratedPeer is inactive: " + decoratedPeer);
 946                         }
 947                         LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 948                         return false;
 949                     }
 950                 }
 951 
 952                 boolean res = parentPeer.requestWindowFocus(cause);
 953                 // If parent window can be made focused and has been made focused (synchronously)
 954                 // then we can proceed with children, otherwise we retreat
 955                 if (!res || !parentWindow.isFocused()) {
 956                     if (focusLog.isLoggable(PlatformLogger.FINE)) {
 957                         focusLog.fine("request rejected, res= " + res + ", parentWindow.isFocused()=" +
 958                                       parentWindow.isFocused());
 959                     }
 960                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 961                     return false;
 962                 }
 963 
 964                 KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
 965                 Component focusOwner = kfmPeer.getCurrentFocusOwner();
 966                 return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
 967                         getTarget(), temporary,
 968                         focusedWindowChangeAllowed,
 969                         time, cause, focusOwner);
 970 
 971             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 972                 return true;
 973         }
 974 
 975         return false;
 976     }




 882         }
 883         return size;
 884     }
 885 
 886     @Override
 887     public void updateCursorImmediately() {
 888         getLWToolkit().getCursorManager().updateCursor();
 889     }
 890 
 891     @Override
 892     public boolean isFocusable() {
 893         // Overridden in focusable subclasses like buttons
 894         return false;
 895     }
 896 
 897     @Override
 898     public boolean requestFocus(Component lightweightChild, boolean temporary,
 899                                 boolean focusedWindowChangeAllowed, long time,
 900                                 CausedFocusEvent.Cause cause)
 901     {
 902         if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
 903             focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
 904                             ", focusedWindowChangeAllowed=" + focusedWindowChangeAllowed +
 905                             ", time= " + time + ", cause=" + cause);
 906         }
 907         if (LWKeyboardFocusManagerPeer.processSynchronousLightweightTransfer(
 908                 getTarget(), lightweightChild, temporary,
 909                 focusedWindowChangeAllowed, time)) {
 910             return true;
 911         }
 912 
 913         int result = LWKeyboardFocusManagerPeer.shouldNativelyFocusHeavyweight(
 914                 getTarget(), lightweightChild, temporary,
 915                 focusedWindowChangeAllowed, time, cause);
 916         switch (result) {
 917             case LWKeyboardFocusManagerPeer.SNFH_FAILURE:
 918                 return false;
 919             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
 920                 Window parentWindow = SunToolkit.getContainingWindow(getTarget());
 921                 if (parentWindow == null) {
 922                     focusLog.fine("request rejected, parentWindow is null");
 923                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 924                     return false;
 925                 }
 926                 LWWindowPeer parentPeer = (LWWindowPeer) parentWindow.getPeer();
 927                 if (parentPeer == null) {
 928                     focusLog.fine("request rejected, parentPeer is null");
 929                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 930                     return false;
 931                 }
 932 
 933                 // A fix for 7145768. Ensure the parent window is currently natively focused.
 934                 // The more evident place to perform this check is in KFM.shouldNativelyFocusHeavyweight,
 935                 // however that is the shared code and this particular problem's reproducibility has
 936                 // platform specifics. So, it was decided to narrow down the fix to lwawt (OSX) in
 937                 // current release. TODO: consider fixing it in the shared code.
 938                 if (!focusedWindowChangeAllowed) {
 939                     LWWindowPeer decoratedPeer = parentPeer.isSimpleWindow() ?
 940                         LWWindowPeer.getOwnerFrameDialog(parentPeer) : parentPeer;
 941 
 942                     if (decoratedPeer == null || !decoratedPeer.getPlatformWindow().isActive()) {
 943                         if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
 944                             focusLog.fine("request rejected, focusedWindowChangeAllowed==false, " +
 945                                           "decoratedPeer is inactive: " + decoratedPeer);
 946                         }
 947                         LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 948                         return false;
 949                     }
 950                 }
 951 
 952                 boolean res = parentPeer.requestWindowFocus(cause);
 953                 // If parent window can be made focused and has been made focused (synchronously)
 954                 // then we can proceed with children, otherwise we retreat
 955                 if (!res || !parentWindow.isFocused()) {
 956                     if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
 957                         focusLog.fine("request rejected, res= " + res + ", parentWindow.isFocused()=" +
 958                                       parentWindow.isFocused());
 959                     }
 960                     LWKeyboardFocusManagerPeer.removeLastFocusRequest(getTarget());
 961                     return false;
 962                 }
 963 
 964                 KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance();
 965                 Component focusOwner = kfmPeer.getCurrentFocusOwner();
 966                 return LWKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
 967                         getTarget(), temporary,
 968                         focusedWindowChangeAllowed,
 969                         time, cause, focusOwner);
 970 
 971             case LWKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
 972                 return true;
 973         }
 974 
 975         return false;
 976     }