| Index: ash/wm/common/wm_toplevel_window_event_handler.cc
|
| diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/common/wm_toplevel_window_event_handler.cc
|
| similarity index 59%
|
| copy from ash/wm/toplevel_window_event_handler.cc
|
| copy to ash/wm/common/wm_toplevel_window_event_handler.cc
|
| index 56f045a138c30caf4becdbb33c156d5c625e3fa1..349411ced6f2f7d5bd29e59379584010db3e182e 100644
|
| --- a/ash/wm/toplevel_window_event_handler.cc
|
| +++ b/ash/wm/common/wm_toplevel_window_event_handler.cc
|
| @@ -2,34 +2,17 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ash/wm/toplevel_window_event_handler.h"
|
| +#include "ash/wm/common/wm_toplevel_window_event_handler.h"
|
|
|
| -#include "ash/shell.h"
|
| -#include "ash/wm/aura/wm_window_aura.h"
|
| #include "ash/wm/common/window_resizer.h"
|
| #include "ash/wm/common/window_state.h"
|
| #include "ash/wm/common/window_state_observer.h"
|
| #include "ash/wm/common/wm_event.h"
|
| +#include "ash/wm/common/wm_globals.h"
|
| +#include "ash/wm/common/wm_window.h"
|
| #include "ash/wm/common/wm_window_observer.h"
|
| -#include "ash/wm/resize_shadow_controller.h"
|
| -#include "ash/wm/window_state_aura.h"
|
| -#include "ash/wm/window_util.h"
|
| -#include "base/message_loop/message_loop.h"
|
| -#include "base/run_loop.h"
|
| -#include "ui/aura/client/cursor_client.h"
|
| -#include "ui/aura/env.h"
|
| -#include "ui/aura/window.h"
|
| -#include "ui/aura/window_delegate.h"
|
| -#include "ui/aura/window_event_dispatcher.h"
|
| -#include "ui/aura/window_observer.h"
|
| -#include "ui/aura/window_tree_host.h"
|
| -#include "ui/base/cursor/cursor.h"
|
| #include "ui/base/hit_test.h"
|
| -#include "ui/base/ui_base_types.h"
|
| #include "ui/events/event.h"
|
| -#include "ui/events/event_utils.h"
|
| -#include "ui/events/gestures/gesture_recognizer.h"
|
| -#include "ui/gfx/geometry/point_conversions.h"
|
|
|
| namespace {
|
| const double kMinHorizVelocityForWindowSwipe = 1100;
|
| @@ -37,12 +20,13 @@ const double kMinVertVelocityForWindowMinimize = 1000;
|
| }
|
|
|
| namespace ash {
|
| +namespace wm {
|
|
|
| namespace {
|
|
|
| // Returns whether |window| can be moved via a two finger drag given
|
| // the hittest results of the two fingers.
|
| -bool CanStartTwoFingerMove(aura::Window* window,
|
| +bool CanStartTwoFingerMove(WmWindow* window,
|
| int window_component1,
|
| int window_component2) {
|
| // We allow moving a window via two fingers when the hittest components are
|
| @@ -50,8 +34,8 @@ bool CanStartTwoFingerMove(aura::Window* window,
|
| // the tab strip is full and hitting the caption area is difficult. We check
|
| // the window type and the state type so that we do not steal touches from the
|
| // web contents.
|
| - if (!wm::GetWindowState(window)->IsNormalOrSnapped() ||
|
| - window->type() != ui::wm::WINDOW_TYPE_NORMAL) {
|
| + if (!window->GetWindowState()->IsNormalOrSnapped() ||
|
| + window->GetType() != ui::wm::WINDOW_TYPE_NORMAL) {
|
| return false;
|
| }
|
| int component1_behavior =
|
| @@ -59,26 +43,19 @@ bool CanStartTwoFingerMove(aura::Window* window,
|
| int component2_behavior =
|
| WindowResizer::GetBoundsChangeForWindowComponent(window_component2);
|
| return (component1_behavior & WindowResizer::kBoundsChange_Resizes) == 0 &&
|
| - (component2_behavior & WindowResizer::kBoundsChange_Resizes) == 0;
|
| + (component2_behavior & WindowResizer::kBoundsChange_Resizes) == 0;
|
| }
|
|
|
| // Returns whether |window| can be moved or resized via one finger given
|
| // |window_component|.
|
| bool CanStartOneFingerDrag(int window_component) {
|
| - return WindowResizer::GetBoundsChangeForWindowComponent(
|
| - window_component) != 0;
|
| -}
|
| -
|
| -gfx::Point ConvertPointToParent(aura::Window* window,
|
| - const gfx::Point& point) {
|
| - gfx::Point result(point);
|
| - aura::Window::ConvertPointToTarget(window, window->parent(), &result);
|
| - return result;
|
| + return WindowResizer::GetBoundsChangeForWindowComponent(window_component) !=
|
| + 0;
|
| }
|
|
|
| // Returns the window component containing |event|'s location.
|
| -int GetWindowComponent(aura::Window* window, const ui::LocatedEvent& event) {
|
| - return window->delegate()->GetNonClientComponent(event.location());
|
| +int GetWindowComponent(WmWindow* window, const ui::LocatedEvent& event) {
|
| + return window->GetNonClientComponent(event.location());
|
| }
|
|
|
| } // namespace
|
| @@ -87,13 +64,13 @@ int GetWindowComponent(aura::Window* window, const ui::LocatedEvent& event) {
|
|
|
| // Wraps a WindowResizer and installs an observer on its target window. When
|
| // the window is destroyed ResizerWindowDestroyed() is invoked back on the
|
| -// ToplevelWindowEventHandler to clean up.
|
| -class ToplevelWindowEventHandler::ScopedWindowResizer
|
| +// WmToplevelWindowEventHandler to clean up.
|
| +class WmToplevelWindowEventHandler::ScopedWindowResizer
|
| : public wm::WmWindowObserver,
|
| public wm::WindowStateObserver {
|
| public:
|
| - ScopedWindowResizer(ToplevelWindowEventHandler* handler,
|
| - WindowResizer* resizer);
|
| + ScopedWindowResizer(WmToplevelWindowEventHandler* handler,
|
| + std::unique_ptr<WindowResizer> resizer);
|
| ~ScopedWindowResizer() override;
|
|
|
| // Returns true if the drag moves the window and does not resize.
|
| @@ -109,7 +86,7 @@ class ToplevelWindowEventHandler::ScopedWindowResizer
|
| wm::WindowStateType type) override;
|
|
|
| private:
|
| - ToplevelWindowEventHandler* handler_;
|
| + WmToplevelWindowEventHandler* handler_;
|
| std::unique_ptr<WindowResizer> resizer_;
|
|
|
| // Whether ScopedWindowResizer grabbed capture.
|
| @@ -118,12 +95,10 @@ class ToplevelWindowEventHandler::ScopedWindowResizer
|
| DISALLOW_COPY_AND_ASSIGN(ScopedWindowResizer);
|
| };
|
|
|
| -ToplevelWindowEventHandler::ScopedWindowResizer::ScopedWindowResizer(
|
| - ToplevelWindowEventHandler* handler,
|
| - WindowResizer* resizer)
|
| - : handler_(handler),
|
| - resizer_(resizer),
|
| - grabbed_capture_(false) {
|
| +WmToplevelWindowEventHandler::ScopedWindowResizer::ScopedWindowResizer(
|
| + WmToplevelWindowEventHandler* handler,
|
| + std::unique_ptr<WindowResizer> resizer)
|
| + : handler_(handler), resizer_(std::move(resizer)), grabbed_capture_(false) {
|
| wm::WmWindow* target = resizer_->GetTarget();
|
| target->AddObserver(this);
|
| target->GetWindowState()->AddObserver(this);
|
| @@ -134,7 +109,7 @@ ToplevelWindowEventHandler::ScopedWindowResizer::ScopedWindowResizer(
|
| }
|
| }
|
|
|
| -ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() {
|
| +WmToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() {
|
| wm::WmWindow* target = resizer_->GetTarget();
|
| target->RemoveObserver(this);
|
| target->GetWindowState()->RemoveObserver(this);
|
| @@ -142,54 +117,48 @@ ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() {
|
| target->ReleaseCapture();
|
| }
|
|
|
| -bool ToplevelWindowEventHandler::ScopedWindowResizer::IsMove() const {
|
| +bool WmToplevelWindowEventHandler::ScopedWindowResizer::IsMove() const {
|
| return resizer_->details().bounds_change ==
|
| - WindowResizer::kBoundsChange_Repositions;
|
| + WindowResizer::kBoundsChange_Repositions;
|
| }
|
|
|
| -void
|
| -ToplevelWindowEventHandler::ScopedWindowResizer::OnPreWindowStateTypeChange(
|
| - wm::WindowState* window_state,
|
| - wm::WindowStateType old) {
|
| - handler_->CompleteDrag(DRAG_COMPLETE);
|
| +void WmToplevelWindowEventHandler::ScopedWindowResizer::
|
| + OnPreWindowStateTypeChange(wm::WindowState* window_state,
|
| + wm::WindowStateType old) {
|
| + handler_->CompleteDrag(DragResult::SUCCESS);
|
| }
|
|
|
| -void ToplevelWindowEventHandler::ScopedWindowResizer::OnWindowDestroying(
|
| +void WmToplevelWindowEventHandler::ScopedWindowResizer::OnWindowDestroying(
|
| wm::WmWindow* window) {
|
| DCHECK_EQ(resizer_->GetTarget(), window);
|
| handler_->ResizerWindowDestroyed();
|
| }
|
|
|
| -// ToplevelWindowEventHandler --------------------------------------------------
|
| +// WmToplevelWindowEventHandler
|
| +// --------------------------------------------------
|
|
|
| -ToplevelWindowEventHandler::ToplevelWindowEventHandler()
|
| - : first_finger_hittest_(HTNOWHERE),
|
| - in_move_loop_(false),
|
| - in_gesture_drag_(false),
|
| - drag_reverted_(false),
|
| - destroyed_(NULL) {
|
| - Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
|
| +WmToplevelWindowEventHandler::WmToplevelWindowEventHandler(WmGlobals* globals)
|
| + : globals_(globals), first_finger_hittest_(HTNOWHERE) {
|
| + globals_->AddDisplayObserver(this);
|
| }
|
|
|
| -ToplevelWindowEventHandler::~ToplevelWindowEventHandler() {
|
| - Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this);
|
| - if (destroyed_)
|
| - *destroyed_ = true;
|
| +WmToplevelWindowEventHandler::~WmToplevelWindowEventHandler() {
|
| + globals_->RemoveDisplayObserver(this);
|
| }
|
|
|
| -void ToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
|
| +void WmToplevelWindowEventHandler::OnKeyEvent(ui::KeyEvent* event) {
|
| if (window_resizer_.get() && event->type() == ui::ET_KEY_PRESSED &&
|
| event->key_code() == ui::VKEY_ESCAPE) {
|
| - CompleteDrag(DRAG_REVERT);
|
| + CompleteDrag(DragResult::REVERT);
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::OnMouseEvent(
|
| - ui::MouseEvent* event) {
|
| +void WmToplevelWindowEventHandler::OnMouseEvent(ui::MouseEvent* event,
|
| + WmWindow* target) {
|
| if (event->handled())
|
| return;
|
| if ((event->flags() &
|
| - (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
|
| + (ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON)) != 0)
|
| return;
|
|
|
| if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) {
|
| @@ -202,7 +171,6 @@ void ToplevelWindowEventHandler::OnMouseEvent(
|
| if (in_gesture_drag_)
|
| return;
|
|
|
| - aura::Window* target = static_cast<aura::Window*>(event->target());
|
| switch (event->type()) {
|
| case ui::ET_MOUSE_PRESSED:
|
| HandleMousePressed(target, event);
|
| @@ -224,24 +192,23 @@ void ToplevelWindowEventHandler::OnMouseEvent(
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| +void WmToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event,
|
| + WmWindow* target) {
|
| if (event->handled())
|
| return;
|
| - aura::Window* target = static_cast<aura::Window*>(event->target());
|
| - if (!target->delegate())
|
| + if (!target->HasNonClientArea())
|
| return;
|
|
|
| if (window_resizer_.get() && !in_gesture_drag_)
|
| return;
|
|
|
| if (window_resizer_.get() &&
|
| - wm::WmWindowAura::GetAuraWindow(
|
| - window_resizer_->resizer()->GetTarget()) != target) {
|
| + window_resizer_->resizer()->GetTarget() != target) {
|
| return;
|
| }
|
|
|
| if (event->details().touch_points() > 2) {
|
| - if (CompleteDrag(DRAG_COMPLETE))
|
| + if (CompleteDrag(DragResult::SUCCESS))
|
| event->StopPropagation();
|
| return;
|
| }
|
| @@ -252,22 +219,16 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| if (!(WindowResizer::GetBoundsChangeForWindowComponent(component) &
|
| WindowResizer::kBoundsChange_Resizes))
|
| return;
|
| - ResizeShadowController* controller =
|
| - Shell::GetInstance()->resize_shadow_controller();
|
| - if (controller)
|
| - controller->ShowShadow(target, component);
|
| + target->ShowResizeShadow(component);
|
| return;
|
| }
|
| case ui::ET_GESTURE_END: {
|
| - ResizeShadowController* controller =
|
| - Shell::GetInstance()->resize_shadow_controller();
|
| - if (controller)
|
| - controller->HideShadow(target);
|
| + target->HideResizeShadow();
|
|
|
| if (window_resizer_.get() &&
|
| (event->details().touch_points() == 1 ||
|
| !CanStartOneFingerDrag(first_finger_hittest_))) {
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| event->StopPropagation();
|
| }
|
| return;
|
| @@ -282,17 +243,18 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| // ET_GESTURE_SCROLL_UPDATE jumps from the position of the first
|
| // finger to the position in the middle of the two fingers. For this
|
| // reason two finger resizing is not supported.
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| event->StopPropagation();
|
| }
|
| } else {
|
| int second_finger_hittest = GetWindowComponent(target, *event);
|
| - if (CanStartTwoFingerMove(
|
| - target, first_finger_hittest_, second_finger_hittest)) {
|
| + if (CanStartTwoFingerMove(target, first_finger_hittest_,
|
| + second_finger_hittest)) {
|
| gfx::Point location_in_parent =
|
| event->details().bounding_box().CenterPoint();
|
| AttemptToStartDrag(target, location_in_parent, HTCAPTION,
|
| - aura::client::WINDOW_MOVE_SOURCE_TOUCH);
|
| + aura::client::WINDOW_MOVE_SOURCE_TOUCH,
|
| + EndClosure());
|
| event->StopPropagation();
|
| }
|
| }
|
| @@ -310,9 +272,9 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| if (!CanStartOneFingerDrag(component))
|
| return;
|
| gfx::Point location_in_parent(
|
| - ConvertPointToParent(target, event->location()));
|
| + target->ConvertPointToTarget(target->GetParent(), event->location()));
|
| AttemptToStartDrag(target, location_in_parent, component,
|
| - aura::client::WINDOW_MOVE_SOURCE_TOUCH);
|
| + aura::client::WINDOW_MOVE_SOURCE_TOUCH, EndClosure());
|
| event->StopPropagation();
|
| return;
|
| }
|
| @@ -334,17 +296,17 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| // called.
|
| // TODO(pkotwicz): Pass drag completion status to
|
| // WindowMoveClient::EndMoveLoop().
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| event->StopPropagation();
|
| return;
|
| case ui::ET_SCROLL_FLING_START:
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
|
|
| // TODO(pkotwicz): Fix tests which inadvertantly start flings and check
|
| // window_resizer_->IsMove() instead of the hittest component at |event|'s
|
| // location.
|
| if (GetWindowComponent(target, *event) != HTCAPTION ||
|
| - !wm::GetWindowState(target)->IsNormalOrSnapped()) {
|
| + !target->GetWindowState()->IsNormalOrSnapped()) {
|
| return;
|
| }
|
|
|
| @@ -368,10 +330,10 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| DCHECK_GT(event->details().touch_points(), 0);
|
| if (event->details().touch_points() == 1)
|
| return;
|
| - if (!wm::GetWindowState(target)->IsNormalOrSnapped())
|
| + if (!target->GetWindowState()->IsNormalOrSnapped())
|
| return;
|
|
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
|
|
| if (event->details().swipe_down()) {
|
| SetWindowStateTypeFromGesture(target, wm::WINDOW_STATE_TYPE_MINIMIZED);
|
| @@ -391,144 +353,93 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
|
| }
|
| }
|
|
|
| -aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop(
|
| - aura::Window* source,
|
| - const gfx::Vector2d& drag_offset,
|
| - aura::client::WindowMoveSource move_source) {
|
| - DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
|
| - aura::Window* root_window = source->GetRootWindow();
|
| - DCHECK(root_window);
|
| - gfx::Point drag_location;
|
| - if (move_source == aura::client::WINDOW_MOVE_SOURCE_TOUCH &&
|
| - aura::Env::GetInstance()->is_touch_down()) {
|
| - gfx::PointF drag_location_f;
|
| - bool has_point = ui::GestureRecognizer::Get()->
|
| - GetLastTouchPointForTarget(source, &drag_location_f);
|
| - drag_location = gfx::ToFlooredPoint(drag_location_f);
|
| - DCHECK(has_point);
|
| - } else {
|
| - drag_location =
|
| - root_window->GetHost()->dispatcher()->GetLastMouseLocationInRoot();
|
| - aura::Window::ConvertPointToTarget(
|
| - root_window, source->parent(), &drag_location);
|
| - }
|
| - // Set the cursor before calling AttemptToStartDrag(), as that will
|
| - // eventually call LockCursor() and prevent the cursor from changing.
|
| - aura::client::CursorClient* cursor_client =
|
| - aura::client::GetCursorClient(root_window);
|
| - if (cursor_client)
|
| - cursor_client->SetCursor(ui::kCursorPointer);
|
| - if (!AttemptToStartDrag(source, drag_location, HTCAPTION, move_source))
|
| - return aura::client::MOVE_CANCELED;
|
| -
|
| - in_move_loop_ = true;
|
| - bool destroyed = false;
|
| - destroyed_ = &destroyed;
|
| - base::MessageLoop* loop = base::MessageLoop::current();
|
| - base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
|
| - base::RunLoop run_loop;
|
| - quit_closure_ = run_loop.QuitClosure();
|
| - run_loop.Run();
|
| - if (destroyed)
|
| - return aura::client::MOVE_CANCELED;
|
| - destroyed_ = NULL;
|
| - in_move_loop_ = false;
|
| - return drag_reverted_ ? aura::client::MOVE_CANCELED :
|
| - aura::client::MOVE_SUCCESSFUL;
|
| -}
|
| -
|
| -void ToplevelWindowEventHandler::EndMoveLoop() {
|
| - if (in_move_loop_)
|
| - CompleteDrag(DRAG_REVERT);
|
| -}
|
| -
|
| -void ToplevelWindowEventHandler::OnDisplayConfigurationChanging() {
|
| - CompleteDrag(DRAG_REVERT);
|
| -}
|
| -
|
| -bool ToplevelWindowEventHandler::AttemptToStartDrag(
|
| - aura::Window* window,
|
| +bool WmToplevelWindowEventHandler::AttemptToStartDrag(
|
| + WmWindow* window,
|
| const gfx::Point& point_in_parent,
|
| int window_component,
|
| - aura::client::WindowMoveSource source) {
|
| + aura::client::WindowMoveSource source,
|
| + const EndClosure& end_closure) {
|
| if (window_resizer_.get())
|
| return false;
|
| - WindowResizer* resizer =
|
| - CreateWindowResizer(wm::WmWindowAura::Get(window), point_in_parent,
|
| - window_component, source)
|
| - .release();
|
| + std::unique_ptr<WindowResizer> resizer(
|
| + CreateWindowResizer(window, point_in_parent, window_component, source));
|
| if (!resizer)
|
| return false;
|
|
|
| - window_resizer_.reset(new ScopedWindowResizer(this, resizer));
|
| + end_closure_ = end_closure;
|
| + window_resizer_.reset(new ScopedWindowResizer(this, std::move(resizer)));
|
|
|
| - pre_drag_window_bounds_ = window->bounds();
|
| + pre_drag_window_bounds_ = window->GetBounds();
|
| in_gesture_drag_ = (source == aura::client::WINDOW_MOVE_SOURCE_TOUCH);
|
| return true;
|
| }
|
|
|
| -bool ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
|
| +void WmToplevelWindowEventHandler::RevertDrag() {
|
| + CompleteDrag(DragResult::REVERT);
|
| +}
|
| +
|
| +bool WmToplevelWindowEventHandler::CompleteDrag(DragResult result) {
|
| if (!window_resizer_)
|
| return false;
|
|
|
| - std::unique_ptr<ScopedWindowResizer> resizer(window_resizer_.release());
|
| - switch (status) {
|
| - case DRAG_COMPLETE:
|
| + std::unique_ptr<ScopedWindowResizer> resizer(std::move(window_resizer_));
|
| + switch (result) {
|
| + case DragResult::SUCCESS:
|
| resizer->resizer()->CompleteDrag();
|
| break;
|
| - case DRAG_REVERT:
|
| + case DragResult::REVERT:
|
| resizer->resizer()->RevertDrag();
|
| break;
|
| - case DRAG_RESIZER_WINDOW_DESTROYED:
|
| + case DragResult::WINDOW_DESTROYED:
|
| // We explicitly do not invoke RevertDrag() since that may do things to
|
| - // WindowResizer::GetAuraTarget() which was destroyed.
|
| + // the window that was destroyed.
|
| break;
|
| }
|
| - drag_reverted_ = (status != DRAG_COMPLETE);
|
|
|
| first_finger_hittest_ = HTNOWHERE;
|
| in_gesture_drag_ = false;
|
| - if (in_move_loop_)
|
| - quit_closure_.Run();
|
| + if (!end_closure_.is_null()) {
|
| + // Clear local state in case running the closure deletes us.
|
| + EndClosure end_closure = end_closure_;
|
| + end_closure_.Reset();
|
| + end_closure.Run(result);
|
| + }
|
| return true;
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleMousePressed(
|
| - aura::Window* target,
|
| - ui::MouseEvent* event) {
|
| - if (event->phase() != ui::EP_PRETARGET || !target->delegate())
|
| +void WmToplevelWindowEventHandler::HandleMousePressed(WmWindow* target,
|
| + ui::MouseEvent* event) {
|
| + if (event->phase() != ui::EP_PRETARGET || !target->HasNonClientArea())
|
| return;
|
|
|
| // We also update the current window component here because for the
|
| // mouse-drag-release-press case, where the mouse is released and
|
| // pressed without mouse move event.
|
| int component = GetWindowComponent(target, *event);
|
| - if ((event->flags() &
|
| - (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) == 0 &&
|
| + if ((event->flags() & (ui::EF_IS_DOUBLE_CLICK | ui::EF_IS_TRIPLE_CLICK)) ==
|
| + 0 &&
|
| WindowResizer::GetBoundsChangeForWindowComponent(component)) {
|
| gfx::Point location_in_parent(
|
| - ConvertPointToParent(target, event->location()));
|
| + target->ConvertPointToTarget(target->GetParent(), event->location()));
|
| AttemptToStartDrag(target, location_in_parent, component,
|
| - aura::client::WINDOW_MOVE_SOURCE_MOUSE);
|
| + aura::client::WINDOW_MOVE_SOURCE_MOUSE, EndClosure());
|
| // Set as handled so that other event handlers do no act upon the event
|
| // but still receive it so that they receive both parts of each pressed/
|
| // released pair.
|
| event->SetHandled();
|
| } else {
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleMouseReleased(
|
| - aura::Window* target,
|
| - ui::MouseEvent* event) {
|
| +void WmToplevelWindowEventHandler::HandleMouseReleased(WmWindow* target,
|
| + ui::MouseEvent* event) {
|
| if (event->phase() == ui::EP_PRETARGET)
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleDrag(
|
| - aura::Window* target,
|
| - ui::LocatedEvent* event) {
|
| +void WmToplevelWindowEventHandler::HandleDrag(WmWindow* target,
|
| + ui::LocatedEvent* event) {
|
| // This function only be triggered to move window
|
| // by mouse drag or touch move event.
|
| DCHECK(event->type() == ui::ET_MOUSE_DRAGGED ||
|
| @@ -543,62 +454,53 @@ void ToplevelWindowEventHandler::HandleDrag(
|
| if (!window_resizer_)
|
| return;
|
| window_resizer_->resizer()->Drag(
|
| - ConvertPointToParent(target, event->location()), event->flags());
|
| + target->ConvertPointToTarget(target->GetParent(), event->location()),
|
| + event->flags());
|
| event->StopPropagation();
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleMouseMoved(
|
| - aura::Window* target,
|
| - ui::LocatedEvent* event) {
|
| +void WmToplevelWindowEventHandler::HandleMouseMoved(WmWindow* target,
|
| + ui::LocatedEvent* event) {
|
| // Shadow effects are applied after target handling. Note that we don't
|
| // respect ER_HANDLED here right now since we have not had a reason to allow
|
| // the target to cancel shadow rendering.
|
| - if (event->phase() != ui::EP_POSTTARGET || !target->delegate())
|
| + if (event->phase() != ui::EP_POSTTARGET || !target->HasNonClientArea())
|
| return;
|
|
|
| // TODO(jamescook): Move the resize cursor update code into here from
|
| // CompoundEventFilter?
|
| - ResizeShadowController* controller =
|
| - Shell::GetInstance()->resize_shadow_controller();
|
| - if (controller) {
|
| - if (event->flags() & ui::EF_IS_NON_CLIENT) {
|
| - int component =
|
| - target->delegate()->GetNonClientComponent(event->location());
|
| - controller->ShowShadow(target, component);
|
| - } else {
|
| - controller->HideShadow(target);
|
| - }
|
| + if (event->flags() & ui::EF_IS_NON_CLIENT) {
|
| + int component = target->GetNonClientComponent(event->location());
|
| + target->ShowResizeShadow(component);
|
| + } else {
|
| + target->HideResizeShadow();
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleMouseExited(
|
| - aura::Window* target,
|
| - ui::LocatedEvent* event) {
|
| +void WmToplevelWindowEventHandler::HandleMouseExited(WmWindow* target,
|
| + ui::LocatedEvent* event) {
|
| // Shadow effects are applied after target handling. Note that we don't
|
| // respect ER_HANDLED here right now since we have not had a reason to allow
|
| // the target to cancel shadow rendering.
|
| if (event->phase() != ui::EP_POSTTARGET)
|
| return;
|
|
|
| - ResizeShadowController* controller =
|
| - Shell::GetInstance()->resize_shadow_controller();
|
| - if (controller)
|
| - controller->HideShadow(target);
|
| + target->HideResizeShadow();
|
| }
|
|
|
| -void ToplevelWindowEventHandler::HandleCaptureLost(ui::LocatedEvent* event) {
|
| +void WmToplevelWindowEventHandler::HandleCaptureLost(ui::LocatedEvent* event) {
|
| if (event->phase() == ui::EP_PRETARGET) {
|
| // We complete the drag instead of reverting it, as reverting it will result
|
| // in a weird behavior when a dragged tab produces a modal dialog while the
|
| // drag is in progress. crbug.com/558201.
|
| - CompleteDrag(DRAG_COMPLETE);
|
| + CompleteDrag(DragResult::SUCCESS);
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
|
| - aura::Window* window,
|
| +void WmToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
|
| + WmWindow* window,
|
| wm::WindowStateType new_state_type) {
|
| - wm::WindowState* window_state = ash::wm::GetWindowState(window);
|
| + wm::WindowState* window_state = window->GetWindowState();
|
| // TODO(oshima): Move extra logic (set_unminimize_to_restore_bounds,
|
| // SetRestoreBoundsInParent) that modifies the window state
|
| // into WindowState.
|
| @@ -635,8 +537,13 @@ void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
|
| }
|
| }
|
|
|
| -void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
|
| - CompleteDrag(DRAG_RESIZER_WINDOW_DESTROYED);
|
| +void WmToplevelWindowEventHandler::ResizerWindowDestroyed() {
|
| + CompleteDrag(DragResult::WINDOW_DESTROYED);
|
| +}
|
| +
|
| +void WmToplevelWindowEventHandler::OnDisplayConfigurationChanging() {
|
| + CompleteDrag(DragResult::REVERT);
|
| }
|
|
|
| +} // namespace wm
|
| } // namespace ash
|
|
|