forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mus Demo: Demonstrate external window mode
Previously the only user of mus was ChromeOS, and so Chrome currently creates all toplevel windows as children of an ash-managed root window. In this sense, all created windows are 'internal' to this virtual root. However, as desktop Linux also transitions to using Mus, it is necessary to support 'external' window mode where toplevel windows are created as native (x11, wayland, ...) windows. This CL adjusts the Mus Demo so that non-ChromeOS Ozone platforms work in external mode. For now, only a single external window is created by Mus Demo. Supporting multiple external windows will require some code refactoring in WindowTreeHostFactory that will be handled in a follow-up CL [1]. The CL also disables an assertion for these non-ChromeOS Ozone platforms until display & screen managers are refactored to remove assumptions specific to internal mode [2]. [1] https://codereview.chromium.org/2700493005 [2] https://bugs.chromium.org/p/chromium/issues/detail?id=693081 BUG=666958 TEST=./out/LinuxOzoneX11/mash --service=mus_demo --ozone-platform=x11 or ./out/LinuxOzoneX11/mus_demo_unittests --ozone-platform=x11 Review-Url: https://codereview.chromium.org/2622103004 Cr-Commit-Position: refs/heads/master@{#451922}
- Loading branch information
Showing
10 changed files
with
163 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2017 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 "services/service_manager/public/c/main.h" | ||
#include "services/service_manager/public/cpp/service_runner.h" | ||
#include "services/ui/demo/mus_demo_external.h" | ||
|
||
MojoResult ServiceMain(MojoHandle service_request_handle) { | ||
service_manager::ServiceRunner runner(new ui::demo::MusDemoExternal); | ||
return runner.Run(service_request_handle); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2017 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 "services/ui/demo/mus_demo_external.h" | ||
|
||
#include "services/service_manager/public/cpp/service_context.h" | ||
#include "services/ui/demo/window_tree_data.h" | ||
#include "services/ui/public/interfaces/constants.mojom.h" | ||
#include "services/ui/public/interfaces/window_tree_host.mojom.h" | ||
#include "ui/aura/mus/window_tree_client.h" | ||
#include "ui/aura/mus/window_tree_host_mus.h" | ||
#include "ui/display/display.h" | ||
|
||
namespace ui { | ||
namespace demo { | ||
|
||
namespace { | ||
|
||
class WindowTreeDataExternal : public WindowTreeData { | ||
public: | ||
// Creates a new window tree host associated to the WindowTreeData. | ||
WindowTreeDataExternal(mojom::WindowTreeHostFactory* factory, | ||
mojom::WindowTreeClientPtr tree_client, | ||
int square_size) | ||
: WindowTreeData(square_size) { | ||
factory->CreateWindowTreeHost(MakeRequest(&host_), std::move(tree_client)); | ||
} | ||
|
||
private: | ||
// Holds the Mojo pointer to the window tree host. | ||
mojom::WindowTreeHostPtr host_; | ||
}; | ||
|
||
// Size of square in pixels to draw. | ||
const int kSquareSize = 500; | ||
} // namespace | ||
|
||
MusDemoExternal::MusDemoExternal() {} | ||
|
||
MusDemoExternal::~MusDemoExternal() {} | ||
|
||
void MusDemoExternal::OnStartImpl( | ||
std::unique_ptr<aura::WindowTreeClient>* window_tree_client, | ||
std::unique_ptr<WindowTreeData>* window_tree_data) { | ||
context()->connector()->BindInterface(ui::mojom::kServiceName, | ||
&window_tree_host_factory_); | ||
mojom::WindowTreeClientPtr tree_client; | ||
*window_tree_client = base::MakeUnique<aura::WindowTreeClient>( | ||
context()->connector(), this, nullptr, MakeRequest(&tree_client)); | ||
// TODO(tonikitoo,fwang): Open two external windows with different square | ||
// sizes. | ||
*window_tree_data = base::MakeUnique<WindowTreeDataExternal>( | ||
window_tree_host_factory_.get(), std::move(tree_client), kSquareSize); | ||
|
||
// TODO(tonikitoo,fwang): Implement management of displays in external mode. | ||
// For now, a fake display is created in order to work around an assertion in | ||
// aura::GetDeviceScaleFactorFromDisplay(). | ||
AddPrimaryDisplay(display::Display(0)); | ||
} | ||
|
||
void MusDemoExternal::OnEmbed( | ||
std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | ||
InitWindowTreeData(std::move(window_tree_host)); | ||
} | ||
|
||
void MusDemoExternal::OnEmbedRootDestroyed( | ||
aura::WindowTreeHostMus* window_tree_host) { | ||
CleanupWindowTreeData(); | ||
} | ||
|
||
} // namespace demo | ||
} // namespace ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2017 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 SERVICES_UI_DEMO_MUS_DEMO_EXTERNAL_H_ | ||
#define SERVICES_UI_DEMO_MUS_DEMO_EXTERNAL_H_ | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "services/ui/demo/mus_demo.h" | ||
#include "services/ui/public/interfaces/window_tree_host.mojom.h" | ||
|
||
namespace ui { | ||
namespace demo { | ||
|
||
// MusDemoExternal demonstrates Mus operating in "external" mode: A new platform | ||
// window (and hence acceleratedWidget) is created for each aura window. | ||
class MusDemoExternal : public MusDemo { | ||
public: | ||
MusDemoExternal(); | ||
~MusDemoExternal() final; | ||
|
||
private: | ||
// ui::demo::MusDemo: | ||
void OnStartImpl(std::unique_ptr<aura::WindowTreeClient>* window_tree_client, | ||
std::unique_ptr<WindowTreeData>* window_tree_data) final; | ||
|
||
// aura::WindowTreeClientDelegate: | ||
void OnEmbed(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) final; | ||
void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) final; | ||
|
||
mojom::WindowTreeHostFactoryPtr window_tree_host_factory_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MusDemoExternal); | ||
}; | ||
|
||
} // namespace demo | ||
} // namespace ui | ||
|
||
#endif // SERVICES_UI_DEMO_MUS_DEMO_EXTERNAL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters