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

Side by Side Diff: ash/wm/panels/panel_window_resizer.cc

Issue 12441010: Attach panel while dragging to bring it in front of other panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Get workspace event handler from workspace controller. Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/panels/panel_window_resizer.h" 5 #include "ash/wm/panels/panel_window_resizer.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shelf/shelf_types.h" 9 #include "ash/shelf/shelf_types.h"
10 #include "ash/shelf/shelf_widget.h" 10 #include "ash/shelf/shelf_widget.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 12 #include "ash/shell_window_ids.h"
13 #include "ash/wm/panels/panel_layout_manager.h" 13 #include "ash/wm/panels/panel_layout_manager.h"
14 #include "ash/wm/property_util.h" 14 #include "ash/wm/property_util.h"
15 #include "ash/wm/toplevel_window_event_handler.h"
15 #include "ash/wm/window_properties.h" 16 #include "ash/wm/window_properties.h"
17 #include "ash/wm/workspace/workspace_event_handler.h"
18 #include "ash/wm/workspace_controller.h"
16 #include "ui/aura/client/aura_constants.h" 19 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
18 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
20 #include "ui/aura/window_delegate.h" 23 #include "ui/aura/window_delegate.h"
21 #include "ui/base/hit_test.h" 24 #include "ui/base/hit_test.h"
22 #include "ui/base/ui_base_types.h" 25 #include "ui/base/ui_base_types.h"
23 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
24 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
25 28
26 namespace ash { 29 namespace ash {
27 30
28 namespace { 31 namespace {
29 const int kPanelSnapToLauncherDistance = 30; 32 const int kPanelSnapToLauncherDistance = 30;
30 } // namespace 33 } // namespace
31 34
32 PanelWindowResizer::~PanelWindowResizer() { 35 PanelWindowResizer::~PanelWindowResizer() {
33 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); 36 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
34 } 37 }
35 38
36 // static 39 // static
37 PanelWindowResizer* 40 PanelWindowResizer*
38 PanelWindowResizer::Create(aura::Window* window, 41 PanelWindowResizer::Create(aura::Window* window,
39 const gfx::Point& location, 42 const gfx::Point& location,
40 int window_component) { 43 int window_component) {
41 Details details(window, location, window_component); 44 Details details(window, location, window_component);
42 return details.is_resizable ? new PanelWindowResizer(details) : NULL; 45 return details.is_resizable ? new PanelWindowResizer(details) : NULL;
43 } 46 }
44 47
45 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { 48 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
46 gfx::Rect bounds(CalculateBoundsForDrag(details_, location)); 49 gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
47 if (bounds != details_.window->bounds()) { 50 if (bounds != details_.window->bounds()) {
48 if (!did_move_or_resize_) { 51 if (!did_move_or_resize_) {
49 if (!details_.restore_bounds.IsEmpty()) 52 if (!details_.restore_bounds.IsEmpty())
50 ClearRestoreBounds(details_.window); 53 ClearRestoreBounds(details_.window);
51 StartedDragging(); 54 StartedDragging();
52 } 55 }
53 did_move_or_resize_ = true; 56 did_move_or_resize_ = true;
54 should_attach_ = AttachToLauncher(&bounds); 57 should_attach_ = AttachToLauncher(&bounds);
55 details_.window->SetBounds(bounds); 58 details_.window->SetBounds(bounds);
56 } 59 }
57 } 60 }
58 61
59 void PanelWindowResizer::CompleteDrag(int event_flags) { 62 void PanelWindowResizer::CompleteDrag(int event_flags) {
60 if (should_attach_ != was_attached_) { 63 if (details_.window->GetProperty(internal::kPanelAttachedKey) !=
64 should_attach_) {
61 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_); 65 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_);
62 details_.window->SetDefaultParentByRootWindow( 66 details_.window->SetDefaultParentByRootWindow(
63 details_.window->GetRootWindow(), 67 details_.window->GetRootWindow(),
64 details_.window->bounds()); 68 details_.window->bounds());
65 } 69 }
66 FinishDragging(); 70 FinishDragging();
67 } 71 }
68 72
69 void PanelWindowResizer::RevertDrag() { 73 void PanelWindowResizer::RevertDrag() {
70 if (!did_move_or_resize_) 74 if (!did_move_or_resize_)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 should_attach = true; 137 should_attach = true;
134 bounds->set_y(launcher_bounds.bottom()); 138 bounds->set_y(launcher_bounds.bottom());
135 } 139 }
136 break; 140 break;
137 } 141 }
138 } 142 }
139 return should_attach; 143 return should_attach;
140 } 144 }
141 145
142 void PanelWindowResizer::StartedDragging() { 146 void PanelWindowResizer::StartedDragging() {
143 if (was_attached_) 147 // Tell the panel layout manager that we are dragging this panel before
144 panel_layout_manager_->StartDragging(details_.window); 148 // attaching it so that it does not get repositioned.
149 panel_layout_manager_->StartDragging(details_.window);
150 if (!was_attached_) {
151 ash::internal::RootWindowController* root_window_controller =
152 GetRootWindowController(details_.window->GetRootWindow());
153 // Pass the resize handler from the workspace event handler to the panel
154 // container event handler so it can continue to carry out the drag.
155 root_window_controller->workspace_controller()->GetEventHandlerForWindow(
156 details_.window)->PassResizer(
157 root_window_controller->panel_container_handler());
158
159 // Attach the panel while dragging placing it in front of other panels.
160 details_.window->SetProperty(internal::kPanelAttachedKey, true);
161 details_.window->SetDefaultParentByRootWindow(
162 details_.window->GetRootWindow(),
163 details_.window->bounds());
164 }
145 } 165 }
146 166
147 void PanelWindowResizer::FinishDragging() { 167 void PanelWindowResizer::FinishDragging() {
148 if (was_attached_) 168 panel_layout_manager_->FinishDragging();
149 panel_layout_manager_->FinishDragging();
150 } 169 }
151 170
152 } // namespace aura 171 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698