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

bugfix: wlr layer shell surface are guaranteed to have a nonzero size #3675

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/server/frontend_wayland/layer_shell_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ auto mf::LayerSurfaceV1::vert_padding(Anchors const& anchors, Margin const& marg

auto mf::LayerSurfaceV1::unpadded_requested_size() const -> geom::Size
{
auto size = requested_window_size().value_or(current_size());
auto size = requested_window_size().value_or(current_size().value_or(geom::Size(640, 480)));
size.width -= horiz_padding(anchors.committed(), margin.committed());
size.height -= vert_padding(anchors.committed(), margin.committed());
return size;
Expand Down
20 changes: 12 additions & 8 deletions src/server/frontend_wayland/window_wl_surface_role.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,26 +284,30 @@ void mf::WindowWlSurfaceRole::remove_state_now(MirWindowState state)

auto mf::WindowWlSurfaceRole::pending_size() const -> geom::Size
{
auto size = current_size();
auto size = current_size().value_or(geom::Size{0, 0});
if (pending_explicit_width)
size.width = pending_explicit_width.value();
if (pending_explicit_height)
size.height = pending_explicit_height.value();
return size;
}

auto mf::WindowWlSurfaceRole::current_size() const -> geom::Size
auto mf::WindowWlSurfaceRole::current_size() const -> std::optional<geom::Size>
{
if (surface)
{
auto const buffer_size = surface.value().buffer_size().value_or(geom::Size{});

return {
committed_width_set_explicitly.value_or(buffer_size.width),
committed_height_set_explicitly.value_or(buffer_size.height)};
auto buffer_size = surface.value().buffer_size();
if (committed_width_set_explicitly || committed_height_set_explicitly)
{
return geom::Size{
committed_width_set_explicitly.value_or(buffer_size ? buffer_size.value().width : geom::Width{0}),
committed_height_set_explicitly.value_or(buffer_size ? buffer_size.value().height : geom::Height{0})};
}
else
return buffer_size;
}

return geom::Size{0, 0};
return std::nullopt;
}

auto mf::WindowWlSurfaceRole::requested_window_size() const -> std::optional<geom::Size>
Expand Down
4 changes: 2 additions & 2 deletions src/server/frontend_wayland/window_wl_surface_role.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class WindowWlSurfaceRole
/// The size the window will be after the next commit
auto pending_size() const -> geometry::Size;

/// The size the window currently is (the committed size, or a reasonable default if it has never committed)
auto current_size() const -> geometry::Size;
/// The size the window currently is (the committed size, or std::nullopt if it has never committed)
auto current_size() const -> std::optional<geometry::Size>;

/// Window size requested by Mir
auto requested_window_size() const -> std::optional<geometry::Size>;
Expand Down
Loading