summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 19:21:00 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 19:21:00 +0000
commitffae320d04b03d404df54cf63d1fdb1e36eabc89 (patch)
treeee97700e88541f7f00188f559381fb1254be8816 /ash/wm
parent3bb99779444dab729ec6693a9005c4bd6178aaae (diff)
downloadchromium_src-ffae320d04b03d404df54cf63d1fdb1e36eabc89.zip
chromium_src-ffae320d04b03d404df54cf63d1fdb1e36eabc89.tar.gz
chromium_src-ffae320d04b03d404df54cf63d1fdb1e36eabc89.tar.bz2
Avoid changing |drag_reverted_| if the drag was already completed on ChromeOS
This is part #2 of https://codereview.chromium.org/354343002/ BUG=None TEST=None Review URL: https://codereview.chromium.org/345133005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/toplevel_window_event_handler.cc46
-rw-r--r--ash/wm/toplevel_window_event_handler.h12
2 files changed, 28 insertions, 30 deletions
diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc
index a759e8b..ce1d020 100644
--- a/ash/wm/toplevel_window_event_handler.cc
+++ b/ash/wm/toplevel_window_event_handler.cc
@@ -219,10 +219,8 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
}
if (event->details().touch_points() > 2) {
- if (window_resizer_.get()) {
- CompleteDrag(DRAG_COMPLETE);
+ if (CompleteDrag(DRAG_COMPLETE))
event->StopPropagation();
- }
return;
}
@@ -446,20 +444,30 @@ bool ToplevelWindowEventHandler::AttemptToStartDrag(
return true;
}
-void ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
+bool ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
+ if (!window_resizer_)
+ return false;
+
scoped_ptr<ScopedWindowResizer> resizer(window_resizer_.release());
- if (resizer) {
- if (status == DRAG_COMPLETE)
+ switch (status) {
+ case DRAG_COMPLETE:
resizer->resizer()->CompleteDrag();
- else
+ break;
+ case DRAG_REVERT:
resizer->resizer()->RevertDrag();
+ break;
+ case DRAG_RESIZER_WINDOW_DESTROYED:
+ // We explicitly do not invoke RevertDrag() since that may do things to
+ // WindowResizer::GetTarget() which was destroyed.
+ break;
}
- drag_reverted_ = (status == DRAG_REVERT);
+ drag_reverted_ = (status != DRAG_COMPLETE);
first_finger_hittest_ = HTNOWHERE;
in_gesture_drag_ = false;
if (in_move_loop_)
quit_closure_.Run();
+ return true;
}
void ToplevelWindowEventHandler::HandleMousePressed(
@@ -494,20 +502,8 @@ void ToplevelWindowEventHandler::HandleMouseReleased(
if (event->phase() != ui::EP_PRETARGET)
return;
- if (window_resizer_) {
- CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
- DRAG_COMPLETE : DRAG_REVERT);
- }
-
- // Completing the drag may result in hiding the window. If this happens
- // mark the event as handled so no other handlers/observers act upon the
- // event. They should see the event on a hidden window, to determine targets
- // of destructive actions such as hiding. They should not act upon them.
- if (window_resizer_ &&
- event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
- !target->IsVisible()) {
- event->SetHandled();
- }
+ CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
+ DRAG_COMPLETE : DRAG_REVERT);
}
void ToplevelWindowEventHandler::HandleDrag(
@@ -611,11 +607,7 @@ void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
}
void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
- // We explicitly don't invoke RevertDrag() since that may do things to window.
- // Instead we destroy the resizer.
- window_resizer_.reset();
-
- CompleteDrag(DRAG_REVERT);
+ CompleteDrag(DRAG_RESIZER_WINDOW_DESTROYED);
}
} // namespace ash
diff --git a/ash/wm/toplevel_window_event_handler.h b/ash/wm/toplevel_window_event_handler.h
index 5d9caf8..246b042 100644
--- a/ash/wm/toplevel_window_event_handler.h
+++ b/ash/wm/toplevel_window_event_handler.h
@@ -58,7 +58,12 @@ class ASH_EXPORT ToplevelWindowEventHandler
enum DragCompletionStatus {
DRAG_COMPLETE,
- DRAG_REVERT
+ DRAG_REVERT,
+
+ // To be used when WindowResizer::GetTarget() is destroyed. Neither
+ // completes nor reverts the drag because both access the WindowResizer's
+ // window.
+ DRAG_RESIZER_WINDOW_DESTROYED
};
// Attempts to start a drag if one is not already in progress. Returns true if
@@ -68,8 +73,9 @@ class ASH_EXPORT ToplevelWindowEventHandler
int window_component,
aura::client::WindowMoveSource source);
- // Finishes the drag.
- void CompleteDrag(DragCompletionStatus status);
+ // Completes or reverts the drag if one is in progress. Returns true if a
+ // drag was completed or reverted.
+ bool CompleteDrag(DragCompletionStatus status);
void HandleMousePressed(aura::Window* target, ui::MouseEvent* event);
void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event);