< 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,
*** 2158,2170 **** } 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() { --- 2157,2169 ---- } 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() {
*** 2184,2194 **** 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"); } } --- 2183,2193 ---- 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"); } }
*** 2196,2206 **** 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) { --- 2195,2205 ---- 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) {
*** 2308,2318 **** // 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, --- 2307,2317 ---- // 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,
*** 2373,2383 **** * 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"); } --- 2372,2382 ---- * 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"); }
*** 2439,2458 **** 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); --- 2438,2457 ---- 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);
*** 2664,2680 **** * 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); --- 2663,2679 ---- * 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);
*** 2720,2731 **** 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); --- 2719,2730 ---- 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);
*** 2796,2806 **** }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent ! return new CausedFocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null --- 2795,2805 ---- }); } // 'opposite' will be fixed by // DefaultKeyboardFocusManager.realOppositeComponent ! return new FocusEvent(newSource, FocusEvent.FOCUS_GAINED, temporary, opposite, lwFocusRequest.cause); } if (currentFocusOwner != null
*** 2809,2820 **** { // 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) } --- 2808,2819 ---- { // 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) }
*** 2833,2856 **** 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 || --- 2832,2855 ---- 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 ||
*** 2872,2890 **** 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); --- 2871,2889 ---- 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 >