summaryrefslogtreecommitdiffstats
path: root/mash/wm/window_manager.h
blob: 7dbe07e8df4b88b4777a23731502623137551016 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2015 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.

#ifndef MASH_WM_WINDOW_MANAGER_H_
#define MASH_WM_WINDOW_MANAGER_H_

#include <stdint.h>

#include "base/macros.h"
#include "components/mus/common/types.h"
#include "components/mus/public/cpp/window_manager_delegate.h"
#include "components/mus/public/cpp/window_observer.h"
#include "components/mus/public/interfaces/window_manager.mojom.h"
#include "mash/shell/public/interfaces/shell.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"

namespace mash {
namespace wm {

class RootWindowController;

class WindowManager : public mus::WindowObserver,
                      public mus::WindowManagerDelegate,
                      public mash::shell::mojom::ScreenlockStateListener {
 public:
  WindowManager();
  ~WindowManager() override;

  void Initialize(RootWindowController* root_controller,
                  mash::shell::mojom::ShellPtr shell);

  mus::WindowManagerClient* window_manager_client() {
    return window_manager_client_;
  }

 private:
  gfx::Rect CalculateDefaultBounds(mus::Window* window) const;
  gfx::Rect GetMaximizedWindowBounds() const;

  mus::Window* NewTopLevelWindow(
      std::map<std::string, std::vector<uint8_t>>* properties);

  // mus::WindowObserver:
  void OnTreeChanging(const TreeChangeParams& params) override;
  void OnWindowEmbeddedAppDisconnected(mus::Window* window) override;

  // WindowManagerDelegate:
  void SetWindowManagerClient(mus::WindowManagerClient* client) override;
  bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
  bool OnWmSetProperty(mus::Window* window,
                       const std::string& name,
                       scoped_ptr<std::vector<uint8_t>>* new_data) override;
  mus::Window* OnWmCreateTopLevelWindow(
      std::map<std::string, std::vector<uint8_t>>* properties) override;
  void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override;

  // mash::shell::mojom::ScreenlockStateListener:
  void ScreenlockStateChanged(bool locked) override;

  RootWindowController* root_controller_;
  mus::WindowManagerClient* window_manager_client_;

  mojo::Binding<mash::shell::mojom::ScreenlockStateListener> binding_;

  DISALLOW_COPY_AND_ASSIGN(WindowManager);
};

}  // namespace wm
}  // namespace mash

#endif  // MASH_WM_WINDOW_MANAGER_H_