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

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

Issue 2731663002: Remove WmWindowProperty (Closed)
Patch Set: Created 3 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
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/common/wm/panels/panel_window_resizer.h" 5 #include "ash/common/wm/panels/panel_window_resizer.h"
6 6
7 #include "ash/common/shelf/wm_shelf.h" 7 #include "ash/common/shelf/wm_shelf.h"
8 #include "ash/common/wm/panels/panel_layout_manager.h" 8 #include "ash/common/wm/panels/panel_layout_manager.h"
9 #include "ash/common/wm/window_parenting_utils.h" 9 #include "ash/common/wm/window_parenting_utils.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
11 #include "ash/common/wm_lookup.h" 11 #include "ash/common/wm_lookup.h"
12 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
13 #include "ash/common/wm_window_property.h"
14 #include "ash/public/cpp/shell_window_ids.h" 13 #include "ash/public/cpp/shell_window_ids.h"
14 #include "ash/public/cpp/window_properties.h"
15 #include "ash/root_window_controller.h" 15 #include "ash/root_window_controller.h"
16 #include "ui/base/hit_test.h" 16 #include "ui/base/hit_test.h"
17 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
18 #include "ui/display/display.h" 18 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 19 #include "ui/display/screen.h"
20 20
21 namespace ash { 21 namespace ash {
22 22
23 namespace { 23 namespace {
24 24
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 FinishDragging(); 99 FinishDragging();
100 } 100 }
101 101
102 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer, 102 PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
103 wm::WindowState* window_state) 103 wm::WindowState* window_state)
104 : WindowResizer(window_state), 104 : WindowResizer(window_state),
105 next_window_resizer_(next_window_resizer), 105 next_window_resizer_(next_window_resizer),
106 panel_container_(NULL), 106 panel_container_(NULL),
107 initial_panel_container_(NULL), 107 initial_panel_container_(NULL),
108 did_move_or_resize_(false), 108 did_move_or_resize_(false),
109 was_attached_( 109 was_attached_(GetTarget()->aura_window()->GetProperty(kPanelAttachedKey)),
110 GetTarget()->GetBoolProperty(WmWindowProperty::PANEL_ATTACHED)),
111 weak_ptr_factory_(this) { 110 weak_ptr_factory_(this) {
112 DCHECK(details().is_resizable); 111 DCHECK(details().is_resizable);
113 panel_container_ = GetTarget()->GetRootWindow()->GetChildByShellWindowId( 112 panel_container_ = GetTarget()->GetRootWindow()->GetChildByShellWindowId(
114 kShellWindowId_PanelContainer); 113 kShellWindowId_PanelContainer);
115 initial_panel_container_ = panel_container_; 114 initial_panel_container_ = panel_container_;
116 } 115 }
117 116
118 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, 117 bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds,
119 gfx::Point* offset) { 118 gfx::Point* offset) {
120 bool should_attach = false; 119 bool should_attach = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 151 }
153 152
154 void PanelWindowResizer::StartedDragging() { 153 void PanelWindowResizer::StartedDragging() {
155 // Tell the panel layout manager that we are dragging this panel before 154 // Tell the panel layout manager that we are dragging this panel before
156 // attaching it so that it does not get repositioned. 155 // attaching it so that it does not get repositioned.
157 if (panel_container_) 156 if (panel_container_)
158 PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget()); 157 PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget());
159 if (!was_attached_) { 158 if (!was_attached_) {
160 // Attach the panel while dragging, placing it in front of other panels. 159 // Attach the panel while dragging, placing it in front of other panels.
161 WmWindow* target = GetTarget(); 160 WmWindow* target = GetTarget();
162 target->SetBoolProperty(WmWindowProperty::PANEL_ATTACHED, true); 161 target->aura_window()->SetProperty(kPanelAttachedKey, true);
163 // We use root window coordinates to ensure that during the drag the panel 162 // We use root window coordinates to ensure that during the drag the panel
164 // is reparented to a container in the root window that has that window. 163 // is reparented to a container in the root window that has that window.
165 WmWindow* target_root = target->GetRootWindow(); 164 WmWindow* target_root = target->GetRootWindow();
166 WmWindow* old_parent = target->GetParent(); 165 WmWindow* old_parent = target->GetParent();
167 target->SetParentUsingContext(target_root, 166 target->SetParentUsingContext(target_root,
168 target_root->GetBoundsInScreen()); 167 target_root->GetBoundsInScreen());
169 wm::ReparentTransientChildrenOfChild(target, old_parent, 168 wm::ReparentTransientChildrenOfChild(target, old_parent,
170 target->GetParent()); 169 target->GetParent());
171 } 170 }
172 } 171 }
173 172
174 void PanelWindowResizer::FinishDragging() { 173 void PanelWindowResizer::FinishDragging() {
175 if (!did_move_or_resize_) 174 if (!did_move_or_resize_)
176 return; 175 return;
177 if (GetTarget()->GetBoolProperty(WmWindowProperty::PANEL_ATTACHED) != 176 if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) !=
178 details().should_attach_to_shelf) { 177 details().should_attach_to_shelf) {
179 GetTarget()->SetBoolProperty(WmWindowProperty::PANEL_ATTACHED, 178 GetTarget()->aura_window()->SetProperty(kPanelAttachedKey,
180 details().should_attach_to_shelf); 179 details().should_attach_to_shelf);
181 // We use last known location to ensure that after the drag the panel 180 // We use last known location to ensure that after the drag the panel
182 // is reparented to a container in the root window that has that location. 181 // is reparented to a container in the root window that has that location.
183 WmWindow* target = GetTarget(); 182 WmWindow* target = GetTarget();
184 WmWindow* target_root = target->GetRootWindow(); 183 WmWindow* target_root = target->GetRootWindow();
185 WmWindow* old_parent = target->GetParent(); 184 WmWindow* old_parent = target->GetParent();
186 target->SetParentUsingContext(target_root, 185 target->SetParentUsingContext(target_root,
187 gfx::Rect(last_location_, gfx::Size())); 186 gfx::Rect(last_location_, gfx::Size()));
188 wm::ReparentTransientChildrenOfChild(target, old_parent, 187 wm::ReparentTransientChildrenOfChild(target, old_parent,
189 target->GetParent()); 188 target->GetParent());
190 } 189 }
191 190
192 // If we started the drag in one root window and moved into another root 191 // If we started the drag in one root window and moved into another root
193 // but then canceled the drag we may need to inform the original layout 192 // but then canceled the drag we may need to inform the original layout
194 // manager that the drag is finished. 193 // manager that the drag is finished.
195 if (initial_panel_container_ != panel_container_) 194 if (initial_panel_container_ != panel_container_)
196 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); 195 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging();
197 if (panel_container_) 196 if (panel_container_)
198 PanelLayoutManager::Get(panel_container_)->FinishDragging(); 197 PanelLayoutManager::Get(panel_container_)->FinishDragging();
199 } 198 }
200 199
201 void PanelWindowResizer::UpdateLauncherPosition() { 200 void PanelWindowResizer::UpdateLauncherPosition() {
202 if (panel_container_) { 201 if (panel_container_) {
203 PanelLayoutManager::Get(panel_container_) 202 PanelLayoutManager::Get(panel_container_)
204 ->shelf() 203 ->shelf()
205 ->UpdateIconPositionForPanel(GetTarget()); 204 ->UpdateIconPositionForPanel(GetTarget());
206 } 205 }
207 } 206 }
208 207
209 } // namespace ash 208 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698