| Index: components/exo/wayland/server.cc
|
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
|
| index ee3a25aa333b40c14033de982e02b5aa1aff6724..f25ab4ada6a36e0c6d5bf992c148398aacfead0a 100644
|
| --- a/components/exo/wayland/server.cc
|
| +++ b/components/exo/wayland/server.cc
|
| @@ -1042,7 +1042,7 @@ class WaylandDisplayObserver : public display::DisplayObserver {
|
| wl_resource* output_resource)
|
| : display_id_(display.id()), output_resource_(output_resource) {
|
| display::Screen::GetScreen()->AddObserver(this);
|
| - SendDisplayMetrics(display);
|
| + SendDisplayMetricsObsolete(display);
|
| }
|
| ~WaylandDisplayObserver() override {
|
| display::Screen::GetScreen()->RemoveObserver(this);
|
| @@ -1059,12 +1059,12 @@ class WaylandDisplayObserver : public display::DisplayObserver {
|
| if (changed_metrics &
|
| (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
|
| DISPLAY_METRIC_ROTATION)) {
|
| - SendDisplayMetrics(display);
|
| + SendDisplayMetricsObsolete(display);
|
| }
|
| }
|
|
|
| private:
|
| - void SendDisplayMetrics(const display::Display& display) {
|
| + void SendDisplayMetricsObsolete(const display::Display& display) {
|
| const ash::DisplayInfo& info =
|
| ash::Shell::GetInstance()->display_manager()->GetDisplayInfo(
|
| display.id());
|
| @@ -1519,6 +1519,13 @@ void remote_surface_unset_system_modal(wl_client* client,
|
| GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false);
|
| }
|
|
|
| +void remote_surface_set_background_opacity(wl_client* client,
|
| + wl_resource* resource,
|
| + wl_fixed_t opacity) {
|
| + GetUserDataAs<ShellSurface>(resource)->SetBackgroundOpacity(
|
| + 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 +1542,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_background_opacity};
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // notification_surface_interface:
|
| @@ -1567,7 +1575,9 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| ash::Shell* shell = ash::Shell::GetInstance();
|
| shell->activation_client()->AddObserver(this);
|
| display::Screen::GetScreen()->AddObserver(this);
|
| - SendConfigure();
|
| + SendConfigureObsolete();
|
| + SendPrimaryDisplayMetrics();
|
| +
|
| SendActivated(shell->activation_client()->GetActiveWindow(), nullptr);
|
| }
|
| ~WaylandRemoteShell() override {
|
| @@ -1591,15 +1601,25 @@ 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 {
|
| + uint32_t changed_metrics) override {
|
| + if (display::Screen::GetScreen()->GetPrimaryDisplay().id() ==
|
| + display.id() &&
|
| + (changed_metrics &
|
| + (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
|
| + DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA))) {
|
| + SendPrimaryDisplayMetrics();
|
| + }
|
| +
|
| if (display.id() == display_id_)
|
| - SendConfigure();
|
| + SendConfigureObsolete();
|
| }
|
|
|
| // Overridden from ash::ShellObserver:
|
| - void OnDisplayWorkAreaInsetsChanged() override { SendConfigure(); }
|
| + void OnDisplayWorkAreaInsetsChanged() override { SendConfigureObsolete(); }
|
| void OnMaximizeModeStarted() override {
|
| SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET);
|
| + layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET;
|
| +
|
| send_configure_after_layout_change_ = true;
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure,
|
| @@ -1608,6 +1628,7 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
| }
|
| void OnMaximizeModeEnded() override {
|
| SendLayoutModeChange(ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED);
|
| + layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED;
|
| send_configure_after_layout_change_ = true;
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| FROM_HERE, base::Bind(&WaylandRemoteShell::MaybeSendConfigure,
|
| @@ -1625,13 +1646,51 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
|
|
| private:
|
| void MaybeSendConfigure() {
|
| - if (send_configure_after_layout_change_)
|
| - SendConfigure();
|
| + if (send_configure_after_layout_change_) {
|
| + SendPrimaryDisplayMetrics();
|
| + SendConfigureObsolete();
|
| + }
|
| }
|
|
|
| - void SendConfigure() {
|
| + void SendPrimaryDisplayMetrics() {
|
| + const float kInchInMm = 25.4f;
|
| +
|
| + if (wl_resource_get_version(remote_shell_resource_) < 9)
|
| + return;
|
| +
|
| send_configure_after_layout_change_ = false;
|
| const display::Display& display =
|
| + display::Screen::GetScreen()->GetPrimaryDisplay();
|
| + 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_display_changed(
|
| + remote_shell_resource_, native_bounds.x(), native_bounds.y(),
|
| + static_cast<int>(kInchInMm * native_bounds.width() / info.device_dpi()),
|
| + static_cast<int>(kInchInMm * native_bounds.height() /
|
| + info.device_dpi()),
|
| + WL_OUTPUT_SUBPIXEL_UNKNOWN, OutputTransform(display.rotation()),
|
| + native_bounds.width(), native_bounds.height(), 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 SendConfigureObsolete() {
|
| + send_configure_after_layout_change_ = false;
|
| +
|
| + if (wl_resource_get_version(remote_shell_resource_) >= 9)
|
| + return;
|
| +
|
| + const display::Display& display =
|
| ash::Shell::GetInstance()->display_manager()->GetDisplayForId(
|
| display_id_);
|
| gfx::Insets work_area_insets = display.GetWorkAreaInsets();
|
| @@ -1693,6 +1752,8 @@ class WaylandRemoteShell : public ash::ShellObserver,
|
|
|
| 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 +1899,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,
|
|
|