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

Side by Side Diff: components/mus/demo/mus_demo.h

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « components/mus/demo/manifest.json ('k') | components/mus/demo/mus_demo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 5 #ifndef COMPONENTS_MUS_DEMO_MUS_DEMO_H_
6 #define COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 6 #define COMPONENTS_MUS_DEMO_MUS_DEMO_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "components/mus/public/cpp/window.h"
17 #include "components/mus/public/cpp/window_manager_delegate.h" 16 #include "components/mus/public/cpp/window_manager_delegate.h"
18 #include "components/mus/public/cpp/window_tree_client_delegate.h" 17 #include "components/mus/public/cpp/window_tree_client_delegate.h"
19 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
20 #include "mojo/public/cpp/bindings/binding_set.h"
21 #include "services/shell/public/cpp/connector.h"
22 #include "services/shell/public/cpp/shell_client.h" 18 #include "services/shell/public/cpp/shell_client.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
24 20
25 namespace bitmap_uploader { 21 namespace bitmap_uploader {
26 class BitmapUploader; 22 class BitmapUploader;
27 } 23 }
28 24
29 namespace mus_demo { 25 namespace mus_demo {
30 26
31 // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new 27 // A simple MUS Demo mojo app. This app connects to the mojo:mus, creates a new
32 // window and draws a spinning square in the center of the window. Provides a 28 // window and draws a spinning square in the center of the window. Provides a
33 // simple way to demonstrate that the graphic stack works as intended. 29 // simple way to demonstrate that the graphic stack works as intended.
34 class MusDemo : public shell::ShellClient, 30 class MusDemo : public shell::ShellClient,
35 public mus::mojom::WindowManagerFactory,
36 public mus::WindowTreeClientDelegate, 31 public mus::WindowTreeClientDelegate,
37 public mus::WindowManagerDelegate { 32 public mus::WindowManagerDelegate {
38 public: 33 public:
39 MusDemo(); 34 MusDemo();
40 ~MusDemo() override; 35 ~MusDemo() override;
41 36
42 private: 37 private:
43 // shell::ShellClient: 38 // shell::ShellClient:
44 void Initialize(shell::Connector* connector, 39 void Initialize(shell::Connector* connector,
45 const shell::Identity& identity, 40 const shell::Identity& identity,
46 uint32_t id) override; 41 uint32_t id) override;
47 bool AcceptConnection(shell::Connection* connection) override; 42 bool AcceptConnection(shell::Connection* connection) override;
48 43
49 // WindowTreeClientDelegate: 44 // WindowTreeClientDelegate:
50 void OnEmbed(mus::Window* root) override; 45 void OnEmbed(mus::Window* root) override;
51 void OnUnembed(mus::Window* root) override;
52 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; 46 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override;
53 void OnEventObserved(const ui::Event& event, mus::Window* target) override; 47 void OnEventObserved(const ui::Event& event, mus::Window* target) override;
54 48
55 // mus::mojom::WindowManagerFactory:
56 void CreateWindowManager(
57 mus::mojom::DisplayPtr display,
58 mus::mojom::WindowTreeClientRequest request) override;
59
60 // WindowManagerDelegate: 49 // WindowManagerDelegate:
61 void SetWindowManagerClient(mus::WindowManagerClient* client) override; 50 void SetWindowManagerClient(mus::WindowManagerClient* client) override;
62 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; 51 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override;
63 bool OnWmSetProperty( 52 bool OnWmSetProperty(
64 mus::Window* window, 53 mus::Window* window,
65 const std::string& name, 54 const std::string& name,
66 std::unique_ptr<std::vector<uint8_t>>* new_data) override; 55 std::unique_ptr<std::vector<uint8_t>>* new_data) override;
67 mus::Window* OnWmCreateTopLevelWindow( 56 mus::Window* OnWmCreateTopLevelWindow(
68 std::map<std::string, std::vector<uint8_t>>* properties) override; 57 std::map<std::string, std::vector<uint8_t>>* properties) override;
69 void OnWmClientJankinessChanged(const std::set<mus::Window*>& client_windows, 58 void OnWmClientJankinessChanged(const std::set<mus::Window*>& client_windows,
70 bool janky) override; 59 bool janky) override;
60 void OnWmNewDisplay(mus::Window* window,
61 const display::Display& display) override;
71 void OnAccelerator(uint32_t id, const ui::Event& event) override; 62 void OnAccelerator(uint32_t id, const ui::Event& event) override;
72 63
73 // Allocate a bitmap the same size as the window to draw into. 64 // Allocate a bitmap the same size as the window to draw into.
74 void AllocBitmap(); 65 void AllocBitmap();
75 66
76 // Draws one frame, incrementing the rotation angle. 67 // Draws one frame, incrementing the rotation angle.
77 void DrawFrame(); 68 void DrawFrame();
78 69
79 shell::Connector* connector_ = nullptr; 70 shell::Connector* connector_ = nullptr;
80 71
81 mus::Window* window_ = nullptr; 72 mus::Window* window_ = nullptr;
82 mus::WindowManagerClient* window_manager_client_ = nullptr; 73 mus::WindowTreeClient* window_tree_client_ = nullptr;
83 mojo::Binding<mus::mojom::WindowManagerFactory>
84 window_manager_factory_binding_;
85 74
86 // Used to send frames to mus. 75 // Used to send frames to mus.
87 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_; 76 std::unique_ptr<bitmap_uploader::BitmapUploader> uploader_;
88 77
89 // Bitmap that is the same size as our client window area. 78 // Bitmap that is the same size as our client window area.
90 SkBitmap bitmap_; 79 SkBitmap bitmap_;
91 80
92 // Timer for calling DrawFrame(). 81 // Timer for calling DrawFrame().
93 base::RepeatingTimer timer_; 82 base::RepeatingTimer timer_;
94 83
95 // Current rotation angle for drawing. 84 // Current rotation angle for drawing.
96 double angle_ = 0.0; 85 double angle_ = 0.0;
97 86
98 DISALLOW_COPY_AND_ASSIGN(MusDemo); 87 DISALLOW_COPY_AND_ASSIGN(MusDemo);
99 }; 88 };
100 89
101 } // namespace mus_demo 90 } // namespace mus_demo
102 91
103 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_ 92 #endif // COMPONENTS_MUS_DEMO_MUS_DEMO_H_
OLDNEW
« no previous file with comments | « components/mus/demo/manifest.json ('k') | components/mus/demo/mus_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698