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

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: Synced. Created 6 years, 9 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/activation_client.h" 10 #include "ui/aura/client/activation_client.h"
11 #include "ui/aura/client/aura_constants.h" 11 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/client/cursor_client.h" 12 #include "ui/aura/client/cursor_client.h"
13 #include "ui/aura/client/drag_drop_client.h" 13 #include "ui/aura/client/drag_drop_client.h"
14 #include "ui/aura/client/focus_client.h" 14 #include "ui/aura/client/focus_client.h"
15 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
16 #include "ui/aura/client/window_move_client.h" 16 #include "ui/aura/client/window_move_client.h"
17 #include "ui/aura/client/window_tree_client.h" 17 #include "ui/aura/client/window_tree_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/aura/window_event_dispatcher.h" 20 #include "ui/aura/window_event_dispatcher.h"
21 #include "ui/aura/window_observer.h" 21 #include "ui/aura/window_observer.h"
22 #include "ui/base/dragdrop/os_exchange_data.h" 22 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "ui/base/ui_base_switches_util.h"
23 #include "ui/base/ui_base_types.h" 24 #include "ui/base/ui_base_types.h"
24 #include "ui/compositor/layer.h" 25 #include "ui/compositor/layer.h"
25 #include "ui/events/event.h" 26 #include "ui/events/event.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/font_list.h" 28 #include "ui/gfx/font_list.h"
28 #include "ui/gfx/screen.h" 29 #include "ui/gfx/screen.h"
29 #include "ui/native_theme/native_theme_aura.h" 30 #include "ui/native_theme/native_theme_aura.h"
30 #include "ui/views/corewm/window_util.h" 31 #include "ui/views/corewm/window_util.h"
31 #include "ui/views/drag_utils.h" 32 #include "ui/views/drag_utils.h"
32 #include "ui/views/ime/input_method_bridge.h" 33 #include "ui/views/ime/input_method_bridge.h"
34 #include "ui/views/ime/null_input_method.h"
33 #include "ui/views/views_delegate.h" 35 #include "ui/views/views_delegate.h"
34 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 36 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
35 #include "ui/views/widget/drop_helper.h" 37 #include "ui/views/widget/drop_helper.h"
36 #include "ui/views/widget/native_widget_delegate.h" 38 #include "ui/views/widget/native_widget_delegate.h"
37 #include "ui/views/widget/root_view.h" 39 #include "ui/views/widget/root_view.h"
38 #include "ui/views/widget/tooltip_manager_aura.h" 40 #include "ui/views/widget/tooltip_manager_aura.h"
39 #include "ui/views/widget/widget_aura_utils.h" 41 #include "ui/views/widget/widget_aura_utils.h"
40 #include "ui/views/widget/widget_delegate.h" 42 #include "ui/views/widget/widget_delegate.h"
41 #include "ui/views/widget/window_reorderer.h" 43 #include "ui/views/widget/window_reorderer.h"
42 #include "ui/wm/public/window_types.h" 44 #include "ui/wm/public/window_types.h"
(...skipping 231 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::IsNewTextInputFocusEnabled())
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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 return aura::Env::GetInstance()->IsMouseButtonDown(); 1155 return aura::Env::GetInstance()->IsMouseButtonDown();
1145 } 1156 }
1146 1157
1147 // static 1158 // static
1148 bool NativeWidgetPrivate::IsTouchDown() { 1159 bool NativeWidgetPrivate::IsTouchDown() {
1149 return aura::Env::GetInstance()->is_touch_down(); 1160 return aura::Env::GetInstance()->is_touch_down();
1150 } 1161 }
1151 1162
1152 } // namespace internal 1163 } // namespace internal
1153 } // namespace views 1164 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698