OLD | NEW |
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_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
11 #include "ash/screen_ash.h" | 11 #include "ash/screen_ash.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
14 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" |
16 #include "ash/wm/frame_painter.h" | 17 #include "ash/wm/frame_painter.h" |
17 #include "ash/wm/property_util.h" | 18 #include "ash/wm/property_util.h" |
18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
| 20 #include "ash/wm/window_properties.h" |
19 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
20 #include "base/auto_reset.h" | 22 #include "base/auto_reset.h" |
21 #include "base/bind.h" | 23 #include "base/bind.h" |
22 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
24 #include "third_party/skia/include/core/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
25 #include "third_party/skia/include/core/SkPath.h" | 27 #include "third_party/skia/include/core/SkPath.h" |
26 #include "ui/aura/client/activation_client.h" | 28 #include "ui/aura/client/activation_client.h" |
27 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/focus_manager.h" | 30 #include "ui/aura/focus_manager.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // Weak pointer owned by this widget's content view. | 245 // Weak pointer owned by this widget's content view. |
244 CalloutWidgetBackground* background_; | 246 CalloutWidgetBackground* background_; |
245 | 247 |
246 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget); | 248 DISALLOW_COPY_AND_ASSIGN(PanelCalloutWidget); |
247 }; | 249 }; |
248 | 250 |
249 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
250 // PanelLayoutManager public implementation: | 252 // PanelLayoutManager public implementation: |
251 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) | 253 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) |
252 : panel_container_(panel_container), | 254 : panel_container_(panel_container), |
| 255 in_add_window_(false), |
253 in_layout_(false), | 256 in_layout_(false), |
254 dragged_panel_(NULL), | 257 dragged_panel_(NULL), |
255 launcher_(NULL), | 258 launcher_(NULL), |
256 shelf_layout_manager_(NULL), | 259 shelf_layout_manager_(NULL), |
257 shelf_hidden_(false), | 260 shelf_hidden_(false), |
258 last_active_panel_(NULL), | 261 last_active_panel_(NULL), |
259 weak_factory_(this) { | 262 weak_factory_(this) { |
260 DCHECK(panel_container); | 263 DCHECK(panel_container); |
261 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 264 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
262 AddObserver(this); | 265 AddObserver(this); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 324 |
322 //////////////////////////////////////////////////////////////////////////////// | 325 //////////////////////////////////////////////////////////////////////////////// |
323 // PanelLayoutManager, aura::LayoutManager implementation: | 326 // PanelLayoutManager, aura::LayoutManager implementation: |
324 void PanelLayoutManager::OnWindowResized() { | 327 void PanelLayoutManager::OnWindowResized() { |
325 Relayout(); | 328 Relayout(); |
326 } | 329 } |
327 | 330 |
328 void PanelLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 331 void PanelLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
329 if (child->type() == aura::client::WINDOW_TYPE_POPUP) | 332 if (child->type() == aura::client::WINDOW_TYPE_POPUP) |
330 return; | 333 return; |
| 334 if (in_add_window_) |
| 335 return; |
| 336 base::AutoReset<bool> auto_reset_in_add_window(&in_add_window_, true); |
| 337 if (!child->GetProperty(kPanelAttachedKey)) { |
| 338 // This should only happen when a window is added to panel container as a |
| 339 // result of bounds change from within the application during a drag. |
| 340 // If so we have already stopped the drag and should reparent the panel |
| 341 // back to appropriate container and ignore it. |
| 342 // TODO(varkha): Updating bounds during a drag can cause problems and a more |
| 343 // general solution is needed. See http://crbug.com/251813 . |
| 344 child->SetDefaultParentByRootWindow( |
| 345 child->GetRootWindow(), |
| 346 child->GetRootWindow()->GetBoundsInScreen()); |
| 347 DCHECK(child->parent()->id() != kShellWindowId_PanelContainer); |
| 348 return; |
| 349 } |
331 PanelInfo panel_info; | 350 PanelInfo panel_info; |
332 panel_info.window = child; | 351 panel_info.window = child; |
333 panel_info.callout_widget = new PanelCalloutWidget(panel_container_); | 352 panel_info.callout_widget = new PanelCalloutWidget(panel_container_); |
334 if (child != dragged_panel_) { | 353 if (child != dragged_panel_) { |
335 // Set the panel to 0 opacity until it has been positioned to prevent it | 354 // Set the panel to 0 opacity until it has been positioned to prevent it |
336 // from flashing briefly at position (0, 0). | 355 // from flashing briefly at position (0, 0). |
337 child->layer()->SetOpacity(0); | 356 child->layer()->SetOpacity(0); |
338 panel_info.slide_in = true; | 357 panel_info.slide_in = true; |
339 } | 358 } |
340 panel_windows_.push_back(panel_info); | 359 panel_windows_.push_back(panel_info); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 843 |
825 void PanelLayoutManager::OnKeyboardBoundsChanging( | 844 void PanelLayoutManager::OnKeyboardBoundsChanging( |
826 const gfx::Rect& keyboard_bounds) { | 845 const gfx::Rect& keyboard_bounds) { |
827 // This bounds change will have caused a change to the Shelf which does not | 846 // This bounds change will have caused a change to the Shelf which does not |
828 // propogate automatically to this class, so manually recalculate bounds. | 847 // propogate automatically to this class, so manually recalculate bounds. |
829 OnWindowResized(); | 848 OnWindowResized(); |
830 } | 849 } |
831 | 850 |
832 } // namespace internal | 851 } // namespace internal |
833 } // namespace ash | 852 } // namespace ash |
OLD | NEW |