summaryrefslogtreecommitdiffstats
path: root/ash/wm/workspace/maximized_workspace.cc
blob: d741e8e51399fa2a94914f43fc88414baa33eb68 (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
// Copyright (c) 2012 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/workspace/maximized_workspace.h"

#include "ash/screen_ash.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_manager.h"
#include "base/logging.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/screen.h"

namespace ash {
namespace internal {

MaximizedWorkspace::MaximizedWorkspace(WorkspaceManager* manager)
    : Workspace(manager, TYPE_MAXIMIZED) {
}

MaximizedWorkspace::~MaximizedWorkspace() {
}

bool MaximizedWorkspace::CanAdd(aura::Window* window) const {
  return is_empty() && (wm::IsWindowFullscreen(window) ||
                        wm::IsWindowMaximized(window));
}

void MaximizedWorkspace::OnWindowAddedAfter(aura::Window* window,
                                            aura::Window* after) {
  ResetWindowBounds(window);
}

void MaximizedWorkspace::OnWindowRemoved(aura::Window* window) {
}

void MaximizedWorkspace::ResetWindowBounds(aura::Window* window) {
  if (wm::IsWindowFullscreen(window)) {
    SetWindowBounds(window,
                    ScreenAsh::GetDisplayBoundsInParent(window));
  } else {
    SetWindowBounds(window,
                    ScreenAsh::GetMaximizedWindowBoundsInParent(window));
  }
}

}  // namespace internal
}  // namespace ash