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

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

Issue 8576005: IME (input method editor) support for Aura, part 3 of 3: Use ui::InputMethod in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moving IME code to aura_shell. not ready for review Created 9 years 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
« no previous file with comments | « ui/base/keycodes/keyboard_code_conversion.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string_util.h" 8 #include "base/string_util.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/drag_drop_client.h" 10 #include "ui/aura/client/drag_drop_client.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/views/widget/tooltip_manager_aura.h" 25 #include "ui/views/widget/tooltip_manager_aura.h"
26 #include "ui/views/widget/widget_delegate.h" 26 #include "ui/views/widget/widget_delegate.h"
27 27
28 #if defined(OS_WIN) 28 #if defined(OS_WIN)
29 #include "base/win/scoped_gdi_object.h" 29 #include "base/win/scoped_gdi_object.h"
30 #include "base/win/win_util.h" 30 #include "base/win/win_util.h"
31 #include "ui/base/l10n/l10n_util_win.h" 31 #include "ui/base/l10n/l10n_util_win.h"
32 #endif 32 #endif
33 33
34 #if defined(HAVE_IBUS) 34 #if defined(HAVE_IBUS)
35 #include "ui/views/ime/input_method_ibus.h" 35 #include "ui/views/ime/input_method_bridge.h"
36 #else 36 #else
37 #include "ui/views/ime/mock_input_method.h" 37 #include "ui/views/ime/mock_input_method.h"
38 #endif 38 #endif
39 39
40 namespace views { 40 namespace views {
41 41
42 namespace { 42 namespace {
43 43
44 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { 44 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) {
45 switch (type) { 45 switch (type) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 void NativeWidgetAura::ReleaseMouseCapture() { 273 void NativeWidgetAura::ReleaseMouseCapture() {
274 window_->ReleaseCapture(); 274 window_->ReleaseCapture();
275 } 275 }
276 276
277 bool NativeWidgetAura::HasMouseCapture() const { 277 bool NativeWidgetAura::HasMouseCapture() const {
278 return window_->HasCapture(); 278 return window_->HasCapture();
279 } 279 }
280 280
281 InputMethod* NativeWidgetAura::CreateInputMethod() { 281 InputMethod* NativeWidgetAura::CreateInputMethod() {
282 #if defined(HAVE_IBUS) 282 #if defined(HAVE_IBUS)
283 InputMethod* input_method = new InputMethodIBus(this); 283 ui::InputMethod* host = aura::RootWindow::GetInstance()->input_method();
284 DCHECK(host);
285 InputMethod* input_method = new InputMethodBridge(this, host);
284 #else 286 #else
287 // Use the mock IME for unit tests.
285 InputMethod* input_method = new MockInputMethod(this); 288 InputMethod* input_method = new MockInputMethod(this);
286 #endif 289 #endif
287 input_method->Init(GetWidget()); 290 input_method->Init(GetWidget());
288 return input_method; 291 return input_method;
289 } 292 }
290 293
291 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 294 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
292 const gfx::Rect parent_bounds = window_->parent()->bounds(); 295 const gfx::Rect parent_bounds = window_->parent()->bounds();
293 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, 296 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2,
294 (parent_bounds.height() - size.height())/2, 297 (parent_bounds.height() - size.height())/2,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 Widget* widget = GetWidget(); 569 Widget* widget = GetWidget();
567 if (widget->is_top_level()) { 570 if (widget->is_top_level()) {
568 InputMethod* input_method = widget->GetInputMethod(); 571 InputMethod* input_method = widget->GetInputMethod();
569 input_method->OnBlur(); 572 input_method->OnBlur();
570 widget->GetFocusManager()->StoreFocusedView(); 573 widget->GetFocusManager()->StoreFocusedView();
571 } 574 }
572 delegate_->OnNativeBlur(NULL); 575 delegate_->OnNativeBlur(NULL);
573 } 576 }
574 577
575 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { 578 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) {
576 // TODO(beng): Need an InputMethodAura to properly handle character events. 579 // TODO(yusukes): Need an ui::InputMethod to properly handle character events.
577 // Right now, we just skip these. 580 // Right now, we just skip these.
578 if (event->is_char()) 581 if (event->is_char())
579 return false; 582 return false;
580 583
581 DCHECK(window_->IsVisible()); 584 DCHECK(window_->IsVisible());
582 InputMethod* input_method = GetWidget()->GetInputMethod(); 585 InputMethod* input_method = GetWidget()->GetInputMethod();
583 DCHECK(input_method); 586 DCHECK(input_method);
584 // TODO(oshima): DispatchKeyEvent should return bool?
585 KeyEvent views_event(event); 587 KeyEvent views_event(event);
586 input_method->DispatchKeyEvent(views_event); 588 input_method->DispatchKeyEvent(views_event);
587 return true; 589 return true;
588 } 590 }
589 591
590 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { 592 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) {
591 return cursor_; 593 return cursor_;
592 } 594 }
593 595
594 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { 596 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 793 }
792 } 794 }
793 795
794 // static 796 // static
795 bool NativeWidgetPrivate::IsMouseButtonDown() { 797 bool NativeWidgetPrivate::IsMouseButtonDown() {
796 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); 798 return aura::RootWindow::GetInstance()->IsMouseButtonDown();
797 } 799 }
798 800
799 } // namespace internal 801 } // namespace internal
800 } // namespace views 802 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/keycodes/keyboard_code_conversion.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698