Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid spurious configure events #3048

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions src/server/frontend_wayland/window_wl_surface_role.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ auto mf::WindowWlSurfaceRole::pending_size() const -> geom::Size

auto mf::WindowWlSurfaceRole::current_size() const -> geom::Size
{
auto size = committed_size.value_or(geom::Size{640, 480});
auto size = geom::Size{640, 480};
if ((!committed_width_set_explicitly || !committed_height_set_explicitly) && surface)
{
if (auto const buffer_size = surface.value().buffer_size())
Expand Down Expand Up @@ -357,11 +357,7 @@ void mf::WindowWlSurfaceRole::commit(WlSurfaceState const& state)
spec().state = mir_window_state_hidden;
}

if (!committed_size || size != committed_size.value())
{
spec().width = size.width;
spec().height = size.height;
}
apply_client_size(spec());

if (state.surface_data_needs_refresh())
{
Expand All @@ -386,7 +382,6 @@ void mf::WindowWlSurfaceRole::commit(WlSurfaceState const& state)
create_scene_surface();
}

committed_size = size;
if (pending_explicit_width)
committed_width_set_explicitly = true;
if (pending_explicit_height)
Expand Down Expand Up @@ -457,9 +452,9 @@ void mf::WindowWlSurfaceRole::create_scene_surface()
return;

auto& mods = spec();
auto const request_size = pending_size();
mods.width = request_size.width;
mods.height = request_size.height;

apply_client_size(mods);

mods.streams = std::vector<shell::StreamSpecification>{};
mods.input_shape = std::vector<geom::Rectangle>{};
surface.value().populate_surface_data(mods.streams.value(), mods.input_shape.value(), {});
Expand All @@ -475,10 +470,7 @@ void mf::WindowWlSurfaceRole::create_scene_surface()
// The shell isn't guaranteed to respect the requested size
// TODO: make initial updates atomic somehow
auto const content_size = scene_surface->content_size();
if (content_size != request_size)
{
observer->content_resized_to(scene_surface.get(), content_size);
}
observer->content_resized_to(scene_surface.get(), content_size);
auto const focus_state = scene_surface->focus_state();
if (focus_state != mir_window_focus_state_unfocused)
{
Expand All @@ -504,3 +496,26 @@ void mf::WindowWlSurfaceRole::create_scene_surface()
// Invalidates mods
pending_changes.reset();
}

void mf::WindowWlSurfaceRole::apply_client_size(mir::shell::SurfaceSpecification& mods)
{
if ((!committed_width_set_explicitly || !committed_height_set_explicitly) && surface)
{
if (auto const buffer_size = surface.value().buffer_size())
{
if (!committed_width_set_explicitly)
{
mods.width = buffer_size->width;
}
if (!committed_height_set_explicitly)
{
mods.height = buffer_size->height;
}
}
}

if (pending_explicit_width)
mods.width = pending_explicit_width.value();
if (pending_explicit_height)
mods.height = pending_explicit_height.value();
}
5 changes: 2 additions & 3 deletions src/server/frontend_wayland/window_wl_surface_role.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ class WindowWlSurfaceRole
bool committed_height_set_explicitly{false};
/// @}

/// The last committed window size (either explicitly set or taken from the surface buffer size)
std::optional<geometry::Size> committed_size;

/// The min and max size of the window as of last commit
/// @{
geometry::Size committed_min_size;
Expand All @@ -164,6 +161,8 @@ class WindowWlSurfaceRole

// Ask the derived class to destroy the wayland role object (as only it can do that)
virtual void destroy_role() const = 0;

void apply_client_size(mir::shell::SurfaceSpecification& mods);
};

}
Expand Down
35 changes: 0 additions & 35 deletions tests/acceptance-tests/wayland/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,41 +113,6 @@ set(EXPECTED_FAILURES

# Not yet implemented, see https://github.com/MirServer/mir/issues/2861
XdgPopupTest.when_parent_surface_is_moved_a_reactive_popup_is_moved

# These tests depend on us not sending a configure event when the latest buffer was
# the "new" size. Even if we have sent a configure event with a different size
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/0
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/1
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/2
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/3
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/4
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/5
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/6
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/7
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/8
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/9
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/10
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/11
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/12
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/13
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/14
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/15
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/16
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/17
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/18
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/19
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/20
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/21
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/22
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/23
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/24
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/25
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/26
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/27
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/28
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/29
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/30
Anchor/LayerSurfaceLayoutTest.maximized_xdg_toplevel_is_shrunk_for_exclusive_zone/31
)

if (MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN)
Expand Down
Loading