Chromium Code Reviews| Index: components/exo/wayland/server.cc |
| diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
| index c66325c23ffb1dcf36d18a00fc861d73532ee2fb..8a1ab15361312e2ab223c3dc0b53762fefad7942 100644 |
| --- a/components/exo/wayland/server.cc |
| +++ b/components/exo/wayland/server.cc |
| @@ -638,7 +638,13 @@ void shell_surface_resize(wl_client* client, |
| } |
| void shell_surface_set_toplevel(wl_client* client, wl_resource* resource) { |
| - GetUserDataAs<ShellSurface>(resource)->Init(); |
| + ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); |
| + |
| + // Early out if shell surface has already been mapped. |
| + if (shell_surface->enabled()) |
| + return; |
|
lpique
2016/01/28 20:48:32
Note: SetEnabled() basically does this same early
reveman
2016/01/28 21:35:19
Good point. Changed this to unconditionally call S
|
| + |
| + shell_surface->SetEnabled(true); |
| } |
| void shell_surface_set_transient(wl_client* client, |
| @@ -655,8 +661,14 @@ void shell_surface_set_fullscreen(wl_client* client, |
| uint32_t method, |
| uint32_t framerate, |
| wl_resource* output_resource) { |
| - GetUserDataAs<ShellSurface>(resource)->Init(); |
| - GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true); |
| + ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); |
| + |
| + // Early out if shell surface has already been mapped. |
| + if (shell_surface->enabled()) |
| + return; |
|
lpique
2016/01/28 20:48:32
If you remove this new check here or below (as abo
reveman
2016/01/28 21:35:20
Correct. It shouldn't be possible to change the st
|
| + |
| + shell_surface->SetEnabled(true); |
| + shell_surface->SetFullscreen(true); |
| } |
| void shell_surface_set_popup(wl_client* client, |
| @@ -673,8 +685,14 @@ void shell_surface_set_popup(wl_client* client, |
| void shell_surface_set_maximized(wl_client* client, |
| wl_resource* resource, |
| wl_resource* output_resource) { |
| - GetUserDataAs<ShellSurface>(resource)->Init(); |
| - GetUserDataAs<ShellSurface>(resource)->Maximize(); |
| + ShellSurface* shell_surface = GetUserDataAs<ShellSurface>(resource); |
| + |
| + // Early out if shell surface has already been mapped. |
| + if (shell_surface->enabled()) |
| + return; |
| + |
| + shell_surface->SetEnabled(true); |
| + shell_surface->Maximize(); |
| } |
| void shell_surface_set_title(wl_client* client, |
| @@ -725,6 +743,10 @@ void shell_get_shell_surface(wl_client* client, |
| return; |
| } |
| + // Shell surfaces are initially disabled and needs to be explicitly mapped |
| + // before they are enabled and can become visible. |
| + shell_surface->SetEnabled(false); |
| + |
| shell_surface->set_surface_destroyed_callback(base::Bind( |
| &wl_resource_destroy, base::Unretained(shell_surface_resource))); |
| @@ -952,9 +974,6 @@ void xdg_shell_get_xdg_surface(wl_client* client, |
| return; |
| } |
| - // An XdgSurface is a toplevel shell surface. |
| - shell_surface->Init(); |
| - |
| shell_surface->set_close_callback(base::Bind( |
| &xdg_surface_send_close, base::Unretained(xdg_surface_resource))); |