Commit 5229bd56 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

lacros: zaura_surface should be created only once.

It turned out that hiding and showing a toplevel window results
a protocol error set by EXO -
zaura_shell@14: error 0: an aura surface object for that surface already
exists.

This error happens if the client shows, hides and then shows
the same window. zaura_surface doesn't do anything with
xdg_surface and it's better to move that down to the
WaylandToplevelWindow and initialize upon OnInitalize.

R=tonikitoo@igalia.com

Bug: 1113900
Change-Id: I41649281ccae847fc7f4b7306df5cdd8d89f81bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404348Reviewed-by: default avatarAntonio Gomes (GMT-4) <tonikitoo@igalia.com>
Commit-Queue: Antonio Gomes (GMT-4) <tonikitoo@igalia.com>
Auto-Submit: Maksim Sisov (GMT+3) <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#806205}
parent 68b7ac65
......@@ -4,6 +4,8 @@
#include "ui/ozone/platform/wayland/host/wayland_toplevel_window.h"
#include <aura-shell-client-protocol.h>
#include "base/run_loop.h"
#include "base/unguessable_token.h"
#include "build/chromeos_buildflags.h"
......@@ -342,6 +344,7 @@ bool WaylandToplevelWindow::OnInitialize(
#endif
SetWaylandExtension(this, static_cast<WaylandExtension*>(this));
SetWmMoveLoopHandler(this, static_cast<WmMoveLoopHandler*>(this));
InitializeAuraShell();
return true;
}
......@@ -416,4 +419,14 @@ void WaylandToplevelWindow::SetOrResetRestoredBounds() {
}
}
void WaylandToplevelWindow::InitializeAuraShell() {
if (connection()->aura_shell()) {
DCHECK(!aura_surface_);
aura_surface_.reset(zaura_shell_get_aura_surface(
connection()->aura_shell(), root_surface()->surface()));
zaura_surface_set_fullscreen_mode(aura_surface_.get(),
ZAURA_SURFACE_FULLSCREEN_MODE_IMMERSIVE);
}
}
} // namespace ui
......@@ -97,6 +97,9 @@ class WaylandToplevelWindow : public WaylandWindow,
void SetOrResetRestoredBounds();
// Initializes the aura-shell EXO extension, if available.
void InitializeAuraShell();
// Wrappers around shell surface.
std::unique_ptr<ShellSurfaceWrapper> shell_surface_;
......@@ -142,6 +145,8 @@ class WaylandToplevelWindow : public WaylandWindow,
base::OnceClosure drag_loop_quit_closure_;
wl::Object<zaura_surface> aura_surface_;
base::WeakPtrFactory<WaylandToplevelWindow> weak_ptr_factory_{this};
};
......
......@@ -4,7 +4,6 @@
#include "ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h"
#include <aura-shell-client-protocol.h>
#include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h>
......@@ -289,8 +288,6 @@ bool XDGSurfaceWrapperImpl::InitializeStable(bool with_toplevel) {
}
xdg_toplevel_add_listener(xdg_toplevel_.get(), &xdg_toplevel_listener, this);
InitializeAuraShell();
wayland_window_->root_surface()->Commit();
connection_->ScheduleFlush();
return true;
......@@ -332,21 +329,9 @@ bool XDGSurfaceWrapperImpl::InitializeV6(bool with_toplevel) {
zxdg_toplevel_v6_add_listener(zxdg_toplevel_v6_.get(),
&zxdg_toplevel_v6_listener, this);
InitializeAuraShell();
wayland_window_->root_surface()->Commit();
connection_->ScheduleFlush();
return true;
}
void XDGSurfaceWrapperImpl::InitializeAuraShell() {
if (connection_->aura_shell()) {
DCHECK(!aura_surface_);
aura_surface_.reset(zaura_shell_get_aura_surface(
connection_->aura_shell(), wayland_window_->root_surface()->surface()));
zaura_surface_set_fullscreen_mode(aura_surface_.get(),
ZAURA_SURFACE_FULLSCREEN_MODE_IMMERSIVE);
}
}
} // namespace ui
......@@ -77,9 +77,6 @@ class XDGSurfaceWrapperImpl : public ShellSurfaceWrapper {
// Initializes using XDG Shell V6 protocol.
bool InitializeV6(bool with_toplevel);
// Initializes the aura-shell EXO extension, if available.
void InitializeAuraShell();
// Non-owing WaylandWindow that uses this surface wrapper.
WaylandWindow* const wayland_window_;
WaylandConnection* const connection_;
......@@ -90,7 +87,6 @@ class XDGSurfaceWrapperImpl : public ShellSurfaceWrapper {
wl::Object<zxdg_toplevel_v6> zxdg_toplevel_v6_;
wl::Object<struct xdg_surface> xdg_surface_;
wl::Object<xdg_toplevel> xdg_toplevel_;
wl::Object<zaura_surface> aura_surface_;
bool surface_for_popup_ = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment