diff --git a/src/wayland/subcompositor_interface.cpp b/src/wayland/subcompositor_interface.cpp index 2a57e1f962..877c4dec42 100644 --- a/src/wayland/subcompositor_interface.cpp +++ b/src/wayland/subcompositor_interface.cpp @@ -288,6 +288,24 @@ SubSurfaceInterface::Mode SubSurfaceInterface::mode() const return d->mode; } +bool SubSurfaceInterface::isSynchronized() const +{ + Q_D(); + if (d->mode == Mode::Synchronized) { + return true; + } + if (d->parent.isNull()) { + // that shouldn't happen, but let's assume false + return false; + } + if (!d->parent->subSurface().isNull()) { + // follow parent's mode + return d->parent->subSurface()->isSynchronized(); + } + // parent is no subsurface, thus parent is in desync mode and this surface is in desync mode + return false; +} + SubSurfaceInterface::Private *SubSurfaceInterface::d_func() const { return reinterpret_cast(d.data()); diff --git a/src/wayland/subcompositor_interface.h b/src/wayland/subcompositor_interface.h index d908948dc3..56470e251a 100644 --- a/src/wayland/subcompositor_interface.h +++ b/src/wayland/subcompositor_interface.h @@ -70,6 +70,18 @@ public: }; Mode mode() const; + /** + * Whether this SubSurfaceInterface is in synchronized mode. + * A SubSurface is in synchronized mode if either @link mode is + * @c Mode::Synchronized or if the parent surface is in synchronized + * mode. If a SubSurfaceInterface is in synchronized mode all child + * SubSurfaceInterfaces are also in synchronized mode ignoring the actual mode. + * @returns Whether this SubSurfaceInterface is in synchronized mode. + * @see mode + * @since 5.7 + **/ + bool isSynchronized() const; + QPointer surface(); QPointer parentSurface();