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

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: rebase, 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
« ui/aura/event.h ('K') | « ui/views/ime/input_method_bridge.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/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/client/drag_drop_client.h" 11 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/client/shadow_types.h" 12 #include "ui/aura/client/shadow_types.h"
13 #include "ui/aura/event.h" 13 #include "ui/aura/event.h"
14 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/aura/window_observer.h" 16 #include "ui/aura/window_observer.h"
17 #include "ui/aura/window_types.h" 17 #include "ui/aura/window_types.h"
18 #include "ui/base/dragdrop/os_exchange_data.h" 18 #include "ui/base/dragdrop/os_exchange_data.h"
19 #include "ui/base/ui_base_types.h" 19 #include "ui/base/ui_base_types.h"
20 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/compositor/layer.h" 21 #include "ui/gfx/compositor/layer.h"
22 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
23 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
24 #include "ui/views/ime/input_method_bridge.h"
24 #include "ui/views/widget/drop_helper.h" 25 #include "ui/views/widget/drop_helper.h"
25 #include "ui/views/widget/native_widget_delegate.h" 26 #include "ui/views/widget/native_widget_delegate.h"
26 #include "ui/views/widget/tooltip_manager_aura.h" 27 #include "ui/views/widget/tooltip_manager_aura.h"
27 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
28 29
29 #if defined(OS_WIN) 30 #if defined(OS_WIN)
30 #include "base/win/scoped_gdi_object.h" 31 #include "base/win/scoped_gdi_object.h"
31 #include "base/win/win_util.h" 32 #include "base/win/win_util.h"
32 #include "ui/base/l10n/l10n_util_win.h" 33 #include "ui/base/l10n/l10n_util_win.h"
33 #endif 34 #endif
34 35
35 #if defined(HAVE_IBUS)
36 #include "ui/views/ime/input_method_ibus.h"
37 #else
38 #include "ui/views/ime/mock_input_method.h"
39 #endif
40
41 namespace views { 36 namespace views {
42 37
43 namespace { 38 namespace {
44 39
45 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { 40 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) {
46 switch (type) { 41 switch (type) {
47 case Widget::InitParams::TYPE_WINDOW: 42 case Widget::InitParams::TYPE_WINDOW:
48 return aura::WINDOW_TYPE_NORMAL; 43 return aura::WINDOW_TYPE_NORMAL;
49 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: 44 case Widget::InitParams::TYPE_WINDOW_FRAMELESS:
50 case Widget::InitParams::TYPE_CONTROL: 45 case Widget::InitParams::TYPE_CONTROL:
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 288
294 void NativeWidgetAura::ReleaseMouseCapture() { 289 void NativeWidgetAura::ReleaseMouseCapture() {
295 window_->ReleaseCapture(); 290 window_->ReleaseCapture();
296 } 291 }
297 292
298 bool NativeWidgetAura::HasMouseCapture() const { 293 bool NativeWidgetAura::HasMouseCapture() const {
299 return window_->HasCapture(); 294 return window_->HasCapture();
300 } 295 }
301 296
302 InputMethod* NativeWidgetAura::CreateInputMethod() { 297 InputMethod* NativeWidgetAura::CreateInputMethod() {
303 #if defined(HAVE_IBUS) 298 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
304 InputMethod* input_method = new InputMethodIBus(this); 299 ui::InputMethod* host = reinterpret_cast<ui::InputMethod*>(
305 #else 300 root_window->GetProperty(aura::kRootWindowInputMethod));
306 InputMethod* input_method = new MockInputMethod(this); 301 InputMethod* input_method = new InputMethodBridge(this, host);
307 #endif
308 input_method->Init(GetWidget()); 302 input_method->Init(GetWidget());
309 return input_method; 303 return input_method;
310 } 304 }
311 305
312 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { 306 void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
313 const gfx::Rect parent_bounds = window_->parent()->bounds(); 307 const gfx::Rect parent_bounds = window_->parent()->bounds();
314 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, 308 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2,
315 (parent_bounds.height() - size.height())/2, 309 (parent_bounds.height() - size.height())/2,
316 size.width(), 310 size.width(),
317 size.height())); 311 size.height()));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 void NativeWidgetAura::OnBlur() { 613 void NativeWidgetAura::OnBlur() {
620 Widget* widget = GetWidget(); 614 Widget* widget = GetWidget();
621 if (widget->is_top_level()) { 615 if (widget->is_top_level()) {
622 InputMethod* input_method = widget->GetInputMethod(); 616 InputMethod* input_method = widget->GetInputMethod();
623 input_method->OnBlur(); 617 input_method->OnBlur();
624 } 618 }
625 delegate_->OnNativeBlur(NULL); 619 delegate_->OnNativeBlur(NULL);
626 } 620 }
627 621
628 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { 622 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) {
629 // TODO(beng): Need an InputMethodAura to properly handle character events. 623 // TODO(yusukes): Need an ui::InputMethod to properly handle character events.
630 // Right now, we just skip these. 624 // Right now, we just skip these.
631 if (event->is_char()) 625 if (event->is_char())
632 return false; 626 return false;
633 627
634 DCHECK(window_->IsVisible()); 628 DCHECK(window_->IsVisible());
635 InputMethod* input_method = GetWidget()->GetInputMethod(); 629 InputMethod* input_method = GetWidget()->GetInputMethod();
636 DCHECK(input_method); 630 DCHECK(input_method);
637 // TODO(oshima): DispatchKeyEvent should return bool?
638 KeyEvent views_event(event); 631 KeyEvent views_event(event);
639 input_method->DispatchKeyEvent(views_event); 632 input_method->DispatchKeyEvent(views_event);
640 return true; 633 return true;
641 } 634 }
642 635
643 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { 636 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) {
644 return cursor_; 637 return cursor_;
645 } 638 }
646 639
647 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { 640 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 844 }
852 } 845 }
853 846
854 // static 847 // static
855 bool NativeWidgetPrivate::IsMouseButtonDown() { 848 bool NativeWidgetPrivate::IsMouseButtonDown() {
856 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); 849 return aura::RootWindow::GetInstance()->IsMouseButtonDown();
857 } 850 }
858 851
859 } // namespace internal 852 } // namespace internal
860 } // namespace views 853 } // namespace views
OLDNEW
« ui/aura/event.h ('K') | « ui/views/ime/input_method_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698