Commit df548cc4 authored by Martin Flöser's avatar Martin Flöser
Browse files

[kwin_wayland] Track all created Wayland::Surface

Add static accessors to get all Surfaces and the Surface for a
wl_surface to Wayland::Surface.
parent 17c1eadd
......@@ -27,15 +27,19 @@ namespace KWin
namespace Wayland
{
QList<Surface*> Surface::s_surfaces = QList<Surface*>();
Surface::Surface(QObject *parent)
: QObject(parent)
, m_surface(nullptr)
, m_frameCallbackInstalled(false)
{
s_surfaces << this;
}
Surface::~Surface()
{
s_surfaces.removeAll(this);
release();
}
......@@ -121,5 +125,23 @@ void Surface::attachBuffer(wl_buffer *buffer, const QPoint &offset)
wl_surface_attach(m_surface, buffer, offset.x(), offset.y());
}
Surface *Surface::get(wl_surface *native)
{
auto it = std::find_if(s_surfaces.constBegin(), s_surfaces.constEnd(),
[native](Surface *s) {
return s->m_surface == native;
}
);
if (it != s_surfaces.constEnd()) {
return *(it);
}
return nullptr;
}
const QList< Surface* > &Surface::all()
{
return s_surfaces;
}
}
}
......@@ -62,12 +62,16 @@ public:
static void frameCallback(void *data, wl_callback *callback, uint32_t time);
static const QList<Surface*> &all();
static Surface *get(wl_surface *native);
Q_SIGNALS:
void frameRendered();
private:
void handleFrameCallback();
static const wl_callback_listener s_listener;
static QList<Surface*> s_surfaces;
wl_surface *m_surface;
bool m_frameCallbackInstalled;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment