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

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: Reset the text input client in FocusController. 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 window_->ReleaseCapture(); 263 window_->ReleaseCapture();
262 } 264 }
263 265
264 bool NativeWidgetAura::HasCapture() const { 266 bool NativeWidgetAura::HasCapture() const {
265 return window_ && window_->HasCapture(); 267 return window_ && window_->HasCapture();
266 } 268 }
267 269
268 InputMethod* NativeWidgetAura::CreateInputMethod() { 270 InputMethod* NativeWidgetAura::CreateInputMethod() {
269 if (!window_) 271 if (!window_)
270 return NULL; 272 return NULL;
273
274 if (switches::IsTextInputFocusManagerEnabled())
275 return new NullInputMethod();
276
271 aura::Window* root_window = window_->GetRootWindow(); 277 aura::Window* root_window = window_->GetRootWindow();
272 ui::InputMethod* host = 278 ui::InputMethod* host =
273 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 279 root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
274 return new InputMethodBridge(this, host, true); 280 return new InputMethodBridge(this, host, true);
275 } 281 }
276 282
277 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { 283 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() {
278 return this; 284 return this;
279 } 285 }
280 286
287 ui::InputMethod* NativeWidgetAura::GetHostInputMethod() {
288 aura::Window* root_window = window_->GetRootWindow();
289 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
290 }
291
281 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 292 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
282 if (!window_) 293 if (!window_)
283 return; 294 return;
284 295
285 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); 296 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow());
286 // When centering window, we take the intersection of the host and 297 // When centering window, we take the intersection of the host and
287 // the parent. We assume the root window represents the visible 298 // the parent. We assume the root window represents the visible
288 // rect of a single screen. 299 // rect of a single screen.
289 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> 300 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)->
290 GetDisplayNearestWindow(window_).work_area(); 301 GetDisplayNearestWindow(window_).work_area();
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 1145 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
1135 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 1146 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
1136 return gfx::FontList(gfx::Font(caption_font)); 1147 return gfx::FontList(gfx::Font(caption_font));
1137 #else 1148 #else
1138 return gfx::FontList(); 1149 return gfx::FontList();
1139 #endif 1150 #endif
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