summaryrefslogtreecommitdiffstats
path: root/src/compositor/wayland_wrapper/qwlsurface_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compositor/wayland_wrapper/qwlsurface_p.h')
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index 103b5994a..d08fb4cd6 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -65,6 +65,8 @@ QT_BEGIN_NAMESPACE
class QTouchEvent;
+class QWaylandUnmapLock;
+
namespace QtWayland {
class Compositor;
@@ -74,12 +76,20 @@ class InputPanelSurface;
class SubSurface;
class FrameCallback;
+class SurfaceRole;
+class RoleBase;
+
class Q_COMPOSITOR_EXPORT Surface : public QtWaylandServer::wl_surface
{
public:
Surface(struct wl_client *client, uint32_t id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface);
~Surface();
+ bool setRole(const SurfaceRole *role, wl_resource *errorResource, uint32_t errorCode);
+ const SurfaceRole *role() const { return m_role; }
+ template<class T>
+ bool setRoleHandler(T *handler);
+
static Surface *fromResource(struct ::wl_resource *resource);
QWaylandSurface::Type type() const;
@@ -141,7 +151,11 @@ public:
void releaseSurfaces();
void frameStarted();
+ void addUnmapLock(QWaylandUnmapLock *l);
+ void removeUnmapLock(QWaylandUnmapLock *l);
+
void setMapped(bool mapped);
+ void setVisibility(QWindow::Visibility visibility) { m_visibility = visibility; }
inline bool isDestroyed() const { return m_destroyed; }
@@ -176,6 +190,7 @@ protected:
QWaylandBufferRef m_bufferRef;
bool m_surfaceMapped;
QWaylandBufferAttacher *m_attacher;
+ QVector<QWaylandUnmapLock *> m_unmapLocks;
struct {
SurfaceBuffer *buffer;
@@ -211,12 +226,66 @@ protected:
Qt::ScreenOrientation m_contentOrientation;
QWindow::Visibility m_visibility;
+ const SurfaceRole *m_role;
+ RoleBase *m_roleHandler;
+
void setBackBuffer(SurfaceBuffer *buffer);
SurfaceBuffer *createSurfaceBuffer(struct ::wl_resource *buffer);
friend class QWaylandSurface;
+ friend class RoleBase;
+};
+
+class SurfaceRole
+{
+public:
+ const char *name;
+};
+
+class RoleBase
+{
+public:
+ virtual ~RoleBase() {
+ if (m_surface) {
+ m_surface->m_roleHandler = 0; m_surface = 0;
+ }
+ }
+
+protected:
+ RoleBase() : m_surface(0) {}
+ static inline RoleBase *roleOf(Surface *s) { return s->m_roleHandler; }
+
+ virtual void configure(int dx, int dy) = 0;
+
+private:
+ Surface *m_surface;
+ friend class Surface;
+};
+
+template<class T>
+class SurfaceRoleHandler : public RoleBase
+{
+public:
+ static T *get(Surface *surface) {
+ if (surface->role() == T::role()) {
+ return static_cast<T *>(roleOf(surface));
+ }
+ return 0;
+ }
};
+template<class T>
+bool Surface::setRoleHandler(T *handler)
+{
+ RoleBase *base = handler;
+ if (m_role == T::role()) {
+ m_roleHandler = base;
+ base->m_surface = this;
+ return true;
+ }
+ return false;
+}
+
}
QT_END_NAMESPACE