2014-08-28 07:52:35 +00:00
|
|
|
/********************************************************************
|
2014-09-17 13:57:56 +00:00
|
|
|
Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2014-08-28 07:52:35 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) version 3, or any
|
|
|
|
later version accepted by the membership of KDE e.V. (or its
|
|
|
|
successor approved by the membership of KDE e.V.), which shall
|
|
|
|
act as a proxy defined in Section 6 of version 3 of the license.
|
2014-08-28 07:52:35 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
2014-08-28 07:52:35 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2014-09-17 13:57:56 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2014-08-28 07:52:35 +00:00
|
|
|
|
2014-09-17 13:57:56 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2014-08-28 07:52:35 +00:00
|
|
|
*********************************************************************/
|
|
|
|
#include "surface_interface.h"
|
2014-10-14 12:04:35 +00:00
|
|
|
#include "surface_interface_p.h"
|
2014-08-28 12:22:53 +00:00
|
|
|
#include "buffer_interface.h"
|
2014-11-19 15:53:56 +00:00
|
|
|
#include "clientconnection.h"
|
2014-08-28 07:52:35 +00:00
|
|
|
#include "compositor_interface.h"
|
2017-10-20 16:28:25 +00:00
|
|
|
#include "idleinhibit_interface_p.h"
|
2016-11-08 13:17:15 +00:00
|
|
|
#include "pointerconstraints_interface_p.h"
|
2014-10-16 12:59:01 +00:00
|
|
|
#include "region_interface.h"
|
2014-10-14 12:04:35 +00:00
|
|
|
#include "subcompositor_interface.h"
|
|
|
|
#include "subsurface_interface_p.h"
|
2016-04-05 12:26:53 +00:00
|
|
|
// Qt
|
|
|
|
#include <QListIterator>
|
2014-09-19 05:06:31 +00:00
|
|
|
// Wayland
|
|
|
|
#include <wayland-server.h>
|
2014-10-14 12:04:35 +00:00
|
|
|
// std
|
|
|
|
#include <algorithm>
|
2014-08-28 07:52:35 +00:00
|
|
|
|
2014-09-17 14:10:38 +00:00
|
|
|
namespace KWayland
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-09-17 14:10:38 +00:00
|
|
|
namespace Server
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
|
2014-11-20 15:40:14 +00:00
|
|
|
SurfaceInterface::Private::Private(SurfaceInterface *q, CompositorInterface *c, wl_resource *parentResource)
|
|
|
|
: Resource::Private(q, c, parentResource, &wl_surface_interface, &s_interface)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
SurfaceInterface::Private::~Private()
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
destroy();
|
2014-09-19 05:06:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 08:57:46 +00:00
|
|
|
void SurfaceInterface::Private::addChild(QPointer< SubSurfaceInterface > child)
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
2016-03-21 14:53:13 +00:00
|
|
|
// protocol is not precise on how to handle the addition of new sub surfaces
|
|
|
|
pending.children.append(child);
|
|
|
|
subSurfacePending.children.append(child);
|
|
|
|
current.children.append(child);
|
2016-03-21 13:32:31 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
|
|
|
emit q->subSurfaceTreeChanged();
|
|
|
|
QObject::connect(child.data(), &SubSurfaceInterface::positionChanged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
QObject::connect(child->surface().data(), &SurfaceInterface::damaged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
QObject::connect(child->surface().data(), &SurfaceInterface::unmapped, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
QObject::connect(child->surface().data(), &SurfaceInterface::subSurfaceTreeChanged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
2014-10-14 12:04:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 08:57:46 +00:00
|
|
|
void SurfaceInterface::Private::removeChild(QPointer< SubSurfaceInterface > child)
|
2014-10-14 12:04:35 +00:00
|
|
|
{
|
2016-03-21 14:53:13 +00:00
|
|
|
// protocol is not precise on how to handle the addition of new sub surfaces
|
|
|
|
pending.children.removeAll(child);
|
|
|
|
subSurfacePending.children.removeAll(child);
|
|
|
|
current.children.removeAll(child);
|
2016-03-21 13:32:31 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
|
|
|
emit q->subSurfaceTreeChanged();
|
|
|
|
QObject::disconnect(child.data(), &SubSurfaceInterface::positionChanged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
2016-03-24 11:45:46 +00:00
|
|
|
if (!child->surface().isNull()) {
|
|
|
|
QObject::disconnect(child->surface().data(), &SurfaceInterface::damaged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
QObject::disconnect(child->surface().data(), &SurfaceInterface::unmapped, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
QObject::disconnect(child->surface().data(), &SurfaceInterface::subSurfaceTreeChanged, q, &SurfaceInterface::subSurfaceTreeChanged);
|
|
|
|
}
|
2014-10-14 12:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SurfaceInterface::Private::raiseChild(QPointer<SubSurfaceInterface> subsurface, SurfaceInterface *sibling)
|
|
|
|
{
|
2014-11-14 09:55:06 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
2014-10-14 12:04:35 +00:00
|
|
|
auto it = std::find(pending.children.begin(), pending.children.end(), subsurface);
|
|
|
|
if (it == pending.children.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (pending.children.count() == 1) {
|
|
|
|
// nothing to do
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (sibling == q) {
|
|
|
|
// it's to the parent, so needs to become last item
|
|
|
|
pending.children.append(*it);
|
|
|
|
pending.children.erase(it);
|
2016-03-18 08:57:46 +00:00
|
|
|
pending.childrenChanged = true;
|
2014-10-14 12:04:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!sibling->subSurface()) {
|
|
|
|
// not a sub surface
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto siblingIt = std::find(pending.children.begin(), pending.children.end(), sibling->subSurface());
|
|
|
|
if (siblingIt == pending.children.end() || siblingIt == it) {
|
|
|
|
// not a sibling
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto value = (*it);
|
|
|
|
pending.children.erase(it);
|
|
|
|
// find the iterator again
|
|
|
|
siblingIt = std::find(pending.children.begin(), pending.children.end(), sibling->subSurface());
|
|
|
|
pending.children.insert(++siblingIt, value);
|
2016-03-18 08:57:46 +00:00
|
|
|
pending.childrenChanged = true;
|
2014-10-14 12:04:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SurfaceInterface::Private::lowerChild(QPointer<SubSurfaceInterface> subsurface, SurfaceInterface *sibling)
|
|
|
|
{
|
2014-11-14 09:55:06 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
2014-10-14 12:04:35 +00:00
|
|
|
auto it = std::find(pending.children.begin(), pending.children.end(), subsurface);
|
|
|
|
if (it == pending.children.end()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (pending.children.count() == 1) {
|
|
|
|
// nothing to do
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (sibling == q) {
|
|
|
|
// it's to the parent, so needs to become first item
|
|
|
|
auto value = *it;
|
|
|
|
pending.children.erase(it);
|
|
|
|
pending.children.prepend(value);
|
2016-03-18 08:57:46 +00:00
|
|
|
pending.childrenChanged = true;
|
2014-10-14 12:04:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!sibling->subSurface()) {
|
|
|
|
// not a sub surface
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto siblingIt = std::find(pending.children.begin(), pending.children.end(), sibling->subSurface());
|
|
|
|
if (siblingIt == pending.children.end() || siblingIt == it) {
|
|
|
|
// not a sibling
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto value = (*it);
|
|
|
|
pending.children.erase(it);
|
|
|
|
// find the iterator again
|
|
|
|
siblingIt = std::find(pending.children.begin(), pending.children.end(), sibling->subSurface());
|
|
|
|
pending.children.insert(siblingIt, value);
|
2016-03-18 08:57:46 +00:00
|
|
|
pending.childrenChanged = true;
|
2014-10-14 12:04:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:07:50 +00:00
|
|
|
void SurfaceInterface::Private::setShadow(const QPointer<ShadowInterface> &shadow)
|
|
|
|
{
|
|
|
|
pending.shadow = shadow;
|
|
|
|
pending.shadowIsSet = true;
|
|
|
|
}
|
|
|
|
|
2015-08-26 12:42:58 +00:00
|
|
|
void SurfaceInterface::Private::setBlur(const QPointer<BlurInterface> &blur)
|
|
|
|
{
|
|
|
|
pending.blur = blur;
|
|
|
|
pending.blurIsSet = true;
|
|
|
|
}
|
|
|
|
|
2015-09-09 11:04:11 +00:00
|
|
|
void SurfaceInterface::Private::setSlide(const QPointer<SlideInterface> &slide)
|
|
|
|
{
|
|
|
|
pending.slide = slide;
|
|
|
|
pending.slideIsSet = true;
|
|
|
|
}
|
|
|
|
|
2015-09-02 16:13:25 +00:00
|
|
|
void SurfaceInterface::Private::setContrast(const QPointer<ContrastInterface> &contrast)
|
|
|
|
{
|
|
|
|
pending.contrast = contrast;
|
|
|
|
pending.contrastIsSet = true;
|
|
|
|
}
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
void SurfaceInterface::Private::installPointerConstraint(LockedPointerInterface *lock)
|
|
|
|
{
|
|
|
|
Q_ASSERT(lockedPointer.isNull());
|
|
|
|
Q_ASSERT(confinedPointer.isNull());
|
|
|
|
lockedPointer = QPointer<LockedPointerInterface>(lock);
|
2018-05-29 08:35:28 +00:00
|
|
|
|
|
|
|
auto cleanUp = [this]() {
|
|
|
|
lockedPointer.clear();
|
|
|
|
disconnect(constrainsOneShotConnection);
|
|
|
|
constrainsOneShotConnection = QMetaObject::Connection();
|
|
|
|
disconnect(constrainsUnboundConnection);
|
|
|
|
constrainsUnboundConnection = QMetaObject::Connection();
|
|
|
|
emit q_func()->pointerConstraintsChanged();
|
|
|
|
};
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
if (lock->lifeTime() == LockedPointerInterface::LifeTime::OneShot) {
|
|
|
|
constrainsOneShotConnection = QObject::connect(lock, &LockedPointerInterface::lockedChanged, q_func(),
|
2018-05-29 08:35:28 +00:00
|
|
|
[this, cleanUp] {
|
|
|
|
if (lockedPointer.isNull() || lockedPointer->isLocked()) {
|
2016-11-08 13:17:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-05-29 08:35:28 +00:00
|
|
|
cleanUp();
|
2016-11-08 13:17:15 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
constrainsUnboundConnection = QObject::connect(lock, &LockedPointerInterface::unbound, q_func(),
|
2018-05-29 08:35:28 +00:00
|
|
|
[this, cleanUp] {
|
2016-11-08 13:17:15 +00:00
|
|
|
if (lockedPointer.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-29 08:35:28 +00:00
|
|
|
cleanUp();
|
2016-11-08 13:17:15 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
emit q_func()->pointerConstraintsChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::Private::installPointerConstraint(ConfinedPointerInterface *confinement)
|
|
|
|
{
|
|
|
|
Q_ASSERT(lockedPointer.isNull());
|
|
|
|
Q_ASSERT(confinedPointer.isNull());
|
|
|
|
confinedPointer = QPointer<ConfinedPointerInterface>(confinement);
|
2018-05-29 08:35:28 +00:00
|
|
|
|
|
|
|
auto cleanUp = [this]() {
|
|
|
|
confinedPointer.clear();
|
|
|
|
disconnect(constrainsOneShotConnection);
|
|
|
|
constrainsOneShotConnection = QMetaObject::Connection();
|
|
|
|
disconnect(constrainsUnboundConnection);
|
|
|
|
constrainsUnboundConnection = QMetaObject::Connection();
|
|
|
|
emit q_func()->pointerConstraintsChanged();
|
|
|
|
};
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
if (confinement->lifeTime() == ConfinedPointerInterface::LifeTime::OneShot) {
|
|
|
|
constrainsOneShotConnection = QObject::connect(confinement, &ConfinedPointerInterface::confinedChanged, q_func(),
|
2018-05-29 08:35:28 +00:00
|
|
|
[this, cleanUp] {
|
|
|
|
if (confinedPointer.isNull() || confinedPointer->isConfined()) {
|
2016-11-08 13:17:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-05-29 08:35:28 +00:00
|
|
|
cleanUp();
|
2016-11-08 13:17:15 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
constrainsUnboundConnection = QObject::connect(confinement, &ConfinedPointerInterface::unbound, q_func(),
|
2018-05-29 08:35:28 +00:00
|
|
|
[this, cleanUp] {
|
2016-11-08 13:17:15 +00:00
|
|
|
if (confinedPointer.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-29 08:35:28 +00:00
|
|
|
cleanUp();
|
2016-11-08 13:17:15 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
emit q_func()->pointerConstraintsChanged();
|
|
|
|
}
|
|
|
|
|
2018-05-29 08:35:28 +00:00
|
|
|
void SurfaceInterface::Private::installIdleInhibitor(IdleInhibitorInterface *inhibitor)
|
|
|
|
{
|
|
|
|
idleInhibitors << inhibitor;
|
|
|
|
QObject::connect(inhibitor, &IdleInhibitorInterface::aboutToBeUnbound, q,
|
|
|
|
[this, inhibitor] {
|
|
|
|
idleInhibitors.removeOne(inhibitor);
|
|
|
|
if (idleInhibitors.isEmpty()) {
|
|
|
|
emit q_func()->inhibitsIdleChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (idleInhibitors.count() == 1) {
|
|
|
|
emit q_func()->inhibitsIdleChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-09 14:39:50 +00:00
|
|
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
2014-09-19 05:06:31 +00:00
|
|
|
const struct wl_surface_interface SurfaceInterface::Private::s_interface = {
|
2016-05-25 08:04:17 +00:00
|
|
|
resourceDestroyedCallback,
|
2014-09-19 05:06:31 +00:00
|
|
|
attachCallback,
|
|
|
|
damageCallback,
|
2018-01-23 15:26:42 +00:00
|
|
|
frameCallback,
|
2014-09-19 05:06:31 +00:00
|
|
|
opaqueRegionCallback,
|
|
|
|
inputRegionCallback,
|
|
|
|
commitCallback,
|
|
|
|
bufferTransformCallback,
|
|
|
|
bufferScaleCallback
|
|
|
|
};
|
2015-09-09 14:39:50 +00:00
|
|
|
#endif
|
2014-09-19 05:06:31 +00:00
|
|
|
|
2014-11-20 15:40:14 +00:00
|
|
|
SurfaceInterface::SurfaceInterface(CompositorInterface *parent, wl_resource *parentResource)
|
|
|
|
: Resource(new Private(this, parent, parentResource))
|
2014-09-19 05:06:31 +00:00
|
|
|
{
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
SurfaceInterface::~SurfaceInterface() = default;
|
|
|
|
|
2014-08-28 07:52:35 +00:00
|
|
|
void SurfaceInterface::frameRendered(quint32 msec)
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-08-28 07:52:35 +00:00
|
|
|
// notify all callbacks
|
2015-11-04 13:50:15 +00:00
|
|
|
const bool needsFlush = !d->current.callbacks.isEmpty();
|
2014-09-19 05:06:31 +00:00
|
|
|
while (!d->current.callbacks.isEmpty()) {
|
|
|
|
wl_resource *r = d->current.callbacks.takeFirst();
|
2014-08-28 07:52:35 +00:00
|
|
|
wl_callback_send_done(r, msec);
|
|
|
|
wl_resource_destroy(r);
|
|
|
|
}
|
2016-03-18 08:13:27 +00:00
|
|
|
for (auto it = d->current.children.constBegin(); it != d->current.children.constEnd(); ++it) {
|
|
|
|
const auto &subSurface = *it;
|
|
|
|
if (subSurface.isNull() || subSurface->d_func()->surface.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
subSurface->d_func()->surface->frameRendered(msec);
|
|
|
|
}
|
2015-11-04 13:50:15 +00:00
|
|
|
if (needsFlush) {
|
|
|
|
client()->flush();
|
|
|
|
}
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::destroy()
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2016-05-25 06:59:10 +00:00
|
|
|
// copy all existing callbacks to new list and clear existing lists
|
|
|
|
// the wl_resource_destroy on the callback resource goes into destroyFrameCallback
|
|
|
|
// which would modify the list we are iterating on
|
|
|
|
QList<wl_resource *> callbacksToDestroy;
|
|
|
|
callbacksToDestroy << current.callbacks;
|
|
|
|
current.callbacks.clear();
|
|
|
|
callbacksToDestroy << pending.callbacks;
|
|
|
|
pending.callbacks.clear();
|
|
|
|
callbacksToDestroy << subSurfacePending.callbacks;
|
|
|
|
subSurfacePending.callbacks.clear();
|
|
|
|
for (auto it = callbacksToDestroy.constBegin(), end = callbacksToDestroy.constEnd(); it != end; it++) {
|
|
|
|
wl_resource_destroy(*it);
|
2016-03-18 08:57:46 +00:00
|
|
|
}
|
2014-09-19 05:06:31 +00:00
|
|
|
if (current.buffer) {
|
|
|
|
current.buffer->unref();
|
2014-08-28 12:22:53 +00:00
|
|
|
}
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 08:57:46 +00:00
|
|
|
void SurfaceInterface::Private::swapStates(State *source, State *target, bool emitChanged)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-14 09:55:06 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
2016-03-30 08:16:39 +00:00
|
|
|
bool bufferChanged = source->bufferIsSet;
|
2016-03-18 08:57:46 +00:00
|
|
|
const bool opaqueRegionChanged = source->opaqueIsSet;
|
|
|
|
const bool inputRegionChanged = source->inputIsSet;
|
|
|
|
const bool scaleFactorChanged = source->scaleIsSet && (target->scale != source->scale);
|
2016-03-23 13:34:51 +00:00
|
|
|
const bool transformChanged = source->transformIsSet && (target->transform != source->transform);
|
2016-03-18 08:57:46 +00:00
|
|
|
const bool shadowChanged = source->shadowIsSet;
|
|
|
|
const bool blurChanged = source->blurIsSet;
|
|
|
|
const bool contrastChanged = source->contrastIsSet;
|
|
|
|
const bool slideChanged = source->slideIsSet;
|
|
|
|
const bool childrenChanged = source->childrenChanged;
|
2015-03-03 09:16:11 +00:00
|
|
|
bool sizeChanged = false;
|
2016-03-18 08:57:46 +00:00
|
|
|
auto buffer = target->buffer;
|
2014-11-28 07:33:32 +00:00
|
|
|
if (bufferChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
// TODO: is the reffing correct for subsurfaces?
|
2015-03-03 09:16:11 +00:00
|
|
|
QSize oldSize;
|
2016-03-18 08:57:46 +00:00
|
|
|
if (target->buffer) {
|
|
|
|
oldSize = target->buffer->size();
|
|
|
|
if (emitChanged) {
|
|
|
|
target->buffer->unref();
|
|
|
|
QObject::disconnect(target->buffer, &BufferInterface::sizeChanged, q, &SurfaceInterface::sizeChanged);
|
|
|
|
} else {
|
|
|
|
delete target->buffer;
|
|
|
|
target->buffer = nullptr;
|
|
|
|
}
|
2014-11-28 07:33:32 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
if (source->buffer) {
|
|
|
|
if (emitChanged) {
|
|
|
|
source->buffer->ref();
|
|
|
|
QObject::connect(source->buffer, &BufferInterface::sizeChanged, q, &SurfaceInterface::sizeChanged);
|
|
|
|
}
|
|
|
|
const QSize newSize = source->buffer->size();
|
2015-03-03 09:16:11 +00:00
|
|
|
sizeChanged = newSize.isValid() && newSize != oldSize;
|
2014-11-28 07:33:32 +00:00
|
|
|
}
|
2016-03-30 08:16:39 +00:00
|
|
|
if (!target->buffer && !source->buffer && emitChanged) {
|
|
|
|
// null buffer set on a not mapped surface, don't emit unmapped
|
|
|
|
bufferChanged = false;
|
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
buffer = source->buffer;
|
|
|
|
}
|
|
|
|
// copy values
|
|
|
|
if (bufferChanged) {
|
|
|
|
target->buffer = buffer;
|
|
|
|
target->damage = source->damage;
|
|
|
|
target->bufferIsSet = source->bufferIsSet;
|
|
|
|
}
|
|
|
|
if (childrenChanged) {
|
|
|
|
target->childrenChanged = source->childrenChanged;
|
|
|
|
target->children = source->children;
|
2014-08-28 12:22:53 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
target->callbacks.append(source->callbacks);
|
|
|
|
|
2015-07-15 09:07:50 +00:00
|
|
|
if (shadowChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->shadow = source->shadow;
|
|
|
|
target->shadowIsSet = true;
|
2015-07-15 09:07:50 +00:00
|
|
|
}
|
2015-08-26 12:42:58 +00:00
|
|
|
if (blurChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->blur = source->blur;
|
|
|
|
target->blurIsSet = true;
|
2015-08-26 12:42:58 +00:00
|
|
|
}
|
2015-09-02 16:13:25 +00:00
|
|
|
if (contrastChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->contrast = source->contrast;
|
|
|
|
target->contrastIsSet = true;
|
2015-09-02 16:13:25 +00:00
|
|
|
}
|
2015-09-09 11:04:11 +00:00
|
|
|
if (slideChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->slide = source->slide;
|
|
|
|
target->slideIsSet = true;
|
2015-09-09 11:04:11 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
if (inputRegionChanged) {
|
|
|
|
target->input = source->input;
|
|
|
|
target->inputIsInfinite = source->inputIsInfinite;
|
|
|
|
target->inputIsSet = true;
|
|
|
|
}
|
|
|
|
if (opaqueRegionChanged) {
|
|
|
|
target->opaque = source->opaque;
|
|
|
|
target->opaqueIsSet = true;
|
|
|
|
}
|
|
|
|
if (scaleFactorChanged) {
|
|
|
|
target->scale = source->scale;
|
|
|
|
target->scaleIsSet = true;
|
|
|
|
}
|
2016-03-23 13:34:51 +00:00
|
|
|
if (transformChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->transform = source->transform;
|
|
|
|
target->transformIsSet = true;
|
2014-10-14 12:04:35 +00:00
|
|
|
}
|
2016-11-08 13:17:15 +00:00
|
|
|
if (!lockedPointer.isNull()) {
|
|
|
|
lockedPointer->d_func()->commit();
|
|
|
|
}
|
|
|
|
if (!confinedPointer.isNull()) {
|
|
|
|
confinedPointer->d_func()->commit();
|
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
|
|
|
|
*source = State{};
|
|
|
|
source->children = target->children;
|
2014-08-28 07:52:35 +00:00
|
|
|
if (opaqueRegionChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
emit q->opaqueChanged(target->opaque);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
if (inputRegionChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
emit q->inputChanged(target->input);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
if (scaleFactorChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
emit q->scaleChanged(target->scale);
|
2016-11-07 09:56:32 +00:00
|
|
|
if (buffer && !sizeChanged) {
|
|
|
|
emit q->sizeChanged();
|
|
|
|
}
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
2016-03-23 13:34:51 +00:00
|
|
|
if (transformChanged) {
|
2016-03-18 08:57:46 +00:00
|
|
|
emit q->transformChanged(target->transform);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
if (bufferChanged && emitChanged) {
|
2018-09-15 17:56:11 +00:00
|
|
|
if (target->buffer && !target->damage.isEmpty()) {
|
2015-05-26 09:37:00 +00:00
|
|
|
const QRegion windowRegion = QRegion(0, 0, q->size().width(), q->size().height());
|
|
|
|
if (!windowRegion.isEmpty()) {
|
2016-03-18 08:57:46 +00:00
|
|
|
target->damage = windowRegion.intersected(target->damage);
|
|
|
|
if (emitChanged) {
|
2016-03-29 13:54:18 +00:00
|
|
|
subSurfaceIsMapped = true;
|
2016-04-01 06:36:34 +00:00
|
|
|
trackedDamage = trackedDamage.united(target->damage);
|
2016-03-18 08:57:46 +00:00
|
|
|
emit q->damaged(target->damage);
|
2016-03-23 16:01:39 +00:00
|
|
|
// workaround for https://bugreports.qt.io/browse/QTBUG-52092
|
|
|
|
// if the surface is a sub-surface, but the main surface is not yet mapped, fake frame rendered
|
2018-02-04 15:57:23 +00:00
|
|
|
if (subSurface) {
|
|
|
|
const auto mainSurface = subSurface->mainSurface();
|
|
|
|
if (!mainSurface || !mainSurface->buffer()) {
|
|
|
|
q->frameRendered(0);
|
|
|
|
}
|
2016-03-23 16:01:39 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
}
|
2015-05-26 09:37:00 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
} else if (!target->buffer && emitChanged) {
|
2016-03-29 13:54:18 +00:00
|
|
|
subSurfaceIsMapped = false;
|
2014-11-28 07:33:32 +00:00
|
|
|
emit q->unmapped();
|
|
|
|
}
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
if (!emitChanged) {
|
|
|
|
return;
|
|
|
|
}
|
2015-03-03 09:16:11 +00:00
|
|
|
if (sizeChanged) {
|
|
|
|
emit q->sizeChanged();
|
|
|
|
}
|
2015-07-15 09:07:50 +00:00
|
|
|
if (shadowChanged) {
|
|
|
|
emit q->shadowChanged();
|
|
|
|
}
|
2015-08-26 12:42:58 +00:00
|
|
|
if (blurChanged) {
|
|
|
|
emit q->blurChanged();
|
|
|
|
}
|
2015-09-02 16:13:25 +00:00
|
|
|
if (contrastChanged) {
|
|
|
|
emit q->contrastChanged();
|
|
|
|
}
|
2015-09-09 11:04:11 +00:00
|
|
|
if (slideChanged) {
|
|
|
|
emit q->slideOnShowHideChanged();
|
|
|
|
}
|
2016-03-21 13:32:31 +00:00
|
|
|
if (childrenChanged) {
|
|
|
|
emit q->subSurfaceTreeChanged();
|
|
|
|
}
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 08:57:46 +00:00
|
|
|
void SurfaceInterface::Private::commit()
|
|
|
|
{
|
|
|
|
if (!subSurface.isNull() && subSurface->isSynchronized()) {
|
|
|
|
swapStates(&pending, &subSurfacePending, false);
|
|
|
|
} else {
|
|
|
|
swapStates(&pending, ¤t, true);
|
|
|
|
if (!subSurface.isNull()) {
|
|
|
|
subSurface->d_func()->commit();
|
|
|
|
}
|
|
|
|
// commit all subSurfaces to apply position changes
|
|
|
|
// "The cached state is applied to the sub-surface immediately after the parent surface's state is applied"
|
|
|
|
for (auto it = current.children.constBegin(); it != current.children.constEnd(); ++it) {
|
|
|
|
const auto &subSurface = *it;
|
|
|
|
if (subSurface.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
subSurface->d_func()->commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::Private::commitSubSurface()
|
|
|
|
{
|
|
|
|
if (subSurface.isNull() || !subSurface->isSynchronized()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
swapStates(&subSurfacePending, ¤t, true);
|
|
|
|
// "The cached state is applied to the sub-surface immediately after the parent surface's state is applied"
|
|
|
|
for (auto it = current.children.constBegin(); it != current.children.constEnd(); ++it) {
|
|
|
|
const auto &subSurface = *it;
|
|
|
|
if (subSurface.isNull() || !subSurface->isSynchronized()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
subSurface->d_func()->commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::damage(const QRect &rect)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.damage = pending.damage.united(rect);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::setScale(qint32 scale)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.scale = scale;
|
2016-03-18 08:57:46 +00:00
|
|
|
pending.scaleIsSet = true;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::setTransform(OutputInterface::Transform transform)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.transform = transform;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::addFrameCallback(uint32_t callback)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-19 18:01:15 +00:00
|
|
|
wl_resource *r = client->createResource(&wl_callback_interface, 1, callback);
|
2014-08-28 07:52:35 +00:00
|
|
|
if (!r) {
|
2014-11-14 08:45:02 +00:00
|
|
|
wl_resource_post_no_memory(resource);
|
2014-08-28 07:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
wl_resource_set_implementation(r, nullptr, this, destroyFrameCallback);
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.callbacks << r;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::attachBuffer(wl_resource *buffer, const QPoint &offset)
|
2014-08-28 12:22:53 +00:00
|
|
|
{
|
2014-11-28 07:33:32 +00:00
|
|
|
pending.bufferIsSet = true;
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.offset = offset;
|
|
|
|
if (pending.buffer) {
|
|
|
|
delete pending.buffer;
|
2014-08-28 12:22:53 +00:00
|
|
|
}
|
2014-11-28 07:33:32 +00:00
|
|
|
if (!buffer) {
|
|
|
|
// got a null buffer, deletes content in next frame
|
|
|
|
pending.buffer = nullptr;
|
|
|
|
pending.damage = QRegion();
|
|
|
|
return;
|
|
|
|
}
|
2014-11-14 09:55:06 +00:00
|
|
|
Q_Q(SurfaceInterface);
|
2014-09-19 05:06:31 +00:00
|
|
|
pending.buffer = new BufferInterface(buffer, q);
|
2014-11-07 08:04:19 +00:00
|
|
|
QObject::connect(pending.buffer, &BufferInterface::aboutToBeDestroyed, q,
|
|
|
|
[this](BufferInterface *buffer) {
|
|
|
|
if (pending.buffer == buffer) {
|
|
|
|
pending.buffer = nullptr;
|
|
|
|
}
|
2016-03-18 08:57:46 +00:00
|
|
|
if (subSurfacePending.buffer == buffer) {
|
|
|
|
subSurfacePending.buffer = nullptr;
|
|
|
|
}
|
2014-11-07 08:04:19 +00:00
|
|
|
if (current.buffer == buffer) {
|
|
|
|
current.buffer->unref();
|
|
|
|
current.buffer = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2014-08-28 12:22:53 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::destroyFrameCallback(wl_resource *r)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-14 09:20:43 +00:00
|
|
|
auto s = cast<Private>(r);
|
2014-09-19 05:06:31 +00:00
|
|
|
s->current.callbacks.removeAll(r);
|
|
|
|
s->pending.callbacks.removeAll(r);
|
2016-03-18 08:57:46 +00:00
|
|
|
s->subSurfacePending.callbacks.removeAll(r);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::attachCallback(wl_client *client, wl_resource *resource, wl_resource *buffer, int32_t sx, int32_t sy)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(client)
|
2014-11-14 09:20:43 +00:00
|
|
|
cast<Private>(resource)->attachBuffer(buffer, QPoint(sx, sy));
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::damageCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(client)
|
2014-11-14 09:20:43 +00:00
|
|
|
cast<Private>(resource)->damage(QRect(x, y, width, height));
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 15:26:42 +00:00
|
|
|
void SurfaceInterface::Private::frameCallback(wl_client *client, wl_resource *resource, uint32_t callback)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-14 09:20:43 +00:00
|
|
|
auto s = cast<Private>(resource);
|
2014-11-19 15:53:56 +00:00
|
|
|
Q_ASSERT(client == *s->client);
|
2014-08-28 07:52:35 +00:00
|
|
|
s->addFrameCallback(callback);
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::opaqueRegionCallback(wl_client *client, wl_resource *resource, wl_resource *region)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-14 09:20:43 +00:00
|
|
|
auto s = cast<Private>(resource);
|
2014-11-19 15:53:56 +00:00
|
|
|
Q_ASSERT(client == *s->client);
|
2014-10-16 12:59:01 +00:00
|
|
|
auto r = RegionInterface::get(region);
|
|
|
|
s->setOpaque(r ? r->region() : QRegion());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::Private::setOpaque(const QRegion ®ion)
|
|
|
|
{
|
|
|
|
pending.opaqueIsSet = true;
|
|
|
|
pending.opaque = region;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::inputRegionCallback(wl_client *client, wl_resource *resource, wl_resource *region)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2014-11-14 09:20:43 +00:00
|
|
|
auto s = cast<Private>(resource);
|
2014-11-19 15:53:56 +00:00
|
|
|
Q_ASSERT(client == *s->client);
|
2014-10-16 12:59:01 +00:00
|
|
|
auto r = RegionInterface::get(region);
|
|
|
|
s->setInput(r ? r->region() : QRegion(), !r);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::Private::setInput(const QRegion ®ion, bool isInfinite)
|
|
|
|
{
|
|
|
|
pending.inputIsSet = true;
|
|
|
|
pending.inputIsInfinite = isInfinite;
|
|
|
|
pending.input = region;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::commitCallback(wl_client *client, wl_resource *resource)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(client)
|
2014-11-14 09:20:43 +00:00
|
|
|
cast<Private>(resource)->commit();
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::bufferTransformCallback(wl_client *client, wl_resource *resource, int32_t transform)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(client)
|
2014-11-14 09:20:43 +00:00
|
|
|
cast<Private>(resource)->setTransform(OutputInterface::Transform(transform));
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
void SurfaceInterface::Private::bufferScaleCallback(wl_client *client, wl_resource *resource, int32_t scale)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(client)
|
2014-11-14 09:20:43 +00:00
|
|
|
cast<Private>(resource)->setScale(scale);
|
2014-09-19 05:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QRegion SurfaceInterface::damage() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRegion SurfaceInterface::opaque() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.opaque;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRegion SurfaceInterface::input() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.input;
|
|
|
|
}
|
|
|
|
|
2014-10-16 12:59:01 +00:00
|
|
|
bool SurfaceInterface::inputIsInfitine() const
|
2015-09-16 14:43:58 +00:00
|
|
|
{
|
|
|
|
return inputIsInfinite();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SurfaceInterface::inputIsInfinite() const
|
2014-10-16 12:59:01 +00:00
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-10-16 12:59:01 +00:00
|
|
|
return d->current.inputIsInfinite;
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:06:31 +00:00
|
|
|
qint32 SurfaceInterface::scale() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputInterface::Transform SurfaceInterface::transform() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferInterface *SurfaceInterface::buffer()
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint SurfaceInterface::offset() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-09-19 05:06:31 +00:00
|
|
|
return d->current.offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceInterface *SurfaceInterface::get(wl_resource *native)
|
|
|
|
{
|
2014-11-14 14:13:06 +00:00
|
|
|
return Private::get<SurfaceInterface>(native);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 07:41:48 +00:00
|
|
|
SurfaceInterface *SurfaceInterface::get(quint32 id, const ClientConnection *client)
|
2015-02-09 13:31:20 +00:00
|
|
|
{
|
2015-04-02 07:41:48 +00:00
|
|
|
return Private::get<SurfaceInterface>(id, client);
|
2015-02-09 13:31:20 +00:00
|
|
|
}
|
|
|
|
|
2014-10-14 12:04:35 +00:00
|
|
|
QList< QPointer< SubSurfaceInterface > > SurfaceInterface::childSubSurfaces() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-10-14 12:04:35 +00:00
|
|
|
return d->current.children;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointer< SubSurfaceInterface > SurfaceInterface::subSurface() const
|
|
|
|
{
|
2014-11-14 08:45:02 +00:00
|
|
|
Q_D();
|
2014-10-14 12:04:35 +00:00
|
|
|
return d->subSurface;
|
|
|
|
}
|
|
|
|
|
2015-03-03 09:16:11 +00:00
|
|
|
QSize SurfaceInterface::size() const
|
|
|
|
{
|
|
|
|
Q_D();
|
2016-11-07 09:56:32 +00:00
|
|
|
// TODO: apply transform to the buffer size
|
2015-03-03 09:16:11 +00:00
|
|
|
if (d->current.buffer) {
|
2016-11-07 09:56:32 +00:00
|
|
|
return d->current.buffer->size() / scale();
|
2015-03-03 09:16:11 +00:00
|
|
|
}
|
|
|
|
return QSize();
|
|
|
|
}
|
|
|
|
|
2015-07-15 09:07:50 +00:00
|
|
|
QPointer< ShadowInterface > SurfaceInterface::shadow() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->current.shadow;
|
|
|
|
}
|
|
|
|
|
2015-08-26 12:42:58 +00:00
|
|
|
QPointer< BlurInterface > SurfaceInterface::blur() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->current.blur;
|
|
|
|
}
|
|
|
|
|
2015-09-02 16:13:25 +00:00
|
|
|
QPointer< ContrastInterface > SurfaceInterface::contrast() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->current.contrast;
|
|
|
|
}
|
|
|
|
|
2015-09-09 11:04:11 +00:00
|
|
|
QPointer< SlideInterface > SurfaceInterface::slideOnShowHide() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->current.slide;
|
|
|
|
}
|
|
|
|
|
2016-03-29 10:05:05 +00:00
|
|
|
bool SurfaceInterface::isMapped() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
if (d->subSurface) {
|
|
|
|
// from spec:
|
|
|
|
// "A sub-surface becomes mapped, when a non-NULL wl_buffer is applied and the parent surface is mapped."
|
2016-03-29 13:54:18 +00:00
|
|
|
return d->subSurfaceIsMapped && !d->subSurface->parentSurface().isNull() && d->subSurface->parentSurface()->isMapped();
|
2016-03-29 10:05:05 +00:00
|
|
|
}
|
|
|
|
return d->current.buffer != nullptr;
|
|
|
|
}
|
|
|
|
|
2016-04-01 06:36:34 +00:00
|
|
|
QRegion SurfaceInterface::trackedDamage() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->trackedDamage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::resetTrackedDamage()
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
d->trackedDamage = QRegion();
|
|
|
|
}
|
|
|
|
|
2016-08-22 12:18:23 +00:00
|
|
|
QVector<OutputInterface *> SurfaceInterface::outputs() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->outputs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SurfaceInterface::setOutputs(const QVector<OutputInterface *> &outputs)
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
QVector<OutputInterface *> removedOutputs = d->outputs;
|
|
|
|
for (auto it = outputs.constBegin(), end = outputs.constEnd(); it != end; ++it) {
|
|
|
|
const auto o = *it;
|
|
|
|
removedOutputs.removeOne(o);
|
|
|
|
}
|
|
|
|
for (auto it = removedOutputs.constBegin(), end = removedOutputs.constEnd(); it != end; ++it) {
|
|
|
|
const auto resources = (*it)->clientResources(client());
|
|
|
|
for (wl_resource *r : resources) {
|
|
|
|
wl_surface_send_leave(d->resource, r);
|
|
|
|
}
|
2017-08-26 10:53:09 +00:00
|
|
|
disconnect(d->outputDestroyedConnections.take(*it));
|
2016-08-22 12:18:23 +00:00
|
|
|
}
|
|
|
|
QVector<OutputInterface *> addedOutputsOutputs = outputs;
|
|
|
|
for (auto it = d->outputs.constBegin(), end = d->outputs.constEnd(); it != end; ++it) {
|
|
|
|
const auto o = *it;
|
|
|
|
addedOutputsOutputs.removeOne(o);
|
|
|
|
}
|
|
|
|
for (auto it = addedOutputsOutputs.constBegin(), end = addedOutputsOutputs.constEnd(); it != end; ++it) {
|
2017-08-26 10:53:09 +00:00
|
|
|
const auto o = *it;
|
|
|
|
const auto resources = o->clientResources(client());
|
2016-08-22 12:18:23 +00:00
|
|
|
for (wl_resource *r : resources) {
|
|
|
|
wl_surface_send_enter(d->resource, r);
|
|
|
|
}
|
2017-08-26 10:53:09 +00:00
|
|
|
d->outputDestroyedConnections[o] = connect(o, &Global::aboutToDestroyGlobal, this, [this, o] {
|
|
|
|
Q_D();
|
|
|
|
auto outputs = d->outputs;
|
|
|
|
if (outputs.removeOne(o)) {
|
|
|
|
setOutputs(outputs);
|
|
|
|
}});
|
2016-08-22 12:18:23 +00:00
|
|
|
}
|
|
|
|
// TODO: send enter when the client binds the OutputInterface another time
|
|
|
|
|
|
|
|
d->outputs = outputs;
|
|
|
|
}
|
|
|
|
|
2016-04-05 12:26:53 +00:00
|
|
|
SurfaceInterface *SurfaceInterface::surfaceAt(const QPointF &position)
|
|
|
|
{
|
|
|
|
if (!isMapped()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
Q_D();
|
|
|
|
// go from top to bottom. Top most child is last in list
|
|
|
|
QListIterator<QPointer<SubSurfaceInterface>> it(d->current.children);
|
|
|
|
it.toBack();
|
|
|
|
while (it.hasPrevious()) {
|
|
|
|
const auto ¤t = it.previous();
|
|
|
|
auto surface = current->surface();
|
|
|
|
if (surface.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (auto s = surface->surfaceAt(position - current->position())) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// check whether the geometry contains the pos
|
|
|
|
if (!size().isEmpty() && QRectF(QPoint(0, 0), size()).contains(position)) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-10-02 16:11:52 +00:00
|
|
|
SurfaceInterface *SurfaceInterface::inputSurfaceAt(const QPointF &position)
|
|
|
|
{
|
|
|
|
// TODO: Most of this is very similar to SurfaceInterface::surfaceAt
|
|
|
|
// Is there a way to reduce the code duplication?
|
|
|
|
if (!isMapped()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
Q_D();
|
|
|
|
// go from top to bottom. Top most child is last in list
|
|
|
|
QListIterator<QPointer<SubSurfaceInterface>> it(d->current.children);
|
|
|
|
it.toBack();
|
|
|
|
while (it.hasPrevious()) {
|
|
|
|
const auto ¤t = it.previous();
|
|
|
|
auto surface = current->surface();
|
|
|
|
if (surface.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (auto s = surface->inputSurfaceAt(position - current->position())) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// check whether the geometry and input region contain the pos
|
|
|
|
if (!size().isEmpty() && QRectF(QPoint(0, 0), size()).contains(position) &&
|
|
|
|
(inputIsInfinite() || input().contains(position.toPoint()))) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-11-08 13:17:15 +00:00
|
|
|
QPointer<LockedPointerInterface> SurfaceInterface::lockedPointer() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->lockedPointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointer<ConfinedPointerInterface> SurfaceInterface::confinedPointer() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->confinedPointer;
|
|
|
|
}
|
|
|
|
|
2017-10-20 16:28:25 +00:00
|
|
|
bool SurfaceInterface::inhibitsIdle() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return !d->idleInhibitors.isEmpty();
|
|
|
|
}
|
|
|
|
|
2019-02-06 08:26:43 +00:00
|
|
|
void SurfaceInterface::setDataProxy(SurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
d->dataProxy = surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
SurfaceInterface* SurfaceInterface::dataProxy() const
|
|
|
|
{
|
|
|
|
Q_D();
|
|
|
|
return d->dataProxy;
|
|
|
|
}
|
|
|
|
|
2014-11-14 08:45:02 +00:00
|
|
|
SurfaceInterface::Private *SurfaceInterface::d_func() const
|
|
|
|
{
|
|
|
|
return reinterpret_cast<Private*>(d.data());
|
|
|
|
}
|
|
|
|
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
}
|