diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-02 21:35:48 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-02 21:35:48 +0000 |
commit | 9a6ee3bc91dbb302c73f2355236466cacfeb604f (patch) | |
tree | f5c15b3cd852ef5f0735ec825d34dd767cda9994 | |
parent | 9833514789f079b3d8353ce2cf43ec64e4e92b69 (diff) | |
download | chromium_src-9a6ee3bc91dbb302c73f2355236466cacfeb604f.zip chromium_src-9a6ee3bc91dbb302c73f2355236466cacfeb604f.tar.gz chromium_src-9a6ee3bc91dbb302c73f2355236466cacfeb604f.tar.bz2 |
Remove RootView::ConvertPointToMouseHandler.
The function does not seem to do what it claims to do, and it does not seem to
be actually necessary at all. Remove some other unused event constructors.
BUG=chromium-os:14715
TEST=none
Review URL: http://codereview.chromium.org/6883293
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83795 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/events/event.cc | 24 | ||||
-rw-r--r-- | views/events/event.h | 21 | ||||
-rw-r--r-- | views/events/event_x.cc | 12 | ||||
-rw-r--r-- | views/widget/root_view.cc | 28 | ||||
-rw-r--r-- | views/widget/root_view.h | 9 |
5 files changed, 12 insertions, 82 deletions
diff --git a/views/events/event.cc b/views/events/event.cc index ac3bd2a..3247087 100644 --- a/views/events/event.cc +++ b/views/events/event.cc @@ -172,15 +172,6 @@ uint16 KeyEvent::GetCharacterFromKeyCode(ui::KeyboardCode key_code, int flags) { //////////////////////////////////////////////////////////////////////////////// // MouseEvent, public: -// TODO(msw): Kill this legacy constructor when we update uses. -MouseEvent::MouseEvent(ui::EventType type, - View* source, - View* target, - const gfx::Point &l, - int flags) - : LocatedEvent(MouseEvent(type, l.x(), l.y(), flags), source, target) { -} - MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) : LocatedEvent(model, source, target) { } @@ -189,21 +180,6 @@ MouseEvent::MouseEvent(const MouseEvent& model, View* source, View* target) // TouchEvent, public: #if defined(TOUCH_UI) -TouchEvent::TouchEvent(ui::EventType type, - int x, - int y, - int flags, - int touch_id, - float radius, - float angle, - float ratio) - : LocatedEvent(type, gfx::Point(x, y), flags), - touch_id_(touch_id), - radius_(radius), - angle_(angle), - ratio_(ratio) { -} - TouchEvent::TouchEvent(const TouchEvent& model, View* source, View* target) : LocatedEvent(model, source, target), touch_id_(model.touch_id_), diff --git a/views/events/event.h b/views/events/event.h index 12e2e2f..7b67310 100644 --- a/views/events/event.h +++ b/views/events/event.h @@ -99,6 +99,7 @@ class Event { Event(const Event& model) : native_event_(model.native_event()), + native_event_2_(model.native_event_2()), type_(model.type()), time_stamp_(model.time_stamp()), flags_(model.flags()) { @@ -176,16 +177,6 @@ class MouseEvent : public LocatedEvent { : LocatedEvent(type, gfx::Point(x, y), flags) { } - // TODO(msw): Kill this legacy constructor when we update uses. - // Create a new mouse event from a type and a point. If source / target views - // are provided, the point will be converted from |source| coordinate system - // to |target| coordinate system. - MouseEvent(ui::EventType type, - View* source, - View* target, - const gfx::Point &l, - int flags); - // Conveniences to quickly test what button is down bool IsOnlyLeftMouseButton() const { return (flags() & ui::EF_LEFT_BUTTON_DOWN) && @@ -239,16 +230,6 @@ class TouchEvent : public LocatedEvent { public: TouchEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native); - // Create a new touch event. - TouchEvent(ui::EventType type, - int x, - int y, - int flags, - int touch_id, - float radius, - float angle, - float ratio); - // Create a new TouchEvent which is identical to the provided model. // If source / target views are provided, the model location will be converted // from |source| coordinate system to |target| coordinate system. diff --git a/views/events/event_x.cc b/views/events/event_x.cc index 65a1281..5441282 100644 --- a/views/events/event_x.cc +++ b/views/events/event_x.cc @@ -137,6 +137,8 @@ ui::EventType EventTypeFromNative(NativeEvent2 native_event) { case GenericEvent: { XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(native_event->xcookie.data); + if (TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid)) + return GetTouchEventType(native_event); switch (xievent->evtype) { case XI_ButtonPress: return (xievent->detail == 4 || xievent->detail == 5) ? @@ -189,7 +191,7 @@ gfx::Point GetEventLocation(XEvent* xev) { return gfx::Point(); } -int GetLocatedEventFlags(XEvent* xev, bool touch) { +int GetLocatedEventFlags(XEvent* xev) { switch (xev->type) { case ButtonPress: case ButtonRelease: @@ -202,6 +204,8 @@ int GetLocatedEventFlags(XEvent* xev, bool touch) { #if defined(HAVE_XINPUT2) case GenericEvent: { XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data); + bool touch = + TouchFactory::GetInstance()->IsTouchDevice(xievent->sourceid); switch (xievent->evtype) { case XI_ButtonPress: case XI_ButtonRelease: @@ -298,7 +302,7 @@ LocatedEvent::LocatedEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native) : Event(native_event_2, EventTypeFromNative(native_event_2), - GetLocatedEventFlags(native_event_2, false), + GetLocatedEventFlags(native_event_2), from_native), location_(GetEventLocation(native_event_2)) { } @@ -368,9 +372,7 @@ MouseWheelEvent::MouseWheelEvent(NativeEvent2 native_event_2, #if defined(HAVE_XINPUT2) TouchEvent::TouchEvent(NativeEvent2 native_event_2, FromNativeEvent2 from_native) - : LocatedEvent(GetTouchEventType(native_event_2), - GetEventLocation(native_event_2), - GetLocatedEventFlags(native_event_2, true)), + : LocatedEvent(native_event_2, from_native), touch_id_(GetTouchIDFromXEvent(native_event_2)), radius_(GetTouchRadiusFromXEvent(native_event_2)), angle_(GetTouchAngleFromXEvent(native_event_2)), diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc index cd9761d..029a84b 100644 --- a/views/widget/root_view.cc +++ b/views/widget/root_view.cc @@ -244,9 +244,7 @@ bool RootView::OnMouseDragged(const MouseEvent& event) { if (mouse_pressed_handler_) { SetMouseLocationAndFlags(e); - gfx::Point p; - ConvertPointToMouseHandler(e.location(), &p); - MouseEvent mouse_event(e.type(), p.x(), p.y(), e.flags()); + MouseEvent mouse_event(e, this, mouse_pressed_handler_); return mouse_pressed_handler_->ProcessMouseDragged(mouse_event, &drag_info); } return false; @@ -257,9 +255,7 @@ void RootView::OnMouseReleased(const MouseEvent& event) { UpdateCursor(e); if (mouse_pressed_handler_) { - gfx::Point p; - ConvertPointToMouseHandler(e.location(), &p); - MouseEvent mouse_released(e.type(), p.x(), p.y(), e.flags()); + MouseEvent mouse_released(e, this, mouse_pressed_handler_); // We allow the view to delete us from ProcessMouseReleased. As such, // configure state such that we're done first, then call View. View* mouse_pressed_handler = mouse_pressed_handler_; @@ -392,7 +388,7 @@ View::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) { #endif void RootView::SetMouseHandler(View *new_mh) { - // If we're clearing the mouse handler, clear explicit_mouse_handler as well. + // If we're clearing the mouse handler, clear explicit_mouse_handler_ as well. explicit_mouse_handler_ = (new_mh != NULL); mouse_pressed_handler_ = new_mh; } @@ -441,24 +437,6 @@ void RootView::OnPaint(gfx::Canvas* canvas) { //////////////////////////////////////////////////////////////////////////////// // RootView, private: -// Coordinate conversion ------------------------------------------------------- - -bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point* p) { - // If the mouse_handler was set explicitly, keep sending events even if it was - // re-parented in a different window. (a non explicit mouse handler is - // automatically cleared when the control is removed from the hierarchy) - *p = l; - if (explicit_mouse_handler_) { - // If the mouse_pressed_handler_ is not connected, we send the - // event in screen coordinate system - ConvertPointToScreen(this, p); - if (mouse_pressed_handler_->GetWidget()) - ConvertPointToView(NULL, mouse_pressed_handler_, p); - } else - ConvertPointToView(this, mouse_pressed_handler_, p); - return true; -} - // Input ----------------------------------------------------------------------- void RootView::UpdateCursor(const MouseEvent& event) { diff --git a/views/widget/root_view.h b/views/widget/root_view.h index 11541d2..8660d4e 100644 --- a/views/widget/root_view.h +++ b/views/widget/root_view.h @@ -134,13 +134,6 @@ class RootView : public View, friend class GestureManager; #endif - // Coordinate conversion ----------------------------------------------------- - - // Convert a point to our current mouse handler. Returns false if the - // mouse handler is not connected to a Widget. In that case, the - // conversion cannot take place and |p| is unchanged - bool ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point* p); - // Input --------------------------------------------------------------------- // Update the cursor given a mouse event. This is called by non mouse_move @@ -174,7 +167,7 @@ class RootView : public View, // a double-click lands on the same view as its single-click part. View* last_click_handler_; - // true if mouse_handler_ has been explicitly set + // true if mouse_pressed_handler_ has been explicitly set bool explicit_mouse_handler_; // Last position/flag of a mouse press/drag. Used if capture stops and we need |