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

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 173803002: Redesigns the text input focus handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments from msw. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/cursor_client.h" 11 #include "ui/aura/client/cursor_client.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/client/screen_position_client.h" 13 #include "ui/aura/client/screen_position_client.h"
14 #include "ui/aura/client/window_tree_client.h" 14 #include "ui/aura/client/window_tree_client.h"
15 #include "ui/aura/env.h" 15 #include "ui/aura/env.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h" 17 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/aura/window_observer.h" 18 #include "ui/aura/window_observer.h"
19 #include "ui/base/dragdrop/os_exchange_data.h" 19 #include "ui/base/dragdrop/os_exchange_data.h"
20 #include "ui/base/ui_base_switches_util.h"
20 #include "ui/base/ui_base_types.h" 21 #include "ui/base/ui_base_types.h"
21 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
22 #include "ui/events/event.h" 23 #include "ui/events/event.h"
23 #include "ui/gfx/canvas.h" 24 #include "ui/gfx/canvas.h"
24 #include "ui/gfx/font_list.h" 25 #include "ui/gfx/font_list.h"
25 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
26 #include "ui/native_theme/native_theme_aura.h" 27 #include "ui/native_theme/native_theme_aura.h"
27 #include "ui/views/drag_utils.h" 28 #include "ui/views/drag_utils.h"
28 #include "ui/views/ime/input_method_bridge.h" 29 #include "ui/views/ime/input_method_bridge.h"
30 #include "ui/views/ime/null_input_method.h"
29 #include "ui/views/views_delegate.h" 31 #include "ui/views/views_delegate.h"
30 #include "ui/views/widget/drop_helper.h" 32 #include "ui/views/widget/drop_helper.h"
31 #include "ui/views/widget/native_widget_delegate.h" 33 #include "ui/views/widget/native_widget_delegate.h"
32 #include "ui/views/widget/root_view.h" 34 #include "ui/views/widget/root_view.h"
33 #include "ui/views/widget/tooltip_manager_aura.h" 35 #include "ui/views/widget/tooltip_manager_aura.h"
34 #include "ui/views/widget/widget_aura_utils.h" 36 #include "ui/views/widget/widget_aura_utils.h"
35 #include "ui/views/widget/widget_delegate.h" 37 #include "ui/views/widget/widget_delegate.h"
36 #include "ui/views/widget/window_reorderer.h" 38 #include "ui/views/widget/window_reorderer.h"
37 #include "ui/wm/core/window_util.h" 39 #include "ui/wm/core/window_util.h"
38 #include "ui/wm/public/activation_client.h" 40 #include "ui/wm/public/activation_client.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 window_->ReleaseCapture(); 276 window_->ReleaseCapture();
275 } 277 }
276 278
277 bool NativeWidgetAura::HasCapture() const { 279 bool NativeWidgetAura::HasCapture() const {
278 return window_ && window_->HasCapture(); 280 return window_ && window_->HasCapture();
279 } 281 }
280 282
281 InputMethod* NativeWidgetAura::CreateInputMethod() { 283 InputMethod* NativeWidgetAura::CreateInputMethod() {
282 if (!window_) 284 if (!window_)
283 return NULL; 285 return NULL;
286
287 if (switches::IsTextInputFocusManagerEnabled())
288 return new NullInputMethod();
289
284 aura::Window* root_window = window_->GetRootWindow(); 290 aura::Window* root_window = window_->GetRootWindow();
285 ui::InputMethod* host = 291 ui::InputMethod* host =
286 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 292 root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
287 return new InputMethodBridge(this, host, true); 293 return new InputMethodBridge(this, host, true);
288 } 294 }
289 295
290 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { 296 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() {
291 return this; 297 return this;
292 } 298 }
293 299
300 ui::InputMethod* NativeWidgetAura::GetHostInputMethod() {
301 aura::Window* root_window = window_->GetRootWindow();
302 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
303 }
304
294 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 305 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
295 if (!window_) 306 if (!window_)
296 return; 307 return;
297 308
298 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); 309 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow());
299 // When centering window, we take the intersection of the host and 310 // When centering window, we take the intersection of the host and
300 // the parent. We assume the root window represents the visible 311 // the parent. We assume the root window represents the visible
301 // rect of a single screen. 312 // rect of a single screen.
302 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> 313 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)->
303 GetDisplayNearestWindow(window_).work_area(); 314 GetDisplayNearestWindow(window_).work_area();
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 return aura::Env::GetInstance()->IsMouseButtonDown(); 1145 return aura::Env::GetInstance()->IsMouseButtonDown();
1135 } 1146 }
1136 1147
1137 // static 1148 // static
1138 bool NativeWidgetPrivate::IsTouchDown() { 1149 bool NativeWidgetPrivate::IsTouchDown() {
1139 return aura::Env::GetInstance()->is_touch_down(); 1150 return aura::Env::GetInstance()->is_touch_down();
1140 } 1151 }
1141 1152
1142 } // namespace internal 1153 } // namespace internal
1143 } // namespace views 1154 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698