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

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

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (exposing DragWindowResizer for tests, rebase) Created 7 years, 6 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
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/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/launcher/launcher.h" 8 #include "ash/launcher/launcher.h"
9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
11 #include "ash/shelf/shelf_types.h" 10 #include "ash/shelf/shelf_types.h"
12 #include "ash/shelf/shelf_widget.h" 11 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 12 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
15 #include "ash/wm/coordinate_conversion.h" 14 #include "ash/wm/coordinate_conversion.h"
16 #include "ash/wm/panels/panel_layout_manager.h" 15 #include "ash/wm/panels/panel_layout_manager.h"
17 #include "ash/wm/property_util.h" 16 #include "ash/wm/property_util.h"
18 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
19 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
(...skipping 30 matching lines...) Expand all
50 PanelWindowResizer::Create(WindowResizer* next_window_resizer, 49 PanelWindowResizer::Create(WindowResizer* next_window_resizer,
51 aura::Window* window, 50 aura::Window* window,
52 const gfx::Point& location, 51 const gfx::Point& location,
53 int window_component) { 52 int window_component) {
54 Details details(window, location, window_component); 53 Details details(window, location, window_component);
55 return details.is_resizable ? 54 return details.is_resizable ?
56 new PanelWindowResizer(next_window_resizer, details) : NULL; 55 new PanelWindowResizer(next_window_resizer, details) : NULL;
57 } 56 }
58 57
59 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { 58 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
59 last_location_ = location;
60 wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_);
60 bool destroyed = false; 61 bool destroyed = false;
61 if (!did_move_or_resize_) { 62 if (!did_move_or_resize_) {
62 did_move_or_resize_ = true; 63 did_move_or_resize_ = true;
63 StartedDragging(); 64 StartedDragging();
64 } 65 }
65 gfx::Point location_in_screen = location; 66 gfx::Point location_in_screen = location;
66 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); 67 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen);
67 68
68 // Check if the destination has changed displays. 69 // Check if the destination has changed displays.
69 gfx::Screen* screen = Shell::GetScreen(); 70 gfx::Screen* screen = Shell::GetScreen();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void PanelWindowResizer::RevertDrag() { 118 void PanelWindowResizer::RevertDrag() {
118 next_window_resizer_->RevertDrag(); 119 next_window_resizer_->RevertDrag();
119 should_attach_ = was_attached_; 120 should_attach_ = was_attached_;
120 FinishDragging(); 121 FinishDragging();
121 } 122 }
122 123
123 aura::Window* PanelWindowResizer::GetTarget() { 124 aura::Window* PanelWindowResizer::GetTarget() {
124 return next_window_resizer_->GetTarget(); 125 return next_window_resizer_->GetTarget();
125 } 126 }
126 127
128 const gfx::Point& PanelWindowResizer::GetInitialLocationForTest() const {
129 return details_.initial_location_in_parent;
130 }
131
127 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, 132 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
128 const Details& details) 133 const Details& details)
129 : details_(details), 134 : details_(details),
130 next_window_resizer_(next_window_resizer), 135 next_window_resizer_(next_window_resizer),
131 panel_container_(NULL), 136 panel_container_(NULL),
132 did_move_or_resize_(false), 137 did_move_or_resize_(false),
133 was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)), 138 was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)),
134 should_attach_(was_attached_), 139 should_attach_(was_attached_),
135 destroyed_(NULL) { 140 destroyed_(NULL) {
136 DCHECK(details_.is_resizable); 141 DCHECK(details_.is_resizable);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 GetTarget()->GetBoundsInScreen()); 202 GetTarget()->GetBoundsInScreen());
198 } 203 }
199 } 204 }
200 205
201 void PanelWindowResizer::FinishDragging() { 206 void PanelWindowResizer::FinishDragging() {
202 if (!did_move_or_resize_) 207 if (!did_move_or_resize_)
203 return; 208 return;
204 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) != 209 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) !=
205 should_attach_) { 210 should_attach_) {
206 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_); 211 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_);
207 GetTarget()->SetDefaultParentByRootWindow( 212 gfx::Rect near_last_location(last_location_, gfx::Size());
208 GetTarget()->GetRootWindow(), 213 GetTarget()->SetDefaultParentByRootWindow(GetTarget()->GetRootWindow(),
209 GetTarget()->GetBoundsInScreen()); 214 near_last_location);
210 } 215 }
211 if (panel_container_) 216 if (panel_container_)
212 GetPanelLayoutManager(panel_container_)->FinishDragging(); 217 GetPanelLayoutManager(panel_container_)->FinishDragging();
213 } 218 }
214 219
215 void PanelWindowResizer::UpdateLauncherPosition() { 220 void PanelWindowResizer::UpdateLauncherPosition() {
216 if (panel_container_) { 221 if (panel_container_) {
217 GetPanelLayoutManager(panel_container_)->launcher()-> 222 GetPanelLayoutManager(panel_container_)->launcher()->
218 UpdateIconPositionForWindow(GetTarget()); 223 UpdateIconPositionForWindow(GetTarget());
219 } 224 }
220 } 225 }
221 226
222 } // namespace aura 227 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698