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

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: Fix merge. 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"
(...skipping 18 matching lines...) Expand all
29 const int kPanelSnapToLauncherDistance = 30; 29 const int kPanelSnapToLauncherDistance = 30;
30 } // namespace 30 } // namespace
31 31
32 PanelWindowResizer::~PanelWindowResizer() { 32 PanelWindowResizer::~PanelWindowResizer() {
33 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); 33 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
34 } 34 }
35 35
36 // static 36 // static
37 PanelWindowResizer* 37 PanelWindowResizer*
38 PanelWindowResizer::Create(aura::Window* window, 38 PanelWindowResizer::Create(aura::Window* window,
39 const gfx::Point& location, 39 const gfx::Point& location,
40 int window_component) { 40 int window_component) {
41 Details details(window, location, window_component); 41 Details details(window, location, window_component);
42 return details.is_resizable ? new PanelWindowResizer(details) : NULL; 42 return details.is_resizable ? new PanelWindowResizer(details) : NULL;
43 } 43 }
44 44
45 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { 45 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
46 gfx::Rect bounds(CalculateBoundsForDrag(details_, location)); 46 gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
47 if (bounds != details_.window->bounds()) { 47 if (bounds != details_.window->bounds()) {
48 if (!did_move_or_resize_) { 48 if (!did_move_or_resize_) {
49 if (!details_.restore_bounds.IsEmpty()) 49 if (!details_.restore_bounds.IsEmpty())
50 ClearRestoreBounds(details_.window); 50 ClearRestoreBounds(details_.window);
51 StartedDragging(); 51 StartedDragging();
52 } 52 }
53 did_move_or_resize_ = true; 53 did_move_or_resize_ = true;
54 should_attach_ = AttachToLauncher(&bounds); 54 should_attach_ = AttachToLauncher(&bounds);
55 details_.window->SetBounds(bounds); 55 details_.window->SetBounds(bounds);
56 if (should_attach_) 56 if (should_attach_)
57 UpdateLauncherPosition(); 57 UpdateLauncherPosition();
58 } 58 }
59 } 59 }
60 60
61 void PanelWindowResizer::CompleteDrag(int event_flags) { 61 void PanelWindowResizer::CompleteDrag(int event_flags) {
62 if (should_attach_ != was_attached_) { 62 if (details_.window->GetProperty(internal::kPanelAttachedKey) !=
63 should_attach_) {
63 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_); 64 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_);
64 details_.window->SetDefaultParentByRootWindow( 65 details_.window->SetDefaultParentByRootWindow(
65 details_.window->GetRootWindow(), 66 details_.window->GetRootWindow(),
66 details_.window->bounds()); 67 details_.window->bounds());
67 } 68 }
68 FinishDragging(); 69 FinishDragging();
69 } 70 }
70 71
71 void PanelWindowResizer::RevertDrag() { 72 void PanelWindowResizer::RevertDrag() {
72 if (!did_move_or_resize_) 73 if (!did_move_or_resize_)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 should_attach = true; 136 should_attach = true;
136 bounds->set_y(launcher_bounds.bottom()); 137 bounds->set_y(launcher_bounds.bottom());
137 } 138 }
138 break; 139 break;
139 } 140 }
140 } 141 }
141 return should_attach; 142 return should_attach;
142 } 143 }
143 144
144 void PanelWindowResizer::StartedDragging() { 145 void PanelWindowResizer::StartedDragging() {
145 if (was_attached_) 146 // Tell the panel layout manager that we are dragging this panel before
146 panel_layout_manager_->StartDragging(details_.window); 147 // attaching it so that it does not get repositioned.
148 panel_layout_manager_->StartDragging(details_.window);
149 if (!was_attached_) {
150 // Attach the panel while dragging placing it in front of other panels.
151 details_.window->SetProperty(internal::kContinueDragAfterReparent, true);
152 details_.window->SetProperty(internal::kPanelAttachedKey, true);
153 details_.window->SetDefaultParentByRootWindow(
154 details_.window->GetRootWindow(),
155 details_.window->bounds());
156 }
147 } 157 }
148 158
149 void PanelWindowResizer::FinishDragging() { 159 void PanelWindowResizer::FinishDragging() {
150 if (was_attached_) 160 panel_layout_manager_->FinishDragging();
151 panel_layout_manager_->FinishDragging();
152 } 161 }
153 162
154 void PanelWindowResizer::UpdateLauncherPosition() { 163 void PanelWindowResizer::UpdateLauncherPosition() {
155 panel_layout_manager_->launcher()->UpdateIconPositionForWindow( 164 panel_layout_manager_->launcher()->UpdateIconPositionForWindow(
156 details_.window); 165 details_.window);
157 } 166 }
158 167
159 } // namespace aura 168 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698