Chromium Code Reviews| 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 "views/widget/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 10 #include "ui/aura/desktop_observer.h" | 10 #include "ui/aura/desktop_observer.h" |
| 11 #include "ui/aura/event.h" | 11 #include "ui/aura/event.h" |
| 12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_types.h" | 13 #include "ui/aura/window_types.h" |
| 14 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/compositor/layer.h" | 16 #include "ui/gfx/compositor/layer.h" |
| 17 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
| 18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 #include "views/widget/native_widget_delegate.h" | 19 #include "views/widget/native_widget_delegate.h" |
| 20 #include "views/widget/tooltip_manager_views.h" | 20 #include "views/widget/tooltip_manager_views.h" |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 #include "base/win/scoped_gdi_object.h" | 23 #include "base/win/scoped_gdi_object.h" |
| 24 #include "base/win/win_util.h" | 24 #include "base/win/win_util.h" |
| 25 #include "ui/base/l10n/l10n_util_win.h" | 25 #include "ui/base/l10n/l10n_util_win.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #if defined(HAVE_IBUS) | 28 #if defined(HAVE_IBUS) |
|
James Su
2011/11/21 08:23:36
do we still need this check?
Yusuke Sato
2011/11/22 11:09:30
If we use InputMethodBridge here, views_unittests
| |
| 29 #include "ui/views/ime/input_method_ibus.h" | 29 #include "ui/views/ime/input_method_bridge.h" |
| 30 #else | 30 #else |
| 31 #include "ui/views/ime/mock_input_method.h" | 31 #include "ui/views/ime/mock_input_method.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace views { | 34 namespace views { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { | 38 aura::WindowType GetAuraWindowTypeForWidgetType(Widget::InitParams::Type type) { |
| 39 switch (type) { | 39 switch (type) { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 256 |
| 257 void NativeWidgetAura::ReleaseMouseCapture() { | 257 void NativeWidgetAura::ReleaseMouseCapture() { |
| 258 window_->ReleaseCapture(); | 258 window_->ReleaseCapture(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 bool NativeWidgetAura::HasMouseCapture() const { | 261 bool NativeWidgetAura::HasMouseCapture() const { |
| 262 return window_->HasCapture(); | 262 return window_->HasCapture(); |
| 263 } | 263 } |
| 264 | 264 |
| 265 InputMethod* NativeWidgetAura::CreateInputMethod() { | 265 InputMethod* NativeWidgetAura::CreateInputMethod() { |
| 266 #if defined(HAVE_IBUS) | 266 #if defined(HAVE_IBUS) |
|
James Su
2011/11/21 08:23:36
Do we still need this check?
Yusuke Sato
2011/11/22 11:09:30
ditto.
| |
| 267 InputMethod* input_method = new InputMethodIBus(this); | 267 ui::InputMethod* host = aura::Desktop::GetInstance()->GetInputMethod(); |
| 268 InputMethod* input_method = new InputMethodBridge(this, host); | |
| 268 #else | 269 #else |
| 270 // Use the mock IME for unit tests. | |
| 269 InputMethod* input_method = new MockInputMethod(this); | 271 InputMethod* input_method = new MockInputMethod(this); |
| 270 #endif | 272 #endif |
| 271 input_method->Init(GetWidget()); | 273 input_method->Init(GetWidget()); |
| 272 return input_method; | 274 return input_method; |
| 273 } | 275 } |
| 274 | 276 |
| 275 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 277 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
| 276 const gfx::Rect parent_bounds = window_->parent()->bounds(); | 278 const gfx::Rect parent_bounds = window_->parent()->bounds(); |
| 277 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, | 279 window_->SetBounds(gfx::Rect((parent_bounds.width() - size.width())/2, |
| 278 (parent_bounds.height() - size.height())/2, | 280 (parent_bounds.height() - size.height())/2, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 Widget* widget = GetWidget(); | 554 Widget* widget = GetWidget(); |
| 553 if (widget->is_top_level()) { | 555 if (widget->is_top_level()) { |
| 554 InputMethod* input_method = widget->GetInputMethod(); | 556 InputMethod* input_method = widget->GetInputMethod(); |
| 555 input_method->OnBlur(); | 557 input_method->OnBlur(); |
| 556 widget->GetFocusManager()->StoreFocusedView(); | 558 widget->GetFocusManager()->StoreFocusedView(); |
| 557 } | 559 } |
| 558 delegate_->OnNativeBlur(NULL); | 560 delegate_->OnNativeBlur(NULL); |
| 559 } | 561 } |
| 560 | 562 |
| 561 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { | 563 bool NativeWidgetAura::OnKeyEvent(aura::KeyEvent* event) { |
| 562 // TODO(beng): Need an InputMethodAura to properly handle character events. | 564 DCHECK(!event->is_char()); |
| 563 // Right now, we just skip these. | |
| 564 if (event->is_char()) | |
| 565 return false; | |
| 566 | |
| 567 DCHECK(window_->IsVisible()); | 565 DCHECK(window_->IsVisible()); |
| 568 InputMethod* input_method = GetWidget()->GetInputMethod(); | 566 InputMethod* input_method = GetWidget()->GetInputMethod(); |
| 569 DCHECK(input_method); | 567 DCHECK(input_method); |
| 570 // TODO(oshima): DispatchKeyEvent should return bool? | |
| 571 KeyEvent views_event(event); | 568 KeyEvent views_event(event); |
| 572 input_method->DispatchKeyEvent(views_event); | 569 input_method->DispatchKeyEvent(views_event); |
| 573 return true; | 570 return true; |
| 574 } | 571 } |
| 575 | 572 |
| 576 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { | 573 gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { |
| 577 return cursor_; | 574 return cursor_; |
| 578 } | 575 } |
| 579 | 576 |
| 580 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { | 577 int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 NOTIMPLEMENTED(); | 727 NOTIMPLEMENTED(); |
| 731 } | 728 } |
| 732 | 729 |
| 733 // static | 730 // static |
| 734 bool NativeWidgetPrivate::IsMouseButtonDown() { | 731 bool NativeWidgetPrivate::IsMouseButtonDown() { |
| 735 return aura::Desktop::GetInstance()->IsMouseButtonDown(); | 732 return aura::Desktop::GetInstance()->IsMouseButtonDown(); |
| 736 } | 733 } |
| 737 | 734 |
| 738 } // namespace internal | 735 } // namespace internal |
| 739 } // namespace views | 736 } // namespace views |
| OLD | NEW |