summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp19
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.cpp11
-rw-r--r--src/compositor/compositor_api/qwaylandoutput.h4
-rw-r--r--src/compositor/compositor_api/qwaylandquickcompositor.cpp13
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp44
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.h3
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.cpp90
-rw-r--r--src/compositor/compositor_api/qwaylandsurface.h40
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.cpp2
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor.cpp13
-rw-r--r--src/compositor/wayland_wrapper/qwlcompositor_p.h7
-rw-r--r--src/compositor/wayland_wrapper/qwloutput.cpp3
-rw-r--r--src/compositor/wayland_wrapper/qwloutput_p.h1
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface.cpp63
-rw-r--r--src/compositor/wayland_wrapper/qwlsurface_p.h11
15 files changed, 274 insertions, 50 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 0d5d84eb..28e8f9d4 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -40,6 +41,7 @@
#include "qwaylandcompositor.h"
+#include "qwaylandclient.h"
#include "qwaylandinput.h"
#include "qwaylandoutput.h"
#include "qwaylandglobalinterface.h"
@@ -175,13 +177,20 @@ void QWaylandCompositor::surfaceAboutToBeDestroyed(QWaylandSurface *surface)
QWaylandSurfaceView *QWaylandCompositor::pickView(const QPointF &globalPosition) const
{
- Q_FOREACH (QtWayland::Surface *surface, m_compositor->surfaces()) {
- foreach (QWaylandSurfaceView *view, surface->waylandSurface()->views())
- if (QRectF(view->pos(), surface->size()).contains(globalPosition))
- return view;
+ Q_FOREACH (QWaylandOutput *output, outputs()) {
+ // Skip coordinates not in output
+ if (!QRectF(output->geometry()).contains(globalPosition))
+ continue;
+
+ Q_FOREACH (QWaylandSurface *surface, output->surfaces()) {
+ Q_FOREACH (QWaylandSurfaceView *view, surface->views()) {
+ if (QRectF(view->pos(), surface->size()).contains(globalPosition))
+ return view;
+ }
+ }
}
- return 0;
+ return Q_NULLPTR;
}
QPointF QWaylandCompositor::mapToView(QWaylandSurfaceView *surface, const QPointF &globalPosition) const
diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp
index 8f6c5e2c..ba9f3988 100644
--- a/src/compositor/compositor_api/qwaylandoutput.cpp
+++ b/src/compositor/compositor_api/qwaylandoutput.cpp
@@ -49,6 +49,7 @@
#include "wayland_wrapper/qwloutput_p.h"
#include "qwaylandcompositor.h"
#include "qwaylandoutput.h"
+#include "qwaylandsurface.h"
QWaylandOutput::QWaylandOutput(QWaylandCompositor *compositor, QWindow *window,
const QString &manufacturer, const QString &model)
@@ -244,3 +245,13 @@ QtWayland::Output *QWaylandOutput::handle()
{
return d_ptr;
}
+
+QList<QWaylandSurface *> QWaylandOutput::surfaces() const
+{
+ QList<QWaylandSurface *> list;
+ Q_FOREACH (QWaylandSurface *surface, d_ptr->compositor()->waylandCompositor()->surfaces()) {
+ if (surface->outputs().contains(const_cast<QWaylandOutput *>(this)))
+ list.append(surface);
+ }
+ return list;
+}
diff --git a/src/compositor/compositor_api/qwaylandoutput.h b/src/compositor/compositor_api/qwaylandoutput.h
index 9efbd959..9c9dc376 100644
--- a/src/compositor/compositor_api/qwaylandoutput.h
+++ b/src/compositor/compositor_api/qwaylandoutput.h
@@ -54,6 +54,8 @@ struct wl_resource;
class QWaylandCompositor;
class QWindow;
+class QWaylandSurface;
+class QWaylandClient;
namespace QtWayland {
class Output;
@@ -143,6 +145,8 @@ public:
QtWayland::Output *handle();
+ QList<QWaylandSurface *> surfaces() const;
+
Q_SIGNALS:
void positionChanged();
void geometryChanged();
diff --git a/src/compositor/compositor_api/qwaylandquickcompositor.cpp b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
index 36ee8e76..3a3c0ece 100644
--- a/src/compositor/compositor_api/qwaylandquickcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandquickcompositor.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2014 Jolla Ltd, author: <giulio.camuffo@jollamobile.com>
** Contact: http://www.qt.io/licensing/
**
@@ -32,6 +33,7 @@
****************************************************************************/
#include <QtCompositor/private/qwlcompositor_p.h>
+#include <QtCompositor/private/qwlsurface_p.h>
#include "qwaylandclient.h"
#include "qwaylandquickcompositor.h"
@@ -46,26 +48,17 @@ class QWaylandQuickCompositorPrivate : public QtWayland::Compositor
public:
QWaylandQuickCompositorPrivate(QWaylandQuickCompositor *compositor, QWaylandCompositor::ExtensionFlags extensions)
: QtWayland::Compositor(compositor, extensions)
- , updateScheduled(false)
{
}
void compositor_create_surface(Resource *resource, uint32_t id) Q_DECL_OVERRIDE
{
QWaylandQuickSurface *surface = new QWaylandQuickSurface(resource->client(), id, wl_resource_get_version(resource->handle), static_cast<QWaylandQuickCompositor *>(m_qt_compositor));
+ surface->handle()->addToOutput(primaryOutput()->handle());
m_surfaces << surface->handle();
//BUG: This may not be an on-screen window surface though
m_qt_compositor->surfaceCreated(surface);
}
-
- void updateStarted()
- {
- updateScheduled = false;
- m_qt_compositor->frameStarted();
- m_qt_compositor->cleanupGraphicsResources();
- }
-
- bool updateScheduled;
};
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index 91237b87..44e0edf5 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -77,7 +77,8 @@ public:
bufferRef.destroyTexture();
bufferRef = nextBuffer;
- QQuickWindow *window = static_cast<QQuickWindow *>(surface->output()->window());
+ QQuickWindow *window = static_cast<QQuickWindow *>(surface->mainOutput()->window());
+
// If the next buffer is NULL do not delete the current texture. If the client called
// attach(0) the surface is going to be unmapped anyway, if instead the client attached
// a valid buffer but died before we got here we want to keep the old buffer around
@@ -142,7 +143,8 @@ public:
}
QWaylandSurfacePrivate::surface_commit(resource);
- output()->waylandOutput()->update();
+ Q_FOREACH (QtWayland::Output *output, outputs())
+ output->waylandOutput()->update();
}
BufferAttacher *buffer;
@@ -159,12 +161,8 @@ QWaylandQuickSurface::QWaylandQuickSurface(wl_client *client, quint32 id, int ve
d->buffer->surface = this;
setBufferAttacher(d->buffer);
- QQuickWindow *window = static_cast<QQuickWindow *>(output()->window());
- connect(window, &QQuickWindow::beforeSynchronizing, this, &QWaylandQuickSurface::updateTexture, Qt::DirectConnection);
- connect(window, &QQuickWindow::sceneGraphInvalidated, this, &QWaylandQuickSurface::invalidateTexture, Qt::DirectConnection);
connect(this, &QWaylandSurface::windowPropertyChanged, d->windowPropertyMap, &QQmlPropertyMap::insert);
connect(d->windowPropertyMap, &QQmlPropertyMap::valueChanged, this, &QWaylandSurface::setWindowProperty);
-
}
QWaylandQuickSurface::~QWaylandQuickSurface()
@@ -200,6 +198,40 @@ QObject *QWaylandQuickSurface::windowPropertyMap() const
return d->windowPropertyMap;
}
+bool QWaylandQuickSurface::event(QEvent *e)
+{
+ if (e->type() == static_cast<QEvent::Type>(QWaylandSurfaceLeaveEvent::WaylandSurfaceLeave)) {
+ QWaylandSurfaceLeaveEvent *event = static_cast<QWaylandSurfaceLeaveEvent *>(e);
+
+ if (event->output()) {
+ QQuickWindow *oldWindow = static_cast<QQuickWindow *>(event->output()->window());
+ disconnect(oldWindow, &QQuickWindow::beforeSynchronizing,
+ this, &QWaylandQuickSurface::updateTexture);
+ disconnect(oldWindow, &QQuickWindow::sceneGraphInvalidated,
+ this, &QWaylandQuickSurface::invalidateTexture);
+ }
+
+ return true;
+ }
+
+ if (e->type() == static_cast<QEvent::Type>(QWaylandSurfaceEnterEvent::WaylandSurfaceEnter)) {
+ QWaylandSurfaceEnterEvent *event = static_cast<QWaylandSurfaceEnterEvent *>(e);
+
+ if (event->output()) {
+ QQuickWindow *window = static_cast<QQuickWindow *>(event->output()->window());
+ connect(window, &QQuickWindow::beforeSynchronizing,
+ this, &QWaylandQuickSurface::updateTexture,
+ Qt::DirectConnection);
+ connect(window, &QQuickWindow::sceneGraphInvalidated,
+ this, &QWaylandQuickSurface::invalidateTexture,
+ Qt::DirectConnection);
+ }
+
+ return true;
+ }
+
+ return QObject::event(e);
+}
void QWaylandQuickSurface::updateTexture()
{
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.h b/src/compositor/compositor_api/qwaylandquicksurface.h
index 1c7eea6c..4c37e667 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.h
+++ b/src/compositor/compositor_api/qwaylandquicksurface.h
@@ -67,6 +67,9 @@ public:
QObject *windowPropertyMap() const;
+private:
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
+
Q_SIGNALS:
void useTextureAlphaChanged();
void clientRenderingEnabledChanged();
diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index cbfe9205..e5ecb15b 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2014-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -63,6 +63,9 @@
QT_BEGIN_NAMESPACE
+const QEvent::Type QWaylandSurfaceEnterEvent::WaylandSurfaceEnter = (QEvent::Type)QEvent::registerEventType();
+const QEvent::Type QWaylandSurfaceLeaveEvent::WaylandSurfaceLeave = (QEvent::Type)QEvent::registerEventType();
+
QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *wlClient, quint32 id, int version, QWaylandCompositor *compositor, QWaylandSurface *surface)
: QtWayland::Surface(wlClient, id, version, compositor, surface)
, closing(false)
@@ -72,6 +75,63 @@ QWaylandSurfacePrivate::QWaylandSurfacePrivate(wl_client *wlClient, quint32 id,
{}
+class QWaylandSurfaceEnterEventPrivate
+{
+public:
+ QWaylandSurfaceEnterEventPrivate(QWaylandOutput *_output)
+ : output(_output)
+ {
+ }
+
+ QWaylandOutput *output;
+};
+
+
+QWaylandSurfaceEnterEvent::QWaylandSurfaceEnterEvent(QWaylandOutput *output)
+ : QEvent(WaylandSurfaceEnter)
+ , d(new QWaylandSurfaceEnterEventPrivate(output))
+{
+}
+
+QWaylandSurfaceEnterEvent::~QWaylandSurfaceEnterEvent()
+{
+ delete d;
+}
+
+QWaylandOutput *QWaylandSurfaceEnterEvent::output() const
+{
+ return d->output;
+}
+
+
+class QWaylandSurfaceLeaveEventPrivate
+{
+public:
+ QWaylandSurfaceLeaveEventPrivate(QWaylandOutput *_output)
+ : output(_output)
+ {
+ }
+
+ QWaylandOutput *output;
+};
+
+
+QWaylandSurfaceLeaveEvent::QWaylandSurfaceLeaveEvent(QWaylandOutput *output)
+ : QEvent(WaylandSurfaceLeave)
+ , d(new QWaylandSurfaceLeaveEventPrivate(output))
+{
+}
+
+QWaylandSurfaceLeaveEvent::~QWaylandSurfaceLeaveEvent()
+{
+ delete d;
+}
+
+QWaylandOutput *QWaylandSurfaceLeaveEvent::output() const
+{
+ return d->output;
+}
+
QWaylandSurface::QWaylandSurface(wl_client *client, quint32 id, int version, QWaylandCompositor *compositor)
: QObject(*new QWaylandSurfacePrivate(client, id, version, compositor, this))
@@ -239,12 +299,32 @@ QWaylandCompositor *QWaylandSurface::compositor() const
return d->compositor()->waylandCompositor();
}
-QWaylandOutput *QWaylandSurface::output() const
+QWaylandOutput *QWaylandSurface::mainOutput() const
{
Q_D(const QWaylandSurface);
- if (!d->output())
- return Q_NULLPTR;
- return d->output()->waylandOutput();
+
+ // Returns the output that contains the most if not all
+ // the surface (window managers will take care of setting
+ // this, defaults to the first output)
+ return d->mainOutput()->waylandOutput();
+}
+
+void QWaylandSurface::setMainOutput(QWaylandOutput *mainOutput)
+{
+ Q_D(QWaylandSurface);
+
+ if (mainOutput)
+ d->setMainOutput(mainOutput->handle());
+}
+
+QList<QWaylandOutput *> QWaylandSurface::outputs() const
+{
+ Q_D(const QWaylandSurface);
+
+ QList<QWaylandOutput *> list;
+ Q_FOREACH (QtWayland::Output *output, d->outputs())
+ list.append(output->waylandOutput());
+ return list;
}
QWindow::Visibility QWaylandSurface::visibility() const
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index e16bdb40..bc47e676 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2014-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -81,6 +81,38 @@ protected:
friend class QtWayland::Surface;
};
+class QWaylandSurfaceEnterEventPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceEnterEvent : public QEvent
+{
+public:
+ QWaylandSurfaceEnterEvent(QWaylandOutput *output);
+ ~QWaylandSurfaceEnterEvent();
+
+ QWaylandOutput *output() const;
+
+ static const QEvent::Type WaylandSurfaceEnter;
+
+private:
+ QWaylandSurfaceEnterEventPrivate *d;
+};
+
+class QWaylandSurfaceLeaveEventPrivate;
+
+class Q_COMPOSITOR_EXPORT QWaylandSurfaceLeaveEvent : public QEvent
+{
+public:
+ QWaylandSurfaceLeaveEvent(QWaylandOutput *output);
+ ~QWaylandSurfaceLeaveEvent();
+
+ QWaylandOutput *output() const;
+
+ static const QEvent::Type WaylandSurfaceLeave;
+
+private:
+ QWaylandSurfaceLeaveEventPrivate *d;
+};
+
class Q_COMPOSITOR_EXPORT QWaylandSurface : public QObject
{
Q_OBJECT
@@ -163,7 +195,10 @@ public:
QWaylandCompositor *compositor() const;
- QWaylandOutput *output() const;
+ QWaylandOutput *mainOutput() const;
+ void setMainOutput(QWaylandOutput *mainOutput);
+
+ QList<QWaylandOutput *> outputs() const;
QString className() const;
@@ -223,6 +258,7 @@ Q_SIGNALS:
friend class QWaylandSurfaceView;
friend class QWaylandSurfaceInterface;
+ friend class QtWayland::Surface;
};
QT_END_NAMESPACE
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
index c3951909..90a68c4f 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
@@ -372,7 +372,7 @@ QSGNode *QWaylandSurfaceItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeD
{
bool mapped = surface() && surface()->isMapped();
- if (!mapped || !m_provider->t || !m_paintEnabled) {
+ if (!mapped || !m_provider || !m_provider->t || !m_paintEnabled) {
delete oldNode;
return 0;
}
diff --git a/src/compositor/wayland_wrapper/qwlcompositor.cpp b/src/compositor/wayland_wrapper/qwlcompositor.cpp
index 43c9475e..2fd91f30 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor.cpp
+++ b/src/compositor/wayland_wrapper/qwlcompositor.cpp
@@ -300,6 +300,7 @@ void Compositor::compositor_create_surface(Resource *resource, uint32_t id)
{
QWaylandSurface *surface = new QWaylandSurface(resource->client(), id, resource->version(), m_qt_compositor);
m_surfaces << surface->handle();
+ surface->handle()->addToOutput(primaryOutput()->handle());
//BUG: This may not be an on-screen window surface though
m_qt_compositor->surfaceCreated(surface);
}
@@ -405,18 +406,6 @@ InputDevice* Compositor::defaultInputDevice()
return m_inputDevices.last()->handle();
}
-QList<QtWayland::Surface *> Compositor::surfacesForClient(wl_client *client)
-{
- QList<QtWayland::Surface *> ret;
-
- for (int i=0; i < m_surfaces.count(); ++i) {
- if (m_surfaces.at(i)->resource()->client() == client) {
- ret.append(m_surfaces.at(i));
- }
- }
- return ret;
-}
-
void Compositor::configureTouchExtension(int flags)
{
if (m_touchExtension)
diff --git a/src/compositor/wayland_wrapper/qwlcompositor_p.h b/src/compositor/wayland_wrapper/qwlcompositor_p.h
index 2a55ae49..1efbd2ee 100644
--- a/src/compositor/wayland_wrapper/qwlcompositor_p.h
+++ b/src/compositor/wayland_wrapper/qwlcompositor_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+** Copyright (C) 2014-2015 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
@@ -95,7 +95,6 @@ public:
void init();
void sendFrameCallbacks(QList<QWaylandSurface *> visibleSurfaces);
- void frameFinished(Surface *surface = 0);
InputDevice *defaultInputDevice();
@@ -126,8 +125,8 @@ public:
void initializeDefaultInputDevice();
void initializeWindowManagerProtocol();
- QList<Surface*> surfaces() const { return m_surfaces; }
- QList<Surface*> surfacesForClient(wl_client* client);
+ QList<Surface *> surfaces() const { return m_surfaces; }
+
QWaylandCompositor *waylandCompositor() const { return m_qt_compositor; }
struct wl_display *wl_display() const { return m_display->handle(); }
diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp
index b01ffa59..ba9338d3 100644
--- a/src/compositor/wayland_wrapper/qwloutput.cpp
+++ b/src/compositor/wayland_wrapper/qwloutput.cpp
@@ -43,9 +43,12 @@
#include "qwlcompositor_p.h"
#include "qwlextendedoutput_p.h"
+#include "qwlsurface_p.h"
#include <QtGui/QWindow>
#include <QRect>
+#include <QtCompositor/QWaylandSurface>
+#include <QtCompositor/QWaylandOutput>
QT_BEGIN_NAMESPACE
diff --git a/src/compositor/wayland_wrapper/qwloutput_p.h b/src/compositor/wayland_wrapper/qwloutput_p.h
index 06ff02ed..1bf6e01f 100644
--- a/src/compositor/wayland_wrapper/qwloutput_p.h
+++ b/src/compositor/wayland_wrapper/qwloutput_p.h
@@ -128,6 +128,7 @@ private:
QWaylandOutput::Subpixel m_subpixel;
QWaylandOutput::Transform m_transform;
int m_scaleFactor;
+ QList<QWaylandSurface *> m_surfaces;
void sendGeometryInfo();
};
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index e26eec8b..4cadbb59 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -114,7 +114,7 @@ Surface::Surface(struct wl_client *client, uint32_t id, int version, QWaylandCom
: QtWaylandServer::wl_surface(client, id, version)
, m_compositor(compositor->handle())
, m_waylandSurface(surface)
- , m_output(m_compositor->primaryOutput()->handle())
+ , m_mainOutput(0)
, m_buffer(0)
, m_surfaceMapped(false)
, m_attacher(0)
@@ -278,9 +278,66 @@ Compositor *Surface::compositor() const
return m_compositor;
}
-Output *Surface::output() const
+Output *Surface::mainOutput() const
{
- return m_output;
+ if (!m_mainOutput)
+ return m_compositor->primaryOutput()->handle();
+ return m_mainOutput;
+}
+
+void Surface::setMainOutput(Output *output)
+{
+ m_mainOutput = output;
+}
+
+QList<Output *> Surface::outputs() const
+{
+ return m_outputs;
+}
+
+void Surface::addToOutput(Output *output)
+{
+ if (!output)
+ return;
+
+ if (!m_mainOutput)
+ m_mainOutput = output;
+
+ if (m_outputs.contains(output))
+ return;
+
+ m_outputs.append(output);
+
+ QWaylandSurfaceEnterEvent event(output->waylandOutput());
+ QCoreApplication::sendEvent(waylandSurface(), &event);
+
+ // Send surface enter event
+ Q_FOREACH (Resource *resource, resourceMap().values()) {
+ QList<Output::Resource *> outputs = output->resourceMap().values();
+ for (int i = 0; i < outputs.size(); i++)
+ send_enter(resource->handle, outputs.at(i)->handle);
+ }
+}
+
+void Surface::removeFromOutput(Output *output)
+{
+ if (!output)
+ return;
+
+ m_outputs.removeOne(output);
+
+ if (m_outputs.size() == 0)
+ m_mainOutput = m_compositor->primaryOutput()->handle();
+
+ QWaylandSurfaceLeaveEvent event(output->waylandOutput());
+ QCoreApplication::sendEvent(waylandSurface(), &event);
+
+ // Send surface leave event
+ Q_FOREACH (Resource *resource, resourceMap().values()) {
+ QList<Output::Resource *> outputs = output->resourceMap().values();
+ for (int i = 0; i < outputs.size(); i++)
+ send_leave(resource->handle, outputs.at(i)->handle);
+ }
}
/*!
diff --git a/src/compositor/wayland_wrapper/qwlsurface_p.h b/src/compositor/wayland_wrapper/qwlsurface_p.h
index 0633a938..103b5994 100644
--- a/src/compositor/wayland_wrapper/qwlsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlsurface_p.h
@@ -113,7 +113,13 @@ public:
Compositor *compositor() const;
- Output *output() const;
+ Output *mainOutput() const;
+ void setMainOutput(Output *output);
+
+ QList<Output *> outputs() const;
+
+ void addToOutput(Output *output);
+ void removeFromOutput(Output *output);
QString className() const { return m_className; }
void setClassName(const QString &className);
@@ -162,7 +168,8 @@ protected:
Compositor *m_compositor;
QWaylandSurface *m_waylandSurface;
- Output *m_output;
+ Output *m_mainOutput;
+ QList<Output *> m_outputs;
QRegion m_damage;
SurfaceBuffer *m_buffer;