Commit 5ea85f77 authored by kylechar's avatar kylechar Committed by Commit bot

Add PlatformScreenDelegate and start implementation.

There is currently a single callback provided to PlatformScreen for when
new displays are added. We need to be able to notify not only when new
displays are added but also when displays are modified or removed.
Instead of having three callbacks, the PlatformScreenDelegate interface
is added.

The ui::ws::DisplayManager class implements PlatformScreenDelegate. This
is ultimately the class that needs to know about changes to displays so
it can update root windows accordingly.

There are some changes to ownership and constructor parameters to
facilitate having DisplayManager implement PlatformScreenDelegate. The
WindowServer instance is passed into DisplayManager, as it doesn't make
sense that Display objects owned by DisplayManager are allowed to know
about WindowServer but DisplayManager is not. The DisplayManagerDelegate
interface is simplified and changed to UserDisplayManagerDelegate as
it's no longer needed for DisplayManager.

The instantiation of SurfaceState is moved from Service to WindowServer.
There is no need to have Service know about SurfaceState anymore. Also,
SurfaceState will be moving to the GPU processes regardless.

BUG=641012

Review-Url: https://codereview.chromium.org/2274353003
Cr-Commit-Position: refs/heads/master@{#414710}
parent f29505db
......@@ -7,6 +7,7 @@ import("//build/config/ui.gni")
source_set("display") {
sources = [
"platform_screen.h",
"platform_screen_delegate.h",
]
deps = [
......
......@@ -5,15 +5,9 @@
#ifndef SERVICES_UI_DISPLAY_PLATFORM_SCREEN_H_
#define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_H_
#include <stdint.h>
#include <memory>
#include "base/callback.h"
namespace gfx {
class Rect;
}
#include "services/ui/display/platform_screen_delegate.h"
namespace display {
......@@ -21,21 +15,17 @@ namespace display {
// attached physical displays.
class PlatformScreen {
public:
using ConfiguredDisplayCallback =
base::Callback<void(int64_t, const gfx::Rect&)>;
virtual ~PlatformScreen() {}
// Creates a PlatformScreen instance.
static std::unique_ptr<PlatformScreen> Create();
// Initializes platform specific screen resources.
virtual void Init() = 0;
// ConfigurePhysicalDisplay() configures a single physical display and returns
// its id and bounds for it via |callback|.
virtual void ConfigurePhysicalDisplay(
const ConfiguredDisplayCallback& callback) = 0;
// Triggers initial display configuration to start. On device this will
// configuration the connected displays. Off device this will create one or
// more fake displays and pretend to configure them. A non-null |delegate|
// must be provided that will receive notifications when displays are added,
// removed or modified.
virtual void Init(PlatformScreenDelegate* delegate) = 0;
virtual int64_t GetPrimaryDisplayId() const = 0;
};
......
// Copyright 2016 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_DISPLAY_PLATFORM_SCREEN_DELEGATE_H_
#define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_DELEGATE_H_
#include <stdint.h>
namespace gfx {
class Rect;
}
namespace display {
class PlatformScreen;
// The PlatformScreenDelegate will be informed of changes to the physical
// and/or virtual displays by PlatformScreen.
class PlatformScreenDelegate {
public:
// TODO(kylechar): We need to provide more than just the window bounds when
// displays are added or modified.
// Called when a display is added. |bounds| is in DIP.
virtual void OnDisplayAdded(PlatformScreen* platform_screen,
int64_t id,
const gfx::Rect& bounds) = 0;
// Called when a display is removed.
virtual void OnDisplayRemoved(int64_t id) = 0;
// Called when a display is modified. |bounds| is in DIP.
virtual void OnDisplayModified(int64_t id, const gfx::Rect& bounds) = 0;
protected:
virtual ~PlatformScreenDelegate() {}
};
} // namespace display
#endif // SERVICES_UI_DISPLAY_PLATFORM_SCREEN_DELEGATE_H_
......@@ -4,6 +4,8 @@
#include "services/ui/display/platform_screen_impl.h"
#include <memory>
#include "base/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
......@@ -15,28 +17,27 @@ namespace {
const int64_t kDisplayId = 1;
void FixedSizeScreenConfiguration(
const PlatformScreen::ConfiguredDisplayCallback& callback) {
callback.Run(kDisplayId, gfx::Rect(1024, 768));
}
} // namespace
// static
std::unique_ptr<PlatformScreen> PlatformScreen::Create() {
return base::WrapUnique(new PlatformScreenImpl);
return base::MakeUnique<PlatformScreenImpl>();
}
PlatformScreenImpl::PlatformScreenImpl() {}
PlatformScreenImpl::PlatformScreenImpl() : weak_ptr_factory_(this) {}
PlatformScreenImpl::~PlatformScreenImpl() {}
void PlatformScreenImpl::Init() {}
void PlatformScreenImpl::FixedSizeScreenConfiguration() {
delegate_->OnDisplayAdded(this, kDisplayId, gfx::Rect(1024, 768));
}
void PlatformScreenImpl::ConfigurePhysicalDisplay(
const PlatformScreen::ConfiguredDisplayCallback& callback) {
void PlatformScreenImpl::Init(PlatformScreenDelegate* delegate) {
DCHECK(delegate);
delegate_ = delegate;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&FixedSizeScreenConfiguration, callback));
FROM_HERE, base::Bind(&PlatformScreenImpl::FixedSizeScreenConfiguration,
weak_ptr_factory_.GetWeakPtr()));
}
int64_t PlatformScreenImpl::GetPrimaryDisplayId() const {
......
......@@ -8,6 +8,7 @@
#include <stdint.h>
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "services/ui/display/platform_screen.h"
namespace display {
......@@ -20,12 +21,17 @@ class PlatformScreenImpl : public PlatformScreen {
~PlatformScreenImpl() override;
private:
// Fake creation of a single 1024x768 display.
void FixedSizeScreenConfiguration();
// PlatformScreen.
void Init() override;
void ConfigurePhysicalDisplay(
const PlatformScreen::ConfiguredDisplayCallback& callback) override;
void Init(PlatformScreenDelegate* delegate) override;
int64_t GetPrimaryDisplayId() const override;
PlatformScreenDelegate* delegate_ = nullptr;
base::WeakPtrFactory<PlatformScreenImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PlatformScreenImpl);
};
......
......@@ -36,18 +36,16 @@ PlatformScreenImplOzone::~PlatformScreenImplOzone() {
display_configurator_.RemoveObserver(this);
}
void PlatformScreenImplOzone::Init() {
void PlatformScreenImplOzone::Init(PlatformScreenDelegate* delegate) {
DCHECK(delegate);
delegate_ = delegate;
// We want display configuration to happen even off device to keep the control
// flow similar.
display_configurator_.set_configure_display(true);
display_configurator_.AddObserver(this);
display_configurator_.Init(
ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), false);
}
void PlatformScreenImplOzone::ConfigurePhysicalDisplay(
const PlatformScreen::ConfiguredDisplayCallback& callback) {
callback_ = callback;
if (base::SysInfo::IsRunningOnChromeOS()) {
display_configurator_.ForceInitialConfigure(kChromeOsBootColor);
......@@ -96,7 +94,7 @@ void PlatformScreenImplOzone::OnDisplayModeChanged(
// Keep track of what displays have already been added.
displays_.insert(display->display_id());
callback_.Run(id, bounds);
delegate_->OnDisplayAdded(this, id, bounds);
}
DCHECK(displays_ == all_displays) << "Removing displays is not supported.";
......
......@@ -28,10 +28,7 @@ class PlatformScreenImplOzone : public PlatformScreen,
private:
// PlatformScreen:
void Init() override; // Must not be called until after the ozone platform is
// initialized.
void ConfigurePhysicalDisplay(
const ConfiguredDisplayCallback& callback) override;
void Init(PlatformScreenDelegate* delegate) override;
int64_t GetPrimaryDisplayId() const override;
// ui::DisplayConfigurator::Observer:
......@@ -41,6 +38,7 @@ class PlatformScreenImplOzone : public PlatformScreen,
const ui::DisplayConfigurator::DisplayStateList& displays,
ui::MultipleDisplayState failed_new_state) override;
PlatformScreenDelegate* delegate_ = nullptr;
ui::DisplayConfigurator display_configurator_;
// TODO(kylechar): These values can/should be replaced by DisplayLayout.
......@@ -48,9 +46,6 @@ class PlatformScreenImplOzone : public PlatformScreen,
std::set<uint64_t> displays_;
gfx::Point next_display_origin_;
// Callback for when new displays are configured.
ConfiguredDisplayCallback callback_;
DISALLOW_COPY_AND_ASSIGN(PlatformScreenImplOzone);
};
......
......@@ -81,8 +81,7 @@ struct Service::UserState {
Service::Service()
: test_config_(false),
platform_screen_(display::PlatformScreen::Create()),
ime_registrar_(&ime_server_),
weak_ptr_factory_(this) {}
ime_registrar_(&ime_server_) {}
Service::~Service() {
// Destroy |window_server_| first, since it depends on |event_source_|.
......@@ -133,8 +132,6 @@ void Service::AddUserIfNecessary(const shell::Identity& remote_identity) {
}
void Service::OnStart(const shell::Identity& identity) {
platform_display_init_params_.surfaces_state = new SurfacesState;
base::PlatformThread::SetName("mus");
tracing_.Initialize(connector(), identity.name());
TRACE_EVENT0("mus", "Service::Initialize started");
......@@ -184,9 +181,7 @@ void Service::OnStart(const shell::Identity& identity) {
gpu_proxy_.reset(new GpuServiceProxy());
// Gpu must be running before the PlatformScreen can be initialized.
platform_screen_->Init();
window_server_.reset(
new ws::WindowServer(this, platform_display_init_params_.surfaces_state));
window_server_.reset(new ws::WindowServer(this));
// DeviceDataManager must be initialized before TouchController. On non-Linux
// platforms there is no DeviceDataManager so don't create touch controller.
......@@ -244,11 +239,15 @@ bool Service::IsTestConfig() const {
return test_config_;
}
void Service::UpdateTouchTransforms() {
if (touch_controller_)
touch_controller_->UpdateTouchTransforms();
}
void Service::CreateDefaultDisplays() {
// An asynchronous callback will create the Displays once the physical
// displays are ready.
platform_screen_->ConfigurePhysicalDisplay(base::Bind(
&Service::OnCreatedPhysicalDisplay, weak_ptr_factory_.GetWeakPtr()));
// The display manager will create Displays once hardware or virtual displays
// are ready.
platform_screen_->Init(window_server_->display_manager());
}
void Service::Create(const shell::Identity& remote_identity,
......@@ -340,8 +339,7 @@ void Service::Create(const shell::Identity& remote_identity,
UserState* user_state = GetUserState(remote_identity);
if (!user_state->window_tree_host_factory) {
user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory(
window_server_.get(), remote_identity.user_id(),
platform_display_init_params_));
window_server_.get(), remote_identity.user_id()));
}
user_state->window_tree_host_factory->AddBinding(std::move(request));
}
......@@ -353,18 +351,5 @@ void Service::Create(const shell::Identity& remote_identity,
new ws::WindowServerTestImpl(window_server_.get(), std::move(request));
}
void Service::OnCreatedPhysicalDisplay(int64_t id, const gfx::Rect& bounds) {
platform_display_init_params_.display_bounds = bounds;
platform_display_init_params_.display_id = id;
platform_display_init_params_.platform_screen = platform_screen_.get();
// Display manages its own lifetime.
ws::Display* host_impl =
new ws::Display(window_server_.get(), platform_display_init_params_);
host_impl->Init(nullptr);
if (touch_controller_)
touch_controller_->UpdateTouchTransforms();
}
} // namespace ui
......@@ -13,7 +13,6 @@
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "services/shell/public/cpp/interface_factory.h"
#include "services/shell/public/cpp/service.h"
#include "services/shell/public/cpp/service_runner.h"
......@@ -110,6 +109,7 @@ class Service
void OnNoMoreDisplays() override;
bool IsTestConfig() const override;
void CreateDefaultDisplays() override;
void UpdateTouchTransforms() override;
// shell::InterfaceFactory<mojom::AccessibilityManager> implementation.
void Create(const shell::Identity& remote_identity,
......@@ -160,13 +160,6 @@ class Service
void Create(const shell::Identity& remote_identity,
mojom::WindowServerTestRequest request) override;
// Callback for display configuration. |id| is the identifying token for the
// configured display that will identify a specific physical display across
// configuration changes. |bounds| is the bounds of the display in screen
// coordinates.
void OnCreatedPhysicalDisplay(int64_t id, const gfx::Rect& bounds);
ws::PlatformDisplayInitParams platform_display_init_params_;
std::unique_ptr<ws::WindowServer> window_server_;
std::unique_ptr<ui::PlatformEventSource> event_source_;
tracing::Provider tracing_;
......@@ -189,8 +182,6 @@ class Service
IMERegistrarImpl ime_registrar_;
IMEServerImpl ime_server_;
base::WeakPtrFactory<Service> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(Service);
};
......
......@@ -26,7 +26,6 @@ static_library("lib") {
"display_binding.h",
"display_manager.cc",
"display_manager.h",
"display_manager_delegate.h",
"event_dispatcher.cc",
"event_dispatcher.h",
"event_dispatcher_delegate.h",
......@@ -70,6 +69,7 @@ static_library("lib") {
"user_activity_monitor.h",
"user_display_manager.cc",
"user_display_manager.h",
"user_display_manager_delegate.h",
"user_id.h",
"user_id_tracker.cc",
"user_id_tracker.h",
......
......@@ -44,9 +44,7 @@ class CursorTest : public testing::Test {
// testing::Test:
void SetUp() override {
PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
window_server_.reset(
new WindowServer(&window_server_delegate_,
scoped_refptr<SurfacesState>(new SurfacesState)));
window_server_.reset(new WindowServer(&window_server_delegate_));
window_server_delegate_.set_window_server(window_server_.get());
window_server_delegate_.set_num_displays_to_create(1);
......
......@@ -5,23 +5,27 @@
#include "services/ui/ws/display_manager.h"
#include "base/memory/ptr_util.h"
#include "services/ui/display/platform_screen.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_manager_delegate.h"
#include "services/ui/ws/display_binding.h"
#include "services/ui/ws/event_dispatcher.h"
#include "services/ui/ws/platform_display_init_params.h"
#include "services/ui/ws/server_window.h"
#include "services/ui/ws/user_display_manager.h"
#include "services/ui/ws/user_display_manager_delegate.h"
#include "services/ui/ws/user_id_tracker.h"
#include "services/ui/ws/window_manager_state.h"
#include "services/ui/ws/window_server_delegate.h"
namespace ui {
namespace ws {
DisplayManager::DisplayManager(DisplayManagerDelegate* delegate,
DisplayManager::DisplayManager(WindowServer* window_server,
UserIdTracker* user_id_tracker)
// |next_root_id_| is used as the lower bits, so that starting at 0 is
// fine. |next_display_id_| is used by itself, so we start at 1 to reserve
// 0 as invalid.
: delegate_(delegate),
: window_server_(window_server),
user_id_tracker_(user_id_tracker),
next_root_id_(0) {
user_id_tracker_->AddObserver(this);
......@@ -36,7 +40,7 @@ UserDisplayManager* DisplayManager::GetUserDisplayManager(
const UserId& user_id) {
if (!user_display_managers_.count(user_id)) {
user_display_managers_[user_id] =
base::MakeUnique<UserDisplayManager>(this, delegate_, user_id);
base::MakeUnique<UserDisplayManager>(this, window_server_, user_id);
}
return user_display_managers_[user_id].get();
}
......@@ -61,7 +65,7 @@ void DisplayManager::DestroyDisplay(Display* display) {
// If we have no more roots left, let the app know so it can terminate.
// TODO(sky): move to delegate/observer.
if (displays_.empty() && pending_displays_.empty())
delegate_->OnNoMoreDisplays();
window_server_->OnNoMoreDisplays();
}
void DisplayManager::DestroyAllDisplays() {
......@@ -135,13 +139,13 @@ void DisplayManager::OnDisplayAcceleratedWidgetAvailable(Display* display) {
displays_.insert(display);
pending_displays_.erase(display);
if (is_first_display)
delegate_->OnFirstDisplayReady();
window_server_->OnFirstDisplayReady();
}
void DisplayManager::OnActiveUserIdChanged(const UserId& previously_active_id,
const UserId& active_id) {
WindowManagerState* previous_window_manager_state =
delegate_->GetWindowManagerStateForUser(previously_active_id);
window_server_->GetWindowManagerStateForUser(previously_active_id);
gfx::Point mouse_location_on_screen;
if (previous_window_manager_state) {
mouse_location_on_screen = previous_window_manager_state->event_dispatcher()
......@@ -150,10 +154,35 @@ void DisplayManager::OnActiveUserIdChanged(const UserId& previously_active_id,
}
WindowManagerState* current_window_manager_state =
delegate_->GetWindowManagerStateForUser(active_id);
window_server_->GetWindowManagerStateForUser(active_id);
if (current_window_manager_state)
current_window_manager_state->Activate(mouse_location_on_screen);
}
void DisplayManager::OnDisplayAdded(display::PlatformScreen* platform_screen,
int64_t id,
const gfx::Rect& bounds) {
PlatformDisplayInitParams params;
params.display_bounds = bounds;
params.display_id = id;
params.platform_screen = platform_screen;
params.surfaces_state = window_server_->GetSurfacesState();
ws::Display* display = new ws::Display(window_server_, params);
display->Init(nullptr);
window_server_->delegate()->UpdateTouchTransforms();
}
void DisplayManager::OnDisplayRemoved(int64_t id) {
// TODO(kylechar): Implement.
NOTREACHED();
}
void DisplayManager::OnDisplayModified(int64_t id, const gfx::Rect& bounds) {
// TODO(kylechar): Implement.
NOTREACHED();
}
} // namespace ws
} // namespace ui
......@@ -10,6 +10,7 @@
#include <set>
#include "base/macros.h"
#include "services/ui/display/platform_screen_delegate.h"
#include "services/ui/ws/ids.h"
#include "services/ui/ws/user_id.h"
#include "services/ui/ws/user_id_tracker_observer.h"
......@@ -18,19 +19,19 @@ namespace ui {
namespace ws {
class Display;
class DisplayManagerDelegate;
class ServerWindow;
class UserDisplayManager;
class UserIdTracker;
class WindowManagerDisplayRoot;
class WindowServer;
// DisplayManager manages the set of Displays. DisplayManager distinguishes
// between displays that do yet have an accelerated widget (pending), vs
// those that do.
class DisplayManager : public UserIdTrackerObserver {
class DisplayManager : public UserIdTrackerObserver,
public display::PlatformScreenDelegate {
public:
DisplayManager(DisplayManagerDelegate* delegate,
UserIdTracker* user_id_tracker);
DisplayManager(WindowServer* window_server, UserIdTracker* user_id_tracker);
~DisplayManager() override;
// Returns the UserDisplayManager for |user_id|. DisplayManager owns the
......@@ -76,7 +77,14 @@ class DisplayManager : public UserIdTrackerObserver {
void OnActiveUserIdChanged(const UserId& previously_active_id,
const UserId& active_id) override;
DisplayManagerDelegate* delegate_;
// display::PlatformScreenDelegate:
void OnDisplayAdded(display::PlatformScreen* platform_screen_,
int64_t id,
const gfx::Rect& bounds) override;
void OnDisplayRemoved(int64_t id) override;
void OnDisplayModified(int64_t id, const gfx::Rect& bounds) override;
WindowServer* window_server_;
UserIdTracker* user_id_tracker_;
// Displays are initially added to |pending_displays_|. When the display is
......
......@@ -62,8 +62,7 @@ class DisplayTest : public testing::Test {
// testing::Test:
void SetUp() override {
PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
window_server_.reset(new WindowServer(&window_server_delegate_,
scoped_refptr<SurfacesState>()));
window_server_.reset(new WindowServer(&window_server_delegate_));
window_server_delegate_.set_window_server(window_server_.get());
window_server_->user_id_tracker()->AddUserId(kTestId1);
window_server_->user_id_tracker()->AddUserId(kTestId2);
......
......@@ -426,8 +426,7 @@ WindowEventTargetingHelper::WindowEventTargetingHelper()
surfaces_state_(new SurfacesState()),
window_server_(nullptr) {
PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
window_server_.reset(
new WindowServer(&window_server_delegate_, surfaces_state_));
window_server_.reset(new WindowServer(&window_server_delegate_));
PlatformDisplayInitParams display_init_params;
display_init_params.surfaces_state = surfaces_state_;
display_ = new Display(window_server_.get(), display_init_params);
......
......@@ -487,6 +487,7 @@ class TestWindowServerDelegate : public WindowServerDelegate {
mojom::WindowTreeClientPtr* client) override;
void CreateDefaultDisplays() override;
bool IsTestConfig() const override;
void UpdateTouchTransforms() override {}
private:
// If CreateDefaultDisplays() this is the number of Displays that are
......
......@@ -8,13 +8,13 @@
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_manager.h"
#include "services/ui/ws/display_manager_delegate.h"
#include "services/ui/ws/user_display_manager_delegate.h"
namespace ui {
namespace ws {
UserDisplayManager::UserDisplayManager(ws::DisplayManager* display_manager,
DisplayManagerDelegate* delegate,
UserDisplayManagerDelegate* delegate,
const UserId& user_id)
: display_manager_(display_manager),
delegate_(delegate),
......
......@@ -23,7 +23,7 @@ namespace ws {
class Display;
class DisplayManager;
class DisplayManagerDelegate;
class UserDisplayManagerDelegate;
namespace test {
class UserDisplayManagerTestApi;
......@@ -33,7 +33,7 @@ class UserDisplayManagerTestApi;
class UserDisplayManager : public mojom::DisplayManager {
public:
UserDisplayManager(ws::DisplayManager* display_manager,
DisplayManagerDelegate* delegate,
UserDisplayManagerDelegate* delegate,
const UserId& user_id);
~UserDisplayManager() override;
......@@ -79,7 +79,7 @@ class UserDisplayManager : public mojom::DisplayManager {
ws::DisplayManager* display_manager_;
DisplayManagerDelegate* delegate_;
UserDisplayManagerDelegate* delegate_;
const UserId user_id_;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_WS_DISPLAY_MANAGER_DELEGATE_H_
#define SERVICES_UI_WS_DISPLAY_MANAGER_DELEGATE_H_
#ifndef SERVICES_UI_WS_USER_DISPLAY_MANAGER_DELEGATE_H_
#define SERVICES_UI_WS_USER_DISPLAY_MANAGER_DELEGATE_H_
#include "services/ui/public/interfaces/display.mojom.h"
#include "services/ui/ws/user_id.h"
......@@ -14,25 +14,19 @@ namespace ws {
class Display;
class WindowManagerState;
class DisplayManagerDelegate {
class UserDisplayManagerDelegate {
public:
virtual void OnFirstDisplayReady() = 0;
virtual void OnNoMoreDisplays() = 0;
// Gets the frame decorations for the specified user. Returns true if the
// decorations have been set, false otherwise. |values| may be null.
virtual bool GetFrameDecorationsForUser(
const UserId& user_id,
mojom::FrameDecorationValuesPtr* values) = 0;
virtual WindowManagerState* GetWindowManagerStateForUser(
const UserId& user_id) = 0;
protected:
virtual ~DisplayManagerDelegate() {}
virtual ~UserDisplayManagerDelegate() {}
};
} // namespace ws
} // namespace ui
#endif // SERVICES_UI_WS_DISPLAY_MANAGER_DELEGATE_H_
#endif // SERVICES_UI_WS_USER_DISPLAY_MANAGER_DELEGATE_H_
......@@ -99,8 +99,7 @@ class UserDisplayManagerTest : public testing::Test {
// testing::Test:
void SetUp() override {
PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
window_server_.reset(new WindowServer(&window_server_delegate_,
scoped_refptr<SurfacesState>()));
window_server_.reset(new WindowServer(&window_server_delegate_));
window_server_delegate_.set_window_server(window_server_.get());
}
......
......@@ -37,11 +37,9 @@ struct WindowServer::CurrentMoveLoopState {
gfx::Rect revert_bounds;
};
WindowServer::WindowServer(
WindowServerDelegate* delegate,
const scoped_refptr<ui::SurfacesState>& surfaces_state)
WindowServer::WindowServer(WindowServerDelegate* delegate)
: delegate_(delegate),
surfaces_state_(surfaces_state),
surfaces_state_(new SurfacesState()),
next_client_id_(1),
display_manager_(new DisplayManager(this, &user_id_tracker_)),
current_operation_(nullptr),
......@@ -484,6 +482,37 @@ gfx::Rect WindowServer::GetCurrentMoveLoopRevertBounds() {
return gfx::Rect();
}
void WindowServer::OnFirstDisplayReady() {
delegate_->OnFirstDisplayReady();
}
void WindowServer::OnNoMoreDisplays() {
delegate_->OnNoMoreDisplays();
}
WindowManagerState* WindowServer::GetWindowManagerStateForUser(
const UserId& user_id) {
return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser(
user_id);
}
ui::SurfacesState* WindowServer::GetSurfacesState() {
return surfaces_state_.get();
}
bool WindowServer::GetFrameDecorationsForUser(
const UserId& user_id,
mojom::FrameDecorationValuesPtr* values) {
WindowManagerState* window_manager_state =
window_manager_window_tree_factory_set_.GetWindowManagerStateForUser(
user_id);
if (!window_manager_state)
return false;
if (values && window_manager_state->got_frame_decoration_values())
*values = window_manager_state->frame_decoration_values().Clone();
return window_manager_state->got_frame_decoration_values();
}
bool WindowServer::GetAndClearInFlightWindowManagerChange(
uint32_t window_manager_change_id,
InFlightWindowManagerChange* change) {
......@@ -546,10 +575,6 @@ bool WindowServer::IsUserInHighContrastMode(const UserId& user) const {
return (iter == high_contrast_mode_.end()) ? false : iter->second;
}
ui::SurfacesState* WindowServer::GetSurfacesState() {
return surfaces_state_.get();
}
void WindowServer::OnScheduleWindowPaint(ServerWindow* window) {
if (in_destructor_)
return;
......@@ -739,33 +764,6 @@ void WindowServer::OnTransientWindowRemoved(ServerWindow* window,
}
}
void WindowServer::OnFirstDisplayReady() {
delegate_->OnFirstDisplayReady();
}
void WindowServer::OnNoMoreDisplays() {
delegate_->OnNoMoreDisplays();
}
bool WindowServer::GetFrameDecorationsForUser(
const UserId& user_id,
mojom::FrameDecorationValuesPtr* values) {
WindowManagerState* window_manager_state =
window_manager_window_tree_factory_set_.GetWindowManagerStateForUser(
user_id);
if (!window_manager_state)
return false;
if (values && window_manager_state->got_frame_decoration_values())
*values = window_manager_state->frame_decoration_values().Clone();
return window_manager_state->got_frame_decoration_values();
}
WindowManagerState* WindowServer::GetWindowManagerStateForUser(
const UserId& user_id) {
return window_manager_window_tree_factory_set_.GetWindowManagerStateForUser(
user_id);
}
void WindowServer::OnActiveUserIdChanged(const UserId& previously_active_id,
const UserId& active_id) {
if (IsUserInHighContrastMode(previously_active_id) ==
......
......@@ -21,11 +21,11 @@
#include "services/ui/public/interfaces/window_tree_host.mojom.h"
#include "services/ui/surfaces/surfaces_state.h"
#include "services/ui/ws/display.h"
#include "services/ui/ws/display_manager_delegate.h"
#include "services/ui/ws/ids.h"
#include "services/ui/ws/operation.h"
#include "services/ui/ws/server_window_delegate.h"
#include "services/ui/ws/server_window_observer.h"
#include "services/ui/ws/user_display_manager_delegate.h"
#include "services/ui/ws/user_id_tracker.h"
#include "services/ui/ws/user_id_tracker_observer.h"
#include "services/ui/ws/window_manager_window_tree_factory_set.h"
......@@ -46,11 +46,10 @@ class WindowTreeBinding;
// WindowTrees) as well as providing the root of the hierarchy.
class WindowServer : public ServerWindowDelegate,
public ServerWindowObserver,
public DisplayManagerDelegate,
public UserDisplayManagerDelegate,
public UserIdTrackerObserver {
public:
WindowServer(WindowServerDelegate* delegate,
const scoped_refptr<ui::SurfacesState>& surfaces_state);
explicit WindowServer(WindowServerDelegate* delegate);
~WindowServer() override;
WindowServerDelegate* delegate() { return delegate_; }
......@@ -216,6 +215,18 @@ class WindowServer : public ServerWindowDelegate,
gfx::Rect GetCurrentMoveLoopRevertBounds();
bool in_move_loop() const { return !!current_move_loop_; }
void OnFirstDisplayReady();
void OnNoMoreDisplays();
WindowManagerState* GetWindowManagerStateForUser(const UserId& user_id);
// ServerWindowDelegate:
ui::SurfacesState* GetSurfacesState() override;
// UserDisplayManagerDelegate:
bool GetFrameDecorationsForUser(
const UserId& user_id,
mojom::FrameDecorationValuesPtr* values) override;
private:
struct CurrentMoveLoopState;
friend class Operation;
......@@ -266,7 +277,6 @@ class WindowServer : public ServerWindowDelegate,
bool IsUserInHighContrastMode(const UserId& user) const;
// Overridden from ServerWindowDelegate:
ui::SurfacesState* GetSurfacesState() override;
void OnScheduleWindowPaint(ServerWindow* window) override;
const ServerWindow* GetRootWindow(const ServerWindow* window) const override;
void ScheduleSurfaceDestruction(ServerWindow* window) override;
......@@ -309,15 +319,6 @@ class WindowServer : public ServerWindowDelegate,
void OnTransientWindowRemoved(ServerWindow* window,
ServerWindow* transient_child) override;
// DisplayManagerDelegate:
void OnFirstDisplayReady() override;
void OnNoMoreDisplays() override;
bool GetFrameDecorationsForUser(
const UserId& user_id,
mojom::FrameDecorationValuesPtr* values) override;
WindowManagerState* GetWindowManagerStateForUser(
const UserId& user_id) override;
// UserIdTrackerObserver:
void OnActiveUserIdChanged(const UserId& previously_active_id,
const UserId& active_id) override;
......
......@@ -47,6 +47,10 @@ class WindowServerDelegate {
virtual bool IsTestConfig() const = 0;
// Called when touchscreen coordinate transforms should be updated. For
// example when displays or touch input devices are added/removed.
virtual void UpdateTouchTransforms() = 0;
// Creates a WindowTreeBinding. Default implementation returns null, which
// creates DefaultBinding.
virtual std::unique_ptr<WindowTreeBinding> CreateWindowTreeBinding(
......
......@@ -12,13 +12,12 @@
namespace ui {
namespace ws {
WindowTreeHostFactory::WindowTreeHostFactory(
WindowServer* window_server,
const UserId& user_id,
const PlatformDisplayInitParams& platform_display_init_params)
: window_server_(window_server),
user_id_(user_id),
platform_display_init_params_(platform_display_init_params) {}
WindowTreeHostFactory::WindowTreeHostFactory(WindowServer* window_server,
const UserId& user_id)
: window_server_(window_server), user_id_(user_id) {
platform_display_init_params_.surfaces_state =
window_server_->GetSurfacesState();
}
WindowTreeHostFactory::~WindowTreeHostFactory() {}
......
......@@ -19,10 +19,7 @@ class WindowServer;
class WindowTreeHostFactory : public mojom::WindowTreeHostFactory {
public:
WindowTreeHostFactory(
WindowServer* window_server,
const UserId& user_id,
const PlatformDisplayInitParams& platform_display_init_params);
WindowTreeHostFactory(WindowServer* window_server, const UserId& user_id);
~WindowTreeHostFactory() override;
void AddBinding(mojom::WindowTreeHostFactoryRequest request);
......@@ -34,7 +31,7 @@ class WindowTreeHostFactory : public mojom::WindowTreeHostFactory {
WindowServer* window_server_;
const UserId user_id_;
const PlatformDisplayInitParams platform_display_init_params_;
PlatformDisplayInitParams platform_display_init_params_;
mojo::BindingSet<mojom::WindowTreeHostFactory> bindings_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostFactory);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment