Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: components/exo/wayland/server.cc

Issue 2645663004: exo: Initial support for multiple displays in ARC (Closed)
Patch Set: Address nits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/exo/shell_surface_unittest.cc ('k') | components/exo/wm_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <gaming-input-unstable-v2-server-protocol.h> 9 #include <gaming-input-unstable-v2-server-protocol.h>
10 #include <grp.h> 10 #include <grp.h>
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 wl_shell_surface_send_ping(resource, serial); 1001 wl_shell_surface_send_ping(resource, serial);
1002 wl_client_flush(wl_resource_get_client(resource)); 1002 wl_client_flush(wl_resource_get_client(resource));
1003 } 1003 }
1004 1004
1005 uint32_t HandleShellSurfaceConfigureCallback( 1005 uint32_t HandleShellSurfaceConfigureCallback(
1006 wl_resource* resource, 1006 wl_resource* resource,
1007 const gfx::Size& size, 1007 const gfx::Size& size,
1008 ash::wm::WindowStateType state_type, 1008 ash::wm::WindowStateType state_type,
1009 bool resizing, 1009 bool resizing,
1010 bool activated, 1010 bool activated,
1011 const gfx::Point& origin) { 1011 const gfx::Vector2d& origin_offset) {
1012 wl_shell_surface_send_configure(resource, WL_SHELL_SURFACE_RESIZE_NONE, 1012 wl_shell_surface_send_configure(resource, WL_SHELL_SURFACE_RESIZE_NONE,
1013 size.width(), size.height()); 1013 size.width(), size.height());
1014 wl_client_flush(wl_resource_get_client(resource)); 1014 wl_client_flush(wl_resource_get_client(resource));
1015 return 0; 1015 return 0;
1016 } 1016 }
1017 1017
1018 void shell_get_shell_surface(wl_client* client, 1018 void shell_get_shell_surface(wl_client* client,
1019 wl_resource* resource, 1019 wl_resource* resource,
1020 uint32_t id, 1020 uint32_t id,
1021 wl_resource* surface) { 1021 wl_resource* surface) {
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 *value = state; 1527 *value = state;
1528 } 1528 }
1529 1529
1530 uint32_t HandleXdgToplevelV6ConfigureCallback( 1530 uint32_t HandleXdgToplevelV6ConfigureCallback(
1531 wl_resource* resource, 1531 wl_resource* resource,
1532 wl_resource* surface_resource, 1532 wl_resource* surface_resource,
1533 const gfx::Size& size, 1533 const gfx::Size& size,
1534 ash::wm::WindowStateType state_type, 1534 ash::wm::WindowStateType state_type,
1535 bool resizing, 1535 bool resizing,
1536 bool activated, 1536 bool activated,
1537 const gfx::Point& origin) { 1537 const gfx::Vector2d& origin_offset) {
1538 wl_array states; 1538 wl_array states;
1539 wl_array_init(&states); 1539 wl_array_init(&states);
1540 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) 1540 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED)
1541 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED); 1541 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED);
1542 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) 1542 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN)
1543 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN); 1543 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN);
1544 if (resizing) 1544 if (resizing)
1545 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_RESIZING); 1545 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_RESIZING);
1546 if (activated) 1546 if (activated)
1547 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_ACTIVATED); 1547 AddXdgToplevelV6State(&states, ZXDG_TOPLEVEL_V6_STATE_ACTIVATED);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 DCHECK(value); 1665 DCHECK(value);
1666 *value = state; 1666 *value = state;
1667 } 1667 }
1668 1668
1669 uint32_t HandleXdgSurfaceV5ConfigureCallback( 1669 uint32_t HandleXdgSurfaceV5ConfigureCallback(
1670 wl_resource* resource, 1670 wl_resource* resource,
1671 const gfx::Size& size, 1671 const gfx::Size& size,
1672 ash::wm::WindowStateType state_type, 1672 ash::wm::WindowStateType state_type,
1673 bool resizing, 1673 bool resizing,
1674 bool activated, 1674 bool activated,
1675 const gfx::Point& origin) { 1675 const gfx::Vector2d& origin_offset) {
1676 wl_array states; 1676 wl_array states;
1677 wl_array_init(&states); 1677 wl_array_init(&states);
1678 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED) 1678 if (state_type == ash::wm::WINDOW_STATE_TYPE_MAXIMIZED)
1679 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_MAXIMIZED); 1679 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_MAXIMIZED);
1680 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN) 1680 if (state_type == ash::wm::WINDOW_STATE_TYPE_FULLSCREEN)
1681 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_FULLSCREEN); 1681 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_FULLSCREEN);
1682 if (resizing) 1682 if (resizing)
1683 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_RESIZING); 1683 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_RESIZING);
1684 if (activated) 1684 if (activated)
1685 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_ACTIVATED); 1685 AddXdgSurfaceV5State(&states, XDG_SURFACE_STATE_ACTIVATED);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 shell_surface->SetRectangularSurfaceShadow(content_bounds); 1978 shell_surface->SetRectangularSurfaceShadow(content_bounds);
1979 } 1979 }
1980 1980
1981 void remote_surface_ack_configure(wl_client* client, 1981 void remote_surface_ack_configure(wl_client* client,
1982 wl_resource* resource, 1982 wl_resource* resource,
1983 uint32_t serial) { 1983 uint32_t serial) {
1984 GetUserDataAs<ShellSurface>(resource)->AcknowledgeConfigure(serial); 1984 GetUserDataAs<ShellSurface>(resource)->AcknowledgeConfigure(serial);
1985 } 1985 }
1986 1986
1987 void remote_surface_move(wl_client* client, wl_resource* resource) { 1987 void remote_surface_move(wl_client* client, wl_resource* resource) {
1988 NOTIMPLEMENTED(); 1988 GetUserDataAs<ShellSurface>(resource)->Move();
1989 } 1989 }
1990 1990
1991 const struct zcr_remote_surface_v1_interface remote_surface_implementation = { 1991 const struct zcr_remote_surface_v1_interface remote_surface_implementation = {
1992 remote_surface_destroy, 1992 remote_surface_destroy,
1993 remote_surface_set_app_id, 1993 remote_surface_set_app_id,
1994 remote_surface_set_window_geometry, 1994 remote_surface_set_window_geometry,
1995 remote_surface_set_scale, 1995 remote_surface_set_scale,
1996 remote_surface_set_rectangular_shadow_DEPRECATED, 1996 remote_surface_set_rectangular_shadow_DEPRECATED,
1997 remote_surface_set_rectangular_shadow_background_opacity, 1997 remote_surface_set_rectangular_shadow_background_opacity,
1998 remote_surface_set_title, 1998 remote_surface_set_title,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 helper->RemoveActivationObserver(this); 2052 helper->RemoveActivationObserver(this);
2053 display::Screen::GetScreen()->RemoveObserver(this); 2053 display::Screen::GetScreen()->RemoveObserver(this);
2054 } 2054 }
2055 2055
2056 bool IsMultiDisplaySupported() const { 2056 bool IsMultiDisplaySupported() const {
2057 return wl_resource_get_version(remote_shell_resource_) >= 3; 2057 return wl_resource_get_version(remote_shell_resource_) >= 3;
2058 } 2058 }
2059 2059
2060 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface, 2060 std::unique_ptr<ShellSurface> CreateShellSurface(Surface* surface,
2061 int container) { 2061 int container) {
2062 return display_->CreateRemoteShellSurface(surface, gfx::Point(), container); 2062 return display_->CreateRemoteShellSurface(surface, container);
2063 } 2063 }
2064 2064
2065 std::unique_ptr<NotificationSurface> CreateNotificationSurface( 2065 std::unique_ptr<NotificationSurface> CreateNotificationSurface(
2066 Surface* surface, 2066 Surface* surface,
2067 const std::string& notification_id) { 2067 const std::string& notification_id) {
2068 return display_->CreateNotificationSurface(surface, notification_id); 2068 return display_->CreateNotificationSurface(surface, notification_id);
2069 } 2069 }
2070 2070
2071 // Overridden from display::DisplayObserver: 2071 // Overridden from display::DisplayObserver:
2072 void OnDisplayAdded(const display::Display& new_display) override {
2073 if (IsMultiDisplaySupported())
2074 ScheduleSendDisplayMetrics(0);
2075 }
2076
2077 void OnDisplayRemoved(const display::Display& old_display) override {
2078 if (IsMultiDisplaySupported())
2079 ScheduleSendDisplayMetrics(0);
2080 }
2081
2072 void OnDisplayMetricsChanged(const display::Display& display, 2082 void OnDisplayMetricsChanged(const display::Display& display,
2073 uint32_t changed_metrics) override { 2083 uint32_t changed_metrics) override {
2074 if (display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id()) 2084 if (!IsMultiDisplaySupported() &&
2085 display::Screen::GetScreen()->GetPrimaryDisplay().id() != display.id())
2075 return; 2086 return;
2076 2087
2077 // No need to update when a primary display has changed without bounds 2088 // No need to update when a primary display has changed without bounds
2078 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged 2089 // change. See WaylandPrimaryDisplayObserver::OnDisplayMetricsChanged
2079 // for more details. 2090 // for more details.
2080 if (changed_metrics & 2091 if (changed_metrics &
2081 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR | 2092 (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_DEVICE_SCALE_FACTOR |
2082 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) { 2093 DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_WORK_AREA)) {
2083 ScheduleSendDisplayMetrics(0); 2094 ScheduleSendDisplayMetrics(0);
2084 } 2095 }
(...skipping 24 matching lines...) Expand all
2109 weak_ptr_factory_.GetWeakPtr()), 2120 weak_ptr_factory_.GetWeakPtr()),
2110 base::TimeDelta::FromMilliseconds(delay_ms)); 2121 base::TimeDelta::FromMilliseconds(delay_ms));
2111 } 2122 }
2112 2123
2113 void SendDisplayMetrics() { 2124 void SendDisplayMetrics() {
2114 if (!needs_send_display_metrics_) 2125 if (!needs_send_display_metrics_)
2115 return; 2126 return;
2116 needs_send_display_metrics_ = false; 2127 needs_send_display_metrics_ = false;
2117 2128
2118 const display::Screen* screen = display::Screen::GetScreen(); 2129 const display::Screen* screen = display::Screen::GetScreen();
2119 const display::Display primary_display = screen->GetPrimaryDisplay(); 2130 display::Display primary_display = screen->GetPrimaryDisplay();
2120 2131
2121 const gfx::Insets& work_area_insets = primary_display.GetWorkAreaInsets(); 2132 if (IsMultiDisplaySupported()) {
2133 for (const auto& display : screen->GetAllDisplays()) {
2134 const gfx::Rect& bounds = display.bounds();
2135 const gfx::Insets& insets = display.GetWorkAreaInsets();
2136
2137 zcr_remote_shell_v1_send_workspace(
2138 remote_shell_resource_,
2139 static_cast<uint32_t>(display.id() >> 32),
2140 static_cast<uint32_t>(display.id()),
2141 bounds.x(), bounds.y(), bounds.width(), bounds.height(),
2142 insets.left(), insets.top(), insets.right(), insets.bottom());
2143 }
2144
2145 zcr_remote_shell_v1_send_configure(
2146 remote_shell_resource_,
2147 static_cast<uint32_t>(primary_display.id() >> 32),
2148 static_cast<uint32_t>(primary_display.id()),
2149 OutputTransform(primary_display.rotation()),
2150 wl_fixed_from_double(primary_display.device_scale_factor()),
2151 layout_mode_);
2152 }
2153
2154 const gfx::Insets& insets = primary_display.GetWorkAreaInsets();
2122 2155
2123 zcr_remote_shell_v1_send_configuration_changed( 2156 zcr_remote_shell_v1_send_configuration_changed(
2124 remote_shell_resource_, 2157 remote_shell_resource_,
2125 primary_display.size().width(), 2158 primary_display.size().width(),
2126 primary_display.size().height(), 2159 primary_display.size().height(),
2127 OutputTransform(primary_display.rotation()), 2160 OutputTransform(primary_display.rotation()),
2128 wl_fixed_from_double(primary_display.device_scale_factor()), 2161 wl_fixed_from_double(primary_display.device_scale_factor()),
2129 work_area_insets.left(), work_area_insets.top(), 2162 insets.left(), insets.top(), insets.right(), insets.bottom(),
2130 work_area_insets.right(), work_area_insets.bottom(), layout_mode_); 2163 layout_mode_);
2131 wl_client_flush(wl_resource_get_client(remote_shell_resource_)); 2164 wl_client_flush(wl_resource_get_client(remote_shell_resource_));
2132 } 2165 }
2133 2166
2134 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) { 2167 void SendActivated(aura::Window* gained_active, aura::Window* lost_active) {
2135 Surface* gained_active_surface = 2168 Surface* gained_active_surface =
2136 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr; 2169 gained_active ? ShellSurface::GetMainSurface(gained_active) : nullptr;
2137 Surface* lost_active_surface = 2170 Surface* lost_active_surface =
2138 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr; 2171 lost_active ? ShellSurface::GetMainSurface(lost_active) : nullptr;
2139 wl_resource* gained_active_surface_resource = 2172 wl_resource* gained_active_surface_resource =
2140 gained_active_surface ? GetSurfaceResource(gained_active_surface) 2173 gained_active_surface ? GetSurfaceResource(gained_active_surface)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 zcr_remote_surface_v1_send_state_type_changed(resource, state_type); 2263 zcr_remote_surface_v1_send_state_type_changed(resource, state_type);
2231 wl_client_flush(wl_resource_get_client(resource)); 2264 wl_client_flush(wl_resource_get_client(resource));
2232 } 2265 }
2233 2266
2234 uint32_t HandleRemoteSurfaceConfigureCallback( 2267 uint32_t HandleRemoteSurfaceConfigureCallback(
2235 wl_resource* resource, 2268 wl_resource* resource,
2236 const gfx::Size& size, 2269 const gfx::Size& size,
2237 ash::wm::WindowStateType state_type, 2270 ash::wm::WindowStateType state_type,
2238 bool resizing, 2271 bool resizing,
2239 bool activated, 2272 bool activated,
2240 const gfx::Point& origin) { 2273 const gfx::Vector2d& origin_offset) {
2241 wl_array states; 2274 wl_array states;
2242 wl_array_init(&states); 2275 wl_array_init(&states);
2243 uint32_t serial = wl_display_next_serial( 2276 uint32_t serial = wl_display_next_serial(
2244 wl_client_get_display(wl_resource_get_client(resource))); 2277 wl_client_get_display(wl_resource_get_client(resource)));
2245 zcr_remote_surface_v1_send_configure(resource, origin.x(), origin.y(), 2278 zcr_remote_surface_v1_send_configure(resource,
2279 origin_offset.x(),
2280 origin_offset.y(),
2246 &states, serial); 2281 &states, serial);
2247 wl_client_flush(wl_resource_get_client(resource)); 2282 wl_client_flush(wl_resource_get_client(resource));
2248 wl_array_release(&states); 2283 wl_array_release(&states);
2249 return serial; 2284 return serial;
2250 } 2285 }
2251 2286
2252 void remote_shell_get_remote_surface(wl_client* client, 2287 void remote_shell_get_remote_surface(wl_client* client,
2253 wl_resource* resource, 2288 wl_resource* resource,
2254 uint32_t id, 2289 uint32_t id,
2255 wl_resource* surface, 2290 wl_resource* surface,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 wl_resource_get_version(resource), id); 2344 wl_resource_get_version(resource), id);
2310 SetImplementation(notification_surface_resource, 2345 SetImplementation(notification_surface_resource,
2311 &notification_surface_implementation, 2346 &notification_surface_implementation,
2312 std::move(notification_surface)); 2347 std::move(notification_surface));
2313 } 2348 }
2314 2349
2315 const struct zcr_remote_shell_v1_interface remote_shell_implementation = { 2350 const struct zcr_remote_shell_v1_interface remote_shell_implementation = {
2316 remote_shell_destroy, remote_shell_get_remote_surface, 2351 remote_shell_destroy, remote_shell_get_remote_surface,
2317 remote_shell_get_notification_surface}; 2352 remote_shell_get_notification_surface};
2318 2353
2319 const uint32_t remote_shell_version = 2; 2354 const uint32_t remote_shell_version = 3;
2320 2355
2321 void bind_remote_shell(wl_client* client, 2356 void bind_remote_shell(wl_client* client,
2322 void* data, 2357 void* data,
2323 uint32_t version, 2358 uint32_t version,
2324 uint32_t id) { 2359 uint32_t id) {
2325 wl_resource* resource = 2360 wl_resource* resource =
2326 wl_resource_create(client, &zcr_remote_shell_v1_interface, 2361 wl_resource_create(client, &zcr_remote_shell_v1_interface,
2327 std::min(version, remote_shell_version), id); 2362 std::min(version, remote_shell_version), id);
2328 2363
2329 SetImplementation(resource, &remote_shell_implementation, 2364 SetImplementation(resource, &remote_shell_implementation,
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
3883 DCHECK(event_loop); 3918 DCHECK(event_loop);
3884 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); 3919 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds());
3885 } 3920 }
3886 3921
3887 void Server::Flush() { 3922 void Server::Flush() {
3888 wl_display_flush_clients(wl_display_.get()); 3923 wl_display_flush_clients(wl_display_.get());
3889 } 3924 }
3890 3925
3891 } // namespace wayland 3926 } // namespace wayland
3892 } // namespace exo 3927 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/shell_surface_unittest.cc ('k') | components/exo/wm_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698