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_win.h" | 5 #include "ui/views/widget/native_widget_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 } | 736 } |
737 | 737 |
738 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { | 738 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) { |
739 delegate_->OnNativeBlur(focused_window); | 739 delegate_->OnNativeBlur(focused_window); |
740 InputMethod* input_method = GetInputMethod(); | 740 InputMethod* input_method = GetInputMethod(); |
741 if (input_method) | 741 if (input_method) |
742 input_method->OnBlur(); | 742 input_method->OnBlur(); |
743 } | 743 } |
744 | 744 |
745 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { | 745 bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) { |
746 ui::MouseEvent dpi_event(event); | 746 if (event.IsMouseWheelEvent()) { |
747 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); | 747 ui::MouseWheelEvent dpi_event(event, |
748 dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location())); | 748 static_cast<const ui::MouseWheelEvent&>(event).x_offset() / |
749 delegate_->OnMouseEvent(&dpi_event); | 749 ui::win::GetDeviceScaleFactor(), |
750 return dpi_event.handled(); | 750 static_cast<const ui::MouseWheelEvent&>(event).y_offset() / |
751 ui::win::GetDeviceScaleFactor()); | |
sadrul
2013/06/24 02:09:35
Most of the ui::Events are copyable. Looks like Mo
girard
2013/06/24 20:37:07
If we do this, we'd still need the static_cast in
| |
752 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); | |
753 dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location())); | |
754 delegate_->OnMouseEvent(&dpi_event); | |
755 return dpi_event.handled(); | |
756 } else if (event.IsScrollEvent()) { | |
sadrul
2013/06/24 02:09:35
scroll events (i.e. ET_SCROLL*) are never generate
girard
2013/06/24 20:37:07
Thanks - cleaned this up. (I was trying to be more
| |
757 ui::ScrollEvent dpi_event(static_cast<const ui::ScrollEvent&>(event)); | |
758 dpi_event.Scale(1/ui::win::GetDeviceScaleFactor()); | |
759 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); | |
760 dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location())); | |
761 delegate_->OnMouseEvent(&dpi_event); | |
762 return dpi_event.handled(); | |
763 } else if (event.IsMouseEvent()) { | |
764 ui::MouseEvent dpi_event(event); | |
765 dpi_event.set_location(ui::win::ScreenToDIPPoint(event.location())); | |
766 dpi_event.set_root_location(ui::win::ScreenToDIPPoint(event.location())); | |
767 delegate_->OnMouseEvent(&dpi_event); | |
768 return dpi_event.handled(); | |
769 } | |
770 NOTREACHED(); | |
771 return false; | |
751 } | 772 } |
752 | 773 |
753 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { | 774 bool NativeWidgetWin::HandleKeyEvent(const ui::KeyEvent& event) { |
754 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); | 775 delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&event)); |
755 return event.handled(); | 776 return event.handled(); |
756 } | 777 } |
757 | 778 |
758 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { | 779 bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) { |
759 InputMethod* input_method = GetInputMethod(); | 780 InputMethod* input_method = GetInputMethod(); |
760 if (input_method) | 781 if (input_method) |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 // static | 1034 // static |
1014 bool NativeWidgetPrivate::IsTouchDown() { | 1035 bool NativeWidgetPrivate::IsTouchDown() { |
1015 // This currently isn't necessary because we're not generating touch events on | 1036 // This currently isn't necessary because we're not generating touch events on |
1016 // windows. When we do, this will need to be updated. | 1037 // windows. When we do, this will need to be updated. |
1017 return false; | 1038 return false; |
1018 } | 1039 } |
1019 | 1040 |
1020 } // namespace internal | 1041 } // namespace internal |
1021 | 1042 |
1022 } // namespace views | 1043 } // namespace views |
OLD | NEW |