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

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 (comments) 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" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 PanelWindowResizer::Create(WindowResizer* next_window_resizer, 50 PanelWindowResizer::Create(WindowResizer* next_window_resizer,
51 aura::Window* window, 51 aura::Window* window,
52 const gfx::Point& location, 52 const gfx::Point& location,
53 int window_component) { 53 int window_component) {
54 Details details(window, location, window_component); 54 Details details(window, location, window_component);
55 return details.is_resizable ? 55 return details.is_resizable ?
56 new PanelWindowResizer(next_window_resizer, details) : NULL; 56 new PanelWindowResizer(next_window_resizer, details) : NULL;
57 } 57 }
58 58
59 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { 59 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
60 last_mouse_location_ = location;
61 wm::ConvertPointToScreen(GetTarget()->parent(), &last_mouse_location_);
60 bool destroyed = false; 62 bool destroyed = false;
61 if (!did_move_or_resize_) { 63 if (!did_move_or_resize_) {
62 did_move_or_resize_ = true; 64 did_move_or_resize_ = true;
63 StartedDragging(); 65 StartedDragging();
64 } 66 }
65 gfx::Point location_in_screen = location; 67 gfx::Point location_in_screen = location;
66 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); 68 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen);
67 69
68 // Check if the destination has changed displays. 70 // Check if the destination has changed displays.
69 gfx::Screen* screen = Shell::GetScreen(); 71 gfx::Screen* screen = Shell::GetScreen();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, 129 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
128 const Details& details) 130 const Details& details)
129 : details_(details), 131 : details_(details),
130 next_window_resizer_(next_window_resizer), 132 next_window_resizer_(next_window_resizer),
131 panel_container_(NULL), 133 panel_container_(NULL),
132 did_move_or_resize_(false), 134 did_move_or_resize_(false),
133 was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)), 135 was_attached_(GetTarget()->GetProperty(internal::kPanelAttachedKey)),
134 should_attach_(was_attached_), 136 should_attach_(was_attached_),
135 destroyed_(NULL) { 137 destroyed_(NULL) {
136 DCHECK(details_.is_resizable); 138 DCHECK(details_.is_resizable);
139 root_window_ = details.window->GetRootWindow();
137 panel_container_ = Shell::GetContainer( 140 panel_container_ = Shell::GetContainer(
138 details.window->GetRootWindow(), 141 details.window->GetRootWindow(),
139 internal::kShellWindowId_PanelContainer); 142 internal::kShellWindowId_PanelContainer);
140 } 143 }
141 144
142 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, 145 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds,
143 gfx::Point* offset) { 146 gfx::Point* offset) {
144 bool should_attach = false; 147 bool should_attach = false;
145 if (panel_container_) { 148 if (panel_container_) {
146 internal::PanelLayoutManager* panel_layout_manager = 149 internal::PanelLayoutManager* panel_layout_manager =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 184 }
182 } 185 }
183 return should_attach; 186 return should_attach;
184 } 187 }
185 188
186 void PanelWindowResizer::StartedDragging() { 189 void PanelWindowResizer::StartedDragging() {
187 // Tell the panel layout manager that we are dragging this panel before 190 // Tell the panel layout manager that we are dragging this panel before
188 // attaching it so that it does not get repositioned. 191 // attaching it so that it does not get repositioned.
189 if (panel_container_) 192 if (panel_container_)
190 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); 193 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget());
191 if (!was_attached_) { 194 if (!was_attached_ && !IsWindowDocked(GetTarget())) {
flackr 2013/06/11 17:59:31 Don't we want dragged panels to show in front of o
varkha 2013/06/12 04:52:13 Eliminating window property made this redundant I
192 // Attach the panel while dragging placing it in front of other panels. 195 // Attach the panel while dragging placing it in front of other panels.
193 GetTarget()->SetProperty(internal::kContinueDragAfterReparent, true); 196 GetTarget()->SetProperty(internal::kContinueDragAfterReparent, true);
194 GetTarget()->SetProperty(internal::kPanelAttachedKey, true); 197 GetTarget()->SetProperty(internal::kPanelAttachedKey, true);
195 GetTarget()->SetDefaultParentByRootWindow( 198 GetTarget()->SetDefaultParentByRootWindow(
196 GetTarget()->GetRootWindow(), 199 GetTarget()->GetRootWindow(),
197 GetTarget()->GetBoundsInScreen()); 200 GetTarget()->GetBoundsInScreen());
198 } 201 }
199 } 202 }
200 203
201 void PanelWindowResizer::FinishDragging() { 204 void PanelWindowResizer::FinishDragging() {
202 if (!did_move_or_resize_) 205 if (!did_move_or_resize_)
203 return; 206 return;
204 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) != 207 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) !=
205 should_attach_) { 208 should_attach_) {
206 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_); 209 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_);
207 GetTarget()->SetDefaultParentByRootWindow( 210 gfx::Rect near_last_mouse_location(last_mouse_location_, gfx::Size());
208 GetTarget()->GetRootWindow(), 211 GetTarget()->SetDefaultParentByRootWindow(root_window_,
flackr 2013/06/11 17:59:31 This is using the root window from the start of th
varkha 2013/06/12 04:52:13 We end up using a root pointed by the |near_last_m
209 GetTarget()->GetBoundsInScreen()); 212 near_last_mouse_location);
210 } 213 }
211 if (panel_container_) 214 if (panel_container_)
212 GetPanelLayoutManager(panel_container_)->FinishDragging(); 215 GetPanelLayoutManager(panel_container_)->FinishDragging();
213 } 216 }
214 217
215 void PanelWindowResizer::UpdateLauncherPosition() { 218 void PanelWindowResizer::UpdateLauncherPosition() {
216 if (panel_container_) { 219 if (panel_container_) {
217 GetPanelLayoutManager(panel_container_)->launcher()-> 220 GetPanelLayoutManager(panel_container_)->launcher()->
218 UpdateIconPositionForWindow(GetTarget()); 221 UpdateIconPositionForWindow(GetTarget());
219 } 222 }
220 } 223 }
221 224
222 } // namespace aura 225 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698