Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 173803002: Redesigns the text input focus handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added an unittest and thread checker. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
index 12aec9272d816cc17b93a1f47efd2fb6707d0376..b0e6737d60bd2e936b811f1fea87f37d61be1b6c 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
@@ -15,6 +15,7 @@
#include "ui/aura/window_property.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/hit_test.h"
+#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/display.h"
@@ -25,8 +26,8 @@
#include "ui/views/corewm/tooltip.h"
#include "ui/views/corewm/tooltip_controller.h"
#include "ui/views/drag_utils.h"
-#include "ui/views/ime/input_method.h"
#include "ui/views/ime/input_method_bridge.h"
+#include "ui/views/ime/null_input_method.h"
#include "ui/views/view_constants_aura.h"
#include "ui/views/widget/desktop_aura/desktop_capture_client.h"
#include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h"
@@ -629,6 +630,9 @@ bool DesktopNativeWidgetAura::HasCapture() const {
}
InputMethod* DesktopNativeWidgetAura::CreateInputMethod() {
+ if (switches::IsTextInputFocusManagerEnabled())
+ return new NullInputMethod();
+
ui::InputMethod* host = input_method_event_filter_->input_method();
return new InputMethodBridge(this, host, false);
}
@@ -638,6 +642,10 @@ internal::InputMethodDelegate*
return this;
}
+ui::InputMethod* DesktopNativeWidgetAura::GetHostInputMethod() {
+ return input_method_event_filter_->input_method();
+}
+
void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) {
if (content_window_)
desktop_window_tree_host_->CenterWindow(size);
@@ -1072,16 +1080,26 @@ void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
desktop_window_tree_host_->OnNativeWidgetFocus();
native_widget_delegate_->OnNativeFocus(lost_focus);
- // If focus is moving from a descendant Window to |content_window_| then
- // native activation hasn't changed. We still need to inform the InputMethod
- // we've been focused though.
- InputMethod* input_method = GetWidget()->GetInputMethod();
- if (input_method)
- input_method->OnFocus();
+ if (!switches::IsTextInputFocusManagerEnabled()) {
+ // If focus is moving from a descendant Window to |content_window_| then
+ // native activation hasn't changed. We still need to inform the
+ // InputMethod we've been focused though.
+ InputMethod* input_method = GetWidget()->GetInputMethod();
+ if (input_method)
+ input_method->OnFocus();
+ }
+
+ // Ensure the focused view's TextInputClient is used for text input.
+ views::FocusManager* focus_manager = GetWidget()->GetFocusManager();
+ focus_manager->FocusTextInputClient(focus_manager->GetFocusedView());
} else if (content_window_ == lost_focus) {
desktop_window_tree_host_->OnNativeWidgetBlur();
native_widget_delegate_->OnNativeBlur(
aura::client::GetFocusClient(content_window_)->GetFocusedWindow());
+
+ // Ensure the focused view's TextInputClient is not used for text input.
+ views::FocusManager* focus_manager = GetWidget()->GetFocusManager();
+ focus_manager->BlurTextInputClient(focus_manager->GetFocusedView());
}
}

Powered by Google App Engine
This is Rietveld 408576698