Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: views/events/event_win.cc

Issue 6591120: Update MouseEvent (initial pass). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update MouseEvent (initial pass). Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: views/events/event_win.cc
diff --git a/views/events/event_win.cc b/views/events/event_win.cc
index b79f83907d5cc67123bb39c6ecc6fdbf0d9058ef..33cccf3a387c97c0a642e9d5c16c68e8bbc114fd 100644
--- a/views/events/event_win.cc
+++ b/views/events/event_win.cc
@@ -71,10 +71,74 @@ ui::EventType EventTypeFromNative(NativeEvent native_event) {
return ui::ET_UNKNOWN;
}
+// Get views::Event flags from a native Windows message
int GetFlagsFromNative(NativeEvent native_event) {
- // Allow other applicable messages as necessary.
- DCHECK(native_event.message == WM_MOUSEWHEEL);
- return Event::ConvertWindowsFlags(GET_KEYSTATE_WPARAM(native_event.wParam));
+ UINT win_flags = GET_KEYSTATE_WPARAM(native_event.wParam);
+
+ // TODO(msw): ORing the pressed/released button into the flags is _wrong_.
+ // It makes it impossible to tell which button was modified when multiple
+ // buttons are/were held down. We need to instead put the modified button into
+ // a separate member on the MouseEvent, then audit all consumers of
+ // MouseEvents to fix them to use the resulting values correctly.
+ //
+ // TODO(msw): Should I skip WM_NC*BUTTONUP, as WidgetWin::OnNC*ButtonUp did?
+ switch (native_event.message) {
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ win_flags |= MK_LBUTTON;
+ break;
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_NCMBUTTONDBLCLK:
+ case WM_NCMBUTTONDOWN:
+ case WM_NCMBUTTONUP:
+ win_flags |= MK_MBUTTON;
+ break;
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_NCRBUTTONDBLCLK:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCRBUTTONUP:
+ win_flags |= MK_RBUTTON;
+ break;
+ }
+
+ int flags = 0;
+ flags |= (win_flags & MK_CONTROL) ? ui::EF_CONTROL_DOWN : 0;
+ flags |= (win_flags & MK_SHIFT) ? ui::EF_SHIFT_DOWN : 0;
+ flags |= (GetKeyState(VK_MENU) < 0) ? ui::EF_ALT_DOWN : 0;
+ flags |= (win_flags & MK_LBUTTON) ? ui::EF_LEFT_BUTTON_DOWN : 0;
+ flags |= (win_flags & MK_MBUTTON) ? ui::EF_MIDDLE_BUTTON_DOWN : 0;
+ flags |= (win_flags & MK_RBUTTON) ? ui::EF_RIGHT_BUTTON_DOWN : 0;
+
+ switch (native_event.message) {
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ flags |= ui::EF_IS_DOUBLE_CLICK;
+ break;
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ case WM_NCMBUTTONDOWN:
+ case WM_NCMBUTTONUP:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCRBUTTONUP:
+ flags |= ui::EF_IS_NON_CLIENT;
+ break;
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCMBUTTONDBLCLK:
+ case WM_NCRBUTTONDBLCLK:
+ flags |= ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_NON_CLIENT;
+ break;
+ }
+
+ return flags;
}
} // namespace
@@ -93,24 +157,6 @@ int Event::GetWindowsFlags() const {
return result;
}
-//static
-int Event::ConvertWindowsFlags(UINT win_flags) {
- int r = 0;
- if (win_flags & MK_CONTROL)
- r |= ui::EF_CONTROL_DOWN;
- if (win_flags & MK_SHIFT)
- r |= ui::EF_SHIFT_DOWN;
- if (GetKeyState(VK_MENU) < 0)
- r |= ui::EF_ALT_DOWN;
- if (win_flags & MK_LBUTTON)
- r |= ui::EF_LEFT_BUTTON_DOWN;
- if (win_flags & MK_MBUTTON)
- r |= ui::EF_MIDDLE_BUTTON_DOWN;
- if (win_flags & MK_RBUTTON)
- r |= ui::EF_RIGHT_BUTTON_DOWN;
- return r;
-}
-
////////////////////////////////////////////////////////////////////////////////
// Event, private:

Powered by Google App Engine
This is Rietveld 408576698