| 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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 wl_client_get_display(wl_resource_get_client(resource))); | 998 wl_client_get_display(wl_resource_get_client(resource))); |
| 999 wl_shell_surface_send_ping(resource, serial); | 999 wl_shell_surface_send_ping(resource, serial); |
| 1000 wl_client_flush(wl_resource_get_client(resource)); | 1000 wl_client_flush(wl_resource_get_client(resource)); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 uint32_t HandleShellSurfaceConfigureCallback( | 1003 uint32_t HandleShellSurfaceConfigureCallback( |
| 1004 wl_resource* resource, | 1004 wl_resource* resource, |
| 1005 const gfx::Size& size, | 1005 const gfx::Size& size, |
| 1006 ash::wm::WindowStateType state_type, | 1006 ash::wm::WindowStateType state_type, |
| 1007 bool resizing, | 1007 bool resizing, |
| 1008 bool activated) { | 1008 bool activated, |
| 1009 const gfx::Point& origin) { |
| 1009 wl_shell_surface_send_configure(resource, WL_SHELL_SURFACE_RESIZE_NONE, | 1010 wl_shell_surface_send_configure(resource, WL_SHELL_SURFACE_RESIZE_NONE, |
| 1010 size.width(), size.height()); | 1011 size.width(), size.height()); |
| 1011 wl_client_flush(wl_resource_get_client(resource)); | 1012 wl_client_flush(wl_resource_get_client(resource)); |
| 1012 return 0; | 1013 return 0; |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 void shell_get_shell_surface(wl_client* client, | 1016 void shell_get_shell_surface(wl_client* client, |
| 1016 wl_resource* resource, | 1017 wl_resource* resource, |
| 1017 uint32_t id, | 1018 uint32_t id, |
| 1018 wl_resource* surface) { | 1019 wl_resource* surface) { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 DCHECK(value); | 1524 DCHECK(value); |
| 1524 *value = state; | 1525 *value = state; |
| 1525 } | 1526 } |
| 1526 | 1527 |
| 1527 uint32_t HandleXdgToplevelV6ConfigureCallback( | 1528 uint32_t HandleXdgToplevelV6ConfigureCallback( |
| 1528 wl_resource* resource, | 1529 wl_resource* resource, |
| 1529 wl_resource* surface_resource, | 1530 wl_resource* surface_resource, |
| 1530 const gfx::Size& size, | 1531 const gfx::Size& size, |
| 1531 ash::wm::WindowStateType state_type, | 1532 ash::wm::WindowStateType state_type, |
| 1532 bool resizing, | 1533 bool resizing, |
| 1533 bool activated) { | 1534 bool activated, |
| 1535 const gfx::Point& origin) { |
| 1534 wl_array states; | 1536 wl_array states; |
| 1535 wl_array_init(&states); | 1537 wl_array_init(&states); |
| 1536 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) | 1538 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) |
| 1537 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED); | 1539 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED); |
| 1538 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) | 1540 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) |
| 1539 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN); | 1541 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN); |
| 1540 if (resizing) | 1542 if (resizing) |
| 1541 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_RESIZING); | 1543 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_RESIZING); |
| 1542 if (activated) | 1544 if (activated) |
| 1543 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_ACTIVATED); | 1545 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_ACTIVATED); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 wl_array_add(states, sizeof(xdg_surface_state))); | 1662 wl_array_add(states, sizeof(xdg_surface_state))); |
| 1661 DCHECK(value); | 1663 DCHECK(value); |
| 1662 *value = state; | 1664 *value = state; |
| 1663 } | 1665 } |
| 1664 | 1666 |
| 1665 uint32_t HandleXdgSurfaceV5ConfigureCallback( | 1667 uint32_t HandleXdgSurfaceV5ConfigureCallback( |
| 1666 wl_resource* resource, | 1668 wl_resource* resource, |
| 1667 const gfx::Size& size, | 1669 const gfx::Size& size, |
| 1668 ash::wm::WindowStateType state_type, | 1670 ash::wm::WindowStateType state_type, |
| 1669 bool resizing, | 1671 bool resizing, |
| 1670 bool activated) { | 1672 bool activated, |
| 1673 const gfx::Point& origin) { |
| 1671 wl_array states; | 1674 wl_array states; |
| 1672 wl_array_init(&states); | 1675 wl_array_init(&states); |
| 1673 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) | 1676 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) |
| 1674 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_MAXIMIZED); | 1677 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_MAXIMIZED); |
| 1675 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) | 1678 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) |
| 1676 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_FULLSCREEN); | 1679 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_FULLSCREEN); |
| 1677 if (resizing) | 1680 if (resizing) |
| 1678 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_RESIZING); | 1681 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_RESIZING); |
| 1679 if (activated) | 1682 if (activated) |
| 1680 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_ACTIVATED); | 1683 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_ACTIVATED); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 int32_t width, | 1972 int32_t width, |
| 1970 int32_t height) { | 1973 int32_t height) { |
| 1971 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); | 1974 ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); |
| 1972 gfx::Rect content_bounds(x, y, width, height); | 1975 gfx::Rect content_bounds(x, y, width, height); |
| 1973 shell_surface->SetRectangularSurfaceShadow(content_bounds); | 1976 shell_surface->SetRectangularSurfaceShadow(content_bounds); |
| 1974 } | 1977 } |
| 1975 | 1978 |
| 1976 void remote_surface_ack_configure(wl_client* client, | 1979 void remote_surface_ack_configure(wl_client* client, |
| 1977 wl_resource* resource, | 1980 wl_resource* resource, |
| 1978 uint32_t serial) { | 1981 uint32_t serial) { |
| 1979 NOTIMPLEMENTED(); | 1982 GetUserDataAs<ShellSurface>(resource)->AcknowledgeConfigure(serial); |
| 1980 } | 1983 } |
| 1981 | 1984 |
| 1982 void remote_surface_move(wl_client* client, wl_resource* resource) { | 1985 void remote_surface_move(wl_client* client, wl_resource* resource) { |
| 1983 NOTIMPLEMENTED(); | 1986 NOTIMPLEMENTED(); |
| 1984 } | 1987 } |
| 1985 | 1988 |
| 1986 const struct zcr_remote_surface_v1_interface remote_surface_implementation = { | 1989 const struct zcr_remote_surface_v1_interface remote_surface_implementation = { |
| 1987 remote_surface_destroy, | 1990 remote_surface_destroy, |
| 1988 remote_surface_set_app_id, | 1991 remote_surface_set_app_id, |
| 1989 remote_surface_set_window_geometry, | 1992 remote_surface_set_window_geometry, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2041 SendDisplayMetrics(); | 2044 SendDisplayMetrics(); |
| 2042 SendActivated(helper->GetActiveWindow(), nullptr); | 2045 SendActivated(helper->GetActiveWindow(), nullptr); |
| 2043 } | 2046 } |
| 2044 ~WaylandRemoteShell() override { | 2047 ~WaylandRemoteShell() override { |
| 2045 auto* helper = WMHelper::GetInstance(); | 2048 auto* helper = WMHelper::GetInstance(); |
| 2046 helper->RemoveMaximizeModeObserver(this); | 2049 helper->RemoveMaximizeModeObserver(this); |
| 2047 helper->RemoveActivationObserver(this); | 2050 helper->RemoveActivationObserver(this); |
| 2048 display::Screen::GetScreen()->RemoveObserver(this); | 2051 display::Screen::GetScreen()->RemoveObserver(this); |
| 2049 } | 2052 } |
| 2050 | 2053 |
| 2054 bool IsMultiDisplaySupported() const { |
| 2055 return wl_resource_get_version(remote_shell_resource_) >= 3; |
| 2056 } |
| 2057 |
| 2051 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, | 2058 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, |
| 2052 int container) { | 2059 int container) { |
| 2053 return display_->CreateRemoteShellSurface(surface, container); | 2060 return display_->CreateRemoteShellSurface(surface, gfx::Point(), container); |
| 2054 } | 2061 } |
| 2055 | 2062 |
| 2056 std::unique_ptr<NotificationSurface> CreateNotificationSurface( | 2063 std::unique_ptr<NotificationSurface> CreateNotificationSurface( |
| 2057 Surface* surface, | 2064 Surface* surface, |
| 2058 const std::string& notification_id) { | 2065 const std::string& notification_id) { |
| 2059 return display_->CreateNotificationSurface(surface, notification_id); | 2066 return display_->CreateNotificationSurface(surface, notification_id); |
| 2060 } | 2067 } |
| 2061 | 2068 |
| 2062 // Overridden from display::DisplayObserver: | 2069 // Overridden from display::DisplayObserver: |
| 2063 void OnDisplayMetricsChanged(const display::Display& display, | 2070 void OnDisplayMetricsChanged(const display::Display& display, |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2214 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED; | 2221 state_type = ZCR_REMOTE_SHELL_V1_STATE_TYPE_TRUSTED_PINNED; |
| 2215 break; | 2222 break; |
| 2216 default: | 2223 default: |
| 2217 break; | 2224 break; |
| 2218 } | 2225 } |
| 2219 | 2226 |
| 2220 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); | 2227 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); |
| 2221 wl_client_flush(wl_resource_get_client(resource)); | 2228 wl_client_flush(wl_resource_get_client(resource)); |
| 2222 } | 2229 } |
| 2223 | 2230 |
| 2231 uint32_t HandleRemoteSurfaceConfigureCallback( |
| 2232 wl_resource* resource, |
| 2233 const gfx::Size& size, |
| 2234 ash::wm::WindowStateType state_type, |
| 2235 bool resizing, |
| 2236 bool activated, |
| 2237 const gfx::Point& origin) { |
| 2238 wl_array states; |
| 2239 wl_array_init(&states); |
| 2240 uint32_t serial = wl_display_next_serial( |
| 2241 wl_client_get_display(wl_resource_get_client(resource))); |
| 2242 zcr_remote_surface_v1_send_configure(resource, origin.x(), origin.y(), |
| 2243 &states, serial); |
| 2244 wl_client_flush(wl_resource_get_client(resource)); |
| 2245 wl_array_release(&states); |
| 2246 return serial; |
| 2247 } |
| 2248 |
| 2224 void remote_shell_get_remote_surface(wl_client* client, | 2249 void remote_shell_get_remote_surface(wl_client* client, |
| 2225 wl_resource* resource, | 2250 wl_resource* resource, |
| 2226 uint32_t id, | 2251 uint32_t id, |
| 2227 wl_resource* surface, | 2252 wl_resource* surface, |
| 2228 uint32_t container) { | 2253 uint32_t container) { |
| 2229 std::unique_ptr<ShellSurface> shell_surface = | 2254 WaylandRemoteShell* shell = GetUserDataAs<WaylandRemoteShell>(resource); |
| 2230 GetUserDataAs<WaylandRemoteShell>(resource)->CreateShellSurface( | 2255 std::unique_ptr<ShellSurface> shell_surface = shell->CreateShellSurface( |
| 2231 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container)); | 2256 GetUserDataAs<Surface>(surface), RemoteSurfaceContainer(container)); |
| 2232 if (!shell_surface) { | 2257 if (!shell_surface) { |
| 2233 wl_resource_post_error(resource, ZCR_REMOTE_SHELL_V1_ERROR_ROLE, | 2258 wl_resource_post_error(resource, ZCR_REMOTE_SHELL_V1_ERROR_ROLE, |
| 2234 "surface has already been assigned a role"); | 2259 "surface has already been assigned a role"); |
| 2235 return; | 2260 return; |
| 2236 } | 2261 } |
| 2237 | 2262 |
| 2238 wl_resource* remote_surface_resource = | 2263 wl_resource* remote_surface_resource = |
| 2239 wl_resource_create(client, &zcr_remote_surface_v1_interface, | 2264 wl_resource_create(client, &zcr_remote_surface_v1_interface, |
| 2240 wl_resource_get_version(resource), id); | 2265 wl_resource_get_version(resource), id); |
| 2241 | 2266 |
| 2242 shell_surface->set_close_callback( | 2267 shell_surface->set_close_callback( |
| 2243 base::Bind(&HandleRemoteSurfaceCloseCallback, | 2268 base::Bind(&HandleRemoteSurfaceCloseCallback, |
| 2244 base::Unretained(remote_surface_resource))); | 2269 base::Unretained(remote_surface_resource))); |
| 2245 shell_surface->set_state_changed_callback( | 2270 shell_surface->set_state_changed_callback( |
| 2246 base::Bind(&HandleRemoteSurfaceStateChangedCallback, | 2271 base::Bind(&HandleRemoteSurfaceStateChangedCallback, |
| 2247 base::Unretained(remote_surface_resource))); | 2272 base::Unretained(remote_surface_resource))); |
| 2273 if (shell->IsMultiDisplaySupported()) { |
| 2274 shell_surface->set_configure_callback( |
| 2275 base::Bind(&HandleRemoteSurfaceConfigureCallback, |
| 2276 base::Unretained(remote_surface_resource))); |
| 2277 } |
| 2248 | 2278 |
| 2249 SetImplementation(remote_surface_resource, &remote_surface_implementation, | 2279 SetImplementation(remote_surface_resource, &remote_surface_implementation, |
| 2250 std::move(shell_surface)); | 2280 std::move(shell_surface)); |
| 2251 } | 2281 } |
| 2252 | 2282 |
| 2253 void remote_shell_get_notification_surface(wl_client* client, | 2283 void remote_shell_get_notification_surface(wl_client* client, |
| 2254 wl_resource* resource, | 2284 wl_resource* resource, |
| 2255 uint32_t id, | 2285 uint32_t id, |
| 2256 wl_resource* surface, | 2286 wl_resource* surface, |
| 2257 const char* notification_id) { | 2287 const char* notification_id) { |
| (...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3733 DCHECK(event_loop); | 3763 DCHECK(event_loop); |
| 3734 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | 3764 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
| 3735 } | 3765 } |
| 3736 | 3766 |
| 3737 void Server::Flush() { | 3767 void Server::Flush() { |
| 3738 wl_display_flush_clients(wl_display_.get()); | 3768 wl_display_flush_clients(wl_display_.get()); |
| 3739 } | 3769 } |
| 3740 | 3770 |
| 3741 } // namespace wayland | 3771 } // namespace wayland |
| 3742 } // namespace exo | 3772 } // namespace exo |
| OLD | NEW |