From 754df0c6d46314e69d1bf7278772340afd343a14 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Tue, 9 Jul 2024 14:07:44 +1000 Subject: [PATCH] frontend_wayland/WpViewporter: Better name for `dirty()` We change this to `changed_since_last_resolve()`. --- src/server/frontend_wayland/wl_surface.cpp | 10 +++++----- src/server/frontend_wayland/wp_viewporter.cpp | 9 +++++---- src/server/frontend_wayland/wp_viewporter.h | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/server/frontend_wayland/wl_surface.cpp b/src/server/frontend_wayland/wl_surface.cpp index 8323f8c511b..2ac9b1869d9 100644 --- a/src/server/frontend_wayland/wl_surface.cpp +++ b/src/server/frontend_wayland/wl_surface.cpp @@ -345,11 +345,11 @@ void mf::WlSurface::commit(WlSurfaceState const& state) } bool needs_buffer_submission = - state.scale || // If the scale has changed, or... - state.viewport || // ...we've added a viewport, or... - (viewport && viewport.value().dirty()); // ...the viewport has changed... - // ...then we'll need to submit a new frame, even if the client hasn't - // attached a new buffer. + state.scale || // If the scale has changed, or... + state.viewport || // ...we've added a viewport, or... + (viewport && viewport.value().changed_since_last_resolve()); // ...the viewport has changed... + // ...then we'll need to submit a new frame, even if the client hasn't + // attached a new buffer. auto const executor_send_frame_callbacks = [executor = wayland_executor, weak_self = mw::make_weak(this)]() { diff --git a/src/server/frontend_wayland/wp_viewporter.cpp b/src/server/frontend_wayland/wp_viewporter.cpp index 812e3bf5779..3a65e05a064 100644 --- a/src/server/frontend_wayland/wp_viewporter.cpp +++ b/src/server/frontend_wayland/wp_viewporter.cpp @@ -77,9 +77,9 @@ mf::Viewport::~Viewport() { } -auto mf::Viewport::dirty() -> bool +auto mf::Viewport::changed_since_last_resolve() -> bool { - return std::exchange(dirty_, false); + return viewport_changed; } namespace @@ -165,6 +165,7 @@ auto mf::Viewport::resolve_viewport(int32_t scale, geom::Size buffer_size) const } }(); + viewport_changed = false; return std::make_pair(src_bounds, logical_size); } @@ -200,7 +201,7 @@ void mf::Viewport::set_source(double x, double y, double width, double height) { source = geometry::RectangleD{{x, y}, {width, height}}; } - dirty_ = true; + viewport_changed = true; } void mf::Viewport::set_destination(int32_t width, int32_t height) @@ -233,5 +234,5 @@ void mf::Viewport::set_destination(int32_t width, int32_t height) destination = geometry::Size{width, height}; } - dirty_ = true; + viewport_changed = true; } diff --git a/src/server/frontend_wayland/wp_viewporter.h b/src/server/frontend_wayland/wp_viewporter.h index 7e88bf03376..139bd80995b 100644 --- a/src/server/frontend_wayland/wp_viewporter.h +++ b/src/server/frontend_wayland/wp_viewporter.h @@ -51,9 +51,9 @@ class Viewport : public wayland::Viewport ~Viewport() override; /** - * Have the source or destination values changed since the last call to dirty()? + * Have the source or destination values changed since the last `resolve_viewport`? */ - auto dirty() -> bool; + auto changed_since_last_resolve() -> bool; /** * Combine the viewport parameters with submitted buffer and scale to produce final parameters @@ -68,7 +68,7 @@ class Viewport : public wayland::Viewport void set_source(double x, double y, double width, double height) override; void set_destination(int32_t width, int32_t height) override; - bool dirty_; + bool mutable viewport_changed; wayland::Weak surface; std::optional source; std::optional destination;