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

Unified Diff: ash/wm/window_util.cc

Issue 2696073002: Merge ShelfItemDelegate::ItemSelected & LauncherItemDelegate::Activate. (Closed)
Patch Set: Cleanup Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/window_util.cc
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 0e4f632a3855674123fa855f5a73e8a505f60f7f..559e7f9c4fec4bd801df954284b913ef3fd993ba 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -10,6 +10,8 @@
#include "ash/common/wm/window_state.h"
#include "ash/common/wm/wm_event.h"
#include "ash/common/wm/wm_screen_util.h"
+#include "ash/common/wm_shell.h"
+#include "ash/common/wm_window.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/window_properties.h"
@@ -29,6 +31,22 @@
namespace ash {
namespace wm {
+namespace {
+
+// Move the |window| to the target |root|, using the corresponding container.
James Cook 2017/02/15 00:44:40 nit: document return value ("True if it actually m
msw 2017/02/15 19:59:18 Done.
+bool MoveWindowToRoot(aura::Window* window, aura::Window* root) {
+ if (!root || root == window->GetRootWindow())
+ return false;
+ aura::Window* container = RootWindowController::ForWindow(root)->GetContainer(
+ window->parent()->id());
+ if (!container)
+ return false;
+ container->AddChild(window);
+ return true;
+}
+
+} // namespace
+
// TODO(beng): replace many of these functions with the corewm versions.
void ActivateWindow(aura::Window* window) {
::wm::ActivateWindow(window);
@@ -64,19 +82,17 @@ void PinWindow(aura::Window* window, bool trusted) {
wm::GetWindowState(window)->OnWMEvent(&event);
}
+bool MoveWindowToDisplay(aura::Window* window, int64_t display_id) {
James Cook 2017/02/15 00:44:40 DCHECK(window) and that display_id is valid?
msw 2017/02/15 19:59:18 Added DCHECK(window), but left it returning false
+ WmWindow* root = WmShell::Get()->GetRootWindowForDisplayId(display_id);
+ return root && MoveWindowToRoot(window, root->aura_window());
+}
+
bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) {
views::View* target = static_cast<views::View*>(event.target());
if (!target)
return false;
- aura::Window* target_root =
- target->GetWidget()->GetNativeView()->GetRootWindow();
- if (!target_root || target_root == window->GetRootWindow())
- return false;
- aura::Window* window_container = RootWindowController::ForWindow(target_root)
- ->GetContainer(window->parent()->id());
- // Move the window to the target launcher.
- window_container->AddChild(window);
- return true;
+ aura::Window* root = target->GetWidget()->GetNativeView()->GetRootWindow();
+ return root && MoveWindowToRoot(window, root);
}
void SnapWindowToPixelBoundary(aura::Window* window) {

Powered by Google App Engine
This is Rietveld 408576698