From 8323d217a6b12c6656b68ffdfee44ee60a423539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 18 Mar 2016 10:41:56 +0100 Subject: [PATCH] [server] Add a bool SubSurfaceInterface::isSynchronized() const The mode is not sufficient to determine whether a SubSurface is in synchronized mode. Quoting spec: "Even if a sub-surface is in desynchronized mode, it will behave as in synchronized mode, if its parent surface behaves as in synchronized mode. This rule is applied recursively throughout the tree of surfaces. This means, that one can set a sub-surface into synchronized mode, and then assume that all its child and grand-child sub-surfaces are synchronized, too, without explicitly setting them." --- src/wayland/subcompositor_interface.cpp | 18 ++++++++++++++++++ src/wayland/subcompositor_interface.h | 12 ++++++++++++ 2 files changed, 30 insertions(+) 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();