2461 new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED, 2462 temporary, currentFocusOwner, cause); 2463 // Fix 5028014. Rolled out. 2464 // SunToolkit.postPriorityEvent(newFocusOwnerEvent); 2465 SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent); 2466 2467 if (focusLog.isLoggable(PlatformLogger.FINEST)) 2468 focusLog.finest("2. SNFH_HANDLED for {0}", String.valueOf(descendant)); 2469 return SNFH_SUCCESS_HANDLED; 2470 } else if (hwFocusRequest != null && 2471 hwFocusRequest.heavyweight == heavyweight) { 2472 // 'heavyweight' doesn't have the native focus right now, but 2473 // if all pending requests were completed, it would. Add 2474 // descendant to the heavyweight's list of pending 2475 // lightweight focus transfers. 2476 if (hwFocusRequest.addLightweightRequest(descendant, 2477 temporary, cause)) { 2478 manager.enqueueKeyEvents(time, descendant); 2479 } 2480 2481 if (focusLog.isLoggable(PlatformLogger.FINEST)) 2482 focusLog.finest("3. SNFH_HANDLED for lightweight" + 2483 descendant + " in " + heavyweight); 2484 return SNFH_SUCCESS_HANDLED; 2485 } else { 2486 if (!focusedWindowChangeAllowed) { 2487 // For purposes of computing oldFocusedWindow, we should look at 2488 // the second to last HeavyweightFocusRequest on the queue iff the 2489 // last HeavyweightFocusRequest is CLEAR_GLOBAL_FOCUS_OWNER. If 2490 // there is no second to last HeavyweightFocusRequest, null is an 2491 // acceptable value. 2492 if (hwFocusRequest == 2493 HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) 2494 { 2495 int size = heavyweightRequests.size(); 2496 hwFocusRequest = (HeavyweightFocusRequest)((size >= 2) 2497 ? heavyweightRequests.get(size - 2) 2498 : null); 2499 } 2500 if (focusedWindowChanged(heavyweight, 2501 (hwFocusRequest != null) 2502 ? hwFocusRequest.heavyweight 2503 : nativeFocusedWindow)) { 2504 if (focusLog.isLoggable(PlatformLogger.FINEST)) 2505 focusLog.finest("4. SNFH_FAILURE for " + descendant); 2506 return SNFH_FAILURE; 2507 } 2508 } 2509 2510 manager.enqueueKeyEvents(time, descendant); 2511 heavyweightRequests.add 2512 (new HeavyweightFocusRequest(heavyweight, descendant, 2513 temporary, cause)); 2514 if (focusLog.isLoggable(PlatformLogger.FINEST)) 2515 focusLog.finest("5. SNFH_PROCEED for " + descendant); 2516 return SNFH_SUCCESS_PROCEED; 2517 } 2518 } 2519 } 2520 2521 /** 2522 * Returns the Window which will be active after processing this request, 2523 * or null if this is a duplicate request. The active Window is useful 2524 * because some native platforms do not support setting the native focus 2525 * owner to null. On these platforms, the obvious choice is to set the 2526 * focus owner to the focus proxy of the active Window. 2527 */ 2528 static Window markClearGlobalFocusOwner() { 2529 // need to call this out of synchronized block to avoid possible deadlock 2530 // see 6454631. 2531 final Component nativeFocusedWindow = 2532 getCurrentKeyboardFocusManager().getNativeFocusedWindow(); 2533 2534 synchronized (heavyweightRequests) { 2535 HeavyweightFocusRequest hwFocusRequest = getLastHWRequest(); | 2461 new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED, 2462 temporary, currentFocusOwner, cause); 2463 // Fix 5028014. Rolled out. 2464 // SunToolkit.postPriorityEvent(newFocusOwnerEvent); 2465 SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent); 2466 2467 if (focusLog.isLoggable(PlatformLogger.FINEST)) 2468 focusLog.finest("2. SNFH_HANDLED for {0}", String.valueOf(descendant)); 2469 return SNFH_SUCCESS_HANDLED; 2470 } else if (hwFocusRequest != null && 2471 hwFocusRequest.heavyweight == heavyweight) { 2472 // 'heavyweight' doesn't have the native focus right now, but 2473 // if all pending requests were completed, it would. Add 2474 // descendant to the heavyweight's list of pending 2475 // lightweight focus transfers. 2476 if (hwFocusRequest.addLightweightRequest(descendant, 2477 temporary, cause)) { 2478 manager.enqueueKeyEvents(time, descendant); 2479 } 2480 2481 if (focusLog.isLoggable(PlatformLogger.FINEST)) { 2482 focusLog.finest("3. SNFH_HANDLED for lightweight" + 2483 descendant + " in " + heavyweight); 2484 } 2485 return SNFH_SUCCESS_HANDLED; 2486 } else { 2487 if (!focusedWindowChangeAllowed) { 2488 // For purposes of computing oldFocusedWindow, we should look at 2489 // the second to last HeavyweightFocusRequest on the queue iff the 2490 // last HeavyweightFocusRequest is CLEAR_GLOBAL_FOCUS_OWNER. If 2491 // there is no second to last HeavyweightFocusRequest, null is an 2492 // acceptable value. 2493 if (hwFocusRequest == 2494 HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) 2495 { 2496 int size = heavyweightRequests.size(); 2497 hwFocusRequest = (HeavyweightFocusRequest)((size >= 2) 2498 ? heavyweightRequests.get(size - 2) 2499 : null); 2500 } 2501 if (focusedWindowChanged(heavyweight, 2502 (hwFocusRequest != null) 2503 ? hwFocusRequest.heavyweight 2504 : nativeFocusedWindow)) { 2505 if (focusLog.isLoggable(PlatformLogger.FINEST)) { 2506 focusLog.finest("4. SNFH_FAILURE for " + descendant); 2507 } 2508 return SNFH_FAILURE; 2509 } 2510 } 2511 2512 manager.enqueueKeyEvents(time, descendant); 2513 heavyweightRequests.add 2514 (new HeavyweightFocusRequest(heavyweight, descendant, 2515 temporary, cause)); 2516 if (focusLog.isLoggable(PlatformLogger.FINEST)) { 2517 focusLog.finest("5. SNFH_PROCEED for " + descendant); 2518 } 2519 return SNFH_SUCCESS_PROCEED; 2520 } 2521 } 2522 } 2523 2524 /** 2525 * Returns the Window which will be active after processing this request, 2526 * or null if this is a duplicate request. The active Window is useful 2527 * because some native platforms do not support setting the native focus 2528 * owner to null. On these platforms, the obvious choice is to set the 2529 * focus owner to the focus proxy of the active Window. 2530 */ 2531 static Window markClearGlobalFocusOwner() { 2532 // need to call this out of synchronized block to avoid possible deadlock 2533 // see 6454631. 2534 final Component nativeFocusedWindow = 2535 getCurrentKeyboardFocusManager().getNativeFocusedWindow(); 2536 2537 synchronized (heavyweightRequests) { 2538 HeavyweightFocusRequest hwFocusRequest = getLastHWRequest(); |