forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_manager_application.h
137 lines (104 loc) · 4.28 KB
/
window_manager_application.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// 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_APPLICATION_H_
#define MASH_WM_WINDOW_MANAGER_APPLICATION_H_
#include <set>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "components/mus/common/types.h"
#include "components/mus/public/cpp/window_observer.h"
#include "components/mus/public/cpp/window_tree_delegate.h"
#include "components/mus/public/interfaces/accelerator_registrar.mojom.h"
#include "components/mus/public/interfaces/window_manager.mojom.h"
#include "components/mus/public/interfaces/window_tree_host.mojom.h"
#include "mash/wm/public/interfaces/container.mojom.h"
#include "mojo/application/public/cpp/application_delegate.h"
#include "mojo/application/public/cpp/interface_factory_impl.h"
#include "mojo/common/weak_binding_set.h"
#include "mojo/services/tracing/public/cpp/tracing_impl.h"
namespace ui {
namespace mojo {
class UIInit;
}
}
namespace views {
class AuraInit;
}
namespace mash {
namespace wm {
class AcceleratorRegistrarImpl;
class BackgroundLayout;
class ShadowController;
class ShelfLayout;
class WindowLayout;
class WindowManagerImpl;
class WindowManagerApplication
: public mojo::ApplicationDelegate,
public mus::WindowObserver,
public mus::mojom::WindowTreeHostClient,
public mus::WindowTreeDelegate,
public mojo::InterfaceFactory<mus::mojom::WindowManager>,
public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> {
public:
WindowManagerApplication();
~WindowManagerApplication() override;
mus::Window* root() { return root_; }
int window_count() { return window_count_; }
void IncrementWindowCount() { ++window_count_; }
mus::Window* GetWindowForContainer(mojom::Container container);
mus::Window* GetWindowById(mus::Id id);
bool WindowIsContainer(const mus::Window* window) const;
mojo::ApplicationImpl* app() { return app_; }
mus::mojom::WindowTreeHost* window_tree_host() {
return window_tree_host_.get();
}
private:
void AddAccelerators();
void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar);
// ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override;
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
// WindowTreeHostClient:
void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override;
// WindowTreeDelegate:
void OnEmbed(mus::Window* root) override;
void OnConnectionLost(mus::WindowTreeConnection* connection) override;
// InterfaceFactory<mus::mojom::AcceleratorRegistrar>:
void Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request)
override;
// InterfaceFactory<mus::mojom::WindowManager>:
void Create(
mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mus::mojom::WindowManager> request) override;
// mus::WindowObserver:
void OnWindowDestroyed(mus::Window* window) override;
// Sets up the window containers used for z-space management.
void CreateContainers();
// nullptr until the Mus connection is established via OnEmbed().
mus::Window* root_;
int window_count_;
mojo::ApplicationImpl* app_;
mojo::TracingImpl tracing_;
mus::mojom::WindowTreeHostPtr window_tree_host_;
mojo::Binding<mus::mojom::WindowTreeHostClient> host_client_binding_;
scoped_ptr<ui::mojo::UIInit> ui_init_;
scoped_ptr<views::AuraInit> aura_init_;
// |window_manager_| is created once OnEmbed() is called. Until that time
// |requests_| stores any pending WindowManager interface requests.
scoped_ptr<WindowManagerImpl> window_manager_;
mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_;
ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_;
scoped_ptr<BackgroundLayout> background_layout_;
scoped_ptr<ShelfLayout> shelf_layout_;
scoped_ptr<WindowLayout> window_layout_;
scoped_ptr<ShadowController> shadow_controller_;
std::set<AcceleratorRegistrarImpl*> accelerator_registrars_;
DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication);
};
} // namespace wm
} // namespace mash
#endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_