OLD | NEW |
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 Loading... |
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 Loading... |
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 Widget* widget = GetWidget(); | 571 Widget* widget = GetWidget(); |
570 if (widget->is_top_level()) { | 572 if (widget->is_top_level()) { |
571 InputMethod* input_method = widget->GetInputMethod(); | 573 InputMethod* input_method = widget->GetInputMethod(); |
572 input_method->OnBlur(); | 574 input_method->OnBlur(); |
573 widget->GetFocusManager()->StoreFocusedView(); | 575 widget->GetFocusManager()->StoreFocusedView(); |
574 } | 576 } |
575 delegate_->OnNativeBlur(NULL); | 577 delegate_->OnNativeBlur(NULL); |
576 } | 578 } |
577 | 579 |
578 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 580 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
579 // TODO(beng): Need an InputMethodAura to properly handle character events. | 581 DCHECK(!event->is_char()); |
580 // Right now, we just skip these. | |
581 if (event->is_char()) | |
582 return false; | |
583 | |
584 DCHECK(window_->IsVisible()); | 582 DCHECK(window_->IsVisible()); |
585 InputMethod* input_method = GetWidget()->GetInputMethod(); | 583 InputMethod* input_method = GetWidget()->GetInputMethod(); |
586 DCHECK(input_method); | 584 DCHECK(input_method); |
587 // TODO(oshima): DispatchKeyEvent should return bool? | |
588 KeyEvent views_event(event); | 585 KeyEvent views_event(event); |
589 input_method->DispatchKeyEvent(views_event); | 586 input_method->DispatchKeyEvent(views_event); |
590 return true; | 587 return true; |
591 } | 588 } |
592 | 589 |
593 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | 590 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
594 return cursor_; | 591 return cursor_; |
595 } | 592 } |
596 | 593 |
597 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 594 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 NOTIMPLEMENTED(); | 776 NOTIMPLEMENTED(); |
780 } | 777 } |
781 | 778 |
782 // static | 779 // static |
783 bool NativeWidgetPrivate::IsMouseButtonDown() { | 780 bool NativeWidgetPrivate::IsMouseButtonDown() { |
784 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 781 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
785 } | 782 } |
786 | 783 |
787 } // namespace internal | 784 } // namespace internal |
788 } // namespace views | 785 } // namespace views |
OLD | NEW |