| 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_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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 void NativeWidgetAura::ReleaseMouseCapture() { | 285 void NativeWidgetAura::ReleaseMouseCapture() { |
| 286 window_->ReleaseCapture(); | 286 window_->ReleaseCapture(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool NativeWidgetAura::HasMouseCapture() const { | 289 bool NativeWidgetAura::HasMouseCapture() const { |
| 290 return window_->HasCapture(); | 290 return window_->HasCapture(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 InputMethod* NativeWidgetAura::CreateInputMethod() { | 293 InputMethod* NativeWidgetAura::CreateInputMethod() { |
| 294 #if defined(HAVE_IBUS) | 294 #if defined(HAVE_IBUS) |
| 295 InputMethod* input_method = new InputMethodIBus(this); | 295 ui::InputMethod* host = aura::RootWindow::GetInstance()->GetInputMethod(); |
| 296 InputMethod* input_method = new InputMethodBridge(this, host); |
| 296 #else | 297 #else |
| 298 // Use the mock IME for unit tests. |
| 297 InputMethod* input_method = new MockInputMethod(this); | 299 InputMethod* input_method = new MockInputMethod(this); |
| 298 #endif | 300 #endif |
| 299 input_method->Init(GetWidget()); | 301 input_method->Init(GetWidget()); |
| 300 return input_method; | 302 return input_method; |
| 301 } | 303 } |
| 302 | 304 |
| 303 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 305 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 304 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 306 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
| 305 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 307 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
| 306 (parent_bounds.height() - size.height())/2, | 308 (parent_bounds.height() - size.height())/2, |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 Widget* widget = GetWidget(); | 580 Widget* widget = GetWidget(); |
| 579 if (widget->is_top_level()) { | 581 if (widget->is_top_level()) { |
| 580 InputMethod* input_method = widget->GetInputMethod(); | 582 InputMethod* input_method = widget->GetInputMethod(); |
| 581 input_method->OnBlur(); | 583 input_method->OnBlur(); |
| 582 widget->GetFocusManager()->StoreFocusedView(); | 584 widget->GetFocusManager()->StoreFocusedView(); |
| 583 } | 585 } |
| 584 delegate_->OnNativeBlur(NULL); | 586 delegate_->OnNativeBlur(NULL); |
| 585 } | 587 } |
| 586 | 588 |
| 587 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 589 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
| 588 // TODO(beng): Need an InputMethodAura to properly handle character events. | 590 // TODO(yusukes): Need an ui::InputMethod to properly handle character events. |
| 589 // Right now, we just skip these. | 591 // Right now, we just skip these. |
| 590 if (event->is_char()) | 592 if (event->is_char()) |
| 591 return false; | 593 return false; |
| 592 | 594 |
| 593 DCHECK(window_->IsVisible()); | 595 DCHECK(window_->IsVisible()); |
| 594 InputMethod* input_method = GetWidget()->GetInputMethod(); | 596 InputMethod* input_method = GetWidget()->GetInputMethod(); |
| 595 DCHECK(input_method); | 597 DCHECK(input_method); |
| 596 // TODO(oshima): DispatchKeyEvent should return bool? | |
| 597 KeyEvent views_event(event); | 598 KeyEvent views_event(event); |
| 598 input_method->DispatchKeyEvent(views_event); | 599 input_method->DispatchKeyEvent(views_event); |
| 599 return true; | 600 return true; |
| 600 } | 601 } |
| 601 | 602 |
| 602 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | 603 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
| 603 return cursor_; | 604 return cursor_; |
| 604 } | 605 } |
| 605 | 606 |
| 606 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 607 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 803 } |
| 803 } | 804 } |
| 804 | 805 |
| 805 // static | 806 // static |
| 806 bool NativeWidgetPrivate::IsMouseButtonDown() { | 807 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 807 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); | 808 return aura::RootWindow::GetInstance()->IsMouseButtonDown(); |
| 808 } | 809 } |
| 809 | 810 |
| 810 } // namespace internal | 811 } // namespace internal |
| 811 } // namespace views | 812 } // namespace views |
| OLD | NEW |