| 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 <grp.h> | 7 #include <grp.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 remote_surface_maximize, | 1547 remote_surface_maximize, |
| 1548 remote_surface_minimize, | 1548 remote_surface_minimize, |
| 1549 remote_surface_restore, | 1549 remote_surface_restore, |
| 1550 remote_surface_fullscreen, | 1550 remote_surface_fullscreen, |
| 1551 remote_surface_unfullscreen, | 1551 remote_surface_unfullscreen, |
| 1552 remote_surface_pin, | 1552 remote_surface_pin, |
| 1553 remote_surface_unpin, | 1553 remote_surface_unpin, |
| 1554 remote_surface_set_system_modal, | 1554 remote_surface_set_system_modal, |
| 1555 remote_surface_unset_system_modal}; | 1555 remote_surface_unset_system_modal}; |
| 1556 | 1556 |
| 1557 void remote_surface_destroy_DEPRECATED(wl_client* client, | |
| 1558 wl_resource* resource) { | |
| 1559 wl_resource_destroy(resource); | |
| 1560 } | |
| 1561 | |
| 1562 void remote_surface_set_app_id_DEPRECATED(wl_client* client, | |
| 1563 wl_resource* resource, | |
| 1564 const char* app_id) { | |
| 1565 GetUserDataAs<ShellSurface>(resource)->SetApplicationId(app_id); | |
| 1566 } | |
| 1567 | |
| 1568 void remote_surface_set_window_geometry_DEPRECATED(wl_client* client, | |
| 1569 wl_resource* resource, | |
| 1570 int32_t x, | |
| 1571 int32_t y, | |
| 1572 int32_t width, | |
| 1573 int32_t height) { | |
| 1574 GetUserDataAs<ShellSurface>(resource)->SetGeometry( | |
| 1575 gfx::Rect(x, y, width, height)); | |
| 1576 } | |
| 1577 | |
| 1578 void remote_surface_set_scale_DEPRECATED(wl_client* client, | |
| 1579 wl_resource* resource, | |
| 1580 wl_fixed_t scale) { | |
| 1581 GetUserDataAs<ShellSurface>(resource)->SetScale(wl_fixed_to_double(scale)); | |
| 1582 } | |
| 1583 | |
| 1584 void remote_surface_fullscreen_DEPRECATED(wl_client* client, | |
| 1585 wl_resource* resource) { | |
| 1586 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); | |
| 1587 } | |
| 1588 | |
| 1589 void remote_surface_maximize_DEPRECATED(wl_client* client, | |
| 1590 wl_resource* resource) { | |
| 1591 GetUserDataAs<ShellSurface>(resource)->Maximize(); | |
| 1592 } | |
| 1593 | |
| 1594 void remote_surface_minimize_DEPRECATED(wl_client* client, | |
| 1595 wl_resource* resource) { | |
| 1596 GetUserDataAs<ShellSurface>(resource)->Minimize(); | |
| 1597 } | |
| 1598 | |
| 1599 void remote_surface_restore_DEPRECATED(wl_client* client, | |
| 1600 wl_resource* resource) { | |
| 1601 GetUserDataAs<ShellSurface>(resource)->Restore(); | |
| 1602 } | |
| 1603 | |
| 1604 void remote_surface_pin_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 1605 GetUserDataAs<ShellSurface>(resource)->SetPinned(true, /* trusted */ false); | |
| 1606 } | |
| 1607 | |
| 1608 void remote_surface_unpin_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 1609 GetUserDataAs<ShellSurface>(resource)->SetPinned(false, /* trusted */ false); | |
| 1610 } | |
| 1611 | |
| 1612 void remote_surface_unfullscreen_DEPRECATED(wl_client* client, | |
| 1613 wl_resource* resource) { | |
| 1614 GetUserDataAs<ShellSurface>(resource)->SetFullscreen(false); | |
| 1615 } | |
| 1616 | |
| 1617 void remote_surface_set_rectangular_shadow_DEPRECATED(wl_client* client, | |
| 1618 wl_resource* resource, | |
| 1619 int32_t x, | |
| 1620 int32_t y, | |
| 1621 int32_t width, | |
| 1622 int32_t height) { | |
| 1623 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadow( | |
| 1624 gfx::Rect(x, y, width, height)); | |
| 1625 } | |
| 1626 | |
| 1627 void remote_surface_set_title_DEPRECATED(wl_client* client, | |
| 1628 wl_resource* resource, | |
| 1629 const char* title) { | |
| 1630 GetUserDataAs<ShellSurface>(resource)->SetTitle( | |
| 1631 base::string16(base::UTF8ToUTF16(title))); | |
| 1632 } | |
| 1633 | |
| 1634 void remote_surface_set_top_inset_DEPRECATED(wl_client* client, | |
| 1635 wl_resource* resource, | |
| 1636 int32_t height) { | |
| 1637 GetUserDataAs<ShellSurface>(resource)->SetTopInset(height); | |
| 1638 } | |
| 1639 | |
| 1640 void remote_surface_set_system_modal_DEPRECATED(wl_client* client, | |
| 1641 wl_resource* resource) { | |
| 1642 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(true); | |
| 1643 } | |
| 1644 | |
| 1645 void remote_surface_unset_system_modal_DEPRECATED(wl_client* client, | |
| 1646 wl_resource* resource) { | |
| 1647 GetUserDataAs<ShellSurface>(resource)->SetSystemModal(false); | |
| 1648 } | |
| 1649 | |
| 1650 void remote_surface_set_rectangular_shadow_background_opacity_DEPRECATED( | |
| 1651 wl_client* client, | |
| 1652 wl_resource* resource, | |
| 1653 wl_fixed_t opacity) { | |
| 1654 GetUserDataAs<ShellSurface>(resource)->SetRectangularShadowBackgroundOpacity( | |
| 1655 wl_fixed_to_double(opacity)); | |
| 1656 } | |
| 1657 | |
| 1658 void remote_surface_activate_DEPRECATED(wl_client* client, | |
| 1659 wl_resource* resource, | |
| 1660 uint32_t serial) { | |
| 1661 GetUserDataAs<ShellSurface>(resource)->Activate(); | |
| 1662 } | |
| 1663 | |
| 1664 void remote_surface_pin_with_trusted_flag_DEPRECATED(wl_client* client, | |
| 1665 wl_resource* resource, | |
| 1666 int32_t trusted) { | |
| 1667 GetUserDataAs<ShellSurface>(resource)->SetPinned(true, trusted); | |
| 1668 } | |
| 1669 | |
| 1670 const struct zwp_remote_surface_v1_interface | |
| 1671 remote_surface_implementation_DEPRECATED = { | |
| 1672 remote_surface_destroy_DEPRECATED, | |
| 1673 remote_surface_set_app_id_DEPRECATED, | |
| 1674 remote_surface_set_window_geometry_DEPRECATED, | |
| 1675 remote_surface_set_scale_DEPRECATED, | |
| 1676 remote_surface_fullscreen_DEPRECATED, | |
| 1677 remote_surface_maximize_DEPRECATED, | |
| 1678 remote_surface_minimize_DEPRECATED, | |
| 1679 remote_surface_restore_DEPRECATED, | |
| 1680 remote_surface_pin_DEPRECATED, | |
| 1681 remote_surface_unpin_DEPRECATED, | |
| 1682 remote_surface_unfullscreen_DEPRECATED, | |
| 1683 remote_surface_set_rectangular_shadow_DEPRECATED, | |
| 1684 remote_surface_set_title_DEPRECATED, | |
| 1685 remote_surface_set_top_inset_DEPRECATED, | |
| 1686 remote_surface_set_system_modal_DEPRECATED, | |
| 1687 remote_surface_unset_system_modal_DEPRECATED, | |
| 1688 remote_surface_set_rectangular_shadow_background_opacity_DEPRECATED, | |
| 1689 remote_surface_activate_DEPRECATED, | |
| 1690 remote_surface_pin_with_trusted_flag_DEPRECATED}; | |
| 1691 | |
| 1692 //////////////////////////////////////////////////////////////////////////////// | 1557 //////////////////////////////////////////////////////////////////////////////// |
| 1693 // notification_surface_interface: | 1558 // notification_surface_interface: |
| 1694 | 1559 |
| 1695 void notification_surface_destroy(wl_client* client, wl_resource* resource) { | 1560 void notification_surface_destroy(wl_client* client, wl_resource* resource) { |
| 1696 wl_resource_destroy(resource); | 1561 wl_resource_destroy(resource); |
| 1697 } | 1562 } |
| 1698 | 1563 |
| 1699 const struct zcr_notification_surface_v1_interface | 1564 const struct zcr_notification_surface_v1_interface |
| 1700 notification_surface_implementation = {notification_surface_destroy}; | 1565 notification_surface_implementation = {notification_surface_destroy}; |
| 1701 | 1566 |
| 1702 void notification_surface_destroy_DEPRECATED(wl_client* client, | |
| 1703 wl_resource* resource) { | |
| 1704 wl_resource_destroy(resource); | |
| 1705 } | |
| 1706 | |
| 1707 const struct zwp_notification_surface_v1_interface | |
| 1708 notification_surface_implementation_DEPRECATED = { | |
| 1709 notification_surface_destroy_DEPRECATED}; | |
| 1710 | |
| 1711 //////////////////////////////////////////////////////////////////////////////// | 1567 //////////////////////////////////////////////////////////////////////////////// |
| 1712 // remote_shell_interface: | 1568 // remote_shell_interface: |
| 1713 | 1569 |
| 1714 // Implements remote shell interface and monitors workspace state needed | 1570 // Implements remote shell interface and monitors workspace state needed |
| 1715 // for the remote shell interface. | 1571 // for the remote shell interface. |
| 1716 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, | 1572 class WaylandRemoteShell : public WMHelper::MaximizeModeObserver, |
| 1717 public WMHelper::ActivationObserver, | 1573 public WMHelper::ActivationObserver, |
| 1718 public display::DisplayObserver { | 1574 public display::DisplayObserver { |
| 1719 public: | 1575 public: |
| 1720 WaylandRemoteShell(Display* display, wl_resource* remote_shell_resource) | 1576 WaylandRemoteShell(Display* display, wl_resource* remote_shell_resource) |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 case ash::wm::WINDOW_STATE_TYPE_MAXIMIZED: | 1760 case ash::wm::WINDOW_STATE_TYPE_MAXIMIZED: |
| 1905 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_MAXIMIZED; | 1761 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_MAXIMIZED; |
| 1906 break; | 1762 break; |
| 1907 case ash::wm::WINDOW_STATE_TYPE_FULLSCREEN: | 1763 case ash::wm::WINDOW_STATE_TYPE_FULLSCREEN: |
| 1908 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_FULLSCREEN; | 1764 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_FULLSCREEN; |
| 1909 break; | 1765 break; |
| 1910 case ash::wm::WINDOW_STATE_TYPE_PINNED: | 1766 case ash::wm::WINDOW_STATE_TYPE_PINNED: |
| 1911 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_PINNED; | 1767 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_PINNED; |
| 1912 break; | 1768 break; |
| 1913 case ash::wm::WINDOW_STATE_TYPE_TRUSTED_PINNED: | 1769 case ash::wm::WINDOW_STATE_TYPE_TRUSTED_PINNED: |
| 1914 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED; | 1770 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED; |
| 1915 break; | 1771 break; |
| 1916 default: | 1772 default: |
| 1917 break; | 1773 break; |
| 1918 } | 1774 } |
| 1919 | 1775 |
| 1920 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); | 1776 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); |
| 1921 wl_client_flush(wl_resource_get_client(resource)); | 1777 wl_client_flush(wl_resource_get_client(resource)); |
| 1922 } | 1778 } |
| 1923 | 1779 |
| 1924 void remote_shell_get_remote_surface(wl_client* client, | 1780 void remote_shell_get_remote_surface(wl_client* client, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1991 uint32_t id) { | 1847 uint32_t id) { |
| 1992 wl_resource* resource = | 1848 wl_resource* resource = |
| 1993 wl_resource_create(client, &zcr_remote_shell_v1_interface, | 1849 wl_resource_create(client, &zcr_remote_shell_v1_interface, |
| 1994 std::min(version, remote_shell_version), id); | 1850 std::min(version, remote_shell_version), id); |
| 1995 | 1851 |
| 1996 SetImplementation(resource, &remote_shell_implementation, | 1852 SetImplementation(resource, &remote_shell_implementation, |
| 1997 base::MakeUnique<WaylandRemoteShell>( | 1853 base::MakeUnique<WaylandRemoteShell>( |
| 1998 static_cast<Display*>(data), resource)); | 1854 static_cast<Display*>(data), resource)); |
| 1999 } | 1855 } |
| 2000 | 1856 |
| 2001 // Implements remote shell interface and monitors workspace state needed | |
| 2002 // for the remote shell interface. | |
| 2003 class WaylandRemoteShell_DEPRECATED : public WMHelper::MaximizeModeObserver, | |
| 2004 public WMHelper::ActivationObserver, | |
| 2005 public display::DisplayObserver { | |
| 2006 public: | |
| 2007 WaylandRemoteShell_DEPRECATED(Display* display, | |
| 2008 wl_resource* remote_shell_resource) | |
| 2009 : display_(display), | |
| 2010 remote_shell_resource_(remote_shell_resource), | |
| 2011 weak_ptr_factory_(this) { | |
| 2012 auto* helper = WMHelper::GetInstance(); | |
| 2013 helper->AddMaximizeModeObserver(this); | |
| 2014 helper->AddActivationObserver(this); | |
| 2015 display::Screen::GetScreen()->AddObserver(this); | |
| 2016 | |
| 2017 layout_mode_ = helper->IsMaximizeModeWindowManagerEnabled() | |
| 2018 ? ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET | |
| 2019 : ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | |
| 2020 | |
| 2021 SendPrimaryDisplayMetrics(); | |
| 2022 SendActivated(helper->GetActiveWindow(), nullptr); | |
| 2023 } | |
| 2024 ~WaylandRemoteShell_DEPRECATED() override { | |
| 2025 auto* helper = WMHelper::GetInstance(); | |
| 2026 helper->RemoveMaximizeModeObserver(this); | |
| 2027 helper->RemoveActivationObserver(this); | |
| 2028 display::Screen::GetScreen()->RemoveObserver(this); | |
| 2029 } | |
| 2030 | |
| 2031 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | |
| 2032 int container) { | |
| 2033 return display_->CreateRemoteShellSurface(surface, container); | |
| 2034 } | |
| 2035 | |
| 2036 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | |
| 2037 Surface* surface, | |
| 2038 const std::string& notification_id) { | |
| 2039 return display_->CreateNotificationSurface(surface, notification_id); | |
| 2040 } | |
| 2041 | |
| 2042 // Overridden from display::DisplayObserver: | |
| 2043 void OnDisplayAdded(const display::Display& new_display) override {} | |
| 2044 void OnDisplayRemoved(const display::Display& new_display) override {} | |
| 2045 void OnDisplayMetricsChanged(const display::Display& display, | |
| 2046 uint32_t changed_metrics) override { | |
| 2047 if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id()) | |
| 2048 return; | |
| 2049 | |
| 2050 // No need to update when a primary dislpay has changed without bounds | |
| 2051 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged | |
| 2052 // for more details. | |
| 2053 if (changed_metrics & | |
| 2054 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | | |
| 2055 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { | |
| 2056 SendDisplayMetrics(display); | |
| 2057 } | |
| 2058 SendConfigure_DEPRECATED(display); | |
| 2059 } | |
| 2060 | |
| 2061 // Overridden from WMHelper::MaximizeModeObserver: | |
| 2062 void OnMaximizeModeStarted() override { | |
| 2063 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_TABLET; | |
| 2064 SendLayoutModeChange_DEPRECATED(); | |
| 2065 | |
| 2066 send_configure_after_layout_change_ = true; | |
| 2067 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 2068 FROM_HERE, | |
| 2069 base::Bind(&WaylandRemoteShell_DEPRECATED::MaybeSendConfigure, | |
| 2070 weak_ptr_factory_.GetWeakPtr()), | |
| 2071 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | |
| 2072 } | |
| 2073 void OnMaximizeModeEnded() override { | |
| 2074 layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | |
| 2075 SendLayoutModeChange_DEPRECATED(); | |
| 2076 send_configure_after_layout_change_ = true; | |
| 2077 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | |
| 2078 FROM_HERE, | |
| 2079 base::Bind(&WaylandRemoteShell_DEPRECATED::MaybeSendConfigure, | |
| 2080 weak_ptr_factory_.GetWeakPtr()), | |
| 2081 base::TimeDelta::FromMilliseconds(kConfigureDelayAfterLayoutSwitchMs)); | |
| 2082 } | |
| 2083 | |
| 2084 // Overridden from WMHelper::ActivationObserver: | |
| 2085 void OnWindowActivated( | |
| 2086 aura::Window* gained_active, | |
| 2087 aura::Window* lost_active) override { | |
| 2088 SendActivated(gained_active, lost_active); | |
| 2089 } | |
| 2090 | |
| 2091 private: | |
| 2092 void SendPrimaryDisplayMetrics() { | |
| 2093 const display::Display primary = | |
| 2094 display::Screen::GetScreen()->GetPrimaryDisplay(); | |
| 2095 | |
| 2096 SendConfigure_DEPRECATED(primary); | |
| 2097 SendDisplayMetrics(primary); | |
| 2098 } | |
| 2099 | |
| 2100 void MaybeSendConfigure() { | |
| 2101 if (send_configure_after_layout_change_) | |
| 2102 SendPrimaryDisplayMetrics(); | |
| 2103 } | |
| 2104 | |
| 2105 void SendDisplayMetrics(const display::Display& display) { | |
| 2106 send_configure_after_layout_change_ = false; | |
| 2107 | |
| 2108 if (wl_resource_get_version(remote_shell_resource_) < 9) | |
| 2109 return; | |
| 2110 | |
| 2111 const gfx::Insets& work_area_insets = display.GetWorkAreaInsets(); | |
| 2112 | |
| 2113 zwp_remote_shell_v1_send_configuration_changed( | |
| 2114 remote_shell_resource_, display.size().width(), display.size().height(), | |
| 2115 OutputTransform(display.rotation()), | |
| 2116 wl_fixed_from_double(display.device_scale_factor()), | |
| 2117 work_area_insets.left(), work_area_insets.top(), | |
| 2118 work_area_insets.right(), work_area_insets.bottom(), layout_mode_); | |
| 2119 | |
| 2120 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | |
| 2121 } | |
| 2122 | |
| 2123 void SendConfigure_DEPRECATED(const display::Display& display) { | |
| 2124 send_configure_after_layout_change_ = false; | |
| 2125 | |
| 2126 if (wl_resource_get_version(remote_shell_resource_) >= 9) | |
| 2127 return; | |
| 2128 | |
| 2129 const gfx::Insets& work_area_insets = display.GetWorkAreaInsets(); | |
| 2130 zwp_remote_shell_v1_send_configure( | |
| 2131 remote_shell_resource_, display.size().width(), display.size().height(), | |
| 2132 work_area_insets.left(), work_area_insets.top(), | |
| 2133 work_area_insets.right(), work_area_insets.bottom()); | |
| 2134 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | |
| 2135 } | |
| 2136 | |
| 2137 void SendLayoutModeChange_DEPRECATED() { | |
| 2138 if (wl_resource_get_version(remote_shell_resource_) < 8) | |
| 2139 return; | |
| 2140 zwp_remote_shell_v1_send_layout_mode_changed(remote_shell_resource_, | |
| 2141 layout_mode_); | |
| 2142 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); | |
| 2143 } | |
| 2144 | |
| 2145 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { | |
| 2146 Surface* gained_active_surface = | |
| 2147 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; | |
| 2148 Surface* lost_active_surface = | |
| 2149 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; | |
| 2150 wl_resource* gained_active_surface_resource = | |
| 2151 gained_active_surface ? GetSurfaceResource(gained_active_surface) | |
| 2152 : nullptr; | |
| 2153 wl_resource* lost_active_surface_resource = | |
| 2154 lost_active_surface ? GetSurfaceResource(lost_active_surface) : nullptr; | |
| 2155 | |
| 2156 wl_client* client = wl_resource_get_client(remote_shell_resource_); | |
| 2157 | |
| 2158 // If surface that gained active is not owned by remote shell client then | |
| 2159 // set it to null. | |
| 2160 if (gained_active_surface_resource && | |
| 2161 wl_resource_get_client(gained_active_surface_resource) != client) { | |
| 2162 gained_active_surface_resource = nullptr; | |
| 2163 } | |
| 2164 | |
| 2165 // If surface that lost active is not owned by remote shell client then | |
| 2166 // set it to null. | |
| 2167 if (lost_active_surface_resource && | |
| 2168 wl_resource_get_client(lost_active_surface_resource) != client) { | |
| 2169 lost_active_surface_resource = nullptr; | |
| 2170 } | |
| 2171 | |
| 2172 zwp_remote_shell_v1_send_activated(remote_shell_resource_, | |
| 2173 gained_active_surface_resource, | |
| 2174 lost_active_surface_resource); | |
| 2175 wl_client_flush(client); | |
| 2176 } | |
| 2177 | |
| 2178 // The exo display instance. Not owned. | |
| 2179 Display* const display_; | |
| 2180 | |
| 2181 // The remote shell resource associated with observer. | |
| 2182 wl_resource* const remote_shell_resource_; | |
| 2183 | |
| 2184 bool send_configure_after_layout_change_ = false; | |
| 2185 | |
| 2186 int layout_mode_ = ZWP_REMOTE_SHELL_V1_LAYOUT_MODE_WINDOWED; | |
| 2187 | |
| 2188 base::WeakPtrFactory<WaylandRemoteShell_DEPRECATED> weak_ptr_factory_; | |
| 2189 | |
| 2190 DISALLOW_COPY_AND_ASSIGN(WaylandRemoteShell_DEPRECATED); | |
| 2191 }; | |
| 2192 | |
| 2193 void remote_shell_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 2194 // Nothing to do here. | |
| 2195 } | |
| 2196 | |
| 2197 int RemoteSurfaceContainer_DEPRECATED(uint32_t container) { | |
| 2198 switch (container) { | |
| 2199 case ZWP_REMOTE_SHELL_V1_CONTAINER_DEFAULT: | |
| 2200 return ash::kShellWindowId_DefaultContainer; | |
| 2201 case ZWP_REMOTE_SHELL_V1_CONTAINER_OVERLAY: | |
| 2202 return ash::kShellWindowId_SystemModalContainer; | |
| 2203 default: | |
| 2204 DLOG(WARNING) << "Unsupported container: " << container; | |
| 2205 return ash::kShellWindowId_DefaultContainer; | |
| 2206 } | |
| 2207 } | |
| 2208 | |
| 2209 void HandleRemoteSurfaceCloseCallback_DEPRECATED(wl_resource* resource) { | |
| 2210 zwp_remote_surface_v1_send_close(resource); | |
| 2211 wl_client_flush(wl_resource_get_client(resource)); | |
| 2212 } | |
| 2213 | |
| 2214 void HandleRemoteSurfaceStateChangedCallback_DEPRECATED( | |
| 2215 wl_resource* resource, | |
| 2216 ash::wm::WindowStateType old_state_type, | |
| 2217 ash::wm::WindowStateType new_state_type) { | |
| 2218 DCHECK_NE(old_state_type, new_state_type); | |
| 2219 | |
| 2220 switch (old_state_type) { | |
| 2221 case ash::wm::WINDOW_STATE_TYPE_MINIMIZED: | |
| 2222 if (wl_resource_get_version(resource) >= 2) | |
| 2223 zwp_remote_surface_v1_send_unset_minimized(resource); | |
| 2224 break; | |
| 2225 case ash::wm::WINDOW_STATE_TYPE_MAXIMIZED: | |
| 2226 if (wl_resource_get_version(resource) >= 2) | |
| 2227 zwp_remote_surface_v1_send_unset_maximized(resource); | |
| 2228 break; | |
| 2229 case ash::wm::WINDOW_STATE_TYPE_FULLSCREEN: | |
| 2230 zwp_remote_surface_v1_send_unset_fullscreen(resource); | |
| 2231 break; | |
| 2232 case ash::wm::WINDOW_STATE_TYPE_PINNED: | |
| 2233 case ash::wm::WINDOW_STATE_TYPE_TRUSTED_PINNED: | |
| 2234 if (wl_resource_get_version(resource) >= 3) | |
| 2235 zwp_remote_surface_v1_send_unset_pinned(resource); | |
| 2236 break; | |
| 2237 default: | |
| 2238 break; | |
| 2239 } | |
| 2240 | |
| 2241 uint32_t state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_NORMAL; | |
| 2242 switch (new_state_type) { | |
| 2243 case ash::wm::WINDOW_STATE_TYPE_MINIMIZED: | |
| 2244 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_MINIMIZED; | |
| 2245 if (wl_resource_get_version(resource) >= 2) | |
| 2246 zwp_remote_surface_v1_send_set_minimized(resource); | |
| 2247 break; | |
| 2248 case ash::wm::WINDOW_STATE_TYPE_MAXIMIZED: | |
| 2249 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_MAXIMIZED; | |
| 2250 if (wl_resource_get_version(resource) >= 2) | |
| 2251 zwp_remote_surface_v1_send_set_maximized(resource); | |
| 2252 break; | |
| 2253 case ash::wm::WINDOW_STATE_TYPE_FULLSCREEN: | |
| 2254 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_FULLSCREEN; | |
| 2255 zwp_remote_surface_v1_send_set_fullscreen(resource); | |
| 2256 break; | |
| 2257 case ash::wm::WINDOW_STATE_TYPE_PINNED: | |
| 2258 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_PINNED; | |
| 2259 if (wl_resource_get_version(resource) >= 3) | |
| 2260 zwp_remote_surface_v1_send_set_pinned(resource); | |
| 2261 break; | |
| 2262 case ash::wm::WINDOW_STATE_TYPE_TRUSTED_PINNED: | |
| 2263 state_type = ZWP_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED; | |
| 2264 if (wl_resource_get_version(resource) >= 3) | |
| 2265 zwp_remote_surface_v1_send_set_pinned(resource); | |
| 2266 break; | |
| 2267 default: | |
| 2268 break; | |
| 2269 } | |
| 2270 | |
| 2271 if (wl_resource_get_version(resource) >= 7) | |
| 2272 zwp_remote_surface_v1_send_state_type_changed(resource, state_type); | |
| 2273 | |
| 2274 wl_client_flush(wl_resource_get_client(resource)); | |
| 2275 } | |
| 2276 | |
| 2277 void remote_shell_get_remote_surface_DEPRECATED(wl_client* client, | |
| 2278 wl_resource* resource, | |
| 2279 uint32_t id, | |
| 2280 wl_resource* surface, | |
| 2281 uint32_t container) { | |
| 2282 std::unique_ptr<ShellSurface> shell_surface = | |
| 2283 GetUserDataAs<WaylandRemoteShell>(resource)->CreateShellSurface( | |
| 2284 GetUserDataAs<Surface>(surface), | |
| 2285 RemoteSurfaceContainer_DEPRECATED(container)); | |
| 2286 if (!shell_surface) { | |
| 2287 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | |
| 2288 "surface has already been assigned a role"); | |
| 2289 return; | |
| 2290 } | |
| 2291 | |
| 2292 wl_resource* remote_surface_resource = | |
| 2293 wl_resource_create(client, &zwp_remote_surface_v1_interface, | |
| 2294 wl_resource_get_version(resource), id); | |
| 2295 | |
| 2296 shell_surface->set_close_callback( | |
| 2297 base::Bind(&HandleRemoteSurfaceCloseCallback_DEPRECATED, | |
| 2298 base::Unretained(remote_surface_resource))); | |
| 2299 shell_surface->set_state_changed_callback( | |
| 2300 base::Bind(&HandleRemoteSurfaceStateChangedCallback_DEPRECATED, | |
| 2301 base::Unretained(remote_surface_resource))); | |
| 2302 | |
| 2303 SetImplementation(remote_surface_resource, | |
| 2304 &remote_surface_implementation_DEPRECATED, | |
| 2305 std::move(shell_surface)); | |
| 2306 } | |
| 2307 | |
| 2308 void remote_shell_get_notification_surface_DEPRECATED( | |
| 2309 wl_client* client, | |
| 2310 wl_resource* resource, | |
| 2311 uint32_t id, | |
| 2312 wl_resource* surface, | |
| 2313 const char* notification_id) { | |
| 2314 if (GetUserDataAs<Surface>(surface)->HasSurfaceDelegate()) { | |
| 2315 wl_resource_post_error(resource, ZWP_REMOTE_SHELL_V1_ERROR_ROLE, | |
| 2316 "surface has already been assigned a role"); | |
| 2317 return; | |
| 2318 } | |
| 2319 | |
| 2320 std::unique_ptr<NotificationSurface> notification_surface = | |
| 2321 GetUserDataAs<WaylandRemoteShell>(resource)->CreateNotificationSurface( | |
| 2322 GetUserDataAs<Surface>(surface), std::string(notification_id)); | |
| 2323 if (!notification_surface) { | |
| 2324 wl_resource_post_error(resource, | |
| 2325 ZWP_REMOTE_SHELL_V1_ERROR_INVALID_NOTIFICATION_ID, | |
| 2326 "invalid notification id"); | |
| 2327 return; | |
| 2328 } | |
| 2329 | |
| 2330 wl_resource* notification_surface_resource = | |
| 2331 wl_resource_create(client, &zwp_notification_surface_v1_interface, | |
| 2332 wl_resource_get_version(resource), id); | |
| 2333 SetImplementation(notification_surface_resource, | |
| 2334 ¬ification_surface_implementation_DEPRECATED, | |
| 2335 std::move(notification_surface)); | |
| 2336 } | |
| 2337 | |
| 2338 const struct zwp_remote_shell_v1_interface | |
| 2339 remote_shell_implementation_DEPRECATED = { | |
| 2340 remote_shell_destroy_DEPRECATED, | |
| 2341 remote_shell_get_remote_surface_DEPRECATED, | |
| 2342 remote_shell_get_notification_surface_DEPRECATED}; | |
| 2343 | |
| 2344 const uint32_t remote_shell_version_DEPRECATED = 11; | |
| 2345 | |
| 2346 void bind_remote_shell_DEPRECATED(wl_client* client, | |
| 2347 void* data, | |
| 2348 uint32_t version, | |
| 2349 uint32_t id) { | |
| 2350 wl_resource* resource = wl_resource_create( | |
| 2351 client, &zwp_remote_shell_v1_interface, | |
| 2352 std::min(version, remote_shell_version_DEPRECATED), id); | |
| 2353 | |
| 2354 SetImplementation(resource, &remote_shell_implementation_DEPRECATED, | |
| 2355 base::MakeUnique<WaylandRemoteShell_DEPRECATED>( | |
| 2356 static_cast<Display*>(data), resource)); | |
| 2357 } | |
| 2358 | |
| 2359 //////////////////////////////////////////////////////////////////////////////// | 1857 //////////////////////////////////////////////////////////////////////////////// |
| 2360 // vsync_timing_interface: | 1858 // vsync_timing_interface: |
| 2361 | 1859 |
| 2362 // Implements VSync timing interface by monitoring a compositor for updates | 1860 // Implements VSync timing interface by monitoring a compositor for updates |
| 2363 // to VSync parameters. | 1861 // to VSync parameters. |
| 2364 class VSyncTiming : public ui::CompositorVSyncManager::Observer { | 1862 class VSyncTiming : public ui::CompositorVSyncManager::Observer { |
| 2365 public: | 1863 public: |
| 2366 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } | 1864 ~VSyncTiming() { vsync_manager_->RemoveObserver(this); } |
| 2367 | 1865 |
| 2368 static std::unique_ptr<VSyncTiming> Create(ui::Compositor* compositor, | 1866 static std::unique_ptr<VSyncTiming> Create(ui::Compositor* compositor, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 DISALLOW_COPY_AND_ASSIGN(VSyncTiming); | 1923 DISALLOW_COPY_AND_ASSIGN(VSyncTiming); |
| 2426 }; | 1924 }; |
| 2427 | 1925 |
| 2428 void vsync_timing_destroy(wl_client* client, wl_resource* resource) { | 1926 void vsync_timing_destroy(wl_client* client, wl_resource* resource) { |
| 2429 wl_resource_destroy(resource); | 1927 wl_resource_destroy(resource); |
| 2430 } | 1928 } |
| 2431 | 1929 |
| 2432 const struct zcr_vsync_timing_v1_interface vsync_timing_implementation = { | 1930 const struct zcr_vsync_timing_v1_interface vsync_timing_implementation = { |
| 2433 vsync_timing_destroy}; | 1931 vsync_timing_destroy}; |
| 2434 | 1932 |
| 2435 // Implements VSync timing interface by monitoring a compositor for updates | |
| 2436 // to VSync parameters. | |
| 2437 class VSyncTiming_DEPRECATED : public ui::CompositorVSyncManager::Observer { | |
| 2438 public: | |
| 2439 ~VSyncTiming_DEPRECATED() { vsync_manager_->RemoveObserver(this); } | |
| 2440 | |
| 2441 static std::unique_ptr<VSyncTiming_DEPRECATED> Create( | |
| 2442 ui::Compositor* compositor, | |
| 2443 wl_resource* timing_resource) { | |
| 2444 std::unique_ptr<VSyncTiming_DEPRECATED> vsync_timing( | |
| 2445 new VSyncTiming_DEPRECATED(compositor, timing_resource)); | |
| 2446 // Note: AddObserver() will call OnUpdateVSyncParameters. | |
| 2447 vsync_timing->vsync_manager_->AddObserver(vsync_timing.get()); | |
| 2448 return vsync_timing; | |
| 2449 } | |
| 2450 | |
| 2451 // Overridden from ui::CompositorVSyncManager::Observer: | |
| 2452 void OnUpdateVSyncParameters(base::TimeTicks timebase, | |
| 2453 base::TimeDelta interval) override { | |
| 2454 uint64_t timebase_us = timebase.ToInternalValue(); | |
| 2455 uint64_t interval_us = interval.ToInternalValue(); | |
| 2456 | |
| 2457 // Ignore updates with interval 0. | |
| 2458 if (!interval_us) | |
| 2459 return; | |
| 2460 | |
| 2461 uint64_t offset_us = timebase_us % interval_us; | |
| 2462 | |
| 2463 // Avoid sending update events if interval did not change. | |
| 2464 if (interval_us == last_interval_us_) { | |
| 2465 int64_t offset_delta_us = | |
| 2466 static_cast<int64_t>(last_offset_us_ - offset_us); | |
| 2467 | |
| 2468 // Reduce the amount of events by only sending an update if the offset | |
| 2469 // changed compared to the last offset sent to the client by this amount. | |
| 2470 const int64_t kOffsetDeltaThresholdInMicroseconds = 25; | |
| 2471 | |
| 2472 if (std::abs(offset_delta_us) < kOffsetDeltaThresholdInMicroseconds) | |
| 2473 return; | |
| 2474 } | |
| 2475 | |
| 2476 zwp_vsync_timing_v1_send_update(timing_resource_, timebase_us & 0xffffffff, | |
| 2477 timebase_us >> 32, interval_us & 0xffffffff, | |
| 2478 interval_us >> 32); | |
| 2479 wl_client_flush(wl_resource_get_client(timing_resource_)); | |
| 2480 | |
| 2481 last_interval_us_ = interval_us; | |
| 2482 last_offset_us_ = offset_us; | |
| 2483 } | |
| 2484 | |
| 2485 private: | |
| 2486 VSyncTiming_DEPRECATED(ui::Compositor* compositor, | |
| 2487 wl_resource* timing_resource) | |
| 2488 : vsync_manager_(compositor->vsync_manager()), | |
| 2489 timing_resource_(timing_resource) {} | |
| 2490 | |
| 2491 // The VSync manager being observed. | |
| 2492 scoped_refptr<ui::CompositorVSyncManager> vsync_manager_; | |
| 2493 | |
| 2494 // The VSync timing resource. | |
| 2495 wl_resource* const timing_resource_; | |
| 2496 | |
| 2497 uint64_t last_interval_us_{0}; | |
| 2498 uint64_t last_offset_us_{0}; | |
| 2499 | |
| 2500 DISALLOW_COPY_AND_ASSIGN(VSyncTiming_DEPRECATED); | |
| 2501 }; | |
| 2502 | |
| 2503 void vsync_timing_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 2504 wl_resource_destroy(resource); | |
| 2505 } | |
| 2506 | |
| 2507 const struct zwp_vsync_timing_v1_interface | |
| 2508 vsync_timing_implementation_DEPRECATED = {vsync_timing_destroy_DEPRECATED}; | |
| 2509 | |
| 2510 //////////////////////////////////////////////////////////////////////////////// | 1933 //////////////////////////////////////////////////////////////////////////////// |
| 2511 // vsync_feedback_interface: | 1934 // vsync_feedback_interface: |
| 2512 | 1935 |
| 2513 void vsync_feedback_destroy(wl_client* client, wl_resource* resource) { | 1936 void vsync_feedback_destroy(wl_client* client, wl_resource* resource) { |
| 2514 wl_resource_destroy(resource); | 1937 wl_resource_destroy(resource); |
| 2515 } | 1938 } |
| 2516 | 1939 |
| 2517 void vsync_feedback_get_vsync_timing(wl_client* client, | 1940 void vsync_feedback_get_vsync_timing(wl_client* client, |
| 2518 wl_resource* resource, | 1941 wl_resource* resource, |
| 2519 uint32_t id, | 1942 uint32_t id, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2536 void* data, | 1959 void* data, |
| 2537 uint32_t version, | 1960 uint32_t version, |
| 2538 uint32_t id) { | 1961 uint32_t id) { |
| 2539 wl_resource* resource = | 1962 wl_resource* resource = |
| 2540 wl_resource_create(client, &zcr_vsync_feedback_v1_interface, 1, id); | 1963 wl_resource_create(client, &zcr_vsync_feedback_v1_interface, 1, id); |
| 2541 | 1964 |
| 2542 wl_resource_set_implementation(resource, &vsync_feedback_implementation, | 1965 wl_resource_set_implementation(resource, &vsync_feedback_implementation, |
| 2543 nullptr, nullptr); | 1966 nullptr, nullptr); |
| 2544 } | 1967 } |
| 2545 | 1968 |
| 2546 void vsync_feedback_destroy_DEPRECATED(wl_client* client, | |
| 2547 wl_resource* resource) { | |
| 2548 wl_resource_destroy(resource); | |
| 2549 } | |
| 2550 | |
| 2551 void vsync_feedback_get_vsync_timing_DEPRECATED(wl_client* client, | |
| 2552 wl_resource* resource, | |
| 2553 uint32_t id, | |
| 2554 wl_resource* output) { | |
| 2555 wl_resource* timing_resource = | |
| 2556 wl_resource_create(client, &zwp_vsync_timing_v1_interface, 1, id); | |
| 2557 | |
| 2558 // TODO(reveman): Multi-display support. | |
| 2559 ui::Compositor* compositor = | |
| 2560 ash::Shell::GetPrimaryRootWindow()->layer()->GetCompositor(); | |
| 2561 | |
| 2562 SetImplementation( | |
| 2563 timing_resource, &vsync_timing_implementation_DEPRECATED, | |
| 2564 VSyncTiming_DEPRECATED::Create(compositor, timing_resource)); | |
| 2565 } | |
| 2566 | |
| 2567 const struct zwp_vsync_feedback_v1_interface | |
| 2568 vsync_feedback_implementation_DEPRECATED = { | |
| 2569 vsync_feedback_destroy_DEPRECATED, | |
| 2570 vsync_feedback_get_vsync_timing_DEPRECATED}; | |
| 2571 | |
| 2572 void bind_vsync_feedback_DEPRECATED(wl_client* client, | |
| 2573 void* data, | |
| 2574 uint32_t version, | |
| 2575 uint32_t id) { | |
| 2576 wl_resource* resource = | |
| 2577 wl_resource_create(client, &zwp_vsync_feedback_v1_interface, 1, id); | |
| 2578 | |
| 2579 wl_resource_set_implementation( | |
| 2580 resource, &vsync_feedback_implementation_DEPRECATED, nullptr, nullptr); | |
| 2581 } | |
| 2582 | |
| 2583 //////////////////////////////////////////////////////////////////////////////// | 1969 //////////////////////////////////////////////////////////////////////////////// |
| 2584 // wl_data_device_interface: | 1970 // wl_data_device_interface: |
| 2585 | 1971 |
| 2586 void data_device_start_drag(wl_client* client, | 1972 void data_device_start_drag(wl_client* client, |
| 2587 wl_resource* resource, | 1973 wl_resource* resource, |
| 2588 wl_resource* source_resource, | 1974 wl_resource* source_resource, |
| 2589 wl_resource* origin_resource, | 1975 wl_resource* origin_resource, |
| 2590 wl_resource* icon_resource, | 1976 wl_resource* icon_resource, |
| 2591 uint32_t serial) { | 1977 uint32_t serial) { |
| 2592 NOTIMPLEMENTED(); | 1978 NOTIMPLEMENTED(); |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3248 } | 2634 } |
| 3249 | 2635 |
| 3250 void security_only_visible_on_secure_output(wl_client* client, | 2636 void security_only_visible_on_secure_output(wl_client* client, |
| 3251 wl_resource* resource) { | 2637 wl_resource* resource) { |
| 3252 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); | 2638 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); |
| 3253 } | 2639 } |
| 3254 | 2640 |
| 3255 const struct zcr_security_v1_interface security_implementation = { | 2641 const struct zcr_security_v1_interface security_implementation = { |
| 3256 security_destroy, security_only_visible_on_secure_output}; | 2642 security_destroy, security_only_visible_on_secure_output}; |
| 3257 | 2643 |
| 3258 void security_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 3259 wl_resource_destroy(resource); | |
| 3260 } | |
| 3261 | |
| 3262 void security_only_visible_on_secure_output_DEPRECATED(wl_client* client, | |
| 3263 wl_resource* resource) { | |
| 3264 GetUserDataAs<Security>(resource)->OnlyVisibleOnSecureOutput(); | |
| 3265 } | |
| 3266 | |
| 3267 const struct zwp_security_v1_interface security_implementation_DEPRECATED = { | |
| 3268 security_destroy_DEPRECATED, | |
| 3269 security_only_visible_on_secure_output_DEPRECATED}; | |
| 3270 | |
| 3271 //////////////////////////////////////////////////////////////////////////////// | 2644 //////////////////////////////////////////////////////////////////////////////// |
| 3272 // secure_output_interface: | 2645 // secure_output_interface: |
| 3273 | 2646 |
| 3274 void secure_output_destroy(wl_client* client, wl_resource* resource) { | 2647 void secure_output_destroy(wl_client* client, wl_resource* resource) { |
| 3275 wl_resource_destroy(resource); | 2648 wl_resource_destroy(resource); |
| 3276 } | 2649 } |
| 3277 | 2650 |
| 3278 void secure_output_get_security(wl_client* client, | 2651 void secure_output_get_security(wl_client* client, |
| 3279 wl_resource* resource, | 2652 wl_resource* resource, |
| 3280 uint32_t id, | 2653 uint32_t id, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3300 void* data, | 2673 void* data, |
| 3301 uint32_t version, | 2674 uint32_t version, |
| 3302 uint32_t id) { | 2675 uint32_t id) { |
| 3303 wl_resource* resource = | 2676 wl_resource* resource = |
| 3304 wl_resource_create(client, &zcr_secure_output_v1_interface, 1, id); | 2677 wl_resource_create(client, &zcr_secure_output_v1_interface, 1, id); |
| 3305 | 2678 |
| 3306 wl_resource_set_implementation(resource, &secure_output_implementation, data, | 2679 wl_resource_set_implementation(resource, &secure_output_implementation, data, |
| 3307 nullptr); | 2680 nullptr); |
| 3308 } | 2681 } |
| 3309 | 2682 |
| 3310 void secure_output_destroy_DEPRECATED(wl_client* client, | |
| 3311 wl_resource* resource) { | |
| 3312 wl_resource_destroy(resource); | |
| 3313 } | |
| 3314 | |
| 3315 void secure_output_get_security_DEPRECATED(wl_client* client, | |
| 3316 wl_resource* resource, | |
| 3317 uint32_t id, | |
| 3318 wl_resource* surface_resource) { | |
| 3319 Surface* surface = GetUserDataAs<Surface>(surface_resource); | |
| 3320 if (surface->GetProperty(kSurfaceHasSecurityKey)) { | |
| 3321 wl_resource_post_error(resource, ZWP_SECURE_OUTPUT_V1_ERROR_SECURITY_EXISTS, | |
| 3322 "a security object for that surface already exists"); | |
| 3323 return; | |
| 3324 } | |
| 3325 | |
| 3326 wl_resource* security_resource = | |
| 3327 wl_resource_create(client, &zwp_security_v1_interface, 1, id); | |
| 3328 | |
| 3329 SetImplementation(security_resource, &security_implementation_DEPRECATED, | |
| 3330 base::MakeUnique<Security>(surface)); | |
| 3331 } | |
| 3332 | |
| 3333 const struct zwp_secure_output_v1_interface | |
| 3334 secure_output_implementation_DEPRECATED = { | |
| 3335 secure_output_destroy_DEPRECATED, | |
| 3336 secure_output_get_security_DEPRECATED}; | |
| 3337 | |
| 3338 void bind_secure_output_DEPRECATED(wl_client* client, | |
| 3339 void* data, | |
| 3340 uint32_t version, | |
| 3341 uint32_t id) { | |
| 3342 wl_resource* resource = | |
| 3343 wl_resource_create(client, &zwp_secure_output_v1_interface, 1, id); | |
| 3344 | |
| 3345 wl_resource_set_implementation( | |
| 3346 resource, &secure_output_implementation_DEPRECATED, data, nullptr); | |
| 3347 } | |
| 3348 | |
| 3349 //////////////////////////////////////////////////////////////////////////////// | 2683 //////////////////////////////////////////////////////////////////////////////// |
| 3350 // blending_interface: | 2684 // blending_interface: |
| 3351 | 2685 |
| 3352 // Implements the blending interface to a Surface. The "blend mode" and | 2686 // Implements the blending interface to a Surface. The "blend mode" and |
| 3353 // "alpha"-state is set to SrcOver and 1 upon destruction. A window property | 2687 // "alpha"-state is set to SrcOver and 1 upon destruction. A window property |
| 3354 // will be set during the lifetime of this class to prevent multiple instances | 2688 // will be set during the lifetime of this class to prevent multiple instances |
| 3355 // from being created for the same Surface. | 2689 // from being created for the same Surface. |
| 3356 class Blending : public SurfaceObserver { | 2690 class Blending : public SurfaceObserver { |
| 3357 public: | 2691 public: |
| 3358 explicit Blending(Surface* surface) : surface_(surface) { | 2692 explicit Blending(Surface* surface) : surface_(surface) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3416 | 2750 |
| 3417 void blending_set_alpha(wl_client* client, | 2751 void blending_set_alpha(wl_client* client, |
| 3418 wl_resource* resource, | 2752 wl_resource* resource, |
| 3419 wl_fixed_t alpha) { | 2753 wl_fixed_t alpha) { |
| 3420 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); | 2754 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); |
| 3421 } | 2755 } |
| 3422 | 2756 |
| 3423 const struct zcr_blending_v1_interface blending_implementation = { | 2757 const struct zcr_blending_v1_interface blending_implementation = { |
| 3424 blending_destroy, blending_set_blending, blending_set_alpha}; | 2758 blending_destroy, blending_set_blending, blending_set_alpha}; |
| 3425 | 2759 |
| 3426 void blending_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 3427 wl_resource_destroy(resource); | |
| 3428 } | |
| 3429 | |
| 3430 void blending_set_blending_DEPRECATED(wl_client* client, | |
| 3431 wl_resource* resource, | |
| 3432 uint32_t equation) { | |
| 3433 switch (equation) { | |
| 3434 case ZWP_BLENDING_V1_BLENDING_EQUATION_NONE: | |
| 3435 GetUserDataAs<Blending>(resource)->SetBlendMode(SkXfermode::kSrc_Mode); | |
| 3436 break; | |
| 3437 case ZWP_BLENDING_V1_BLENDING_EQUATION_PREMULT: | |
| 3438 GetUserDataAs<Blending>(resource)->SetBlendMode( | |
| 3439 SkXfermode::kSrcOver_Mode); | |
| 3440 break; | |
| 3441 case ZWP_BLENDING_V1_BLENDING_EQUATION_COVERAGE: | |
| 3442 NOTIMPLEMENTED(); | |
| 3443 break; | |
| 3444 default: | |
| 3445 DLOG(WARNING) << "Unsupported blending equation: " << equation; | |
| 3446 break; | |
| 3447 } | |
| 3448 } | |
| 3449 | |
| 3450 void blending_set_alpha_DEPRECATED(wl_client* client, | |
| 3451 wl_resource* resource, | |
| 3452 wl_fixed_t alpha) { | |
| 3453 GetUserDataAs<Blending>(resource)->SetAlpha(wl_fixed_to_double(alpha)); | |
| 3454 } | |
| 3455 | |
| 3456 const struct zwp_blending_v1_interface blending_implementation_DEPRECATED = { | |
| 3457 blending_destroy_DEPRECATED, blending_set_blending_DEPRECATED, | |
| 3458 blending_set_alpha_DEPRECATED}; | |
| 3459 | |
| 3460 //////////////////////////////////////////////////////////////////////////////// | 2760 //////////////////////////////////////////////////////////////////////////////// |
| 3461 // alpha_compositing_interface: | 2761 // alpha_compositing_interface: |
| 3462 | 2762 |
| 3463 void alpha_compositing_destroy(wl_client* client, wl_resource* resource) { | 2763 void alpha_compositing_destroy(wl_client* client, wl_resource* resource) { |
| 3464 wl_resource_destroy(resource); | 2764 wl_resource_destroy(resource); |
| 3465 } | 2765 } |
| 3466 | 2766 |
| 3467 void alpha_compositing_get_blending(wl_client* client, | 2767 void alpha_compositing_get_blending(wl_client* client, |
| 3468 wl_resource* resource, | 2768 wl_resource* resource, |
| 3469 uint32_t id, | 2769 uint32_t id, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3491 void* data, | 2791 void* data, |
| 3492 uint32_t version, | 2792 uint32_t version, |
| 3493 uint32_t id) { | 2793 uint32_t id) { |
| 3494 wl_resource* resource = | 2794 wl_resource* resource = |
| 3495 wl_resource_create(client, &zcr_alpha_compositing_v1_interface, 1, id); | 2795 wl_resource_create(client, &zcr_alpha_compositing_v1_interface, 1, id); |
| 3496 | 2796 |
| 3497 wl_resource_set_implementation(resource, &alpha_compositing_implementation, | 2797 wl_resource_set_implementation(resource, &alpha_compositing_implementation, |
| 3498 data, nullptr); | 2798 data, nullptr); |
| 3499 } | 2799 } |
| 3500 | 2800 |
| 3501 void alpha_compositing_destroy_DEPRECATED(wl_client* client, | |
| 3502 wl_resource* resource) { | |
| 3503 wl_resource_destroy(resource); | |
| 3504 } | |
| 3505 | |
| 3506 void alpha_compositing_get_blending_DEPRECATED(wl_client* client, | |
| 3507 wl_resource* resource, | |
| 3508 uint32_t id, | |
| 3509 wl_resource* surface_resource) { | |
| 3510 Surface* surface = GetUserDataAs<Surface>(surface_resource); | |
| 3511 if (surface->GetProperty(kSurfaceHasBlendingKey)) { | |
| 3512 wl_resource_post_error(resource, | |
| 3513 ZWP_ALPHA_COMPOSITING_V1_ERROR_BLENDING_EXISTS, | |
| 3514 "a blending object for that surface already exists"); | |
| 3515 return; | |
| 3516 } | |
| 3517 | |
| 3518 wl_resource* blending_resource = | |
| 3519 wl_resource_create(client, &zwp_blending_v1_interface, 1, id); | |
| 3520 | |
| 3521 SetImplementation(blending_resource, &blending_implementation_DEPRECATED, | |
| 3522 base::MakeUnique<Blending>(surface)); | |
| 3523 } | |
| 3524 | |
| 3525 const struct zwp_alpha_compositing_v1_interface | |
| 3526 alpha_compositing_implementation_DEPRECATED = { | |
| 3527 alpha_compositing_destroy_DEPRECATED, | |
| 3528 alpha_compositing_get_blending_DEPRECATED}; | |
| 3529 | |
| 3530 void bind_alpha_compositing_DEPRECATED(wl_client* client, | |
| 3531 void* data, | |
| 3532 uint32_t version, | |
| 3533 uint32_t id) { | |
| 3534 wl_resource* resource = | |
| 3535 wl_resource_create(client, &zwp_alpha_compositing_v1_interface, 1, id); | |
| 3536 | |
| 3537 wl_resource_set_implementation( | |
| 3538 resource, &alpha_compositing_implementation_DEPRECATED, data, nullptr); | |
| 3539 } | |
| 3540 | |
| 3541 //////////////////////////////////////////////////////////////////////////////// | 2801 //////////////////////////////////////////////////////////////////////////////// |
| 3542 // gaming_input_interface: | 2802 // gaming_input_interface: |
| 3543 | 2803 |
| 3544 // Gamepad delegate class that forwards gamepad events to the client resource. | 2804 // Gamepad delegate class that forwards gamepad events to the client resource. |
| 3545 class WaylandGamepadDelegate : public GamepadDelegate { | 2805 class WaylandGamepadDelegate : public GamepadDelegate { |
| 3546 public: | 2806 public: |
| 3547 explicit WaylandGamepadDelegate(wl_resource* gamepad_resource) | 2807 explicit WaylandGamepadDelegate(wl_resource* gamepad_resource) |
| 3548 : gamepad_resource_(gamepad_resource) {} | 2808 : gamepad_resource_(gamepad_resource) {} |
| 3549 | 2809 |
| 3550 // Overridden from GamepadDelegate: | 2810 // Overridden from GamepadDelegate: |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3621 | 2881 |
| 3622 std::unique_ptr<base::Thread> gaming_input_thread( | 2882 std::unique_ptr<base::Thread> gaming_input_thread( |
| 3623 new base::Thread("Exo gaming input polling thread.")); | 2883 new base::Thread("Exo gaming input polling thread.")); |
| 3624 gaming_input_thread->StartWithOptions( | 2884 gaming_input_thread->StartWithOptions( |
| 3625 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 2885 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 3626 | 2886 |
| 3627 SetImplementation(resource, &gaming_input_implementation, | 2887 SetImplementation(resource, &gaming_input_implementation, |
| 3628 std::move(gaming_input_thread)); | 2888 std::move(gaming_input_thread)); |
| 3629 } | 2889 } |
| 3630 | 2890 |
| 3631 // Gamepad delegate class that forwards gamepad events to the client resource. | |
| 3632 class WaylandGamepadDelegate_DEPRECATED : public GamepadDelegate { | |
| 3633 public: | |
| 3634 explicit WaylandGamepadDelegate_DEPRECATED(wl_resource* gamepad_resource) | |
| 3635 : gamepad_resource_(gamepad_resource) {} | |
| 3636 | |
| 3637 // Overridden from GamepadDelegate: | |
| 3638 void OnGamepadDestroying(Gamepad* gamepad) override { delete this; } | |
| 3639 bool CanAcceptGamepadEventsForSurface(Surface* surface) const override { | |
| 3640 wl_resource* surface_resource = GetSurfaceResource(surface); | |
| 3641 return surface_resource && | |
| 3642 wl_resource_get_client(surface_resource) == client(); | |
| 3643 } | |
| 3644 void OnStateChange(bool connected) override { | |
| 3645 uint32_t status = connected ? ZWP_GAMEPAD_V1_GAMEPAD_STATE_ON | |
| 3646 : ZWP_GAMEPAD_V1_GAMEPAD_STATE_OFF; | |
| 3647 zwp_gamepad_v1_send_state_change(gamepad_resource_, status); | |
| 3648 wl_client_flush(client()); | |
| 3649 } | |
| 3650 void OnAxis(int axis, double value) override { | |
| 3651 zwp_gamepad_v1_send_axis(gamepad_resource_, NowInMilliseconds(), axis, | |
| 3652 wl_fixed_from_double(value)); | |
| 3653 } | |
| 3654 void OnButton(int button, bool pressed, double value) override { | |
| 3655 uint32_t state = pressed ? ZWP_GAMEPAD_V1_BUTTON_STATE_PRESSED | |
| 3656 : ZWP_GAMEPAD_V1_BUTTON_STATE_RELEASED; | |
| 3657 zwp_gamepad_v1_send_button(gamepad_resource_, NowInMilliseconds(), button, | |
| 3658 state, wl_fixed_from_double(value)); | |
| 3659 } | |
| 3660 void OnFrame() override { | |
| 3661 zwp_gamepad_v1_send_frame(gamepad_resource_, NowInMilliseconds()); | |
| 3662 wl_client_flush(client()); | |
| 3663 } | |
| 3664 | |
| 3665 private: | |
| 3666 // The client who own this gamepad instance. | |
| 3667 wl_client* client() const { | |
| 3668 return wl_resource_get_client(gamepad_resource_); | |
| 3669 } | |
| 3670 | |
| 3671 // The gamepad resource associated with the gamepad. | |
| 3672 wl_resource* const gamepad_resource_; | |
| 3673 | |
| 3674 DISALLOW_COPY_AND_ASSIGN(WaylandGamepadDelegate_DEPRECATED); | |
| 3675 }; | |
| 3676 | |
| 3677 void gamepad_destroy_DEPRECATED(wl_client* client, wl_resource* resource) { | |
| 3678 wl_resource_destroy(resource); | |
| 3679 } | |
| 3680 | |
| 3681 const struct zwp_gamepad_v1_interface gamepad_implementation_DEPRECATED = { | |
| 3682 gamepad_destroy_DEPRECATED}; | |
| 3683 | |
| 3684 void gaming_input_get_gamepad_DEPRECATED(wl_client* client, | |
| 3685 wl_resource* resource, | |
| 3686 uint32_t id, | |
| 3687 wl_resource* seat) { | |
| 3688 wl_resource* gamepad_resource = wl_resource_create( | |
| 3689 client, &zwp_gamepad_v1_interface, wl_resource_get_version(resource), id); | |
| 3690 | |
| 3691 base::Thread* gaming_input_thread = GetUserDataAs<base::Thread>(resource); | |
| 3692 | |
| 3693 SetImplementation(gamepad_resource, &gamepad_implementation_DEPRECATED, | |
| 3694 base::MakeUnique<Gamepad>( | |
| 3695 new WaylandGamepadDelegate_DEPRECATED(gamepad_resource), | |
| 3696 gaming_input_thread->task_runner().get())); | |
| 3697 } | |
| 3698 | |
| 3699 const struct zwp_gaming_input_v1_interface | |
| 3700 gaming_input_implementation_DEPRECATED = { | |
| 3701 gaming_input_get_gamepad_DEPRECATED}; | |
| 3702 | |
| 3703 void bind_gaming_input_DEPRECATED(wl_client* client, | |
| 3704 void* data, | |
| 3705 uint32_t version, | |
| 3706 uint32_t id) { | |
| 3707 wl_resource* resource = | |
| 3708 wl_resource_create(client, &zwp_gaming_input_v1_interface, version, id); | |
| 3709 | |
| 3710 std::unique_ptr<base::Thread> gaming_input_thread( | |
| 3711 new base::Thread("Exo gaming input polling thread.")); | |
| 3712 gaming_input_thread->StartWithOptions( | |
| 3713 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | |
| 3714 | |
| 3715 SetImplementation(resource, &gaming_input_implementation_DEPRECATED, | |
| 3716 std::move(gaming_input_thread)); | |
| 3717 } | |
| 3718 | |
| 3719 //////////////////////////////////////////////////////////////////////////////// | 2891 //////////////////////////////////////////////////////////////////////////////// |
| 3720 // pointer_stylus interface: | 2892 // pointer_stylus interface: |
| 3721 | 2893 |
| 3722 class WaylandPointerStylusDelegate : public PointerStylusDelegate { | 2894 class WaylandPointerStylusDelegate : public PointerStylusDelegate { |
| 3723 public: | 2895 public: |
| 3724 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) | 2896 WaylandPointerStylusDelegate(wl_resource* resource, Pointer* pointer) |
| 3725 : resource_(resource), pointer_(pointer) { | 2897 : resource_(resource), pointer_(pointer) { |
| 3726 pointer_->SetStylusDelegate(this); | 2898 pointer_->SetStylusDelegate(this); |
| 3727 } | 2899 } |
| 3728 ~WaylandPointerStylusDelegate() override { | 2900 ~WaylandPointerStylusDelegate() override { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3759 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); | 2931 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate); |
| 3760 }; | 2932 }; |
| 3761 | 2933 |
| 3762 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { | 2934 void pointer_stylus_destroy(wl_client* client, wl_resource* resource) { |
| 3763 wl_resource_destroy(resource); | 2935 wl_resource_destroy(resource); |
| 3764 } | 2936 } |
| 3765 | 2937 |
| 3766 const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { | 2938 const struct zcr_pointer_stylus_v1_interface pointer_stylus_implementation = { |
| 3767 pointer_stylus_destroy}; | 2939 pointer_stylus_destroy}; |
| 3768 | 2940 |
| 3769 class WaylandPointerStylusDelegate_DEPRECATED : public PointerStylusDelegate { | |
| 3770 public: | |
| 3771 WaylandPointerStylusDelegate_DEPRECATED(wl_resource* resource, | |
| 3772 Pointer* pointer) | |
| 3773 : resource_(resource), pointer_(pointer) { | |
| 3774 pointer_->SetStylusDelegate(this); | |
| 3775 } | |
| 3776 ~WaylandPointerStylusDelegate_DEPRECATED() override { | |
| 3777 if (pointer_ != nullptr) | |
| 3778 pointer_->SetStylusDelegate(nullptr); | |
| 3779 } | |
| 3780 void OnPointerDestroying(Pointer* pointer) override { pointer_ = nullptr; } | |
| 3781 void OnPointerToolChange(ui::EventPointerType type) override { | |
| 3782 uint wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_MOUSE; | |
| 3783 if (type == ui::EventPointerType::POINTER_TYPE_PEN) | |
| 3784 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_PEN; | |
| 3785 else if (type == ui::EventPointerType::POINTER_TYPE_ERASER) | |
| 3786 wayland_type = ZWP_POINTER_STYLUS_V1_TOOL_TYPE_ERASER; | |
| 3787 zwp_pointer_stylus_v1_send_tool_change(resource_, wayland_type); | |
| 3788 } | |
| 3789 void OnPointerForce(base::TimeTicks time_stamp, float force) override { | |
| 3790 zwp_pointer_stylus_v1_send_force(resource_, | |
| 3791 TimeTicksToMilliseconds(time_stamp), | |
| 3792 wl_fixed_from_double(force)); | |
| 3793 } | |
| 3794 void OnPointerTilt(base::TimeTicks time_stamp, gfx::Vector2dF tilt) override { | |
| 3795 zwp_pointer_stylus_v1_send_tilt( | |
| 3796 resource_, TimeTicksToMilliseconds(time_stamp), | |
| 3797 wl_fixed_from_double(tilt.x()), wl_fixed_from_double(tilt.y())); | |
| 3798 } | |
| 3799 | |
| 3800 private: | |
| 3801 wl_resource* resource_; | |
| 3802 Pointer* pointer_; | |
| 3803 | |
| 3804 // The client who own this pointer stylus instance. | |
| 3805 wl_client* client() const { return wl_resource_get_client(resource_); } | |
| 3806 | |
| 3807 DISALLOW_COPY_AND_ASSIGN(WaylandPointerStylusDelegate_DEPRECATED); | |
| 3808 }; | |
| 3809 | |
| 3810 void pointer_stylus_destroy_DEPRECATED(wl_client* client, | |
| 3811 wl_resource* resource) { | |
| 3812 wl_resource_destroy(resource); | |
| 3813 } | |
| 3814 | |
| 3815 const struct zwp_pointer_stylus_v1_interface | |
| 3816 pointer_stylus_implementation_DEPRECATED = { | |
| 3817 pointer_stylus_destroy_DEPRECATED}; | |
| 3818 | |
| 3819 //////////////////////////////////////////////////////////////////////////////// | 2941 //////////////////////////////////////////////////////////////////////////////// |
| 3820 // stylus interface: | 2942 // stylus interface: |
| 3821 | 2943 |
| 3822 void stylus_get_pointer_stylus(wl_client* client, | 2944 void stylus_get_pointer_stylus(wl_client* client, |
| 3823 wl_resource* resource, | 2945 wl_resource* resource, |
| 3824 uint32_t id, | 2946 uint32_t id, |
| 3825 wl_resource* pointer_resource) { | 2947 wl_resource* pointer_resource) { |
| 3826 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); | 2948 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); |
| 3827 | 2949 |
| 3828 wl_resource* stylus_resource = | 2950 wl_resource* stylus_resource = |
| 3829 wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); | 2951 wl_resource_create(client, &zcr_pointer_stylus_v1_interface, 1, id); |
| 3830 | 2952 |
| 3831 SetImplementation( | 2953 SetImplementation( |
| 3832 stylus_resource, &pointer_stylus_implementation, | 2954 stylus_resource, &pointer_stylus_implementation, |
| 3833 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); | 2955 base::MakeUnique<WaylandPointerStylusDelegate>(stylus_resource, pointer)); |
| 3834 } | 2956 } |
| 3835 | 2957 |
| 3836 const struct zcr_stylus_v1_interface stylus_implementation = { | 2958 const struct zcr_stylus_v1_interface stylus_implementation = { |
| 3837 stylus_get_pointer_stylus}; | 2959 stylus_get_pointer_stylus}; |
| 3838 | 2960 |
| 3839 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { | 2961 void bind_stylus(wl_client* client, void* data, uint32_t version, uint32_t id) { |
| 3840 wl_resource* resource = | 2962 wl_resource* resource = |
| 3841 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); | 2963 wl_resource_create(client, &zcr_stylus_v1_interface, version, id); |
| 3842 wl_resource_set_implementation(resource, &stylus_implementation, data, | 2964 wl_resource_set_implementation(resource, &stylus_implementation, data, |
| 3843 nullptr); | 2965 nullptr); |
| 3844 } | 2966 } |
| 3845 | 2967 |
| 3846 void stylus_get_pointer_stylus_DEPRECATED(wl_client* client, | |
| 3847 wl_resource* resource, | |
| 3848 uint32_t id, | |
| 3849 wl_resource* pointer_resource) { | |
| 3850 Pointer* pointer = GetUserDataAs<Pointer>(pointer_resource); | |
| 3851 | |
| 3852 wl_resource* stylus_resource = | |
| 3853 wl_resource_create(client, &zwp_pointer_stylus_v1_interface, 1, id); | |
| 3854 | |
| 3855 SetImplementation(stylus_resource, &pointer_stylus_implementation_DEPRECATED, | |
| 3856 base::MakeUnique<WaylandPointerStylusDelegate_DEPRECATED>( | |
| 3857 stylus_resource, pointer)); | |
| 3858 } | |
| 3859 | |
| 3860 const struct zwp_stylus_v1_interface stylus_implementation_DEPRECATED = { | |
| 3861 stylus_get_pointer_stylus_DEPRECATED}; | |
| 3862 | |
| 3863 void bind_stylus_DEPRECATED(wl_client* client, | |
| 3864 void* data, | |
| 3865 uint32_t version, | |
| 3866 uint32_t id) { | |
| 3867 wl_resource* resource = | |
| 3868 wl_resource_create(client, &zwp_stylus_v1_interface, version, id); | |
| 3869 wl_resource_set_implementation(resource, &stylus_implementation_DEPRECATED, | |
| 3870 data, nullptr); | |
| 3871 } | |
| 3872 | |
| 3873 } // namespace | 2968 } // namespace |
| 3874 | 2969 |
| 3875 //////////////////////////////////////////////////////////////////////////////// | 2970 //////////////////////////////////////////////////////////////////////////////// |
| 3876 // Server, public: | 2971 // Server, public: |
| 3877 | 2972 |
| 3878 Server::Server(Display* display) | 2973 Server::Server(Display* display) |
| 3879 : display_(display), wl_display_(wl_display_create()) { | 2974 : display_(display), wl_display_(wl_display_create()) { |
| 3880 wl_global_create(wl_display_.get(), &wl_compositor_interface, | 2975 wl_global_create(wl_display_.get(), &wl_compositor_interface, |
| 3881 compositor_version, display_, bind_compositor); | 2976 compositor_version, display_, bind_compositor); |
| 3882 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | 2977 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
| 3883 #if defined(USE_OZONE) | 2978 #if defined(USE_OZONE) |
| 3884 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, | 2979 wl_global_create(wl_display_.get(), &wl_drm_interface, drm_version, display_, |
| 3885 bind_drm); | 2980 bind_drm); |
| 3886 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, | 2981 wl_global_create(wl_display_.get(), &zwp_linux_dmabuf_v1_interface, 1, |
| 3887 display_, bind_linux_dmabuf); | 2982 display_, bind_linux_dmabuf); |
| 3888 #endif | 2983 #endif |
| 3889 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, | 2984 wl_global_create(wl_display_.get(), &wl_subcompositor_interface, 1, display_, |
| 3890 bind_subcompositor); | 2985 bind_subcompositor); |
| 3891 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, | 2986 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, |
| 3892 bind_shell); | 2987 bind_shell); |
| 3893 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, | 2988 wl_global_create(wl_display_.get(), &wl_output_interface, output_version, |
| 3894 display_, bind_output); | 2989 display_, bind_output); |
| 3895 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, | 2990 wl_global_create(wl_display_.get(), &xdg_shell_interface, 1, display_, |
| 3896 bind_xdg_shell); | 2991 bind_xdg_shell); |
| 3897 wl_global_create(wl_display_.get(), &zcr_vsync_feedback_v1_interface, 1, | 2992 wl_global_create(wl_display_.get(), &zcr_vsync_feedback_v1_interface, 1, |
| 3898 display_, bind_vsync_feedback); | 2993 display_, bind_vsync_feedback); |
| 3899 wl_global_create(wl_display_.get(), &zwp_vsync_feedback_v1_interface, 1, | |
| 3900 display_, bind_vsync_feedback_DEPRECATED); | |
| 3901 wl_global_create(wl_display_.get(), &wl_data_device_manager_interface, 1, | 2994 wl_global_create(wl_display_.get(), &wl_data_device_manager_interface, 1, |
| 3902 display_, bind_data_device_manager); | 2995 display_, bind_data_device_manager); |
| 3903 wl_global_create(wl_display_.get(), &wl_seat_interface, seat_version, | 2996 wl_global_create(wl_display_.get(), &wl_seat_interface, seat_version, |
| 3904 display_, bind_seat); | 2997 display_, bind_seat); |
| 3905 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_, | 2998 wl_global_create(wl_display_.get(), &wp_viewporter_interface, 1, display_, |
| 3906 bind_viewporter); | 2999 bind_viewporter); |
| 3907 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, | 3000 wl_global_create(wl_display_.get(), &zcr_secure_output_v1_interface, 1, |
| 3908 display_, bind_secure_output); | 3001 display_, bind_secure_output); |
| 3909 wl_global_create(wl_display_.get(), &zwp_secure_output_v1_interface, 1, | |
| 3910 display_, bind_secure_output_DEPRECATED); | |
| 3911 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, | 3002 wl_global_create(wl_display_.get(), &zcr_alpha_compositing_v1_interface, 1, |
| 3912 display_, bind_alpha_compositing); | 3003 display_, bind_alpha_compositing); |
| 3913 wl_global_create(wl_display_.get(), &zwp_alpha_compositing_v1_interface, 1, | |
| 3914 display_, bind_alpha_compositing_DEPRECATED); | |
| 3915 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, | 3004 wl_global_create(wl_display_.get(), &zcr_remote_shell_v1_interface, |
| 3916 remote_shell_version, display_, bind_remote_shell); | 3005 remote_shell_version, display_, bind_remote_shell); |
| 3917 wl_global_create(wl_display_.get(), &zwp_remote_shell_v1_interface, | |
| 3918 remote_shell_version_DEPRECATED, display_, | |
| 3919 bind_remote_shell_DEPRECATED); | |
| 3920 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, | 3006 wl_global_create(wl_display_.get(), &zcr_gaming_input_v1_interface, 1, |
| 3921 display_, bind_gaming_input); | 3007 display_, bind_gaming_input); |
| 3922 wl_global_create(wl_display_.get(), &zwp_gaming_input_v1_interface, 1, | |
| 3923 display_, bind_gaming_input_DEPRECATED); | |
| 3924 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, | 3008 wl_global_create(wl_display_.get(), &zcr_stylus_v1_interface, 1, display_, |
| 3925 bind_stylus); | 3009 bind_stylus); |
| 3926 wl_global_create(wl_display_.get(), &zwp_stylus_v1_interface, 1, display_, | |
| 3927 bind_stylus_DEPRECATED); | |
| 3928 } | 3010 } |
| 3929 | 3011 |
| 3930 Server::~Server() {} | 3012 Server::~Server() {} |
| 3931 | 3013 |
| 3932 // static | 3014 // static |
| 3933 std::unique_ptr<Server> Server::Create(Display* display) { | 3015 std::unique_ptr<Server> Server::Create(Display* display) { |
| 3934 std::unique_ptr<Server> server(new Server(display)); | 3016 std::unique_ptr<Server> server(new Server(display)); |
| 3935 | 3017 |
| 3936 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); | 3018 char* runtime_dir = getenv("XDG_RUNTIME_DIR"); |
| 3937 if (!runtime_dir) { | 3019 if (!runtime_dir) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3989 DCHECK(event_loop); | 3071 DCHECK(event_loop); |
| 3990 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3072 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3991 } | 3073 } |
| 3992 | 3074 |
| 3993 void Server::Flush() { | 3075 void Server::Flush() { |
| 3994 wl_display_flush_clients(wl_display_.get()); | 3076 wl_display_flush_clients(wl_display_.get()); |
| 3995 } | 3077 } |
| 3996 | 3078 |
| 3997 } // namespace wayland | 3079 } // namespace wayland |
| 3998 } // namespace exo | 3080 } // namespace exo |
| OLD | NEW |