Move installPointerConstraint calls into the constraint handlers

This commit is contained in:
David Edmundson 2022-10-17 13:27:09 +01:00
parent a43ef8ac91
commit dae7d738a3
3 changed files with 19 additions and 15 deletions

View file

@ -62,9 +62,7 @@ void PointerConstraintsV1InterfacePrivate::zwp_pointer_constraints_v1_lock_point
return;
}
auto lockedPointer = new LockedPointerV1Interface(LockedPointerV1Interface::LifeTime(lifetime), regionFromResource(region_resource), lockedPointerResource);
SurfaceInterfacePrivate::get(surface)->installPointerConstraint(lockedPointer);
new LockedPointerV1Interface(surface, LockedPointerV1Interface::LifeTime(lifetime), regionFromResource(region_resource), lockedPointerResource);
}
void PointerConstraintsV1InterfacePrivate::zwp_pointer_constraints_v1_confine_pointer(Resource *resource,
@ -102,10 +100,7 @@ void PointerConstraintsV1InterfacePrivate::zwp_pointer_constraints_v1_confine_po
return;
}
auto confinedPointer =
new ConfinedPointerV1Interface(ConfinedPointerV1Interface::LifeTime(lifetime), regionFromResource(region_resource), confinedPointerResource);
SurfaceInterfacePrivate::get(surface)->installPointerConstraint(confinedPointer);
new ConfinedPointerV1Interface(surface, ConfinedPointerV1Interface::LifeTime(lifetime), regionFromResource(region_resource), confinedPointerResource);
}
void PointerConstraintsV1InterfacePrivate::zwp_pointer_constraints_v1_destroy(Resource *resource)
@ -129,11 +124,13 @@ LockedPointerV1InterfacePrivate *LockedPointerV1InterfacePrivate::get(LockedPoin
}
LockedPointerV1InterfacePrivate::LockedPointerV1InterfacePrivate(LockedPointerV1Interface *q,
SurfaceInterface *surface,
LockedPointerV1Interface::LifeTime lifeTime,
const QRegion &region,
::wl_resource *resource)
: QtWaylandServer::zwp_locked_pointer_v1(resource)
, q(q)
, surface(surface)
, lifeTime(lifeTime)
, region(region)
{
@ -179,9 +176,10 @@ void LockedPointerV1InterfacePrivate::zwp_locked_pointer_v1_set_region(Resource
hasPendingRegion = true;
}
LockedPointerV1Interface::LockedPointerV1Interface(LifeTime lifeTime, const QRegion &region, ::wl_resource *resource)
: d(new LockedPointerV1InterfacePrivate(this, lifeTime, region, resource))
LockedPointerV1Interface::LockedPointerV1Interface(SurfaceInterface *surface, LifeTime lifeTime, const QRegion &region, ::wl_resource *resource)
: d(new LockedPointerV1InterfacePrivate(this, surface, lifeTime, region, resource))
{
SurfaceInterfacePrivate::get(surface)->installPointerConstraint(this);
}
LockedPointerV1Interface::~LockedPointerV1Interface()
@ -231,11 +229,13 @@ ConfinedPointerV1InterfacePrivate *ConfinedPointerV1InterfacePrivate::get(Confin
}
ConfinedPointerV1InterfacePrivate::ConfinedPointerV1InterfacePrivate(ConfinedPointerV1Interface *q,
SurfaceInterface *surface,
ConfinedPointerV1Interface::LifeTime lifeTime,
const QRegion &region,
::wl_resource *resource)
: QtWaylandServer::zwp_confined_pointer_v1(resource)
, q(q)
, surface(surface)
, lifeTime(lifeTime)
, region(region)
{
@ -268,9 +268,10 @@ void ConfinedPointerV1InterfacePrivate::zwp_confined_pointer_v1_set_region(Resou
hasPendingRegion = true;
}
ConfinedPointerV1Interface::ConfinedPointerV1Interface(LifeTime lifeTime, const QRegion &region, ::wl_resource *resource)
: d(new ConfinedPointerV1InterfacePrivate(this, lifeTime, region, resource))
ConfinedPointerV1Interface::ConfinedPointerV1Interface(SurfaceInterface *surface, LifeTime lifeTime, const QRegion &region, ::wl_resource *resource)
: d(new ConfinedPointerV1InterfacePrivate(this, surface, lifeTime, region, resource))
{
SurfaceInterfacePrivate::get(surface)->installPointerConstraint(this);
}
ConfinedPointerV1Interface::~ConfinedPointerV1Interface()

View file

@ -151,7 +151,7 @@ Q_SIGNALS:
void lockedChanged();
private:
LockedPointerV1Interface(LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
LockedPointerV1Interface(SurfaceInterface *surface, LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
std::unique_ptr<LockedPointerV1InterfacePrivate> d;
friend class LockedPointerV1InterfacePrivate;
friend class PointerConstraintsV1InterfacePrivate;
@ -236,7 +236,7 @@ Q_SIGNALS:
void confinedChanged();
private:
ConfinedPointerV1Interface(LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
ConfinedPointerV1Interface(SurfaceInterface *surface, LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
std::unique_ptr<ConfinedPointerV1InterfacePrivate> d;
friend class ConfinedPointerV1InterfacePrivate;
friend class PointerConstraintsV1InterfacePrivate;

View file

@ -8,6 +8,7 @@
#pragma once
#include "pointerconstraints_v1_interface.h"
#include <QPointer>
#include "qwayland-server-pointer-constraints-unstable-v1.h"
@ -39,11 +40,12 @@ class LockedPointerV1InterfacePrivate : public QtWaylandServer::zwp_locked_point
public:
static LockedPointerV1InterfacePrivate *get(LockedPointerV1Interface *pointer);
LockedPointerV1InterfacePrivate(LockedPointerV1Interface *q, LockedPointerV1Interface::LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
LockedPointerV1InterfacePrivate(LockedPointerV1Interface *q, SurfaceInterface *surface, LockedPointerV1Interface::LifeTime lifeTime, const QRegion &region, ::wl_resource *resource);
void commit();
LockedPointerV1Interface *q;
QPointer<SurfaceInterface> surface;
LockedPointerV1Interface::LifeTime lifeTime;
QRegion region;
QRegion pendingRegion;
@ -65,7 +67,7 @@ class ConfinedPointerV1InterfacePrivate : public QtWaylandServer::zwp_confined_p
public:
static ConfinedPointerV1InterfacePrivate *get(ConfinedPointerV1Interface *pointer);
ConfinedPointerV1InterfacePrivate(ConfinedPointerV1Interface *q,
ConfinedPointerV1InterfacePrivate(ConfinedPointerV1Interface *q, SurfaceInterface *surface,
ConfinedPointerV1Interface::LifeTime lifeTime,
const QRegion &region,
::wl_resource *resource);
@ -73,6 +75,7 @@ public:
void commit();
ConfinedPointerV1Interface *q;
QPointer<SurfaceInterface> surface;
ConfinedPointerV1Interface::LifeTime lifeTime;
QRegion region;
QRegion pendingRegion;