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

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

Issue 703643004: Revert of Do not interchange MOUSE_MOVED and MOUSE_DRAGGED events in Widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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') | ui/views/widget/widget_unittest.cc » ('j') | 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 52209f878a6b085057612ef081929f51ba13bd0e..8a9fa71e538c6a2b82fa221ef19e7288d4e0dfe8 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -168,6 +168,7 @@
is_top_level_(false),
native_widget_initialized_(false),
native_widget_destroyed_(false),
+ is_mouse_button_pressed_(false),
ignore_capture_loss_(false),
last_mouse_event_was_move_(false),
auto_release_capture_(true),
@@ -350,6 +351,10 @@
AsNativeWidgetPrivate();
root_view_.reset(CreateRootView());
default_theme_provider_.reset(new ui::DefaultThemeProvider);
+ if (params.type == InitParams::TYPE_MENU) {
+ is_mouse_button_pressed_ =
+ internal::NativeWidgetPrivate::IsMouseButtonDown();
+ }
native_widget_->InitNativeWidget(params);
if (RequiresNonClientView(params.type)) {
non_client_view_ = new NonClientView;
@@ -943,6 +948,8 @@
return;
}
+ if (internal::NativeWidgetPrivate::IsMouseButtonDown())
+ is_mouse_button_pressed_ = true;
root_view_->SetMouseHandler(view);
}
@@ -1183,12 +1190,11 @@
// RootView from anywhere in Widget. Use
// SendEventToProcessor() instead. See crbug.com/348087.
void Widget::OnMouseEvent(ui::MouseEvent* event) {
- if (event->type() != ui::ET_MOUSE_MOVED)
- last_mouse_event_was_move_ = false;
-
View* root_view = GetRootView();
switch (event->type()) {
case ui::ET_MOUSE_PRESSED: {
+ last_mouse_event_was_move_ = false;
+
// We may get deleted by the time we return from OnMousePressed. So we
// use an observer to make sure we are still alive.
WidgetDeletionObserver widget_deletion_observer(this);
@@ -1206,6 +1212,7 @@
if (root_view && root_view->OnMousePressed(*event) &&
widget_deletion_observer.IsWidgetAlive() && IsVisible() &&
internal::NativeWidgetPrivate::IsMouseButtonDown()) {
+ is_mouse_button_pressed_ = true;
if (!native_widget_->HasCapture())
native_widget_->SetCapture();
event->SetHandled();
@@ -1214,6 +1221,8 @@
}
case ui::ET_MOUSE_RELEASED:
+ last_mouse_event_was_move_ = false;
+ is_mouse_button_pressed_ = false;
// Release capture first, to avoid confusion if OnMouseReleased blocks.
if (auto_release_capture_ && native_widget_->HasCapture()) {
base::AutoReset<bool> resetter(&ignore_capture_loss_, true);
@@ -1226,8 +1235,13 @@
return;
case ui::ET_MOUSE_MOVED:
- if (!last_mouse_event_was_move_ ||
- last_mouse_event_position_ != event->location()) {
+ case ui::ET_MOUSE_DRAGGED:
+ if (native_widget_->HasCapture() && is_mouse_button_pressed_) {
+ last_mouse_event_was_move_ = false;
+ if (root_view)
+ root_view->OnMouseDragged(*event);
+ } else if (!last_mouse_event_was_move_ ||
+ last_mouse_event_position_ != event->location()) {
last_mouse_event_position_ = event->location();
last_mouse_event_was_move_ = true;
if (root_view)
@@ -1235,12 +1249,8 @@
}
return;
- case ui::ET_MOUSE_DRAGGED:
- if (root_view)
- root_view->OnMouseDragged(*event);
- return;
-
case ui::ET_MOUSE_EXITED:
+ last_mouse_event_was_move_ = false;
if (root_view)
root_view->OnMouseExited(*event);
return;
@@ -1263,6 +1273,7 @@
View* root_view = GetRootView();
if (root_view)
root_view->OnMouseCaptureLost();
+ is_mouse_button_pressed_ = false;
}
void Widget::OnScrollEvent(ui::ScrollEvent* event) {
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698