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/launcher/launcher_util.h" | 5 #include "ash/launcher/launcher_util.h" |
6 | 6 |
7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
8 #include "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
| 9 #include "ash/shell.h" |
| 10 #include "ui/aura/client/window_types.h" |
| 11 #include "ui/aura/window.h" |
| 12 #include "ui/views/view.h" |
| 13 #include "ui/views/widget/widget.h" |
9 | 14 |
10 namespace ash { | 15 namespace ash { |
11 namespace launcher { | 16 namespace launcher { |
12 | 17 |
13 int GetBrowserItemIndex(const LauncherModel& launcher_model) { | 18 int GetBrowserItemIndex(const LauncherModel& launcher_model) { |
14 for (size_t i = 0; i < launcher_model.items().size(); i++) { | 19 for (size_t i = 0; i < launcher_model.items().size(); i++) { |
15 if (launcher_model.items()[i].type == ash::TYPE_BROWSER_SHORTCUT) | 20 if (launcher_model.items()[i].type == ash::TYPE_BROWSER_SHORTCUT) |
16 return i; | 21 return i; |
17 } | 22 } |
18 return -1; | 23 return -1; |
19 } | 24 } |
20 | 25 |
| 26 void MoveToEventRootIfPanel(aura::Window* maybe_panel, |
| 27 const ui::Event& event) { |
| 28 if (maybe_panel->type() != aura::client::WINDOW_TYPE_PANEL) |
| 29 return; |
| 30 views::View* target = static_cast<views::View*>(event.target()); |
| 31 aura::RootWindow* target_root = |
| 32 target ? target->GetWidget()->GetNativeView()->GetRootWindow() : NULL; |
| 33 if (target_root && target_root != maybe_panel->GetRootWindow()) { |
| 34 aura::Window* panel_container = |
| 35 ash::Shell::GetContainer(target_root, maybe_panel->parent()->id()); |
| 36 // Move the panel to the target launcher. |
| 37 panel_container->AddChild(maybe_panel); |
| 38 } |
| 39 } |
| 40 |
21 } // namespace launcher | 41 } // namespace launcher |
22 } // namespace ash | 42 } // namespace ash |
OLD | NEW |