| 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/events/event.h" | 5 #include "views/events/event.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 10 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return ui::ET_MOUSEWHEEL; | 67 return ui::ET_MOUSEWHEEL; |
| 68 case WM_MOUSELEAVE: | 68 case WM_MOUSELEAVE: |
| 69 case WM_NCMOUSELEAVE: | 69 case WM_NCMOUSELEAVE: |
| 70 return ui::ET_MOUSE_EXITED; | 70 return ui::ET_MOUSE_EXITED; |
| 71 default: | 71 default: |
| 72 NOTREACHED(); | 72 NOTREACHED(); |
| 73 } | 73 } |
| 74 return ui::ET_UNKNOWN; | 74 return ui::ET_UNKNOWN; |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool IsClientMouseEvent(NativeEvent native_event) { | |
| 78 return native_event.message == WM_MOUSELEAVE || | |
| 79 native_event.message == WM_MOUSEHOVER || | |
| 80 (native_event.message >= WM_MOUSEFIRST && | |
| 81 native_event.message <= WM_MOUSELAST); | |
| 82 } | |
| 83 | |
| 84 bool IsNonClientMouseEvent(NativeEvent native_event) { | |
| 85 return native_event.message == WM_NCMOUSELEAVE || | |
| 86 native_event.message == WM_NCMOUSEHOVER || | |
| 87 (native_event.message >= WM_NCMOUSEMOVE && | |
| 88 native_event.message <= WM_NCXBUTTONDBLCLK); | |
| 89 } | |
| 90 | |
| 91 // Get views::Event flags from a native Windows message | 77 // Get views::Event flags from a native Windows message |
| 92 int EventFlagsFromNative(NativeEvent native_event) { | 78 int EventFlagsFromNative(NativeEvent native_event) { |
| 93 int flags = 0; | 79 int flags = 0; |
| 94 | 80 |
| 95 // TODO(msw): ORing the pressed/released button into the flags is _wrong_. | 81 // TODO(msw): ORing the pressed/released button into the flags is _wrong_. |
| 96 // It makes it impossible to tell which button was modified when multiple | 82 // It makes it impossible to tell which button was modified when multiple |
| 97 // buttons are/were held down. We need to instead put the modified button into | 83 // buttons are/were held down. We need to instead put the modified button into |
| 98 // a separate member on the MouseEvent, then audit all consumers of | 84 // a separate member on the MouseEvent, then audit all consumers of |
| 99 // MouseEvents to fix them to use the resulting values correctly. | 85 // MouseEvents to fix them to use the resulting values correctly. |
| 100 switch (native_event.message) { | 86 switch (native_event.message) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 flags |= (win_flags & MK_RBUTTON) ? ui::EF_RIGHT_BUTTON_DOWN : 0; | 151 flags |= (win_flags & MK_RBUTTON) ? ui::EF_RIGHT_BUTTON_DOWN : 0; |
| 166 break; | 152 break; |
| 167 } | 153 } |
| 168 } | 154 } |
| 169 | 155 |
| 170 return flags; | 156 return flags; |
| 171 } | 157 } |
| 172 | 158 |
| 173 } // namespace | 159 } // namespace |
| 174 | 160 |
| 161 bool IsClientMouseEvent(const views::NativeEvent& native_event) { |
| 162 return native_event.message == WM_MOUSELEAVE || |
| 163 native_event.message == WM_MOUSEHOVER || |
| 164 (native_event.message >= WM_MOUSEFIRST && |
| 165 native_event.message <= WM_MOUSELAST); |
| 166 } |
| 167 |
| 168 bool IsNonClientMouseEvent(const views::NativeEvent& native_event) { |
| 169 return native_event.message == WM_NCMOUSELEAVE || |
| 170 native_event.message == WM_NCMOUSEHOVER || |
| 171 (native_event.message >= WM_NCMOUSEMOVE && |
| 172 native_event.message <= WM_NCXBUTTONDBLCLK); |
| 173 } |
| 174 |
| 175 //////////////////////////////////////////////////////////////////////////////// | 175 //////////////////////////////////////////////////////////////////////////////// |
| 176 // Event, public: | 176 // Event, public: |
| 177 | 177 |
| 178 int Event::GetWindowsFlags() const { | 178 int Event::GetWindowsFlags() const { |
| 179 // TODO: need support for x1/x2. | 179 // TODO: need support for x1/x2. |
| 180 int result = 0; | 180 int result = 0; |
| 181 result |= (flags_ & ui::EF_SHIFT_DOWN) ? MK_SHIFT : 0; | 181 result |= (flags_ & ui::EF_SHIFT_DOWN) ? MK_SHIFT : 0; |
| 182 result |= (flags_ & ui::EF_CONTROL_DOWN) ? MK_CONTROL : 0; | 182 result |= (flags_ & ui::EF_CONTROL_DOWN) ? MK_CONTROL : 0; |
| 183 result |= (flags_ & ui::EF_LEFT_BUTTON_DOWN) ? MK_LBUTTON : 0; | 183 result |= (flags_ & ui::EF_LEFT_BUTTON_DOWN) ? MK_LBUTTON : 0; |
| 184 result |= (flags_ & ui::EF_MIDDLE_BUTTON_DOWN) ? MK_MBUTTON : 0; | 184 result |= (flags_ & ui::EF_MIDDLE_BUTTON_DOWN) ? MK_MBUTTON : 0; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 285 |
| 286 MouseWheelEvent::MouseWheelEvent(NativeEvent2 native_event_2, | 286 MouseWheelEvent::MouseWheelEvent(NativeEvent2 native_event_2, |
| 287 FromNativeEvent2 from_native) | 287 FromNativeEvent2 from_native) |
| 288 : MouseEvent(native_event_2, from_native) { | 288 : MouseEvent(native_event_2, from_native) { |
| 289 // No one should ever call this on Windows. | 289 // No one should ever call this on Windows. |
| 290 // TODO(msw): remove once we rid views of Gtk/Gdk. | 290 // TODO(msw): remove once we rid views of Gtk/Gdk. |
| 291 NOTREACHED(); | 291 NOTREACHED(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace views | 294 } // namespace views |
| OLD | NEW |