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

Unified Diff: ui/views/widget/widget.cc

Issue 10479010: Gesture related changes for views: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test and add some mores Created 8 years, 6 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
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index e238c675f3849feb200c88d570f99297a32401b0..7626e96f9bda41ecbecc82ef80b72142cdcc64cd 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -169,6 +169,7 @@ Widget::Widget()
native_widget_initialized_(false),
native_widget_destroyed_(false),
is_mouse_button_pressed_(false),
+ is_touch_down_(false),
last_mouse_event_was_move_(false) {
}
@@ -824,18 +825,25 @@ NativeWidget* Widget::native_widget() {
return native_widget_;
}
-void Widget::SetMouseCapture(views::View* view) {
- is_mouse_button_pressed_ = true;
+void Widget::SetCapture(views::View* view) {
+ if (internal::NativeWidgetPrivate::IsMouseButtonDown())
+ is_mouse_button_pressed_ = true;
+ if (internal::NativeWidgetPrivate::IsTouchDown())
+ is_touch_down_ = true;
root_view_->SetMouseHandler(view);
if (!native_widget_->HasCapture())
native_widget_->SetCapture();
}
-void Widget::ReleaseMouseCapture() {
+void Widget::ReleaseCapture() {
if (native_widget_->HasCapture())
native_widget_->ReleaseCapture();
}
+bool Widget::HasCapture() {
+ return native_widget_->HasCapture();
+}
+
const Event* Widget::GetCurrentEvent() {
return event_stack_.empty() ? NULL : event_stack_.top()->event();
}
@@ -1087,8 +1095,9 @@ bool Widget::OnMouseEvent(const MouseEvent& event) {
}
void Widget::OnMouseCaptureLost() {
- if (is_mouse_button_pressed_)
+ if (is_mouse_button_pressed_ || is_touch_down_)
GetRootView()->OnMouseCaptureLost();
+ is_touch_down_ = false;
is_mouse_button_pressed_ = false;
}
@@ -1099,6 +1108,22 @@ ui::TouchStatus Widget::OnTouchEvent(const TouchEvent& event) {
ui::GestureStatus Widget::OnGestureEvent(const GestureEvent& event) {
ScopedEvent scoped(this, event);
+ switch (event.type()) {
+ case ui::ET_GESTURE_TAP_DOWN:
+ is_touch_down_ = true;
+ // We explicitly don't capture here. Not capturing enables multiple
+ // widgets to get tap events at the same time. Views (such as tab
+ // dragging) may explicitly capture.
+ break;
+
+ case ui::ET_GESTURE_TAP_UP:
+ is_touch_down_ = false;
+ ReleaseCapture();
+ break;
+
+ default:
+ break;
+ }
return GetRootView()->OnGestureEvent(event);
}
« no previous file with comments | « ui/views/widget/widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698