summaryrefslogtreecommitdiffstats
path: root/ash/wm/overview/window_selector_window.cc
blob: a421600cca78a4c7ea8054f6c45badf4049eb3c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/overview/window_selector_window.h"

#include "ui/aura/window.h"

namespace ash {

WindowSelectorWindow::WindowSelectorWindow(aura::Window* window)
    : transform_window_(window) {
}

WindowSelectorWindow::~WindowSelectorWindow() {
}

const aura::RootWindow* WindowSelectorWindow::GetRootWindow() const {
  return transform_window_.window()->GetRootWindow();
}

aura::Window* WindowSelectorWindow::TargetedWindow(
    const aura::Window* target) const {
  if (transform_window_.Contains(target))
    return transform_window_.window();
  return NULL;
}

void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) {
  transform_window_.RestoreWindowOnExit();
}

aura::Window* WindowSelectorWindow::SelectionWindow() const {
  return transform_window_.window();
}

void WindowSelectorWindow::RemoveWindow(const aura::Window* window) {
  DCHECK_EQ(transform_window_.window(), window);
  transform_window_.OnWindowDestroyed();
}

bool WindowSelectorWindow::empty() const {
  return transform_window_.window() == NULL;
}

void WindowSelectorWindow::SetItemBounds(aura::RootWindow* root_window,
                                         const gfx::Rect& target_bounds) {
  gfx::Rect bounding_rect = transform_window_.window()->GetBoundsInScreen();
  transform_window_.SetTransform(root_window,
      ScopedTransformOverviewWindow::GetTransformForRectPreservingAspectRatio(
          transform_window_.window()->GetBoundsInScreen(), target_bounds));
}

}  // namespace ash