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

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

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 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/common/wm/panels/panel_layout_manager.h" 5 #include "ash/common/wm/panels/panel_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/common/shell_window_ids.h" 11 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/wm/shelf/wm_shelf.h" 12 #include "ash/common/wm/shelf/wm_shelf.h"
13 #include "ash/common/wm/shelf/wm_shelf_util.h" 13 #include "ash/common/wm/shelf/wm_shelf_util.h"
14 #include "ash/common/wm/window_animation_types.h" 14 #include "ash/common/wm/window_animation_types.h"
15 #include "ash/common/wm/window_parenting_utils.h" 15 #include "ash/common/wm/window_parenting_utils.h"
16 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm/wm_globals.h" 17 #include "ash/common/wm_lookup.h"
18 #include "ash/common/wm/wm_lookup.h" 18 #include "ash/common/wm_root_window_controller.h"
19 #include "ash/common/wm/wm_root_window_controller.h" 19 #include "ash/common/wm_shell.h"
20 #include "ash/common/wm/wm_window.h" 20 #include "ash/common/wm_window.h"
21 #include "ash/common/wm/wm_window_property.h" 21 #include "ash/common/wm_window_property.h"
22 #include "base/auto_reset.h" 22 #include "base/auto_reset.h"
23 #include "third_party/skia/include/core/SkColor.h" 23 #include "third_party/skia/include/core/SkColor.h"
24 #include "third_party/skia/include/core/SkPaint.h" 24 #include "third_party/skia/include/core/SkPaint.h"
25 #include "third_party/skia/include/core/SkPath.h" 25 #include "third_party/skia/include/core/SkPath.h"
26 #include "ui/compositor/scoped_layer_animation_settings.h" 26 #include "ui/compositor/scoped_layer_animation_settings.h"
27 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
28 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/vector2d.h" 29 #include "ui/gfx/geometry/vector2d.h"
30 #include "ui/views/background.h" 30 #include "ui/views/background.h"
31 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 max_major(0), 99 max_major(0),
100 major_pos(0), 100 major_pos(0),
101 major_length(0), 101 major_length(0),
102 window(NULL), 102 window(NULL),
103 slide_in(false) {} 103 slide_in(false) {}
104 104
105 int min_major; 105 int min_major;
106 int max_major; 106 int max_major;
107 int major_pos; 107 int major_pos;
108 int major_length; 108 int major_length;
109 wm::WmWindow* window; 109 WmWindow* window;
110 bool slide_in; 110 bool slide_in;
111 }; 111 };
112 112
113 bool CompareWindowMajor(const VisiblePanelPositionInfo& win1, 113 bool CompareWindowMajor(const VisiblePanelPositionInfo& win1,
114 const VisiblePanelPositionInfo& win2) { 114 const VisiblePanelPositionInfo& win2) {
115 return win1.major_pos < win2.major_pos; 115 return win1.major_pos < win2.major_pos;
116 } 116 }
117 117
118 void FanOutPanels(std::vector<VisiblePanelPositionInfo>::iterator first, 118 void FanOutPanels(std::vector<VisiblePanelPositionInfo>::iterator first,
119 std::vector<VisiblePanelPositionInfo>::iterator last) { 119 std::vector<VisiblePanelPositionInfo>::iterator last) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 offset.set_x(kPanelSlideInOffset); 168 offset.set_x(kPanelSlideInOffset);
169 else 169 else
170 offset.set_y(kPanelSlideInOffset); 170 offset.set_y(kPanelSlideInOffset);
171 return offset; 171 return offset;
172 } 172 }
173 173
174 } // namespace 174 } // namespace
175 175
176 class PanelCalloutWidget : public views::Widget { 176 class PanelCalloutWidget : public views::Widget {
177 public: 177 public:
178 explicit PanelCalloutWidget(wm::WmWindow* container) : background_(nullptr) { 178 explicit PanelCalloutWidget(WmWindow* container) : background_(nullptr) {
179 InitWidget(container); 179 InitWidget(container);
180 } 180 }
181 181
182 void SetAlignment(wm::ShelfAlignment alignment) { 182 void SetAlignment(wm::ShelfAlignment alignment) {
183 gfx::Rect callout_bounds = GetWindowBoundsInScreen(); 183 gfx::Rect callout_bounds = GetWindowBoundsInScreen();
184 if (wm::IsHorizontalAlignment(alignment)) { 184 if (wm::IsHorizontalAlignment(alignment)) {
185 callout_bounds.set_width(kArrowWidth); 185 callout_bounds.set_width(kArrowWidth);
186 callout_bounds.set_height(kArrowHeight); 186 callout_bounds.set_height(kArrowHeight);
187 } else { 187 } else {
188 callout_bounds.set_width(kArrowHeight); 188 callout_bounds.set_width(kArrowHeight);
189 callout_bounds.set_height(kArrowWidth); 189 callout_bounds.set_height(kArrowWidth);
190 } 190 }
191 SetBounds(callout_bounds); 191 SetBounds(callout_bounds);
192 if (background_->alignment() != alignment) { 192 if (background_->alignment() != alignment) {
193 background_->set_alignment(alignment); 193 background_->set_alignment(alignment);
194 SchedulePaintInRect(gfx::Rect(callout_bounds.size())); 194 SchedulePaintInRect(gfx::Rect(callout_bounds.size()));
195 } 195 }
196 } 196 }
197 197
198 private: 198 private:
199 void InitWidget(wm::WmWindow* parent) { 199 void InitWidget(WmWindow* parent) {
200 views::Widget::InitParams params; 200 views::Widget::InitParams params;
201 params.type = views::Widget::InitParams::TYPE_POPUP; 201 params.type = views::Widget::InitParams::TYPE_POPUP;
202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 202 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
203 params.keep_on_top = true; 203 params.keep_on_top = true;
204 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 204 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
205 params.bounds = parent->ConvertRectToScreen(gfx::Rect()); 205 params.bounds = parent->ConvertRectToScreen(gfx::Rect());
206 params.bounds.set_width(kArrowWidth); 206 params.bounds.set_width(kArrowWidth);
207 params.bounds.set_height(kArrowHeight); 207 params.bounds.set_height(kArrowHeight);
208 params.accept_events = false; 208 params.accept_events = false;
209 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 209 parent->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
210 this, parent->GetShellWindowId(), &params); 210 this, parent->GetShellWindowId(), &params);
211 set_focus_on_creation(false); 211 set_focus_on_creation(false);
212 Init(params); 212 Init(params);
213 wm::WmWindow* widget_window = wm::WmLookup::Get()->GetWindowForWidget(this); 213 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(this);
214 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow()); 214 DCHECK_EQ(widget_window->GetRootWindow(), parent->GetRootWindow());
215 views::View* content_view = new views::View; 215 views::View* content_view = new views::View;
216 background_ = new CalloutWidgetBackground; 216 background_ = new CalloutWidgetBackground;
217 content_view->set_background(background_); 217 content_view->set_background(background_);
218 SetContentsView(content_view); 218 SetContentsView(content_view);
219 widget_window->GetLayer()->SetOpacity(0); 219 widget_window->GetLayer()->SetOpacity(0);
220 } 220 }
221 221
222 // Weak pointer owned by this widget's content view. 222 // Weak pointer owned by this widget's content view.
223 CalloutWidgetBackground* background_; 223 CalloutWidgetBackground* background_;
224 224
225 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget); 225 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget);
226 }; 226 };
227 227
228 views::Widget* PanelLayoutManager::PanelInfo::CalloutWidget() { 228 views::Widget* PanelLayoutManager::PanelInfo::CalloutWidget() {
229 return callout_widget; 229 return callout_widget;
230 } 230 }
231 231
232 //////////////////////////////////////////////////////////////////////////////// 232 ////////////////////////////////////////////////////////////////////////////////
233 // PanelLayoutManager public implementation: 233 // PanelLayoutManager public implementation:
234 PanelLayoutManager::PanelLayoutManager(wm::WmWindow* panel_container) 234 PanelLayoutManager::PanelLayoutManager(WmWindow* panel_container)
235 : panel_container_(panel_container), 235 : panel_container_(panel_container),
236 root_window_controller_(panel_container->GetRootWindowController()), 236 root_window_controller_(panel_container->GetRootWindowController()),
237 in_add_window_(false), 237 in_add_window_(false),
238 in_layout_(false), 238 in_layout_(false),
239 show_callout_widgets_(true), 239 show_callout_widgets_(true),
240 dragged_panel_(NULL), 240 dragged_panel_(NULL),
241 shelf_(nullptr), 241 shelf_(nullptr),
242 last_active_panel_(NULL), 242 last_active_panel_(NULL),
243 weak_factory_(this) { 243 weak_factory_(this) {
244 DCHECK(panel_container); 244 DCHECK(panel_container);
245 wm::WmGlobals* globals = panel_container->GetGlobals(); 245 WmShell* shell = panel_container->GetShell();
246 globals->AddActivationObserver(this); 246 shell->AddActivationObserver(this);
247 globals->AddDisplayObserver(this); 247 shell->AddDisplayObserver(this);
248 globals->AddOverviewModeObserver(this); 248 shell->AddOverviewModeObserver(this);
249 root_window_controller_->AddObserver(this); 249 root_window_controller_->AddObserver(this);
250 } 250 }
251 251
252 PanelLayoutManager::~PanelLayoutManager() { 252 PanelLayoutManager::~PanelLayoutManager() {
253 Shutdown(); 253 Shutdown();
254 } 254 }
255 255
256 // static 256 // static
257 PanelLayoutManager* PanelLayoutManager::Get(wm::WmWindow* window) { 257 PanelLayoutManager* PanelLayoutManager::Get(WmWindow* window) {
258 if (!window) 258 if (!window)
259 return nullptr; 259 return nullptr;
260 260
261 return static_cast<PanelLayoutManager*>( 261 return static_cast<PanelLayoutManager*>(
262 window->GetRootWindow() 262 window->GetRootWindow()
263 ->GetChildByShellWindowId(kShellWindowId_PanelContainer) 263 ->GetChildByShellWindowId(kShellWindowId_PanelContainer)
264 ->GetLayoutManager()); 264 ->GetLayoutManager());
265 } 265 }
266 266
267 void PanelLayoutManager::Shutdown() { 267 void PanelLayoutManager::Shutdown() {
268 if (shelf_) { 268 if (shelf_) {
269 shelf_->RemoveObserver(this); 269 shelf_->RemoveObserver(this);
270 shelf_ = nullptr; 270 shelf_ = nullptr;
271 } 271 }
272 for (PanelList::iterator iter = panel_windows_.begin(); 272 for (PanelList::iterator iter = panel_windows_.begin();
273 iter != panel_windows_.end(); ++iter) { 273 iter != panel_windows_.end(); ++iter) {
274 delete iter->callout_widget; 274 delete iter->callout_widget;
275 } 275 }
276 panel_windows_.clear(); 276 panel_windows_.clear();
277 wm::WmGlobals* globals = panel_container_->GetGlobals(); 277 WmShell* shell = panel_container_->GetShell();
278 globals->RemoveActivationObserver(this); 278 shell->RemoveActivationObserver(this);
279 globals->RemoveDisplayObserver(this); 279 shell->RemoveDisplayObserver(this);
280 globals->RemoveOverviewModeObserver(this); 280 shell->RemoveOverviewModeObserver(this);
281 root_window_controller_->RemoveObserver(this); 281 root_window_controller_->RemoveObserver(this);
282 } 282 }
283 283
284 void PanelLayoutManager::StartDragging(wm::WmWindow* panel) { 284 void PanelLayoutManager::StartDragging(WmWindow* panel) {
285 DCHECK(!dragged_panel_); 285 DCHECK(!dragged_panel_);
286 dragged_panel_ = panel; 286 dragged_panel_ = panel;
287 Relayout(); 287 Relayout();
288 } 288 }
289 289
290 void PanelLayoutManager::FinishDragging() { 290 void PanelLayoutManager::FinishDragging() {
291 dragged_panel_ = NULL; 291 dragged_panel_ = NULL;
292 Relayout(); 292 Relayout();
293 } 293 }
294 294
295 void PanelLayoutManager::SetShelf(wm::WmShelf* shelf) { 295 void PanelLayoutManager::SetShelf(wm::WmShelf* shelf) {
296 DCHECK(!shelf_); 296 DCHECK(!shelf_);
297 shelf_ = shelf; 297 shelf_ = shelf;
298 shelf_->AddObserver(this); 298 shelf_->AddObserver(this);
299 WillChangeVisibilityState(shelf_->GetVisibilityState()); 299 WillChangeVisibilityState(shelf_->GetVisibilityState());
300 } 300 }
301 301
302 void PanelLayoutManager::ToggleMinimize(wm::WmWindow* panel) { 302 void PanelLayoutManager::ToggleMinimize(WmWindow* panel) {
303 DCHECK(panel->GetParent() == panel_container_); 303 DCHECK(panel->GetParent() == panel_container_);
304 wm::WindowState* window_state = panel->GetWindowState(); 304 wm::WindowState* window_state = panel->GetWindowState();
305 if (window_state->IsMinimized()) 305 if (window_state->IsMinimized())
306 window_state->Restore(); 306 window_state->Restore();
307 else 307 else
308 window_state->Minimize(); 308 window_state->Minimize();
309 } 309 }
310 310
311 void PanelLayoutManager::SetShowCalloutWidgets(bool show) { 311 void PanelLayoutManager::SetShowCalloutWidgets(bool show) {
312 if (show_callout_widgets_ == show) 312 if (show_callout_widgets_ == show)
313 return; 313 return;
314 show_callout_widgets_ = show; 314 show_callout_widgets_ = show;
315 UpdateCallouts(); 315 UpdateCallouts();
316 } 316 }
317 317
318 views::Widget* PanelLayoutManager::GetCalloutWidgetForPanel( 318 views::Widget* PanelLayoutManager::GetCalloutWidgetForPanel(WmWindow* panel) {
319 wm::WmWindow* panel) {
320 DCHECK(panel->GetParent() == panel_container_); 319 DCHECK(panel->GetParent() == panel_container_);
321 PanelList::iterator found = 320 PanelList::iterator found =
322 std::find(panel_windows_.begin(), panel_windows_.end(), panel); 321 std::find(panel_windows_.begin(), panel_windows_.end(), panel);
323 DCHECK(found != panel_windows_.end()); 322 DCHECK(found != panel_windows_.end());
324 return found->callout_widget; 323 return found->callout_widget;
325 } 324 }
326 325
327 //////////////////////////////////////////////////////////////////////////////// 326 ////////////////////////////////////////////////////////////////////////////////
328 // PanelLayoutManager, wm::WmLayoutManager implementation: 327 // PanelLayoutManager, WmLayoutManager implementation:
329 void PanelLayoutManager::OnWindowResized() { 328 void PanelLayoutManager::OnWindowResized() {
330 Relayout(); 329 Relayout();
331 } 330 }
332 331
333 void PanelLayoutManager::OnWindowAddedToLayout(wm::WmWindow* child) { 332 void PanelLayoutManager::OnWindowAddedToLayout(WmWindow* child) {
334 if (child->GetType() == ui::wm::WINDOW_TYPE_POPUP) 333 if (child->GetType() == ui::wm::WINDOW_TYPE_POPUP)
335 return; 334 return;
336 if (in_add_window_) 335 if (in_add_window_)
337 return; 336 return;
338 base::AutoReset<bool> auto_reset_in_add_window(&in_add_window_, true); 337 base::AutoReset<bool> auto_reset_in_add_window(&in_add_window_, true);
339 if (!child->GetWindowState()->panel_attached()) { 338 if (!child->GetWindowState()->panel_attached()) {
340 // This should only happen when a window is added to panel container as a 339 // This should only happen when a window is added to panel container as a
341 // result of bounds change from within the application during a drag. 340 // result of bounds change from within the application during a drag.
342 // If so we have already stopped the drag and should reparent the panel 341 // If so we have already stopped the drag and should reparent the panel
343 // back to appropriate container and ignore it. 342 // back to appropriate container and ignore it.
344 // TODO(varkha): Updating bounds during a drag can cause problems and a more 343 // TODO(varkha): Updating bounds during a drag can cause problems and a more
345 // general solution is needed. See http://crbug.com/251813 . 344 // general solution is needed. See http://crbug.com/251813 .
346 wm::WmWindow* old_parent = child->GetParent(); 345 WmWindow* old_parent = child->GetParent();
347 child->SetParentUsingContext(child, 346 child->SetParentUsingContext(child,
348 child->GetRootWindow()->GetBoundsInScreen()); 347 child->GetRootWindow()->GetBoundsInScreen());
349 wm::ReparentTransientChildrenOfChild(child, old_parent, child->GetParent()); 348 wm::ReparentTransientChildrenOfChild(child, old_parent, child->GetParent());
350 DCHECK(child->GetParent()->GetShellWindowId() != 349 DCHECK(child->GetParent()->GetShellWindowId() !=
351 kShellWindowId_PanelContainer); 350 kShellWindowId_PanelContainer);
352 return; 351 return;
353 } 352 }
354 PanelInfo panel_info; 353 PanelInfo panel_info;
355 panel_info.window = child; 354 panel_info.window = child;
356 panel_info.callout_widget = new PanelCalloutWidget(panel_container_); 355 panel_info.callout_widget = new PanelCalloutWidget(panel_container_);
357 panel_info.slide_in = child != dragged_panel_; 356 panel_info.slide_in = child != dragged_panel_;
358 panel_windows_.push_back(panel_info); 357 panel_windows_.push_back(panel_info);
359 child->AddObserver(this); 358 child->AddObserver(this);
360 child->GetWindowState()->AddObserver(this); 359 child->GetWindowState()->AddObserver(this);
361 Relayout(); 360 Relayout();
362 } 361 }
363 362
364 void PanelLayoutManager::OnWillRemoveWindowFromLayout(wm::WmWindow* child) {} 363 void PanelLayoutManager::OnWillRemoveWindowFromLayout(WmWindow* child) {}
365 364
366 void PanelLayoutManager::OnWindowRemovedFromLayout(wm::WmWindow* child) { 365 void PanelLayoutManager::OnWindowRemovedFromLayout(WmWindow* child) {
367 if (child->GetType() == ui::wm::WINDOW_TYPE_POPUP) 366 if (child->GetType() == ui::wm::WINDOW_TYPE_POPUP)
368 return; 367 return;
369 PanelList::iterator found = 368 PanelList::iterator found =
370 std::find(panel_windows_.begin(), panel_windows_.end(), child); 369 std::find(panel_windows_.begin(), panel_windows_.end(), child);
371 if (found != panel_windows_.end()) { 370 if (found != panel_windows_.end()) {
372 delete found->callout_widget; 371 delete found->callout_widget;
373 panel_windows_.erase(found); 372 panel_windows_.erase(found);
374 } 373 }
375 if (restore_windows_on_shelf_visible_) 374 if (restore_windows_on_shelf_visible_)
376 restore_windows_on_shelf_visible_->Remove(child); 375 restore_windows_on_shelf_visible_->Remove(child);
377 child->RemoveObserver(this); 376 child->RemoveObserver(this);
378 child->GetWindowState()->RemoveObserver(this); 377 child->GetWindowState()->RemoveObserver(this);
379 378
380 if (dragged_panel_ == child) 379 if (dragged_panel_ == child)
381 dragged_panel_ = NULL; 380 dragged_panel_ = NULL;
382 381
383 if (last_active_panel_ == child) 382 if (last_active_panel_ == child)
384 last_active_panel_ = NULL; 383 last_active_panel_ = NULL;
385 384
386 Relayout(); 385 Relayout();
387 } 386 }
388 387
389 void PanelLayoutManager::OnChildWindowVisibilityChanged(wm::WmWindow* child, 388 void PanelLayoutManager::OnChildWindowVisibilityChanged(WmWindow* child,
390 bool visible) { 389 bool visible) {
391 if (visible) 390 if (visible)
392 child->GetWindowState()->Restore(); 391 child->GetWindowState()->Restore();
393 Relayout(); 392 Relayout();
394 } 393 }
395 394
396 void PanelLayoutManager::SetChildBounds(wm::WmWindow* child, 395 void PanelLayoutManager::SetChildBounds(WmWindow* child,
397 const gfx::Rect& requested_bounds) { 396 const gfx::Rect& requested_bounds) {
398 gfx::Rect bounds(requested_bounds); 397 gfx::Rect bounds(requested_bounds);
399 const gfx::Rect& max_bounds = panel_container_->GetRootWindow()->GetBounds(); 398 const gfx::Rect& max_bounds = panel_container_->GetRootWindow()->GetBounds();
400 const int max_width = max_bounds.width() * kMaxWidthFactor; 399 const int max_width = max_bounds.width() * kMaxWidthFactor;
401 const int max_height = max_bounds.height() * kMaxHeightFactor; 400 const int max_height = max_bounds.height() * kMaxHeightFactor;
402 if (bounds.width() > max_width) 401 if (bounds.width() > max_width)
403 bounds.set_width(max_width); 402 bounds.set_width(max_width);
404 if (bounds.height() > max_height) 403 if (bounds.height() > max_height)
405 bounds.set_height(max_height); 404 bounds.set_height(max_height);
406 405
(...skipping 20 matching lines...) Expand all
427 const gfx::Size min_size = child->GetMinimumSize(); 426 const gfx::Size min_size = child->GetMinimumSize();
428 bounds.set_width(std::max(min_size.width(), bounds.width())); 427 bounds.set_width(std::max(min_size.width(), bounds.width()));
429 bounds.set_height(std::max(min_size.height(), bounds.height())); 428 bounds.set_height(std::max(min_size.height(), bounds.height()));
430 } 429 }
431 430
432 child->SetBoundsDirect(bounds); 431 child->SetBoundsDirect(bounds);
433 Relayout(); 432 Relayout();
434 } 433 }
435 434
436 //////////////////////////////////////////////////////////////////////////////// 435 ////////////////////////////////////////////////////////////////////////////////
437 // PanelLayoutManager, wm::WmShellObserver implementation: 436 // PanelLayoutManager, WmShellObserver implementation:
438 437
439 void PanelLayoutManager::OnOverviewModeEnded() { 438 void PanelLayoutManager::OnOverviewModeEnded() {
440 Relayout(); 439 Relayout();
441 } 440 }
442 441
443 void PanelLayoutManager::OnShelfAlignmentChanged() { 442 void PanelLayoutManager::OnShelfAlignmentChanged() {
444 Relayout(); 443 Relayout();
445 } 444 }
446 445
447 ///////////////////////////////////////////////////////////////////////////// 446 /////////////////////////////////////////////////////////////////////////////
448 // PanelLayoutManager, WindowObserver implementation: 447 // PanelLayoutManager, WindowObserver implementation:
449 448
450 void PanelLayoutManager::OnWindowPropertyChanged( 449 void PanelLayoutManager::OnWindowPropertyChanged(WmWindow* window,
451 wm::WmWindow* window, 450 WmWindowProperty property) {
452 wm::WmWindowProperty property) {
453 // Trigger a relayout to position the panels whenever the panel icon is set 451 // Trigger a relayout to position the panels whenever the panel icon is set
454 // or changes. 452 // or changes.
455 if (property == wm::WmWindowProperty::SHELF_ID) 453 if (property == WmWindowProperty::SHELF_ID)
456 Relayout(); 454 Relayout();
457 } 455 }
458 456
459 ///////////////////////////////////////////////////////////////////////////// 457 /////////////////////////////////////////////////////////////////////////////
460 // PanelLayoutManager, WindowStateObserver implementation: 458 // PanelLayoutManager, WindowStateObserver implementation:
461 459
462 void PanelLayoutManager::OnPostWindowStateTypeChange( 460 void PanelLayoutManager::OnPostWindowStateTypeChange(
463 wm::WindowState* window_state, 461 wm::WindowState* window_state,
464 wm::WindowStateType old_type) { 462 wm::WindowStateType old_type) {
465 // If the shelf is currently hidden then windows will not actually be shown 463 // If the shelf is currently hidden then windows will not actually be shown
466 // but the set to restore when the shelf becomes visible is updated. 464 // but the set to restore when the shelf becomes visible is updated.
467 if (restore_windows_on_shelf_visible_) { 465 if (restore_windows_on_shelf_visible_) {
468 if (window_state->IsMinimized()) { 466 if (window_state->IsMinimized()) {
469 MinimizePanel(window_state->window()); 467 MinimizePanel(window_state->window());
470 restore_windows_on_shelf_visible_->Remove(window_state->window()); 468 restore_windows_on_shelf_visible_->Remove(window_state->window());
471 } else { 469 } else {
472 restore_windows_on_shelf_visible_->Add(window_state->window()); 470 restore_windows_on_shelf_visible_->Add(window_state->window());
473 } 471 }
474 return; 472 return;
475 } 473 }
476 474
477 if (window_state->IsMinimized()) 475 if (window_state->IsMinimized())
478 MinimizePanel(window_state->window()); 476 MinimizePanel(window_state->window());
479 else 477 else
480 RestorePanel(window_state->window()); 478 RestorePanel(window_state->window());
481 } 479 }
482 480
483 //////////////////////////////////////////////////////////////////////////////// 481 ////////////////////////////////////////////////////////////////////////////////
484 // PanelLayoutManager, wm::WmActivationObserver implementation: 482 // PanelLayoutManager, WmActivationObserver implementation:
485 483
486 void PanelLayoutManager::OnWindowActivated(wm::WmWindow* gained_active, 484 void PanelLayoutManager::OnWindowActivated(WmWindow* gained_active,
487 wm::WmWindow* lost_active) { 485 WmWindow* lost_active) {
488 // Ignore if the panel that is not managed by this was activated. 486 // Ignore if the panel that is not managed by this was activated.
489 if (gained_active && gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL && 487 if (gained_active && gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL &&
490 gained_active->GetParent() == panel_container_) { 488 gained_active->GetParent() == panel_container_) {
491 UpdateStacking(gained_active); 489 UpdateStacking(gained_active);
492 UpdateCallouts(); 490 UpdateCallouts();
493 } 491 }
494 } 492 }
495 493
496 //////////////////////////////////////////////////////////////////////////////// 494 ////////////////////////////////////////////////////////////////////////////////
497 // PanelLayoutManager, wm::WmDisplayObserver::Observer implementation: 495 // PanelLayoutManager, WmDisplayObserver::Observer implementation:
498 496
499 void PanelLayoutManager::OnDisplayConfigurationChanged() { 497 void PanelLayoutManager::OnDisplayConfigurationChanged() {
500 Relayout(); 498 Relayout();
501 } 499 }
502 500
503 //////////////////////////////////////////////////////////////////////////////// 501 ////////////////////////////////////////////////////////////////////////////////
504 // PanelLayoutManager, ShelfLayoutManagerObserver implementation: 502 // PanelLayoutManager, ShelfLayoutManagerObserver implementation:
505 503
506 void PanelLayoutManager::WillChangeVisibilityState( 504 void PanelLayoutManager::WillChangeVisibilityState(
507 ShelfVisibilityState new_state) { 505 ShelfVisibilityState new_state) {
508 // On entering / leaving full screen mode the shelf visibility state is 506 // On entering / leaving full screen mode the shelf visibility state is
509 // changed to / from SHELF_HIDDEN. In this state, panel windows should hide 507 // changed to / from SHELF_HIDDEN. In this state, panel windows should hide
510 // to allow the full-screen application to use the full screen. 508 // to allow the full-screen application to use the full screen.
511 bool shelf_hidden = new_state == ash::SHELF_HIDDEN; 509 bool shelf_hidden = new_state == ash::SHELF_HIDDEN;
512 if (!shelf_hidden) { 510 if (!shelf_hidden) {
513 if (restore_windows_on_shelf_visible_) { 511 if (restore_windows_on_shelf_visible_) {
514 std::unique_ptr<wm::WmWindowTracker> restore_windows( 512 std::unique_ptr<WmWindowTracker> restore_windows(
515 std::move(restore_windows_on_shelf_visible_)); 513 std::move(restore_windows_on_shelf_visible_));
516 for (wm::WmWindow* window : restore_windows->windows()) 514 for (WmWindow* window : restore_windows->windows())
517 RestorePanel(window); 515 RestorePanel(window);
518 } 516 }
519 return; 517 return;
520 } 518 }
521 519
522 if (restore_windows_on_shelf_visible_) 520 if (restore_windows_on_shelf_visible_)
523 return; 521 return;
524 std::unique_ptr<wm::WmWindowTracker> minimized_windows( 522 std::unique_ptr<WmWindowTracker> minimized_windows(new WmWindowTracker);
525 new wm::WmWindowTracker);
526 for (PanelList::iterator iter = panel_windows_.begin(); 523 for (PanelList::iterator iter = panel_windows_.begin();
527 iter != panel_windows_.end();) { 524 iter != panel_windows_.end();) {
528 wm::WmWindow* window = iter->window; 525 WmWindow* window = iter->window;
529 // Minimizing a panel window may remove it from the panel_windows_ list. 526 // Minimizing a panel window may remove it from the panel_windows_ list.
530 // Advance the iterator before minimizing it: http://crbug.com/393047. 527 // Advance the iterator before minimizing it: http://crbug.com/393047.
531 ++iter; 528 ++iter;
532 if (window != dragged_panel_ && window->IsVisible()) { 529 if (window != dragged_panel_ && window->IsVisible()) {
533 minimized_windows->Add(window); 530 minimized_windows->Add(window);
534 window->GetWindowState()->Minimize(); 531 window->GetWindowState()->Minimize();
535 } 532 }
536 } 533 }
537 restore_windows_on_shelf_visible_ = std::move(minimized_windows); 534 restore_windows_on_shelf_visible_ = std::move(minimized_windows);
538 } 535 }
539 536
540 void PanelLayoutManager::OnShelfIconPositionsChanged() { 537 void PanelLayoutManager::OnShelfIconPositionsChanged() {
541 // TODO: As this is called for every animation step now. Relayout needs to be 538 // TODO: As this is called for every animation step now. Relayout needs to be
542 // updated to use current icon position instead of use the ideal bounds so 539 // updated to use current icon position instead of use the ideal bounds so
543 // that the panels slide with their icons instead of jumping. 540 // that the panels slide with their icons instead of jumping.
544 Relayout(); 541 Relayout();
545 } 542 }
546 543
547 //////////////////////////////////////////////////////////////////////////////// 544 ////////////////////////////////////////////////////////////////////////////////
548 // PanelLayoutManager private implementation: 545 // PanelLayoutManager private implementation:
549 546
550 void PanelLayoutManager::MinimizePanel(wm::WmWindow* panel) { 547 void PanelLayoutManager::MinimizePanel(WmWindow* panel) {
551 panel->SetVisibilityAnimationType( 548 panel->SetVisibilityAnimationType(
552 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); 549 wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE);
553 ui::Layer* layer = panel->GetLayer(); 550 ui::Layer* layer = panel->GetLayer();
554 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator()); 551 ui::ScopedLayerAnimationSettings panel_slide_settings(layer->GetAnimator());
555 panel_slide_settings.SetPreemptionStrategy( 552 panel_slide_settings.SetPreemptionStrategy(
556 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 553 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
557 panel_slide_settings.SetTransitionDuration( 554 panel_slide_settings.SetTransitionDuration(
558 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds)); 555 base::TimeDelta::FromMilliseconds(kPanelSlideDurationMilliseconds));
559 gfx::Rect bounds(panel->GetBounds()); 556 gfx::Rect bounds(panel->GetBounds());
560 bounds.Offset(GetSlideInAnimationOffset(shelf_->GetAlignment())); 557 bounds.Offset(GetSlideInAnimationOffset(shelf_->GetAlignment()));
561 panel->SetBoundsDirect(bounds); 558 panel->SetBoundsDirect(bounds);
562 panel->Hide(); 559 panel->Hide();
563 layer->SetOpacity(0); 560 layer->SetOpacity(0);
564 if (panel->IsActive()) 561 if (panel->IsActive())
565 panel->Deactivate(); 562 panel->Deactivate();
566 Relayout(); 563 Relayout();
567 } 564 }
568 565
569 void PanelLayoutManager::RestorePanel(wm::WmWindow* panel) { 566 void PanelLayoutManager::RestorePanel(WmWindow* panel) {
570 PanelList::iterator found = 567 PanelList::iterator found =
571 std::find(panel_windows_.begin(), panel_windows_.end(), panel); 568 std::find(panel_windows_.begin(), panel_windows_.end(), panel);
572 DCHECK(found != panel_windows_.end()); 569 DCHECK(found != panel_windows_.end());
573 found->slide_in = true; 570 found->slide_in = true;
574 Relayout(); 571 Relayout();
575 } 572 }
576 573
577 void PanelLayoutManager::Relayout() { 574 void PanelLayoutManager::Relayout() {
578 if (!shelf_) 575 if (!shelf_)
579 return; 576 return;
580 577
581 // Suppress layouts during overview mode because changing window bounds 578 // Suppress layouts during overview mode because changing window bounds
582 // interfered with overview mode animations. However, layouts need to be done 579 // interfered with overview mode animations. However, layouts need to be done
583 // when the WindowSelectorController is restoring minimized windows so that 580 // when the WindowSelectorController is restoring minimized windows so that
584 // they actually become visible. 581 // they actually become visible.
585 wm::WmGlobals* globals = panel_container_->GetGlobals(); 582 WmShell* shell = panel_container_->GetShell();
586 if (in_layout_ || (globals->IsOverviewModeSelecting() && 583 if (in_layout_ || (shell->IsOverviewModeSelecting() &&
587 !globals->IsOverviewModeRestoringMinimizedWindows())) { 584 !shell->IsOverviewModeRestoringMinimizedWindows())) {
588 return; 585 return;
589 } 586 }
590 587
591 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 588 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
592 589
593 const wm::ShelfAlignment alignment = shelf_->GetAlignment(); 590 const wm::ShelfAlignment alignment = shelf_->GetAlignment();
594 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment()); 591 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
595 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen( 592 gfx::Rect shelf_bounds = panel_container_->ConvertRectFromScreen(
596 shelf_->GetWindow()->GetBoundsInScreen()); 593 shelf_->GetWindow()->GetBoundsInScreen());
597 int panel_start_bounds = kPanelIdealSpacing; 594 int panel_start_bounds = kPanelIdealSpacing;
598 int panel_end_bounds = 595 int panel_end_bounds =
599 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing 596 horizontal ? panel_container_->GetBounds().width() - kPanelIdealSpacing
600 : panel_container_->GetBounds().height() - kPanelIdealSpacing; 597 : panel_container_->GetBounds().height() - kPanelIdealSpacing;
601 wm::WmWindow* active_panel = nullptr; 598 WmWindow* active_panel = nullptr;
602 std::vector<VisiblePanelPositionInfo> visible_panels; 599 std::vector<VisiblePanelPositionInfo> visible_panels;
603 for (PanelList::iterator iter = panel_windows_.begin(); 600 for (PanelList::iterator iter = panel_windows_.begin();
604 iter != panel_windows_.end(); ++iter) { 601 iter != panel_windows_.end(); ++iter) {
605 wm::WmWindow* panel = iter->window; 602 WmWindow* panel = iter->window;
606 iter->callout_widget->SetAlignment(alignment); 603 iter->callout_widget->SetAlignment(alignment);
607 604
608 // Consider the dragged panel as part of the layout as long as it is 605 // Consider the dragged panel as part of the layout as long as it is
609 // touching the shelf. 606 // touching the shelf.
610 if ((!panel->IsVisible() && !iter->slide_in) || 607 if ((!panel->IsVisible() && !iter->slide_in) ||
611 (panel == dragged_panel_ && 608 (panel == dragged_panel_ &&
612 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) { 609 !BoundsAdjacent(panel->GetBounds(), shelf_bounds))) {
613 continue; 610 continue;
614 } 611 }
615 612
(...skipping 10 matching lines...) Expand all
626 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); 623 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
627 624
628 // If both the icon width and height are 0 then there is no icon in the 625 // If both the icon width and height are 0 then there is no icon in the
629 // shelf. If the shelf is hidden, one of the height or width will be 626 // shelf. If the shelf is hidden, one of the height or width will be
630 // 0 but the position in the shelf and major dimension is still reported 627 // 0 but the position in the shelf and major dimension is still reported
631 // correctly and the panel can be aligned above where the hidden icon is. 628 // correctly and the panel can be aligned above where the hidden icon is.
632 if (icon_bounds.width() == 0 && icon_bounds.height() == 0) 629 if (icon_bounds.width() == 0 && icon_bounds.height() == 0)
633 continue; 630 continue;
634 631
635 if (panel->IsFocused() || 632 if (panel->IsFocused() ||
636 panel->Contains(panel->GetGlobals()->GetFocusedWindow())) { 633 panel->Contains(panel->GetShell()->GetFocusedWindow())) {
637 DCHECK(!active_panel); 634 DCHECK(!active_panel);
638 active_panel = panel; 635 active_panel = panel;
639 } 636 }
640 icon_bounds = panel_container_->ConvertRectFromScreen(icon_bounds); 637 icon_bounds = panel_container_->ConvertRectFromScreen(icon_bounds);
641 gfx::Point icon_origin = icon_bounds.origin(); 638 gfx::Point icon_origin = icon_bounds.origin();
642 VisiblePanelPositionInfo position_info; 639 VisiblePanelPositionInfo position_info;
643 int icon_start = horizontal ? icon_origin.x() : icon_origin.y(); 640 int icon_start = horizontal ? icon_origin.x() : icon_origin.y();
644 int icon_end = 641 int icon_end =
645 icon_start + (horizontal ? icon_bounds.width() : icon_bounds.height()); 642 icon_start + (horizontal ? icon_bounds.width() : icon_bounds.height());
646 position_info.major_length = 643 position_info.major_length =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 // If the shelf moved don't animate, move immediately to the new 722 // If the shelf moved don't animate, move immediately to the new
726 // target location. 723 // target location.
727 visible_panels[i].window->SetBoundsDirect(bounds); 724 visible_panels[i].window->SetBoundsDirect(bounds);
728 } 725 }
729 } 726 }
730 727
731 UpdateStacking(active_panel); 728 UpdateStacking(active_panel);
732 UpdateCallouts(); 729 UpdateCallouts();
733 } 730 }
734 731
735 void PanelLayoutManager::UpdateStacking(wm::WmWindow* active_panel) { 732 void PanelLayoutManager::UpdateStacking(WmWindow* active_panel) {
736 if (!active_panel) { 733 if (!active_panel) {
737 if (!last_active_panel_) 734 if (!last_active_panel_)
738 return; 735 return;
739 active_panel = last_active_panel_; 736 active_panel = last_active_panel_;
740 } 737 }
741 738
742 // We want to to stack the panels like a deck of cards: 739 // We want to to stack the panels like a deck of cards:
743 // ,--,--,--,-------.--.--. 740 // ,--,--,--,-------.--.--.
744 // | | | | | | | 741 // | | | | | | |
745 // | | | | | | | 742 // | | | | | | |
746 // 743 //
747 // We use the middle of each panel to figure out how to stack the panels. This 744 // We use the middle of each panel to figure out how to stack the panels. This
748 // allows us to update the stacking when a panel is being dragged around by 745 // allows us to update the stacking when a panel is being dragged around by
749 // the titlebar--even though it doesn't update the shelf icon positions, we 746 // the titlebar--even though it doesn't update the shelf icon positions, we
750 // still want the visual effect. 747 // still want the visual effect.
751 std::map<int, wm::WmWindow*> window_ordering; 748 std::map<int, WmWindow*> window_ordering;
752 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment()); 749 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
753 for (PanelList::const_iterator it = panel_windows_.begin(); 750 for (PanelList::const_iterator it = panel_windows_.begin();
754 it != panel_windows_.end(); ++it) { 751 it != panel_windows_.end(); ++it) {
755 gfx::Rect bounds = it->window->GetBounds(); 752 gfx::Rect bounds = it->window->GetBounds();
756 window_ordering.insert( 753 window_ordering.insert(
757 std::make_pair(horizontal ? bounds.x() + bounds.width() / 2 754 std::make_pair(horizontal ? bounds.x() + bounds.width() / 2
758 : bounds.y() + bounds.height() / 2, 755 : bounds.y() + bounds.height() / 2,
759 it->window)); 756 it->window));
760 } 757 }
761 758
762 wm::WmWindow* previous_panel = nullptr; 759 WmWindow* previous_panel = nullptr;
763 for (std::map<int, wm::WmWindow*>::const_iterator it = 760 for (std::map<int, WmWindow*>::const_iterator it = window_ordering.begin();
764 window_ordering.begin();
765 it != window_ordering.end() && it->second != active_panel; ++it) { 761 it != window_ordering.end() && it->second != active_panel; ++it) {
766 if (previous_panel) 762 if (previous_panel)
767 panel_container_->StackChildAbove(it->second, previous_panel); 763 panel_container_->StackChildAbove(it->second, previous_panel);
768 previous_panel = it->second; 764 previous_panel = it->second;
769 } 765 }
770 766
771 previous_panel = NULL; 767 previous_panel = NULL;
772 for (std::map<int, wm::WmWindow*>::const_reverse_iterator it = 768 for (std::map<int, WmWindow*>::const_reverse_iterator it =
773 window_ordering.rbegin(); 769 window_ordering.rbegin();
774 it != window_ordering.rend() && it->second != active_panel; ++it) { 770 it != window_ordering.rend() && it->second != active_panel; ++it) {
775 if (previous_panel) 771 if (previous_panel)
776 panel_container_->StackChildAbove(it->second, previous_panel); 772 panel_container_->StackChildAbove(it->second, previous_panel);
777 previous_panel = it->second; 773 previous_panel = it->second;
778 } 774 }
779 775
780 panel_container_->StackChildAtTop(active_panel); 776 panel_container_->StackChildAtTop(active_panel);
781 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_) 777 if (dragged_panel_ && dragged_panel_->GetParent() == panel_container_)
782 panel_container_->StackChildAtTop(dragged_panel_); 778 panel_container_->StackChildAtTop(dragged_panel_);
783 last_active_panel_ = active_panel; 779 last_active_panel_ = active_panel;
784 } 780 }
785 781
786 void PanelLayoutManager::UpdateCallouts() { 782 void PanelLayoutManager::UpdateCallouts() {
787 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment()); 783 const bool horizontal = wm::IsHorizontalAlignment(shelf_->GetAlignment());
788 for (PanelList::iterator iter = panel_windows_.begin(); 784 for (PanelList::iterator iter = panel_windows_.begin();
789 iter != panel_windows_.end(); ++iter) { 785 iter != panel_windows_.end(); ++iter) {
790 wm::WmWindow* panel = iter->window; 786 WmWindow* panel = iter->window;
791 views::Widget* callout_widget = iter->callout_widget; 787 views::Widget* callout_widget = iter->callout_widget;
792 wm::WmWindow* callout_widget_window = 788 WmWindow* callout_widget_window =
793 wm::WmLookup::Get()->GetWindowForWidget(callout_widget); 789 WmLookup::Get()->GetWindowForWidget(callout_widget);
794 790
795 gfx::Rect current_bounds = panel->GetBoundsInScreen(); 791 gfx::Rect current_bounds = panel->GetBoundsInScreen();
796 gfx::Rect bounds = 792 gfx::Rect bounds =
797 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); 793 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds());
798 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); 794 gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel);
799 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() || 795 if (icon_bounds.IsEmpty() || !panel->GetLayer()->GetTargetVisibility() ||
800 panel == dragged_panel_ || !show_callout_widgets_) { 796 panel == dragged_panel_ || !show_callout_widgets_) {
801 callout_widget->Hide(); 797 callout_widget->Hide();
802 callout_widget_window->GetLayer()->SetOpacity(0); 798 callout_widget_window->GetLayer()->SetOpacity(0);
803 continue; 799 continue;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 861
866 //////////////////////////////////////////////////////////////////////////////// 862 ////////////////////////////////////////////////////////////////////////////////
867 // keyboard::KeyboardControllerObserver implementation: 863 // keyboard::KeyboardControllerObserver implementation:
868 864
869 void PanelLayoutManager::OnKeyboardBoundsChanging( 865 void PanelLayoutManager::OnKeyboardBoundsChanging(
870 const gfx::Rect& keyboard_bounds) { 866 const gfx::Rect& keyboard_bounds) {
871 gfx::Rect parent_bounds = panel_container_->GetBounds(); 867 gfx::Rect parent_bounds = panel_container_->GetBounds();
872 int available_space = parent_bounds.height() - keyboard_bounds.height(); 868 int available_space = parent_bounds.height() - keyboard_bounds.height();
873 for (PanelList::iterator iter = panel_windows_.begin(); 869 for (PanelList::iterator iter = panel_windows_.begin();
874 iter != panel_windows_.end(); ++iter) { 870 iter != panel_windows_.end(); ++iter) {
875 wm::WmWindow* panel = iter->window; 871 WmWindow* panel = iter->window;
876 wm::WindowState* panel_state = panel->GetWindowState(); 872 wm::WindowState* panel_state = panel->GetWindowState();
877 if (keyboard_bounds.height() > 0) { 873 if (keyboard_bounds.height() > 0) {
878 // Save existing bounds, so that we can restore them when the keyboard 874 // Save existing bounds, so that we can restore them when the keyboard
879 // hides. 875 // hides.
880 panel_state->SaveCurrentBoundsForRestore(); 876 panel_state->SaveCurrentBoundsForRestore();
881 877
882 gfx::Rect panel_bounds = 878 gfx::Rect panel_bounds =
883 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds()); 879 panel->GetParent()->ConvertRectToScreen(panel->GetTargetBounds());
884 int delta = panel_bounds.height() - available_space; 880 int delta = panel_bounds.height() - available_space;
885 // Ensure panels are not pushed above the parent boundaries, shrink any 881 // Ensure panels are not pushed above the parent boundaries, shrink any
886 // panels that violate this constraint. 882 // panels that violate this constraint.
887 if (delta > 0) { 883 if (delta > 0) {
888 panel->SetBoundsDirect( 884 panel->SetBoundsDirect(
889 gfx::Rect(panel_bounds.x(), panel_bounds.y() + delta, 885 gfx::Rect(panel_bounds.x(), panel_bounds.y() + delta,
890 panel_bounds.width(), panel_bounds.height() - delta)); 886 panel_bounds.width(), panel_bounds.height() - delta));
891 } 887 }
892 } else if (panel_state->HasRestoreBounds()) { 888 } else if (panel_state->HasRestoreBounds()) {
893 // Keyboard hidden, restore original bounds if they exist. 889 // Keyboard hidden, restore original bounds if they exist.
894 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen()); 890 panel->SetBoundsDirect(panel_state->GetRestoreBoundsInScreen());
895 } 891 }
896 } 892 }
897 // This bounds change will have caused a change to the Shelf which does not 893 // This bounds change will have caused a change to the Shelf which does not
898 // propogate automatically to this class, so manually recalculate bounds. 894 // propogate automatically to this class, so manually recalculate bounds.
899 OnWindowResized(); 895 OnWindowResized();
900 } 896 }
901 897
902 } // namespace ash 898 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698