| 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 14 matching lines...) Expand all Loading... |
| 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_bridge.h" | 35 #include "ui/views/ime/input_method_ibus.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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 void NativeWidgetAura::ReleaseMouseCapture() { | 271 void NativeWidgetAura::ReleaseMouseCapture() { |
| 272 window_->ReleaseCapture(); | 272 window_->ReleaseCapture(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 bool NativeWidgetAura::HasMouseCapture() const { | 275 bool NativeWidgetAura::HasMouseCapture() const { |
| 276 return window_->HasCapture(); | 276 return window_->HasCapture(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 InputMethod* NativeWidgetAura::CreateInputMethod() { | 279 InputMethod* NativeWidgetAura::CreateInputMethod() { |
| 280 #if defined(HAVE_IBUS) | 280 #if defined(HAVE_IBUS) |
| 281 ui::InputMethod* host = aura::Desktop::GetInstance()->GetInputMethod(); | 281 InputMethod* input_method = new InputMethodIBus(this); |
| 282 InputMethod* input_method = new InputMethodBridge(this, host); | |
| 283 #else | 282 #else |
| 284 // Use the mock IME for unit tests. | |
| 285 InputMethod* input_method = new MockInputMethod(this); | 283 InputMethod* input_method = new MockInputMethod(this); |
| 286 #endif | 284 #endif |
| 287 input_method->Init(GetWidget()); | 285 input_method->Init(GetWidget()); |
| 288 return input_method; | 286 return input_method; |
| 289 } | 287 } |
| 290 | 288 |
| 291 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 289 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 292 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 290 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
| 293 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 291 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
| 294 (parent_bounds.height() - size.height())/2, | 292 (parent_bounds.height() - size.height())/2, |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 Widget* widget = GetWidget(); | 564 Widget* widget = GetWidget(); |
| 567 if (widget->is_top_level()) { | 565 if (widget->is_top_level()) { |
| 568 InputMethod* input_method = widget->GetInputMethod(); | 566 InputMethod* input_method = widget->GetInputMethod(); |
| 569 input_method->OnBlur(); | 567 input_method->OnBlur(); |
| 570 widget->GetFocusManager()->StoreFocusedView(); | 568 widget->GetFocusManager()->StoreFocusedView(); |
| 571 } | 569 } |
| 572 delegate_->OnNativeBlur(NULL); | 570 delegate_->OnNativeBlur(NULL); |
| 573 } | 571 } |
| 574 | 572 |
| 575 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 573 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
| 576 // TODO(yusukes): Need an ui::InputMethod to properly handle character events. | 574 // TODO(beng): Need an InputMethodAura to properly handle character events. |
| 577 // Right now, we just skip these. | 575 // Right now, we just skip these. |
| 578 if (event->is_char()) | 576 if (event->is_char()) |
| 579 return false; | 577 return false; |
| 580 | 578 |
| 581 DCHECK(window_->IsVisible()); | 579 DCHECK(window_->IsVisible()); |
| 582 InputMethod* input_method = GetWidget()->GetInputMethod(); | 580 InputMethod* input_method = GetWidget()->GetInputMethod(); |
| 583 DCHECK(input_method); | 581 DCHECK(input_method); |
| 582 // TODO(oshima): DispatchKeyEvent should return bool? |
| 584 KeyEvent views_event(event); | 583 KeyEvent views_event(event); |
| 585 input_method->DispatchKeyEvent(views_event); | 584 input_method->DispatchKeyEvent(views_event); |
| 586 return true; | 585 return true; |
| 587 } | 586 } |
| 588 | 587 |
| 589 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | 588 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
| 590 return cursor_; | 589 return cursor_; |
| 591 } | 590 } |
| 592 | 591 |
| 593 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 592 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 } | 789 } |
| 791 } | 790 } |
| 792 | 791 |
| 793 // static | 792 // static |
| 794 bool NativeWidgetPrivate::IsMouseButtonDown() { | 793 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 795 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 794 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
| 796 } | 795 } |
| 797 | 796 |
| 798 } // namespace internal | 797 } // namespace internal |
| 799 } // namespace views | 798 } // namespace views |
| OLD | NEW |