Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index ee3a25aa333b40c14033de982e02b5aa1aff6724..8852bae01e9c2c21c7a79cc74aa87847186d8d2e 100644 |
| --- a/components/exo/wayland/server.cc |
| +++ b/components/exo/wayland/server.cc |
| @@ -1038,11 +1038,10 @@ wl_output_transform OutputTransform(display::Display::Rotation rotation) { |
| class WaylandDisplayObserver : public display::DisplayObserver { |
| public: |
| - WaylandDisplayObserver(const display::Display& display, |
|
oshima
2016/07/28 23:05:34
I also changed the wayland output events to use cu
|
| - 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); |
| @@ -1053,18 +1052,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()); |
| @@ -1097,9 +1100,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_; |
| @@ -1112,14 +1112,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))); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -1519,6 +1513,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, |
| @@ -1535,7 +1537,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: |
| @@ -1557,17 +1560,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 { |
| @@ -1591,15 +1593,26 @@ 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 OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); } |
| + void OnDisplayWorkAreaInsetsChanged() override { |
| + SendPrimaryDisplayMetrics(); |
| + } |
| 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, |
| @@ -1607,7 +1620,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, |
| @@ -1624,16 +1638,53 @@ 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 SendDisplayMetrics(const display::Display& display) { |
| + if (wl_resource_get_version(remote_shell_resource_) < 9) |
| + return; |
| + |
| + send_configure_after_layout_change_ = false; |
| + const ash::DisplayInfo& info = |
| + ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( |
| + display.id()); |
| + |
| + gfx::Insets work_area_insets = display.GetWorkAreaInsets(); |
| + gfx::Rect native_bounds = info.bounds_in_native(); |
| + |
| + int refresh_rate = 60000; |
| + zwp_remote_shell_v1_send_configuration_changed( |
| + remote_shell_resource_, |
| + native_bounds.width(), |
| + native_bounds.height(), |
| + info.device_dpi(), |
| + OutputTransform(display.rotation()), |
| + refresh_rate, |
| + wl_fixed_from_double(display.device_scale_factor()), |
| + display.size().width(), display.size().height(), |
| + 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() { |
| + void SendConfigure_DEPRECATED(const display::Display& display) { |
| send_configure_after_layout_change_ = false; |
| - const display::Display& display = |
| - ash::Shell::GetInstance()->display_manager()->GetDisplayForId( |
| - display_id_); |
| + |
| + 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(), |
| @@ -1642,10 +1693,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_)); |
| } |
| @@ -1685,14 +1737,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); |
| @@ -1838,7 +1889,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, |
| @@ -1848,14 +1899,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))); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |