| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/wayland/server.h" | 5 #include "components/exo/wayland/server.h" |
| 6 | 6 |
| 7 #include <alpha-compositing-unstable-v1-server-protocol.h> | 7 #include <alpha-compositing-unstable-v1-server-protocol.h> |
| 8 #include <gaming-input-unstable-v1-server-protocol.h> | 8 #include <gaming-input-unstable-v1-server-protocol.h> |
| 9 #include <grp.h> | 9 #include <grp.h> |
| 10 #include <keyboard-configuration-unstable-v1-server-protocol.h> | 10 #include <keyboard-configuration-unstable-v1-server-protocol.h> |
| (...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1637 // | 1637 // |
| 1638 // P Q | 1638 // P Q |
| 1639 // +-----+ / | 1639 // +-----+ / |
| 1640 // | |/ | 1640 // | |/ |
| 1641 // | 2 +-----------+ | 1641 // | 2 +-----------+ |
| 1642 // | | | | 1642 // | | | |
| 1643 // +-----+ 1 | | 1643 // +-----+ 1 | |
| 1644 // | | | 1644 // | | |
| 1645 // +-----------+ | 1645 // +-----------+ |
| 1646 // | 1646 // |
| 1647 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, | 1647 class WaylandRemoteShell : public WMHelper::ShellObserver, |
| 1648 public WMHelper::ActivationObserver, | 1648 public WMHelper::ActivationObserver, |
| 1649 public display::DisplayObserver { | 1649 public display::DisplayObserver { |
| 1650 public: | 1650 public: |
| 1651 WaylandRemoteShell(Display* display, wl_resource* remote_shell_resource) | 1651 WaylandRemoteShell(Display* display, wl_resource* remote_shell_resource) |
| 1652 : display_(display), | 1652 : display_(display), |
| 1653 remote_shell_resource_(remote_shell_resource), | 1653 remote_shell_resource_(remote_shell_resource), |
| 1654 weak_ptr_factory_(this) { | 1654 weak_ptr_factory_(this) { |
| 1655 auto* helper = WMHelper::GetInstance(); | 1655 auto* helper = WMHelper::GetInstance(); |
| 1656 helper->AddMaximizeModeObserver(this); | 1656 helper->AddShellObserver(this); |
| 1657 helper->AddActivationObserver(this); | 1657 helper->AddActivationObserver(this); |
| 1658 display::Screen::GetScreen()->AddObserver(this); | 1658 display::Screen::GetScreen()->AddObserver(this); |
| 1659 | 1659 |
| 1660 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() | 1660 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() |
| 1661 ? ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET | 1661 ? ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET |
| 1662 : ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 1662 : ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1663 | 1663 |
| 1664 SendDisplayMetrics(); | 1664 SendDisplayMetrics(); |
| 1665 SendActivated(helper->GetActiveWindow(), nullptr); | 1665 SendActivated(helper->GetActiveWindow(), nullptr); |
| 1666 } | 1666 } |
| 1667 ~WaylandRemoteShell() override { | 1667 ~WaylandRemoteShell() override { |
| 1668 auto* helper = WMHelper::GetInstance(); | 1668 auto* helper = WMHelper::GetInstance(); |
| 1669 helper->RemoveMaximizeModeObserver(this); | 1669 helper->RemoveShellObserver(this); |
| 1670 helper->RemoveActivationObserver(this); | 1670 helper->RemoveActivationObserver(this); |
| 1671 display::Screen::GetScreen()->RemoveObserver(this); | 1671 display::Screen::GetScreen()->RemoveObserver(this); |
| 1672 } | 1672 } |
| 1673 | 1673 |
| 1674 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 1674 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
| 1675 int container) { | 1675 int container) { |
| 1676 return display_->CreateRemoteShellSurface( | 1676 return display_->CreateRemoteShellSurface( |
| 1677 surface, container, | 1677 surface, container, |
| 1678 [this](gfx::Rect* bounds) { | 1678 [this](gfx::Rect* bounds) { |
| 1679 *bounds += virtual_origin_.OffsetFromOrigin(); | 1679 *bounds += virtual_origin_.OffsetFromOrigin(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1709 // No need to update when a primary display has changed without bounds | 1709 // No need to update when a primary display has changed without bounds |
| 1710 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged | 1710 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged |
| 1711 // for more details. | 1711 // for more details. |
| 1712 if (changed_metrics & | 1712 if (changed_metrics & |
| 1713 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | | 1713 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | |
| 1714 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { | 1714 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { |
| 1715 ScheduleSendDisplayMetrics(); | 1715 ScheduleSendDisplayMetrics(); |
| 1716 } | 1716 } |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 // Overridden from WMHelper::MaximizeModeObserver: | 1719 // Overridden from WMHelper::ShellObserver: |
| 1720 void OnMaximizeModeStarted() override { | 1720 void OnMaximizeModeStarted() override { |
| 1721 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; | 1721 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; |
| 1722 ScheduleSendDisplayMetrics(kConfigureDelayAfterLayoutSwitchMs); | 1722 ScheduleSendDisplayMetrics(kConfigureDelayAfterLayoutSwitchMs); |
| 1723 } | 1723 } |
| 1724 void OnMaximizeModeEnded() override { | 1724 void OnMaximizeModeEnded() override { |
| 1725 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | 1725 layout_mode_ = ZCR_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; |
| 1726 ScheduleSendDisplayMetrics(kConfigureDelayAfterLayoutSwitchMs); | 1726 ScheduleSendDisplayMetrics(kConfigureDelayAfterLayoutSwitchMs); |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 // Overridden from WMHelper::ActivationObserver: | 1729 // Overridden from WMHelper::ActivationObserver: |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 DCHECK(event_loop); | 3391 DCHECK(event_loop); |
| 3392 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3392 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3393 } | 3393 } |
| 3394 | 3394 |
| 3395 void Server::Flush() { | 3395 void Server::Flush() { |
| 3396 wl_display_flush_clients(wl_display_.get()); | 3396 wl_display_flush_clients(wl_display_.get()); |
| 3397 } | 3397 } |
| 3398 | 3398 |
| 3399 } // namespace wayland | 3399 } // namespace wayland |
| 3400 } // namespace exo | 3400 } // namespace exo |
| OLD | NEW |