| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 return DesktopRootWindowHost::GetNativeTheme(window_); | 640 return DesktopRootWindowHost::GetNativeTheme(window_); |
| 641 #endif | 641 #endif |
| 642 return ui::NativeThemeAura::instance(); | 642 return ui::NativeThemeAura::instance(); |
| 643 } | 643 } |
| 644 | 644 |
| 645 //////////////////////////////////////////////////////////////////////////////// | 645 //////////////////////////////////////////////////////////////////////////////// |
| 646 // NativeWidgetAura, views::InputMethodDelegate implementation: | 646 // NativeWidgetAura, views::InputMethodDelegate implementation: |
| 647 | 647 |
| 648 void NativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 648 void NativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
| 649 FocusManager* focus_manager = GetWidget()->GetFocusManager(); | 649 FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
| 650 if (delegate_->OnKeyEvent(key) || !focus_manager) | 650 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
| 651 if (key.handled() || !focus_manager) |
| 651 return; | 652 return; |
| 652 focus_manager->OnKeyEvent(key); | 653 focus_manager->OnKeyEvent(key); |
| 653 } | 654 } |
| 654 | 655 |
| 655 //////////////////////////////////////////////////////////////////////////////// | 656 //////////////////////////////////////////////////////////////////////////////// |
| 656 // NativeWidgetAura, aura::WindowDelegate implementation: | 657 // NativeWidgetAura, aura::WindowDelegate implementation: |
| 657 | 658 |
| 658 gfx::Size NativeWidgetAura::GetMinimumSize() const { | 659 gfx::Size NativeWidgetAura::GetMinimumSize() const { |
| 659 return delegate_->GetMinimumSize(); | 660 return delegate_->GetMinimumSize(); |
| 660 } | 661 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 scoped_refptr<ui::Texture> NativeWidgetAura::CopyTexture() { | 762 scoped_refptr<ui::Texture> NativeWidgetAura::CopyTexture() { |
| 762 // The layer we create doesn't have an external texture, so this should never | 763 // The layer we create doesn't have an external texture, so this should never |
| 763 // get invoked. | 764 // get invoked. |
| 764 NOTREACHED(); | 765 NOTREACHED(); |
| 765 return scoped_refptr<ui::Texture>(); | 766 return scoped_refptr<ui::Texture>(); |
| 766 } | 767 } |
| 767 | 768 |
| 768 //////////////////////////////////////////////////////////////////////////////// | 769 //////////////////////////////////////////////////////////////////////////////// |
| 769 // NativeWidgetAura, ui::EventHandler implementation: | 770 // NativeWidgetAura, ui::EventHandler implementation: |
| 770 | 771 |
| 771 ui::EventResult NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { | 772 void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { |
| 772 if (event->is_char()) { | 773 if (event->is_char()) { |
| 773 // If a ui::InputMethod object is attached to the root window, character | 774 // If a ui::InputMethod object is attached to the root window, character |
| 774 // events are handled inside the object and are not passed to this function. | 775 // events are handled inside the object and are not passed to this function. |
| 775 // If such object is not attached, character events might be sent (e.g. on | 776 // If such object is not attached, character events might be sent (e.g. on |
| 776 // Windows). In this case, we just skip these. | 777 // Windows). In this case, we just skip these. |
| 777 return ui::ER_UNHANDLED; | 778 return; |
| 778 } | 779 } |
| 779 // Renderer may send a key event back to us if the key event wasn't handled, | 780 // Renderer may send a key event back to us if the key event wasn't handled, |
| 780 // and the window may be invisible by that time. | 781 // and the window may be invisible by that time. |
| 781 if (!window_->IsVisible()) | 782 if (!window_->IsVisible()) |
| 782 return ui::ER_UNHANDLED; | 783 return; |
| 783 GetWidget()->GetInputMethod()->DispatchKeyEvent(*event); | 784 GetWidget()->GetInputMethod()->DispatchKeyEvent(*event); |
| 784 return ui::ER_HANDLED; | 785 event->SetHandled(); |
| 785 } | 786 } |
| 786 | 787 |
| 787 ui::EventResult NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { | 788 ui::EventResult NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
| 788 DCHECK(window_->IsVisible()); | 789 DCHECK(window_->IsVisible()); |
| 789 if (event->type() == ui::ET_MOUSEWHEEL) | 790 if (event->type() == ui::ET_MOUSEWHEEL) |
| 790 return delegate_->OnMouseEvent(*event) ? ui::ER_HANDLED : ui::ER_UNHANDLED; | 791 return delegate_->OnMouseEvent(*event) ? ui::ER_HANDLED : ui::ER_UNHANDLED; |
| 791 | 792 |
| 792 if (tooltip_manager_.get()) | 793 if (tooltip_manager_.get()) |
| 793 tooltip_manager_->UpdateTooltip(); | 794 tooltip_manager_->UpdateTooltip(); |
| 794 return delegate_->OnMouseEvent(*event) ? ui::ER_HANDLED : ui::ER_UNHANDLED; | 795 return delegate_->OnMouseEvent(*event) ? ui::ER_HANDLED : ui::ER_UNHANDLED; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 return aura::Env::GetInstance()->is_mouse_button_down(); | 1065 return aura::Env::GetInstance()->is_mouse_button_down(); |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 // static | 1068 // static |
| 1068 bool NativeWidgetPrivate::IsTouchDown() { | 1069 bool NativeWidgetPrivate::IsTouchDown() { |
| 1069 return aura::Env::GetInstance()->is_touch_down(); | 1070 return aura::Env::GetInstance()->is_touch_down(); |
| 1070 } | 1071 } |
| 1071 | 1072 |
| 1072 } // namespace internal | 1073 } // namespace internal |
| 1073 } // namespace views | 1074 } // namespace views |
| OLD | NEW |