| Index: components/exo/wayland/server.cc
|
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
|
| index 49b1842396b959cdc2b636905eac4ce86b742b31..de54b3408a51fa074c1619d540bc20363aef10c9 100644
|
| --- a/components/exo/wayland/server.cc
|
| +++ b/components/exo/wayland/server.cc
|
| @@ -1040,11 +1040,10 @@ wl_output_transform OutputTransform(display::Display::Rotation rotation) {
|
|
|
| class WaylandDisplayObserver : public display::DisplayObserver {
|
| public:
|
| - WaylandDisplayObserver(const display::Display& display,
|
| - wl_resource* output_resource)
|
| - : display_id_(display.id()), output_resource_(output_resource) {
|
| + WaylandDisplayObserver(wl_resource* output_resource)
|
| + : output_resource_(output_resource) {
|
| display::Screen::GetScreen()->AddObserver(this);
|
| - SendDisplayMetrics(display);
|
| + SendPrimaryDisplayMetrics();
|
| }
|
| ~WaylandDisplayObserver() override {
|
| display::Screen::GetScreen()->RemoveObserver(this);
|
| @@ -1055,18 +1054,22 @@ class WaylandDisplayObserver : public display::DisplayObserver {
|
| void OnDisplayRemoved(const display::Display& new_display) override {}
|
| void OnDisplayMetricsChanged(const display::Display& display,
|
| uint32_t changed_metrics) override {
|
| - if (display.id() != display_id_)
|
| + if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id())
|
| return;
|
|
|
| if (changed_metrics &
|
| (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
|
| DISPLAY_METRIC_ROTATION)) {
|
| - SendDisplayMetrics(display);
|
| + SendPrimaryDisplayMetrics();
|
| }
|
| }
|
|
|
| private:
|
| - void SendDisplayMetrics(const display::Display& display) {
|
| + void SendPrimaryDisplayMetrics() {
|
| + // TODO(reveman): Multi-display support.
|
| + display::Display display =
|
| + display::Screen::GetScreen()->GetPrimaryDisplay();
|
| +
|
| const ash::DisplayInfo& info =
|
| ash::Shell::GetInstance()->display_manager()->GetDisplayInfo(
|
| display.id());
|
| @@ -1099,9 +1102,6 @@ class WaylandDisplayObserver : public display::DisplayObserver {
|
| }
|
| }
|
|
|
| - // The identifier associated with the observed display.
|
| - const int64_t display_id_;
|
| -
|
| // The output resource associated with the display.
|
| wl_resource* const output_resource_;
|
|
|
| @@ -1114,14 +1114,8 @@ void bind_output(wl_client* client, void* data, uint32_t version, uint32_t id) {
|
| wl_resource* resource = wl_resource_create(
|
| client, &wl_output_interface, std::min(version, output_version), id);
|
|
|
| - // TODO(reveman): Multi-display support.
|
| - const display::Display& display = ash::Shell::GetInstance()
|
| - ->display_manager()
|
| - ->GetPrimaryDisplayCandidate();
|
| -
|
| - SetImplementation(
|
| - resource, nullptr,
|
| - base::WrapUnique(new WaylandDisplayObserver(display, resource)));
|
| + SetImplementation(resource, nullptr,
|
| + base::WrapUnique(new WaylandDisplayObserver(resource)));
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -1521,6 +1515,14 @@ void remote_surface_unset_system_modal(wl_client* client,
|
| GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false);
|
| }
|
|
|
| +void remote_surface_set_rectangular_shadow_background_opacity(
|
| + wl_client* client,
|
| + wl_resource* resource,
|
| + wl_fixed_t opacity) {
|
| + GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity(
|
| + wl_fixed_to_double(opacity));
|
| +}
|
| +
|
| const struct zwp_remote_surface_v1_interface remote_surface_implementation = {
|
| remote_surface_destroy,
|
| remote_surface_set_app_id,
|
| @@ -1537,7 +1539,8 @@ const struct zwp_remote_surface_v1_interface remote_surface_implementation = {
|
| remote_surface_set_title,
|
| remote_surface_set_top_inset,
|
| remote_surface_set_system_modal,
|
| - remote_surface_unset_system_modal};
|
| + remote_surface_unset_system_modal,
|
| + remote_surface_set_rectangular_shadow_background_opacity};
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // notification_surface_interface:
|
| @@ -1559,17 +1562,16 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| public display::DisplayObserver {
|
| public:
|
| WaylandRemoteShell(Display* display,
|
| - int64_t display_id,
|
| wl_resource* remote_shell_resource)
|
| : display_(display),
|
| - display_id_(display_id),
|
| remote_shell_resource_(remote_shell_resource),
|
| weak_ptr_factory_(this) {
|
| ash::WmShell::Get()->AddShellObserver(this);
|
| ash::Shell* shell = ash::Shell::GetInstance();
|
| shell->activation_client()->AddObserver(this);
|
| display::Screen::GetScreen()->AddObserver(this);
|
| - SendConfigure();
|
| +
|
| + SendPrimaryDisplayMetrics();
|
| SendActivated(shell->activation_client()->GetActiveWindow(), nullptr);
|
| }
|
| ~WaylandRemoteShell() override {
|
| @@ -1593,14 +1595,23 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| void OnDisplayAdded(const display::Display& new_display) override {}
|
| void OnDisplayRemoved(const display::Display& new_display) override {}
|
| void OnDisplayMetricsChanged(const display::Display& display,
|
| - uint32_t metrics) override {
|
| - if (display.id() == display_id_)
|
| - SendConfigure();
|
| + uint32_t changed_metrics) override {
|
| + if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id())
|
| + return;
|
| +
|
| + if (changed_metrics &
|
| + (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
|
| + DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) {
|
| + SendDisplayMetrics(display);
|
| + }
|
| + SendConfigure_DEPRECATED(display);
|
| }
|
|
|
| // Overridden from ash::ShellObserver:
|
| void OnMaximizeModeStarted() override {
|
| - SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET);
|
| + layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET;
|
| + SendLayoutModeChange_DEPRECATED();
|
| +
|
| send_configure_after_layout_change_ = true;
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure,
|
| @@ -1608,7 +1619,8 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs));
|
| }
|
| void OnMaximizeModeEnded() override {
|
| - SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED);
|
| + layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED;
|
| + SendLayoutModeChange_DEPRECATED();
|
| send_configure_after_layout_change_ = true;
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure,
|
| @@ -1625,16 +1637,43 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| }
|
|
|
| private:
|
| + void SendPrimaryDisplayMetrics() {
|
| + const display::Display primary =
|
| + display::Screen::GetScreen()->GetPrimaryDisplay();
|
| +
|
| + SendConfigure_DEPRECATED(primary);
|
| + SendDisplayMetrics(primary);
|
| + }
|
| +
|
| void MaybeSendConfigure() {
|
| if (send_configure_after_layout_change_)
|
| - SendConfigure();
|
| + SendPrimaryDisplayMetrics();
|
| }
|
|
|
| - void SendConfigure() {
|
| + void SendDisplayMetrics(const display::Display& display) {
|
| + if (wl_resource_get_version(remote_shell_resource_) < 9)
|
| + return;
|
| +
|
| send_configure_after_layout_change_ = false;
|
| - const display::Display& display =
|
| - ash::Shell::GetInstance()->display_manager()->GetDisplayForId(
|
| - display_id_);
|
| +
|
| + gfx::Insets work_area_insets = display.GetWorkAreaInsets();
|
| +
|
| + zwp_remote_shell_v1_send_configuration_changed(
|
| + remote_shell_resource_, display.size().width(), display.size().height(),
|
| + OutputTransform(display.rotation()),
|
| + wl_fixed_from_double(display.device_scale_factor()),
|
| + work_area_insets.left(), work_area_insets.top(),
|
| + work_area_insets.right(), work_area_insets.bottom(), layout_mode_);
|
| +
|
| + wl_client_flush(wl_resource_get_client(remote_shell_resource_));
|
| + }
|
| +
|
| + void SendConfigure_DEPRECATED(const display::Display& display) {
|
| + send_configure_after_layout_change_ = false;
|
| +
|
| + if (wl_resource_get_version(remote_shell_resource_) >= 9)
|
| + return;
|
| +
|
| gfx::Insets work_area_insets = display.GetWorkAreaInsets();
|
| zwp_remote_shell_v1_send_configure(
|
| remote_shell_resource_, display.size().width(), display.size().height(),
|
| @@ -1643,10 +1682,11 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| wl_client_flush(wl_resource_get_client(remote_shell_resource_));
|
| }
|
|
|
| - void SendLayoutModeChange(uint32_t mode) {
|
| + void SendLayoutModeChange_DEPRECATED() {
|
| if (wl_resource_get_version(remote_shell_resource_) < 8)
|
| return;
|
| - zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, mode);
|
| + zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_,
|
| + layout_mode_);
|
| wl_client_flush(wl_resource_get_client(remote_shell_resource_));
|
| }
|
|
|
| @@ -1686,14 +1726,13 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| // The exo display instance. Not owned.
|
| Display* const display_;
|
|
|
| - // The identifier associated with the observed display.
|
| - const int64_t display_id_;
|
| -
|
| // The remote shell resource associated with observer.
|
| wl_resource* const remote_shell_resource_;
|
|
|
| bool send_configure_after_layout_change_ = false;
|
|
|
| + int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED;
|
| +
|
| base::WeakPtrFactory<WaylandRemoteShell> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell);
|
| @@ -1839,7 +1878,7 @@ const struct zwp_remote_shell_v1_interface remote_shell_implementation = {
|
| remote_shell_destroy, remote_shell_get_remote_surface,
|
| remote_shell_get_notification_surface};
|
|
|
| -const uint32_t remote_shell_version = 8;
|
| +const uint32_t remote_shell_version = 9;
|
|
|
| void bind_remote_shell(wl_client* client,
|
| void* data,
|
| @@ -1849,14 +1888,9 @@ void bind_remote_shell(wl_client* client,
|
| wl_resource_create(client, &zwp_remote_shell_v1_interface,
|
| std::min(version, remote_shell_version), id);
|
|
|
| - // TODO(reveman): Multi-display support.
|
| - const display::Display& display = ash::Shell::GetInstance()
|
| - ->display_manager()
|
| - ->GetPrimaryDisplayCandidate();
|
| -
|
| SetImplementation(resource, &remote_shell_implementation,
|
| base::WrapUnique(new WaylandRemoteShell(
|
| - static_cast<Display*>(data), display.id(), resource)));
|
| + static_cast<Display*>(data), resource)));
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|