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

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: git mv desktop_host_unittest.cc desktop_host_ime_unittest.cc 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
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 13 matching lines...) Expand all
24 #include "ui/views/widget/native_widget_delegate.h" 24 #include "ui/views/widget/native_widget_delegate.h"
25 #include "ui/views/widget/tooltip_manager_views.h" 25 #include "ui/views/widget/tooltip_manager_views.h"
26 26
27 #if defined(OS_WIN) 27 #if defined(OS_WIN)
28 #include "base/win/scoped_gdi_object.h" 28 #include "base/win/scoped_gdi_object.h"
29 #include "base/win/win_util.h" 29 #include "base/win/win_util.h"
30 #include "ui/base/l10n/l10n_util_win.h" 30 #include "ui/base/l10n/l10n_util_win.h"
31 #endif 31 #endif
32 32
33 #if defined(HAVE_IBUS) 33 #if defined(HAVE_IBUS)
34 #include "ui/views/ime/input_method_ibus.h" 34 #include "ui/views/ime/input_method_bridge.h"
35 #else 35 #else
36 #include "ui/views/ime/mock_input_method.h" 36 #include "ui/views/ime/mock_input_method.h"
37 #endif 37 #endif
38 38
39 namespace views { 39 namespace views {
40 40
41 namespace { 41 namespace {
42 42
43 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { 43 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) {
44 switch (type) { 44 switch (type) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void NativeWidgetAura::ReleaseMouseCapture() { 272 void NativeWidgetAura::ReleaseMouseCapture() {
273 window_->ReleaseCapture(); 273 window_->ReleaseCapture();
274 } 274 }
275 275
276 bool NativeWidgetAura::HasMouseCapture() const { 276 bool NativeWidgetAura::HasMouseCapture() const {
277 return window_->HasCapture(); 277 return window_->HasCapture();
278 } 278 }
279 279
280 InputMethod* NativeWidgetAura::CreateInputMethod() { 280 InputMethod* NativeWidgetAura::CreateInputMethod() {
281 #if defined(HAVE_IBUS) 281 #if defined(HAVE_IBUS)
282 InputMethod* input_method = new InputMethodIBus(this); 282 ui::InputMethod* host = aura::Desktop::GetInstance()->GetInputMethod();
283 InputMethod* input_method = new InputMethodBridge(this, host);
283 #else 284 #else
285 // Use the mock IME for unit tests.
284 InputMethod* input_method = new MockInputMethod(this); 286 InputMethod* input_method = new MockInputMethod(this);
285 #endif 287 #endif
286 input_method->Init(GetWidget()); 288 input_method->Init(GetWidget());
287 return input_method; 289 return input_method;
288 } 290 }
289 291
290 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 292 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
291 const gfx::Rect parent_bounds = window_->parent()->bounds(); 293 const gfx::Rect parent_bounds = window_->parent()->bounds();
292 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, 294 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2,
293 (parent_bounds.height() - size.height())/2, 295 (parent_bounds.height() - size.height())/2,
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 Widget* widget = GetWidget(); 567 Widget* widget = GetWidget();
566 if (widget->is_top_level()) { 568 if (widget->is_top_level()) {
567 InputMethod* input_method = widget->GetInputMethod(); 569 InputMethod* input_method = widget->GetInputMethod();
568 input_method->OnBlur(); 570 input_method->OnBlur();
569 widget->GetFocusManager()->StoreFocusedView(); 571 widget->GetFocusManager()->StoreFocusedView();
570 } 572 }
571 delegate_->OnNativeBlur(NULL); 573 delegate_->OnNativeBlur(NULL);
572 } 574 }
573 575
574 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { 576 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) {
575 // TODO(beng): Need an InputMethodAura to properly handle character events. 577 DCHECK(!event->is_char());
576 // Right now, we just skip these.
577 if (event->is_char())
578 return false;
579
580 DCHECK(window_->IsVisible()); 578 DCHECK(window_->IsVisible());
581 InputMethod* input_method = GetWidget()->GetInputMethod(); 579 InputMethod* input_method = GetWidget()->GetInputMethod();
582 DCHECK(input_method); 580 DCHECK(input_method);
583 // TODO(oshima): DispatchKeyEvent should return bool?
584 KeyEvent views_event(event); 581 KeyEvent views_event(event);
585 input_method->DispatchKeyEvent(views_event); 582 input_method->DispatchKeyEvent(views_event);
586 return true; 583 return true;
587 } 584 }
588 585
589 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { 586 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) {
590 return cursor_; 587 return cursor_;
591 } 588 }
592 589
593 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { 590 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 NOTIMPLEMENTED(); 764 NOTIMPLEMENTED();
768 } 765 }
769 766
770 // static 767 // static
771 bool NativeWidgetPrivate::IsMouseButtonDown() { 768 bool NativeWidgetPrivate::IsMouseButtonDown() {
772 return aura::Desktop::GetInstance()->IsMouseButtonDown(); 769 return aura::Desktop::GetInstance()->IsMouseButtonDown();
773 } 770 }
774 771
775 } // namespace internal 772 } // namespace internal
776 } // namespace views 773 } // namespace views
OLDNEW
« ui/aura/desktop_host_win.cc ('K') | « ui/base/keycodes/keyboard_code_conversion_x.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698