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/desktop_aura/desktop_root_window_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h" |
6 | 6 |
7 #include "base/win/metro.h" | 7 #include "base/win/metro.h" |
8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 const base::NativeEvent& native_event) { | 570 const base::NativeEvent& native_event) { |
571 } | 571 } |
572 | 572 |
573 void DesktopWindowTreeHostWin::OnDeviceScaleFactorChanged( | 573 void DesktopWindowTreeHostWin::OnDeviceScaleFactorChanged( |
574 float device_scale_factor) { | 574 float device_scale_factor) { |
575 } | 575 } |
576 | 576 |
577 void DesktopWindowTreeHostWin::PrepareForShutdown() { | 577 void DesktopWindowTreeHostWin::PrepareForShutdown() { |
578 } | 578 } |
579 | 579 |
| 580 |
| 581 //////////////////////////////////////////////////////////////////////////////// |
| 582 // DesktopWindowTreeHostWin, ui::EventSource implementation: |
| 583 |
| 584 ui::EventProcessor* DesktopWindowTreeHostWin::GetEventProcessor() { |
| 585 return delegate_->GetEventProcessor(); |
| 586 } |
| 587 |
580 //////////////////////////////////////////////////////////////////////////////// | 588 //////////////////////////////////////////////////////////////////////////////// |
581 // DesktopWindowTreeHostWin, aura::AnimationHost implementation: | 589 // DesktopWindowTreeHostWin, aura::AnimationHost implementation: |
582 | 590 |
583 void DesktopWindowTreeHostWin::SetHostTransitionOffsets( | 591 void DesktopWindowTreeHostWin::SetHostTransitionOffsets( |
584 const gfx::Vector2d& top_left_delta, | 592 const gfx::Vector2d& top_left_delta, |
585 const gfx::Vector2d& bottom_right_delta) { | 593 const gfx::Vector2d& bottom_right_delta) { |
586 gfx::Rect bounds_without_expansion = GetBounds(); | 594 gfx::Rect bounds_without_expansion = GetBounds(); |
587 window_expansion_top_left_delta_ = top_left_delta; | 595 window_expansion_top_left_delta_ = top_left_delta; |
588 window_expansion_bottom_right_delta_ = bottom_right_delta; | 596 window_expansion_bottom_right_delta_ = bottom_right_delta; |
589 SetBounds(bounds_without_expansion); | 597 SetBounds(bounds_without_expansion); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 } | 847 } |
840 | 848 |
841 void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) { | 849 void DesktopWindowTreeHostWin::HandleNativeBlur(HWND focused_window) { |
842 // TODO(beng): inform the native_widget_delegate_. | 850 // TODO(beng): inform the native_widget_delegate_. |
843 InputMethod* input_method = GetInputMethod(); | 851 InputMethod* input_method = GetInputMethod(); |
844 if (input_method) | 852 if (input_method) |
845 input_method->OnBlur(); | 853 input_method->OnBlur(); |
846 } | 854 } |
847 | 855 |
848 bool DesktopWindowTreeHostWin::HandleMouseEvent(const ui::MouseEvent& event) { | 856 bool DesktopWindowTreeHostWin::HandleMouseEvent(const ui::MouseEvent& event) { |
849 return delegate_->OnHostMouseEvent(const_cast<ui::MouseEvent*>(&event)); | 857 SendEventToProcessor(const_cast<ui::MouseEvent*>(&event)); |
| 858 return event.handled(); |
850 } | 859 } |
851 | 860 |
852 bool DesktopWindowTreeHostWin::HandleKeyEvent(const ui::KeyEvent& event) { | 861 bool DesktopWindowTreeHostWin::HandleKeyEvent(const ui::KeyEvent& event) { |
853 return false; | 862 return false; |
854 } | 863 } |
855 | 864 |
856 bool DesktopWindowTreeHostWin::HandleUntranslatedKeyEvent( | 865 bool DesktopWindowTreeHostWin::HandleUntranslatedKeyEvent( |
857 const ui::KeyEvent& event) { | 866 const ui::KeyEvent& event) { |
858 ui::KeyEvent duplicate_event(event); | 867 ui::KeyEvent duplicate_event(event); |
859 return delegate_->OnHostKeyEvent(&duplicate_event); | 868 SendEventToProcessor(&duplicate_event); |
| 869 return duplicate_event.handled(); |
860 } | 870 } |
861 | 871 |
862 void DesktopWindowTreeHostWin::HandleTouchEvent( | 872 void DesktopWindowTreeHostWin::HandleTouchEvent( |
863 const ui::TouchEvent& event) { | 873 const ui::TouchEvent& event) { |
864 // HWNDMessageHandler asynchronously processes touch events. Because of this | 874 // HWNDMessageHandler asynchronously processes touch events. Because of this |
865 // it's possible for the aura::RootWindow to have been destroyed by the time | 875 // it's possible for the aura::RootWindow to have been destroyed by the time |
866 // we attempt to process them. | 876 // we attempt to process them. |
867 if (!GetWidget()->GetNativeView()) | 877 if (!GetWidget()->GetNativeView()) |
868 return; | 878 return; |
869 | 879 |
870 // Currently we assume the window that has capture gets touch events too. | 880 // Currently we assume the window that has capture gets touch events too. |
871 aura::RootWindow* root = | 881 aura::RootWindow* root = |
872 aura::RootWindow::GetForAcceleratedWidget(GetCapture()); | 882 aura::RootWindow::GetForAcceleratedWidget(GetCapture()); |
873 if (root) { | 883 if (root) { |
874 DesktopWindowTreeHostWin* target = | 884 DesktopWindowTreeHostWin* target = |
875 root->window()->GetProperty(kDesktopWindowTreeHostKey); | 885 root->window()->GetProperty(kDesktopWindowTreeHostKey); |
876 if (target && target->HasCapture() && target != this) { | 886 if (target && target->HasCapture() && target != this) { |
877 POINT target_location(event.location().ToPOINT()); | 887 POINT target_location(event.location().ToPOINT()); |
878 ClientToScreen(GetHWND(), &target_location); | 888 ClientToScreen(GetHWND(), &target_location); |
879 ScreenToClient(target->GetHWND(), &target_location); | 889 ScreenToClient(target->GetHWND(), &target_location); |
880 ui::TouchEvent target_event(event, static_cast<View*>(NULL), | 890 ui::TouchEvent target_event(event, static_cast<View*>(NULL), |
881 static_cast<View*>(NULL)); | 891 static_cast<View*>(NULL)); |
882 target_event.set_location(gfx::Point(target_location)); | 892 target_event.set_location(gfx::Point(target_location)); |
883 target_event.set_root_location(target_event.location()); | 893 target_event.set_root_location(target_event.location()); |
884 target->delegate_->OnHostTouchEvent(&target_event); | 894 target->SendEventToProcessor(&target_event); |
885 return; | 895 return; |
886 } | 896 } |
887 } | 897 } |
888 delegate_->OnHostTouchEvent( | 898 SendEventToProcessor(const_cast<ui::TouchEvent*>(&event)); |
889 const_cast<ui::TouchEvent*>(&event)); | |
890 } | 899 } |
891 | 900 |
892 bool DesktopWindowTreeHostWin::HandleIMEMessage(UINT message, | 901 bool DesktopWindowTreeHostWin::HandleIMEMessage(UINT message, |
893 WPARAM w_param, | 902 WPARAM w_param, |
894 LPARAM l_param, | 903 LPARAM l_param, |
895 LRESULT* result) { | 904 LRESULT* result) { |
896 MSG msg = {}; | 905 MSG msg = {}; |
897 msg.hwnd = GetHWND(); | 906 msg.hwnd = GetHWND(); |
898 msg.message = message; | 907 msg.message = message; |
899 msg.wParam = w_param; | 908 msg.wParam = w_param; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 return false; | 956 return false; |
948 } | 957 } |
949 | 958 |
950 void DesktopWindowTreeHostWin::PostHandleMSG(UINT message, | 959 void DesktopWindowTreeHostWin::PostHandleMSG(UINT message, |
951 WPARAM w_param, | 960 WPARAM w_param, |
952 LPARAM l_param) { | 961 LPARAM l_param) { |
953 } | 962 } |
954 | 963 |
955 bool DesktopWindowTreeHostWin::HandleScrollEvent( | 964 bool DesktopWindowTreeHostWin::HandleScrollEvent( |
956 const ui::ScrollEvent& event) { | 965 const ui::ScrollEvent& event) { |
957 return delegate_->OnHostScrollEvent(const_cast<ui::ScrollEvent*>(&event)); | 966 SendEventToProcessor(const_cast<ui::ScrollEvent*>(&event)); |
| 967 return event.handled(); |
958 } | 968 } |
959 | 969 |
960 //////////////////////////////////////////////////////////////////////////////// | 970 //////////////////////////////////////////////////////////////////////////////// |
961 // DesktopWindowTreeHostWin, private: | 971 // DesktopWindowTreeHostWin, private: |
962 | 972 |
963 Widget* DesktopWindowTreeHostWin::GetWidget() { | 973 Widget* DesktopWindowTreeHostWin::GetWidget() { |
964 return native_widget_delegate_->AsWidget(); | 974 return native_widget_delegate_->AsWidget(); |
965 } | 975 } |
966 | 976 |
967 const Widget* DesktopWindowTreeHostWin::GetWidget() const { | 977 const Widget* DesktopWindowTreeHostWin::GetWidget() const { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 | 1012 |
1003 // static | 1013 // static |
1004 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 1014 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
1005 internal::NativeWidgetDelegate* native_widget_delegate, | 1015 internal::NativeWidgetDelegate* native_widget_delegate, |
1006 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 1016 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
1007 return new DesktopWindowTreeHostWin(native_widget_delegate, | 1017 return new DesktopWindowTreeHostWin(native_widget_delegate, |
1008 desktop_native_widget_aura); | 1018 desktop_native_widget_aura); |
1009 } | 1019 } |
1010 | 1020 |
1011 } // namespace views | 1021 } // namespace views |
OLD | NEW |