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

Unified Diff: components/mus/demo/mus_demo.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/demo/mus_demo.h ('k') | components/mus/mus_app.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/demo/mus_demo.cc
diff --git a/components/mus/demo/mus_demo.cc b/components/mus/demo/mus_demo.cc
index c5f02f614f2252bcc6f9a571f8de2ac818913b80..017e36c14b7982ee966df12a82b42e58f5d52eb1 100644
--- a/components/mus/demo/mus_demo.cc
+++ b/components/mus/demo/mus_demo.cc
@@ -6,7 +6,9 @@
#include "base/time/time.h"
#include "components/bitmap_uploader/bitmap_uploader.h"
+#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_tree_client.h"
+#include "services/shell/public/cpp/connector.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageInfo.h"
@@ -54,18 +56,18 @@ void DrawSquare(const gfx::Rect& bounds, double angle, SkCanvas* canvas) {
} // namespace
-MusDemo::MusDemo() : window_manager_factory_binding_(this) {}
+MusDemo::MusDemo() {}
-MusDemo::~MusDemo() {}
+MusDemo::~MusDemo() {
+ delete window_tree_client_;
+}
void MusDemo::Initialize(shell::Connector* connector,
const shell::Identity& identity,
uint32_t id) {
connector_ = connector;
- mus::mojom::WindowManagerFactoryServicePtr wm_factory_service;
- connector->ConnectToInterface("mojo:mus", &wm_factory_service);
- wm_factory_service->SetWindowManagerFactory(
- window_manager_factory_binding_.CreateInterfacePtrAndBind());
+ window_tree_client_ = new mus::WindowTreeClient(this, this, nullptr);
+ window_tree_client_->ConnectAsWindowManager(connector);
}
bool MusDemo::AcceptConnection(shell::Connection* connection) {
@@ -73,36 +75,18 @@ bool MusDemo::AcceptConnection(shell::Connection* connection) {
}
void MusDemo::OnEmbed(mus::Window* window) {
- window_ = window;
-
- // Initialize bitmap uploader for sending frames to MUS.
- uploader_.reset(new bitmap_uploader::BitmapUploader(window_));
- uploader_->Init(connector_);
-
- // Draw initial frame and start the timer to regularly draw frames.
- DrawFrame();
- timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay),
- base::Bind(&MusDemo::DrawFrame, base::Unretained(this)));
+ // Not called for the WindowManager.
+ NOTREACHED();
}
-void MusDemo::OnUnembed(mus::Window* root) {}
-
void MusDemo::OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) {
+ window_tree_client_ = nullptr;
timer_.Stop();
}
void MusDemo::OnEventObserved(const ui::Event& event, mus::Window* target) {}
-// mus::mojom::WindowManagerFactory:
-void MusDemo::CreateWindowManager(mus::mojom::DisplayPtr display,
- mus::mojom::WindowTreeClientRequest request) {
- new mus::WindowTreeClient(this, this, std::move(request));
-}
-
-// mus::WindowManagerDelegate:
-void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) {
- window_manager_client_ = client;
-}
+void MusDemo::SetWindowManagerClient(mus::WindowManagerClient* client) {}
bool MusDemo::OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) {
return true;
@@ -125,6 +109,21 @@ void MusDemo::OnWmClientJankinessChanged(
// Don't care
}
+void MusDemo::OnWmNewDisplay(mus::Window* window,
+ const display::Display& display) {
+ DCHECK(!window_); // Only support one display.
+ window_ = window;
+
+ // Initialize bitmap uploader for sending frames to MUS.
+ uploader_.reset(new bitmap_uploader::BitmapUploader(window_));
+ uploader_->Init(connector_);
+
+ // Draw initial frame and start the timer to regularly draw frames.
+ DrawFrame();
+ timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kFrameDelay),
+ base::Bind(&MusDemo::DrawFrame, base::Unretained(this)));
+}
+
void MusDemo::OnAccelerator(uint32_t id, const ui::Event& event) {
// Don't care
}
« no previous file with comments | « components/mus/demo/mus_demo.h ('k') | components/mus/mus_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698