Skip to content

Commit

Permalink
Merge pull request #3096 from MirServer/fix-wayland-platform
Browse files Browse the repository at this point in the history
[mir:wayland] Fix size and scale
  • Loading branch information
Saviq authored Oct 26, 2023
2 parents 0c846c6 + b89038d commit 8f53b3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
54 changes: 27 additions & 27 deletions src/platforms/wayland/displayclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class mgw::DisplayClient::Output :

DisplayConfigurationOutput dcout;
geom::Size output_size;
float host_scale{1.0f};
int32_t host_scale{1};

wl_output* const output;
DisplayClient* const owner_;
Expand Down Expand Up @@ -276,46 +276,46 @@ void mgw::DisplayClient::Output::done()
xdg_toplevel_add_listener(shell_toplevel, &shell_toplevel_listener, this);

xdg_toplevel_set_fullscreen(shell_toplevel, output);
wl_surface_set_buffer_scale(surface, round(host_scale));
wl_surface_set_buffer_scale(surface, host_scale);
wl_surface_commit(surface);

// After the next roundtrip the surface should be configured
}
else
{
/* TODO: We should handle this by raising a hardware-changed notification and reconfiguring in
* the subsequent `configure()` call.
*/
}
}

void mgw::DisplayClient::Output::toplevel_configure(int32_t width, int32_t height, wl_array* states)
{
(void)states;
pending_toplevel_size = geometry::Size{
width ? width : 1280,
height ? height : 1024};

if (width > 0 && height > 0)
{
pending_toplevel_size = geometry::Size{host_scale*width, host_scale*height};
}
}

void mgw::DisplayClient::Output::surface_configure(uint32_t serial)
{
xdg_surface_ack_configure(shell_surface, serial);
bool const size_is_changed = pending_toplevel_size && (
!dcout.custom_logical_size || dcout.custom_logical_size.value() != pending_toplevel_size.value());
dcout.custom_logical_size = host_scale*pending_toplevel_size.value();
pending_toplevel_size.reset();
output_size = dcout.extents().size;
if (!has_initialized)
{
has_initialized = true;
provider = std::make_shared<WlDisplayProvider>(*owner_->provider, surface, output_size);
}
else if (size_is_changed)
{
/* TODO: We should, again, handle this by storing the pending size, raising a hardware-changed
* notification, and then letting the `configure()` system tear down everything and bring it back
* up at the new size.
*/

if (pending_toplevel_size)
{
bool const size_is_changed = !dcout.custom_logical_size ||
dcout.custom_logical_size.value() != pending_toplevel_size.value();
dcout.custom_logical_size = pending_toplevel_size.value();
pending_toplevel_size.reset();
output_size = dcout.extents().size;
if (!has_initialized)
{
has_initialized = true;
provider = std::make_shared<WlDisplayProvider>(*owner_->provider, surface, output_size);
}
else if (size_is_changed)
{
/* TODO: We should, again, handle this by storing the pending size, raising a hardware-changed
* notification, and then letting the `configure()` system tear down everything and bring it back
* up at the new size.
*/
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/wayland/displayclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class DisplayClient
bool fake_pointer_frame = false;
geometry::DisplacementF pointer_displacement; // Position of current output
geometry::Displacement touch_displacement; // Position of current output
float pointer_scale{1.0f};
int32_t pointer_scale{1};

std::unique_ptr<wl_registry, decltype(&wl_registry_destroy)> registry;

Expand Down

0 comments on commit 8f53b3f

Please sign in to comment.