530 // Switch out the old input method 531 Locale savedLocale = inputMethodLocator.getLocale(); 532 boolean wasInputMethodActive = isInputMethodActive; 533 boolean wasCompositionEnabledSupported = false; 534 boolean wasCompositionEnabled = false; 535 if (inputMethod != null) { 536 try { 537 wasCompositionEnabled = inputMethod.isCompositionEnabled(); 538 wasCompositionEnabledSupported = true; 539 } catch (UnsupportedOperationException e) { } 540 541 if (currentClientComponent != null) { 542 if (!isInputMethodActive) { 543 activateInputMethod(false); 544 } 545 endComposition(); 546 deactivateInputMethod(false); 547 if (inputMethod instanceof InputMethodAdapter) { 548 ((InputMethodAdapter) inputMethod).setClientComponent(null); 549 } 550 } 551 savedLocale = inputMethod.getLocale(); 552 553 // keep the input method instance around for future use 554 if (usedInputMethods == null) { 555 usedInputMethods = new HashMap<>(5); 556 } 557 if (perInputMethodState == null) { 558 perInputMethodState = new HashMap<>(5); 559 } 560 usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod); 561 perInputMethodState.put(inputMethod, 562 Boolean.valueOf(clientWindowNotificationEnabled)); 563 enableClientWindowNotification(inputMethod, false); 564 if (this == inputMethodWindowContext) { 565 inputMethod.hideWindows(); 566 inputMethodWindowContext = null; 567 } 568 inputMethodLocator = null; 569 inputMethod = null; 570 inputMethodCreationFailed = false; 571 } 572 573 // Switch in the new input method 574 if (newLocator.getLocale() == null && savedLocale != null && 575 newLocator.isLocaleAvailable(savedLocale)) { 576 newLocator = newLocator.deriveLocator(savedLocale); 577 } 578 inputMethodLocator = newLocator; 579 inputMethodCreationFailed = false; 580 581 // activate the new input method if the old one was active 582 if (wasInputMethodActive) { 583 inputMethod = getInputMethodInstance(); 584 if (inputMethod instanceof InputMethodAdapter) { 585 ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(awtFocussedComponent); | 530 // Switch out the old input method 531 Locale savedLocale = inputMethodLocator.getLocale(); 532 boolean wasInputMethodActive = isInputMethodActive; 533 boolean wasCompositionEnabledSupported = false; 534 boolean wasCompositionEnabled = false; 535 if (inputMethod != null) { 536 try { 537 wasCompositionEnabled = inputMethod.isCompositionEnabled(); 538 wasCompositionEnabledSupported = true; 539 } catch (UnsupportedOperationException e) { } 540 541 if (currentClientComponent != null) { 542 if (!isInputMethodActive) { 543 activateInputMethod(false); 544 } 545 endComposition(); 546 deactivateInputMethod(false); 547 if (inputMethod instanceof InputMethodAdapter) { 548 ((InputMethodAdapter) inputMethod).setClientComponent(null); 549 } 550 if (null == currentClientComponent.getInputMethodRequests()) 551 wasCompositionEnabledSupported = false; 552 } 553 savedLocale = inputMethod.getLocale(); 554 555 // keep the input method instance around for future use 556 if (usedInputMethods == null) { 557 usedInputMethods = new HashMap<>(5); 558 } 559 if (perInputMethodState == null) { 560 perInputMethodState = new HashMap<>(5); 561 } 562 usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod); 563 perInputMethodState.put(inputMethod, 564 Boolean.valueOf(clientWindowNotificationEnabled)); 565 enableClientWindowNotification(inputMethod, false); 566 if (this == inputMethodWindowContext) { 567 inputMethod.hideWindows(); 568 inputMethod.removeNotify(); 569 inputMethodWindowContext = null; 570 } 571 inputMethodLocator = null; 572 inputMethod = null; 573 inputMethodCreationFailed = false; 574 } 575 576 // Switch in the new input method 577 if (newLocator.getLocale() == null && savedLocale != null && 578 newLocator.isLocaleAvailable(savedLocale)) { 579 newLocator = newLocator.deriveLocator(savedLocale); 580 } 581 inputMethodLocator = newLocator; 582 inputMethodCreationFailed = false; 583 584 // activate the new input method if the old one was active 585 if (wasInputMethodActive) { 586 inputMethod = getInputMethodInstance(); 587 if (inputMethod instanceof InputMethodAdapter) { 588 ((InputMethodAdapter) inputMethod).setAWTFocussedComponent(awtFocussedComponent); |