Commit eaca83ea authored by Daniel Nicoara's avatar Daniel Nicoara Committed by Commit Bot

exo: Don't shift root surface in fullscreen shell

The expectation is that the root surface fills the display space. This
ensures that sub-surfaces with negative origins don't cause the root
surface to be shifted and the host window resized.

Bug: 1015185
Test: Manually with test fullscreen_wayland_client
Test: Compare behavior while running with "weston --shell fullscreen-shell.so"
Change-Id: Id67f6e0584002329bf9941843ae6eb27c01c7225
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866608
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707019}
parent 573ceb81
......@@ -10,6 +10,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
#include "ui/aura/window_targeter.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/dip_util.h"
......@@ -208,6 +209,17 @@ void FullscreenShellSurface::OnWindowDestroying(aura::Window* window) {
window->RemoveObserver(this);
}
void FullscreenShellSurface::UpdateHostWindowBounds() {
// This method applies multiple changes to the window tree. Use ScopedPause
// to ensure that occlusion isn't recomputed before all changes have been
// applied.
aura::WindowOcclusionTracker::ScopedPause pause_occlusion;
host_window()->SetBounds(
gfx::Rect(root_surface()->window()->bounds().size()));
host_window()->SetTransparent(!root_surface()->FillsBoundsOpaquely());
}
void FullscreenShellSurface::CreateFullscreenShellSurfaceWidget(
ui::WindowShowState show_state) {
DCHECK(GetEnabled());
......
......@@ -86,6 +86,9 @@ class FullscreenShellSurface : public SurfaceTreeHost,
void SetChildAxTreeId(ui::AXTreeID child_ax_tree_id);
private:
// Keep the bounds in sync with the root surface bounds.
void UpdateHostWindowBounds() override;
void CreateFullscreenShellSurfaceWidget(ui::WindowShowState show_state);
void CommitWidget();
bool OnPreWidgetCommit();
......
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "components/exo/buffer.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/sub_surface.h"
#include "components/exo/surface.h"
#include "components/exo/test/exo_test_base_views.h"
#include "components/exo/wm_helper.h"
......@@ -191,6 +192,40 @@ TEST_F(FullscreenShellSurfaceTest, Bounds) {
EXPECT_EQ(fullscreen_bounds, expected_bounds);
}
TEST_F(FullscreenShellSurfaceTest, BoundsWithPartiallyOffscreenSubSurface) {
aura::Window* root_window =
WMHelper::GetInstance()->GetRootWindowForNewWindows();
gfx::Rect new_root_bounds(10, 10, 100, 100);
gfx::Rect expected_bounds(new_root_bounds.size());
root_window->SetBounds(new_root_bounds);
gfx::Size buffer_size(100, 100);
auto buffer = std::make_unique<Buffer>(
CreateGpuMemoryBuffer(buffer_size, gfx::BufferFormat::RGBA_8888));
auto parent = std::make_unique<Surface>();
auto fullscreen_surface = std::make_unique<FullscreenShellSurface>();
fullscreen_surface->SetSurface(parent.get());
parent->Attach(buffer.get());
parent->Commit();
EXPECT_EQ(fullscreen_surface->GetWidget()->GetWindowBoundsInScreen(),
expected_bounds);
EXPECT_EQ(parent->window()->bounds(), expected_bounds);
auto surface = std::make_unique<Surface>();
auto sub_surface = std::make_unique<SubSurface>(surface.get(), parent.get());
surface->Attach(buffer.get());
sub_surface->SetPosition(gfx::Point(-50, -50));
parent->Commit();
// Make sure the sub-surface doesn't affect the Fullscreen Shell's Window
// size/position.
EXPECT_EQ(fullscreen_surface->GetWidget()->GetWindowBoundsInScreen(),
expected_bounds);
// The root surface should also have the same position/size as before.
EXPECT_EQ(parent->window()->bounds(), expected_bounds);
}
TEST_F(FullscreenShellSurfaceTest, SetAXChildTree) {
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<FullscreenShellSurface> fullscreen_surface(
......
......@@ -95,8 +95,9 @@ class SurfaceTreeHost : public SurfaceDelegate,
// need to be released back to the client.
void SubmitEmptyCompositorFrame();
// Update the host window's size to cover entire surfaces.
void UpdateHostWindowBounds();
// Update the host window's size to cover sufaces that must be visible and
// not clipped.
virtual void UpdateHostWindowBounds();
private:
viz::CompositorFrame PrepareToSubmitCompositorFrame();
......
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