< prev index next >

src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java

Print this page

        

*** 55,65 **** import sun.util.logging.PlatformLogger; import sun.awt.AppContext; import sun.awt.SunToolkit; - import sun.awt.CausedFocusEvent; import sun.awt.KeyboardFocusManagerPeerProvider; import sun.awt.AWTAccessor; /** * The KeyboardFocusManager is responsible for managing the active and focused --- 55,64 ----
*** 122,132 **** public int shouldNativelyFocusHeavyweight(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time, ! CausedFocusEvent.Cause cause) { return KeyboardFocusManager.shouldNativelyFocusHeavyweight( heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause); } public boolean processSynchronousLightweightTransfer(Component heavyweight, --- 121,131 ---- public int shouldNativelyFocusHeavyweight(Component heavyweight, Component descendant, boolean temporary, boolean focusedWindowChangeAllowed, long time, ! FocusEvent.Cause cause) { return KeyboardFocusManager.shouldNativelyFocusHeavyweight( heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause); } public boolean processSynchronousLightweightTransfer(Component heavyweight,
*** 2162,2174 **** } private static final class LightweightFocusRequest { final Component component; final boolean temporary; ! final CausedFocusEvent.Cause cause; ! LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) { this.component = component; this.temporary = temporary; this.cause = cause; } public String toString() { --- 2161,2173 ---- } private static final class LightweightFocusRequest { final Component component; final boolean temporary; ! final FocusEvent.Cause cause; ! LightweightFocusRequest(Component component, boolean temporary, FocusEvent.Cause cause) { this.component = component; this.temporary = temporary; this.cause = cause; } public String toString() {
*** 2188,2198 **** heavyweight = null; lightweightRequests = null; } HeavyweightFocusRequest(Component heavyweight, Component descendant, ! boolean temporary, CausedFocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (heavyweight == null) { log.fine("Assertion (heavyweight != null) failed"); } } --- 2187,2197 ---- heavyweight = null; lightweightRequests = null; } HeavyweightFocusRequest(Component heavyweight, Component descendant, ! boolean temporary, FocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (heavyweight == null) { log.fine("Assertion (heavyweight != null) failed"); } }
*** 2200,2210 **** this.heavyweight = heavyweight; this.lightweightRequests = new LinkedList<LightweightFocusRequest>(); addLightweightRequest(descendant, temporary, cause); } boolean addLightweightRequest(Component descendant, ! boolean temporary, CausedFocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed"); } if (descendant == null) { --- 2199,2209 ---- this.heavyweight = heavyweight; this.lightweightRequests = new LinkedList<LightweightFocusRequest>(); addLightweightRequest(descendant, temporary, cause); } boolean addLightweightRequest(Component descendant, ! boolean temporary, FocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed"); } if (descendant == null) {
*** 2312,2322 **** // we would never have gotten this far. manager.enqueueKeyEvents(time, descendant); hwFocusRequest = new HeavyweightFocusRequest(heavyweight, descendant, ! temporary, CausedFocusEvent.Cause.UNKNOWN); heavyweightRequests.add(hwFocusRequest); if (currentFocusOwner != null) { currentFocusOwnerEvent = new FocusEvent(currentFocusOwner, --- 2311,2321 ---- // we would never have gotten this far. manager.enqueueKeyEvents(time, descendant); hwFocusRequest = new HeavyweightFocusRequest(heavyweight, descendant, ! temporary, FocusEvent.Cause.UNKNOWN); heavyweightRequests.add(hwFocusRequest); if (currentFocusOwner != null) { currentFocusOwnerEvent = new FocusEvent(currentFocusOwner,
*** 2377,2387 **** * this function from the native event pumping thread, or by holding a * global, native lock during invocation. */ static int shouldNativelyFocusHeavyweight (Component heavyweight, Component descendant, boolean temporary, ! boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (heavyweight == null) { log.fine("Assertion (heavyweight != null) failed"); } --- 2376,2386 ---- * this function from the native event pumping thread, or by holding a * global, native lock during invocation. */ static int shouldNativelyFocusHeavyweight (Component heavyweight, Component descendant, boolean temporary, ! boolean focusedWindowChangeAllowed, long time, FocusEvent.Cause cause) { if (log.isLoggable(PlatformLogger.Level.FINE)) { if (heavyweight == null) { log.fine("Assertion (heavyweight != null) failed"); }
*** 2443,2462 **** temporary, cause); heavyweightRequests.add(hwFocusRequest); if (currentFocusOwner != null) { FocusEvent currentFocusOwnerEvent = ! new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, temporary, descendant, cause); // Fix 5028014. Rolled out. // SunToolkit.postPriorityEvent(currentFocusOwnerEvent); SunToolkit.postEvent(currentFocusOwner.appContext, currentFocusOwnerEvent); } FocusEvent newFocusOwnerEvent = ! new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED, temporary, currentFocusOwner, cause); // Fix 5028014. Rolled out. // SunToolkit.postPriorityEvent(newFocusOwnerEvent); SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent); --- 2442,2461 ---- temporary, cause); heavyweightRequests.add(hwFocusRequest); if (currentFocusOwner != null) { FocusEvent currentFocusOwnerEvent = ! new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, temporary, descendant, cause); // Fix 5028014. Rolled out. // SunToolkit.postPriorityEvent(currentFocusOwnerEvent); SunToolkit.postEvent(currentFocusOwner.appContext, currentFocusOwnerEvent); } FocusEvent newFocusOwnerEvent = ! new FocusEvent(descendant, FocusEvent.FOCUS_GAINED, temporary, currentFocusOwner, cause); // Fix 5028014. Rolled out. // SunToolkit.postPriorityEvent(newFocusOwnerEvent); SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
*** 2668,2684 **** * We're not dispatching FOCUS_LOST while the current focus owner is null. * But regardless of whether it's null or not, we're clearing ALL the local * lw requests. */ if (currentFocusOwner != null) { ! currentFocusOwnerEvent = new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, lwFocusRequest.temporary, lwFocusRequest.component, lwFocusRequest.cause); } FocusEvent newFocusOwnerEvent = ! new CausedFocusEvent(lwFocusRequest.component, FocusEvent.FOCUS_GAINED, lwFocusRequest.temporary, currentFocusOwner == null ? lastFocusOwner : currentFocusOwner, lwFocusRequest.cause); --- 2667,2683 ---- * We're not dispatching FOCUS_LOST while the current focus owner is null. * But regardless of whether it's null or not, we're clearing ALL the local * lw requests. */ if (currentFocusOwner != null) { ! currentFocusOwnerEvent = new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, lwFocusRequest.temporary, lwFocusRequest.component, lwFocusRequest.cause); } FocusEvent newFocusOwnerEvent = ! new FocusEvent(lwFocusRequest.component, FocusEvent.FOCUS_GAINED, lwFocusRequest.temporary, currentFocusOwner == null ? lastFocusOwner : currentFocusOwner, lwFocusRequest.cause);
*** 2724,2735 **** if (fe.getID() == FocusEvent.FOCUS_LOST && (opposite == null || isTemporary(opposite, source))) { temporary = true; } ! return new CausedFocusEvent(source, fe.getID(), temporary, opposite, ! CausedFocusEvent.Cause.NATIVE_SYSTEM); } } static FocusEvent retargetFocusGained(FocusEvent fe) { assert (fe.getID() == FocusEvent.FOCUS_GAINED); --- 2723,2734 ---- if (fe.getID() == FocusEvent.FOCUS_LOST && (opposite == null || isTemporary(opposite, source))) { temporary = true; } ! return new FocusEvent(source, fe.getID(), temporary, opposite, ! FocusEvent.Cause.UNEXPECTED); } } static FocusEvent retargetFocusGained(FocusEvent fe) { assert (fe.getID() == FocusEvent.FOCUS_GAINED);
*** 2800,2810 **** }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent ! return new CausedFocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null --- 2799,2809 ---- }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent ! return new FocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null
*** 2813,2824 **** { // Special case for FOCUS_GAINED in top-levels // If it arrives as the result of activation we should skip it // This event will not have appropriate request record and // on arrival there will be already some focus owner set. ! return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false, ! null, CausedFocusEvent.Cause.ACTIVATION); } return retargetUnexpectedFocusEvent(fe); } // end synchronized(heavyweightRequests) } --- 2812,2823 ---- { // Special case for FOCUS_GAINED in top-levels // If it arrives as the result of activation we should skip it // This event will not have appropriate request record and // on arrival there will be already some focus owner set. ! return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false, ! null, FocusEvent.Cause.ACTIVATION); } return retargetUnexpectedFocusEvent(fe); } // end synchronized(heavyweightRequests) }
*** 2837,2860 **** if (hwFocusRequest == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { if (currentFocusOwner != null) { // Call to KeyboardFocusManager.clearGlobalFocusOwner() heavyweightRequests.removeFirst(); ! return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, false, null, ! CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER); } // Otherwise, fall through to failure case below } else if (opposite == null) { // Focus leaving application if (currentFocusOwner != null) { ! return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, ! true, null, CausedFocusEvent.Cause.ACTIVATION); } else { return fe; } } else if (hwFocusRequest != null && (nativeOpposite == hwFocusRequest.heavyweight || --- 2836,2859 ---- if (hwFocusRequest == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) { if (currentFocusOwner != null) { // Call to KeyboardFocusManager.clearGlobalFocusOwner() heavyweightRequests.removeFirst(); ! return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, false, null, ! FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER); } // Otherwise, fall through to failure case below } else if (opposite == null) { // Focus leaving application if (currentFocusOwner != null) { ! return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, ! true, null, FocusEvent.Cause.ACTIVATION); } else { return fe; } } else if (hwFocusRequest != null && (nativeOpposite == hwFocusRequest.heavyweight ||
*** 2876,2894 **** boolean temporary = isTemporary(opposite, currentFocusOwner) ? true : lwFocusRequest.temporary; ! return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, temporary, lwFocusRequest.component, lwFocusRequest.cause); } else if (focusedWindowChanged(opposite, currentFocusOwner)) { // If top-level changed there might be no focus request in a list // But we know the opposite, we now it is temporary - dispatch the event. if (!fe.isTemporary() && currentFocusOwner != null) { // Create copy of the event with only difference in temporary parameter. ! fe = new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, ! true, opposite, CausedFocusEvent.Cause.ACTIVATION); } return fe; } return retargetUnexpectedFocusEvent(fe); --- 2875,2893 ---- boolean temporary = isTemporary(opposite, currentFocusOwner) ? true : lwFocusRequest.temporary; ! return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, temporary, lwFocusRequest.component, lwFocusRequest.cause); } else if (focusedWindowChanged(opposite, currentFocusOwner)) { // If top-level changed there might be no focus request in a list // But we know the opposite, we now it is temporary - dispatch the event. if (!fe.isTemporary() && currentFocusOwner != null) { // Create copy of the event with only difference in temporary parameter. ! fe = new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST, ! true, opposite, FocusEvent.Cause.ACTIVATION); } return fe; } return retargetUnexpectedFocusEvent(fe);
< prev index next >