| Index: ash/wm/dock/dock_window_resizer.cc
|
| diff --git a/ash/wm/dock/dock_window_resizer.cc b/ash/wm/dock/dock_window_resizer.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8312c8ae720ebe7ea9187708fa5e6b2845783e03
|
| --- /dev/null
|
| +++ b/ash/wm/dock/dock_window_resizer.cc
|
| @@ -0,0 +1,102 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ash/wm/dock/dock_window_resizer.h"
|
| +
|
| +#include "ash/display/display_controller.h"
|
| +#include "ash/launcher/launcher.h"
|
| +#include "ash/root_window_controller.h"
|
| +#include "ash/screen_ash.h"
|
| +#include "ash/shelf/shelf_types.h"
|
| +#include "ash/shelf/shelf_widget.h"
|
| +#include "ash/shell.h"
|
| +#include "ash/shell_window_ids.h"
|
| +#include "ash/wm/coordinate_conversion.h"
|
| +#include "ash/wm/dock/dock_layout_manager.h"
|
| +#include "ash/wm/property_util.h"
|
| +#include "ash/wm/window_properties.h"
|
| +#include "ui/aura/client/aura_constants.h"
|
| +#include "ui/aura/env.h"
|
| +#include "ui/aura/root_window.h"
|
| +#include "ui/aura/window.h"
|
| +#include "ui/aura/window_delegate.h"
|
| +#include "ui/base/hit_test.h"
|
| +#include "ui/base/ui_base_types.h"
|
| +#include "ui/gfx/screen.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +namespace ash {
|
| +
|
| +namespace {
|
| +internal::DockLayoutManager* GetDockLayoutManager(
|
| + aura::Window* dock_container) {
|
| + DCHECK(dock_container->id() == internal::kShellWindowId_DockContainer);
|
| + return static_cast<internal::DockLayoutManager*>(
|
| + dock_container->layout_manager());
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +DockWindowResizer::~DockWindowResizer() {
|
| +}
|
| +
|
| +// static
|
| +DockWindowResizer*
|
| +DockWindowResizer::Create(WindowResizer* next_window_resizer,
|
| + aura::Window* window,
|
| + const gfx::Point& location,
|
| + int window_component) {
|
| + Details details(window, location, window_component);
|
| + return details.is_resizable ?
|
| + new DockWindowResizer(next_window_resizer, details) : NULL;
|
| +}
|
| +
|
| +void DockWindowResizer::Drag(const gfx::Point& location, int event_flags) {
|
| + if (!did_move_or_resize_) {
|
| + did_move_or_resize_ = true;
|
| + StartedDragging();
|
| + }
|
| + next_window_resizer_->Drag(location, event_flags);
|
| +}
|
| +
|
| +void DockWindowResizer::CompleteDrag(int event_flags) {
|
| + // The root window can change when dragging into a different screen.
|
| + next_window_resizer_->CompleteDrag(event_flags);
|
| + FinishDragging();
|
| +}
|
| +
|
| +void DockWindowResizer::RevertDrag() {
|
| + next_window_resizer_->RevertDrag();
|
| + FinishDragging();
|
| +}
|
| +
|
| +aura::Window* DockWindowResizer::GetTarget() {
|
| + return next_window_resizer_->GetTarget();
|
| +}
|
| +
|
| +DockWindowResizer::DockWindowResizer(WindowResizer* next_window_resizer,
|
| + const Details& details)
|
| + : details_(details),
|
| + next_window_resizer_(next_window_resizer),
|
| + dock_container_(NULL),
|
| + did_move_or_resize_(false) {
|
| + DCHECK(details_.is_resizable);
|
| + dock_container_ = Shell::GetContainer(details.window->GetRootWindow(),
|
| + internal::kShellWindowId_DockContainer);
|
| +}
|
| +
|
| +void DockWindowResizer::StartedDragging() {
|
| + // Tell the dock layout manager that we are dragging this window.
|
| + if (dock_container_)
|
| + GetDockLayoutManager(dock_container_)->StartDragging(GetTarget());
|
| +}
|
| +
|
| +void DockWindowResizer::FinishDragging() {
|
| + if (!did_move_or_resize_)
|
| + return;
|
| + if (dock_container_)
|
| + GetDockLayoutManager(dock_container_)->FinishDragging();
|
| +}
|
| +
|
| +} // namespace aura
|
|
|