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

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

Issue 560053002: Do not interchange MOUSE_MOVED and MOUSE_DRAGGED events in Widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years, 3 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: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 8a9fa71e538c6a2b82fa221ef19e7288d4e0dfe8..52209f878a6b085057612ef081929f51ba13bd0e 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -168,7 +168,6 @@ Widget::Widget()
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),
@@ -351,10 +350,6 @@ void Widget::Init(const InitParams& in_params) {
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;
@@ -948,8 +943,6 @@ void Widget::SetCapture(View* view) {
return;
}
- if (internal::NativeWidgetPrivate::IsMouseButtonDown())
- is_mouse_button_pressed_ = true;
root_view_->SetMouseHandler(view);
}
@@ -1190,11 +1183,12 @@ void Widget::OnKeyEvent(ui::KeyEvent* event) {
// 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);
@@ -1212,7 +1206,6 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
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();
@@ -1221,8 +1214,6 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
}
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);
@@ -1235,13 +1226,8 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
return;
case ui::ET_MOUSE_MOVED:
- 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()) {
+ 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)
@@ -1249,8 +1235,12 @@ void Widget::OnMouseEvent(ui::MouseEvent* event) {
}
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;
@@ -1273,7 +1263,6 @@ void Widget::OnMouseCaptureLost() {
View* root_view = GetRootView();
if (root_view)
root_view->OnMouseCaptureLost();
- is_mouse_button_pressed_ = false;
}
void Widget::OnScrollEvent(ui::ScrollEvent* event) {

Powered by Google App Engine
This is Rietveld 408576698