summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 22:09:17 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 22:09:17 +0000
commit6a4056bb3ffa8a28d31c9a9e2dc6d681466f4a37 (patch)
tree37d8348008b4dd11ca7a405a7d88268b55899db5 /views
parentba164c912c0c30dc432d9385b92266a5f732f538 (diff)
downloadchromium_src-6a4056bb3ffa8a28d31c9a9e2dc6d681466f4a37.zip
chromium_src-6a4056bb3ffa8a28d31c9a9e2dc6d681466f4a37.tar.gz
chromium_src-6a4056bb3ffa8a28d31c9a9e2dc6d681466f4a37.tar.bz2
Add NativeWidgetDelegate::OnTouchEvent and move views::View::TouchStatus to ui::TouchStatus.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7147005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89079 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/focus/accelerator_handler_touch.cc3
-rw-r--r--views/touchui/gesture_manager.cc4
-rw-r--r--views/touchui/gesture_manager.h6
-rw-r--r--views/view.cc6
-rw-r--r--views/view.h24
-rw-r--r--views/view_unittest.cc28
-rw-r--r--views/widget/native_widget_delegate.h9
-rw-r--r--views/widget/native_widget_view.cc7
-rw-r--r--views/widget/native_widget_view.h8
-rw-r--r--views/widget/root_view.cc18
-rw-r--r--views/widget/root_view.h8
-rw-r--r--views/widget/widget.cc7
-rw-r--r--views/widget/widget.h6
13 files changed, 77 insertions, 57 deletions
diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc
index 23862d4..9edf516 100644
--- a/views/focus/accelerator_handler_touch.cc
+++ b/views/focus/accelerator_handler_touch.cc
@@ -80,8 +80,7 @@ bool DispatchX2Event(Widget* widget, XEvent* xev) {
// If the TouchEvent is processed by |root|, then return. Otherwise let
// it fall through so it can be used as a MouseEvent, if desired.
TouchEvent touch(xev, from_native);
- View* root = widget->GetRootView();
- if (root->OnTouchEvent(touch) != views::View::TOUCH_STATUS_UNKNOWN)
+ if (widget->OnTouchEvent(touch) != ui::TOUCH_STATUS_UNKNOWN)
return true;
// We do not want to generate a mouse event for an unprocessed touch
diff --git a/views/touchui/gesture_manager.cc b/views/touchui/gesture_manager.cc
index b1d17c8..3f70f30 100644
--- a/views/touchui/gesture_manager.cc
+++ b/views/touchui/gesture_manager.cc
@@ -23,8 +23,8 @@ GestureManager* GestureManager::GetInstance() {
bool GestureManager::ProcessTouchEventForGesture(const TouchEvent& event,
View* source,
- View::TouchStatus status) {
- if (status != View::TOUCH_STATUS_UNKNOWN)
+ ui::TouchStatus status) {
+ if (status != ui::TOUCH_STATUS_UNKNOWN)
return false; // The event was consumed by a touch sequence.
// TODO(rjkroege): A realistic version of the GestureManager will
diff --git a/views/touchui/gesture_manager.h b/views/touchui/gesture_manager.h
index ddd3803..40d487f 100644
--- a/views/touchui/gesture_manager.h
+++ b/views/touchui/gesture_manager.h
@@ -9,6 +9,10 @@
#include "base/memory/singleton.h"
#include "views/view.h"
+namespace ui {
+enum TouchStatus;
+}
+
namespace views {
class TouchEvent;
@@ -33,7 +37,7 @@ class GestureManager {
// Returns true if the event resulted in firing a synthetic event.
virtual bool ProcessTouchEventForGesture(const TouchEvent& event,
View* source,
- View::TouchStatus status);
+ ui::TouchStatus status);
// TODO(rjkroege): Write the remainder of this class.
// It will appear in a subsequent CL.
diff --git a/views/view.cc b/views/view.cc
index 956335e..35a0ccf 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -800,9 +800,9 @@ void View::OnMouseExited(const MouseEvent& event) {
}
#if defined(TOUCH_UI)
-View::TouchStatus View::OnTouchEvent(const TouchEvent& event) {
+ui::TouchStatus View::OnTouchEvent(const TouchEvent& event) {
DVLOG(1) << "visited the OnTouchEvent";
- return TOUCH_STATUS_UNKNOWN;
+ return ui::TOUCH_STATUS_UNKNOWN;
}
#endif
@@ -1626,7 +1626,7 @@ void View::ProcessMouseReleased(const MouseEvent& event) {
}
#if defined(TOUCH_UI)
-View::TouchStatus View::ProcessTouchEvent(const TouchEvent& event) {
+ui::TouchStatus View::ProcessTouchEvent(const TouchEvent& event) {
// TODO(rjkroege): Implement a grab scheme similar to as
// as is found in MousePressed.
return OnTouchEvent(event);
diff --git a/views/view.h b/views/view.h
index cd90af9f..1c412ab 100644
--- a/views/view.h
+++ b/views/view.h
@@ -36,8 +36,9 @@ class Compositor;
class Texture;
class ThemeProvider;
class Transform;
-
-typedef unsigned int TextureID;
+#if defined(TOUCH_UI)
+enum TouchStatus;
+#endif
}
#if defined(OS_WIN)
@@ -144,21 +145,6 @@ class View : public AcceleratorTarget {
public:
typedef std::vector<View*> Views;
-#if defined(TOUCH_UI)
- enum TouchStatus {
- TOUCH_STATUS_UNKNOWN = 0, // Unknown touch status. This is used to indicate
- // that the touch event was not handled.
- TOUCH_STATUS_START, // The touch event initiated a touch sequence.
- TOUCH_STATUS_CONTINUE, // The touch event is part of a previously
- // started touch sequence.
- TOUCH_STATUS_END, // The touch event ended the touch sequence.
- TOUCH_STATUS_CANCEL, // The touch event was cancelled, but didn't
- // terminate the touch sequence.
- TOUCH_STATUS_SYNTH_MOUSE // The touch event was not processed, but a
- // synthetic mouse event generated from the
- // unused touch event was handled.
- };
-#endif
// TO BE MOVED ---------------------------------------------------------------
// TODO(beng): These methods are to be moved to other files/classes.
@@ -620,7 +606,7 @@ class View : public AcceleratorTarget {
#if defined(TOUCH_UI)
// This method is invoked for each touch event. Default implementation
// does nothing. Override as needed.
- virtual TouchStatus OnTouchEvent(const TouchEvent& event);
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event);
#endif
// Set the MouseHandler for a drag session.
@@ -1231,7 +1217,7 @@ class View : public AcceleratorTarget {
#if defined(TOUCH_UI)
// RootView will invoke this with incoming TouchEvents. Returns the
// the result of OnTouchEvent.
- TouchStatus ProcessTouchEvent(const TouchEvent& event);
+ ui::TouchStatus ProcessTouchEvent(const TouchEvent& event);
#endif
// Accelerators --------------------------------------------------------------
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index b6dc1ed..3ffd2f5 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -84,7 +84,7 @@ class TestView : public View {
virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
#if defined(TOUCH_UI)
- virtual TouchStatus OnTouchEvent(const TouchEvent& event);
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event);
#endif
virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
@@ -135,7 +135,7 @@ class MockGestureManager : public GestureManager {
bool ProcessTouchEventForGesture(const TouchEvent& event,
View* source,
- View::TouchStatus status);
+ ui::TouchStatus status);
MockGestureManager();
bool previously_handled_flag_;
@@ -154,7 +154,7 @@ class TestViewIgnoreTouch : public TestView {
virtual ~TestViewIgnoreTouch() {}
private:
- virtual TouchStatus OnTouchEvent(const TouchEvent& event);
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event);
};
#endif
@@ -351,14 +351,14 @@ TEST_F(ViewTest, MouseEvent) {
bool MockGestureManager::ProcessTouchEventForGesture(
const TouchEvent& event,
View* source,
- View::TouchStatus status) {
- if (status != View::TOUCH_STATUS_UNKNOWN) {
+ ui::TouchStatus status) {
+ if (status != ui::TOUCH_STATUS_UNKNOWN) {
dispatched_synthetic_event_ = false;
return false;
}
last_touch_event_ = event.type();
last_view_ = source;
- previously_handled_flag_ = status != View::TOUCH_STATUS_UNKNOWN;
+ previously_handled_flag_ = status != ui::TOUCH_STATUS_UNKNOWN;
dispatched_synthetic_event_ = true;
return true;
}
@@ -366,27 +366,27 @@ bool MockGestureManager::ProcessTouchEventForGesture(
MockGestureManager::MockGestureManager() {
}
-View::TouchStatus TestView::OnTouchEvent(const TouchEvent& event) {
+ui::TouchStatus TestView::OnTouchEvent(const TouchEvent& event) {
last_touch_event_type_ = event.type();
location_.SetPoint(event.x(), event.y());
if (!in_touch_sequence_) {
if (event.type() == ui::ET_TOUCH_PRESSED) {
in_touch_sequence_ = true;
- return TOUCH_STATUS_START;
+ return ui::TOUCH_STATUS_START;
}
} else {
if (event.type() == ui::ET_TOUCH_RELEASED) {
in_touch_sequence_ = false;
- return TOUCH_STATUS_END;
+ return ui::TOUCH_STATUS_END;
}
- return TOUCH_STATUS_CONTINUE;
+ return ui::TOUCH_STATUS_CONTINUE;
}
- return last_touch_event_was_handled_ ? TOUCH_STATUS_CONTINUE :
- TOUCH_STATUS_UNKNOWN;
+ return last_touch_event_was_handled_ ? ui::TOUCH_STATUS_CONTINUE :
+ ui::TOUCH_STATUS_UNKNOWN;
}
-View::TouchStatus TestViewIgnoreTouch::OnTouchEvent(const TouchEvent& event) {
- return TOUCH_STATUS_UNKNOWN;
+ui::TouchStatus TestViewIgnoreTouch::OnTouchEvent(const TouchEvent& event) {
+ return ui::TOUCH_STATUS_UNKNOWN;
}
TEST_F(ViewTest, TouchEvent) {
diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h
index 319bc2e..ec6a941 100644
--- a/views/widget/native_widget_delegate.h
+++ b/views/widget/native_widget_delegate.h
@@ -11,6 +11,12 @@ class Canvas;
class Size;
}
+#if defined(TOUCH_UI)
+namespace ui {
+enum TouchStatus;
+}
+#endif
+
namespace views {
namespace internal {
@@ -83,6 +89,9 @@ class NativeWidgetDelegate {
virtual bool OnKeyEvent(const KeyEvent& event) = 0;
virtual bool OnMouseEvent(const MouseEvent& event) = 0;
virtual void OnMouseCaptureLost() = 0;
+#if defined(TOUCH_UI)
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) = 0;
+#endif
// Runs the specified native command. Returns true if the command is handled.
virtual bool ExecuteCommand(int command_id) = 0;
diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index 75de2c1..3897129 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -79,11 +79,8 @@ void NativeWidgetView::OnMouseExited(const MouseEvent& event) {
}
#if defined(TOUCH_UI)
-View::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
- NOTIMPLEMENTED();
- // TODO(beng): TouchEvents don't go through the Widget right now... so we
- // can't just pass them to the delegate...
- return TOUCH_STATUS_UNKNOWN;
+ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) {
+ return delegate()->OnTouchEvent(event);
}
#endif
diff --git a/views/widget/native_widget_view.h b/views/widget/native_widget_view.h
index 84dcdca..ee0ab01 100644
--- a/views/widget/native_widget_view.h
+++ b/views/widget/native_widget_view.h
@@ -10,6 +10,12 @@
#include "views/widget/native_widget_delegate.h"
#include "views/widget/native_widget_views.h"
+#if defined(TOUCH_UI)
+namespace ui {
+enum TouchStatus;
+}
+#endif
+
namespace views {
class NativeWidgetViews;
@@ -47,7 +53,7 @@ class NativeWidgetView : public View {
virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
#if defined(TOUCH_UI)
- virtual TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
#endif
virtual bool OnKeyPressed(const KeyEvent& event) OVERRIDE;
virtual bool OnKeyReleased(const KeyEvent& event) OVERRIDE;
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 1136908..5002281 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -329,20 +329,20 @@ bool RootView::OnMouseWheel(const MouseWheelEvent& event) {
}
#if defined(TOUCH_UI)
-View::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
+ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
TouchEvent e(event, this);
// If touch_pressed_handler_ is non null, we are currently processing
// a touch down on the screen situation. In that case we send the
// event to touch_pressed_handler_
- View::TouchStatus status = TOUCH_STATUS_UNKNOWN;
+ ui::TouchStatus status = ui::TOUCH_STATUS_UNKNOWN;
if (touch_pressed_handler_) {
TouchEvent touch_event(e, this, touch_pressed_handler_);
status = touch_pressed_handler_->ProcessTouchEvent(touch_event);
if (gesture_manager_->ProcessTouchEventForGesture(e, this, status))
- status = View::TOUCH_STATUS_SYNTH_MOUSE;
- if (status == TOUCH_STATUS_END)
+ status = ui::TOUCH_STATUS_SYNTH_MOUSE;
+ if (status == ui::TOUCH_STATUS_END)
touch_pressed_handler_ = NULL;
return status;
}
@@ -354,7 +354,7 @@ View::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
if (!touch_pressed_handler_->IsEnabled()) {
// Disabled views eat events but are treated as not handled by the
// the GestureManager.
- status = TOUCH_STATUS_UNKNOWN;
+ status = ui::TOUCH_STATUS_UNKNOWN;
break;
}
@@ -370,17 +370,17 @@ View::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
// The touch event wasn't processed. Go up the view hierarchy and dispatch
// the touch event.
- if (status == TOUCH_STATUS_UNKNOWN)
+ if (status == ui::TOUCH_STATUS_UNKNOWN)
continue;
// If the touch didn't initiate a touch-sequence, then reset the touch event
// handler. Otherwise, leave it set so that subsequent touch events are
// dispatched to the same handler.
- if (status != TOUCH_STATUS_START)
+ if (status != ui::TOUCH_STATUS_START)
touch_pressed_handler_ = NULL;
if (gesture_manager_->ProcessTouchEventForGesture(e, this, status))
- status = View::TOUCH_STATUS_SYNTH_MOUSE;
+ status = ui::TOUCH_STATUS_SYNTH_MOUSE;
return status;
}
@@ -389,7 +389,7 @@ View::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) {
// Give the touch event to the gesture manager.
if (gesture_manager_->ProcessTouchEventForGesture(e, this, status))
- status = View::TOUCH_STATUS_SYNTH_MOUSE;
+ status = ui::TOUCH_STATUS_SYNTH_MOUSE;
return status;
}
#endif
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index 67c9e40..efc889d 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -13,6 +13,12 @@
#include "views/focus/focus_search.h"
#include "views/view.h"
+#if defined(TOUCH_UI)
+namespace ui {
+enum TouchStatus;
+}
+#endif
+
namespace views {
class Widget;
@@ -111,7 +117,7 @@ class RootView : public View,
virtual void OnMouseExited(const MouseEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const MouseWheelEvent& event) OVERRIDE;
#if defined(TOUCH_UI)
- virtual TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
#endif
virtual void SetMouseHandler(View* new_mouse_handler) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index ec971f6..5000156 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -783,6 +783,13 @@ void Widget::OnMouseCaptureLost() {
is_mouse_button_pressed_ = false;
}
+#if defined(TOUCH_UI)
+ui::TouchStatus Widget::OnTouchEvent(const TouchEvent& event) {
+ ScopedEvent scoped(this, event);
+ return static_cast<internal::RootView*>(GetRootView())->OnTouchEvent(event);
+}
+#endif
+
bool Widget::ExecuteCommand(int command_id) {
return widget_delegate_->ExecuteWindowsCommand(command_id);
}
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 437ca35..4220cc6 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -43,6 +43,9 @@ class Accelerator;
class Compositor;
class OSExchangeData;
class ThemeProvider;
+#if defined(TOUCH_UI)
+enum TouchStatus;
+#endif
}
using ui::ThemeProvider;
@@ -492,6 +495,9 @@ class Widget : public internal::NativeWidgetDelegate,
virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
+#if defined(TOUCH_UI)
+ virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
+#endif
virtual bool ExecuteCommand(int command_id) OVERRIDE;
virtual Widget* AsWidget() OVERRIDE;
virtual const Widget* AsWidget() const OVERRIDE;