Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index 278c4b336b9bbadea70d5daa2b37a166c47098e5..95b17c31812bdfff389b186afce1360371b90cf4 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 { |
|
reveman
2016/08/02 22:12:35
nit: can you change the name of this to WaylandPri
oshima
2016/08/03 00:22:55
Done.
|
| 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 & |
|
reveman
2016/08/02 22:12:35
nit: can you add a short comment here that makes i
oshima
2016/08/03 00:22:55
Done.
|
| (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
| DISPLAY_METRIC_ROTATION)) { |
| - SendDisplayMetrics(display); |
| + SendPrimaryDisplayMetrics(); |
| } |
| } |
| private: |
| - void SendDisplayMetrics(const display::Display& display) { |
| + void SendPrimaryDisplayMetrics() { |
|
reveman
2016/08/02 22:12:35
nit: keep name as SendDisplayMetrics if you change
oshima
2016/08/03 00:22:55
Done.
|
| + // TODO(reveman): Multi-display support. |
|
reveman
2016/08/02 22:12:35
nit: move this TODO to where we instantiate the cl
oshima
2016/08/03 00:22:55
Done.
|
| + 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))); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -1575,10 +1569,8 @@ 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); |
| @@ -1610,7 +1602,7 @@ class WaylandRemoteShell : public ash::ShellObserver, |
| 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 & |
| @@ -1652,9 +1644,9 @@ class WaylandRemoteShell : public ash::ShellObserver, |
| private: |
| void SendPrimaryDisplayMetrics() { |
| - const display::Display& primary = |
| - ash::Shell::GetInstance()->display_manager()->GetDisplayForId( |
| - display_id_); |
| + const display::Display primary = |
| + display::Screen::GetScreen()->GetPrimaryDisplay(); |
| + |
| SendConfigure_DEPRECATED(primary); |
| SendDisplayMetrics(primary); |
| } |
| @@ -1688,7 +1680,7 @@ class WaylandRemoteShell : public ash::ShellObserver, |
| if (wl_resource_get_version(remote_shell_resource_) >= 9) |
| return; |
| - gfx::Insets work_area_insets = display.GetWorkAreaInsets(); |
| + const gfx::Insets& work_area_insets = display.GetWorkAreaInsets(); |
| zwp_remote_shell_v1_send_configure( |
| remote_shell_resource_, display.size().width(), display.size().height(), |
| work_area_insets.left(), work_area_insets.top(), |
| @@ -1740,9 +1732,6 @@ 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_; |
| @@ -1905,14 +1894,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))); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |