diff options
15 files changed, 168 insertions, 72 deletions
diff --git a/src/qt-compositor/compositor_api/waylandcompositor.cpp b/src/qt-compositor/compositor_api/waylandcompositor.cpp index 317ca2b..a682237 100644 --- a/src/qt-compositor/compositor_api/waylandcompositor.cpp +++ b/src/qt-compositor/compositor_api/waylandcompositor.cpp @@ -154,6 +154,11 @@ void WaylandCompositor::setScreenOrientation(qint32 orientationInDegrees) m_compositor->setScreenOrientation(orientationInDegrees); } +void WaylandCompositor::setOutputGeometry(const QRect &geometry) +{ + m_compositor->setOutputGeometry(geometry); +} + bool WaylandCompositor::isDragging() const { return m_compositor->isDragging(); diff --git a/src/qt-compositor/compositor_api/waylandcompositor.h b/src/qt-compositor/compositor_api/waylandcompositor.h index 841a9a7..11660b8 100644 --- a/src/qt-compositor/compositor_api/waylandcompositor.h +++ b/src/qt-compositor/compositor_api/waylandcompositor.h @@ -84,6 +84,7 @@ public: const char *socketName() const; void setScreenOrientation(qint32 orientationInDegrees); + void setOutputGeometry(const QRect &outputGeometry); bool isDragging() const; void sendDragMoveEvent(const QPoint &global, const QPoint &local, WaylandSurface *surface); diff --git a/src/qt-compositor/compositor_api/waylandsurface.cpp b/src/qt-compositor/compositor_api/waylandsurface.cpp index bb8104f..f16a03f 100644 --- a/src/qt-compositor/compositor_api/waylandsurface.cpp +++ b/src/qt-compositor/compositor_api/waylandsurface.cpp @@ -83,6 +83,18 @@ QByteArray WaylandSurface::authenticationToken() const return d->surface->authenticationToken(); } +QVariantMap WaylandSurface::windowProperties() const +{ + Q_D(const WaylandSurface); + return d->surface->windowProperties(); +} + +void WaylandSurface::setWindowProperty(const QString &name, const QVariant &value) +{ + Q_D(WaylandSurface); + d->surface->setWindowProperty(name, value); +} + void WaylandSurface::sendMousePressEvent(const QPoint &pos, Qt::MouseButton button) { Q_D(WaylandSurface); diff --git a/src/qt-compositor/compositor_api/waylandsurface.h b/src/qt-compositor/compositor_api/waylandsurface.h index 4c46565..dd6685b 100644 --- a/src/qt-compositor/compositor_api/waylandsurface.h +++ b/src/qt-compositor/compositor_api/waylandsurface.h @@ -43,6 +43,7 @@ #include <QtCore/QScopedPointer> #include <QtGui/QImage> +#include <QtCore/QVariantMap> #ifdef QT_COMPOSITOR_WAYLAND_GL #include <QtOpenGL/QGLContext> @@ -101,6 +102,8 @@ public: Wayland::Surface *handle() const; qint64 processId() const; QByteArray authenticationToken() const; + QVariantMap windowProperties() const; + void setWindowProperty(const QString &name, const QVariant &value); signals: void mapped(const QSize &size); diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp index d56f58e..453a9ac 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp @@ -231,6 +231,9 @@ Compositor::Compositor(WaylandCompositor *qt_compositor) m_graphics_hw_integration = GraphicsHardwareIntegration::createGraphicsHardwareIntegration(qt_compositor); #endif m_windowManagerWaylandProtocol = new WindowManagerServerIntegration(this); + connect(m_windowManagerWaylandProtocol, + SIGNAL(windowPropertyChanged(wl_client*,wl_surface*,QString,QVariant)), + SLOT(windowPropertyChanged(wl_client*,wl_surface*,QString,QVariant))); if (wl_compositor_init(base(), &compositor_interface, m_display->handle())) { fprintf(stderr, "Fatal: Error initializing compositor\n"); @@ -283,7 +286,7 @@ void Compositor::createSurface(struct wl_client *client, int id) addClientResource(client, &surface->base()->resource, id, &wl_surface_interface, &surface_interface, destroy_surface); - m_windowManagerWaylandProtocol->updateOrientation(client); + m_windowManagerWaylandProtocol->updateOrientation(client); m_qt_compositor->surfaceCreated(surface->handle()); QList<struct wl_client *> prevClientList = clients(); @@ -340,6 +343,15 @@ void Compositor::processWaylandEvents() fprintf(stderr, "wl_event_loop_dispatch error: %d\n", ret); } +void Compositor::windowPropertyChanged(wl_client *client, wl_surface *changedSurface, const QString &name, const QVariant &value) +{ + for(int i = 0; i < m_surfaces.length(); ++i) { + Surface *surface = m_surfaces[i]; + if (surface->clientHandle() == client && surface->base() == changedSurface) { + surface->setWindowProperty(name, value, false); + } + } +} void Compositor::surfaceDestroyed(Surface *surface) { @@ -459,6 +471,11 @@ void Compositor::setScreenOrientation(qint32 orientationInDegrees) } } +void Compositor::setOutputGeometry(const QRect &geometry) +{ + m_output.setGeometry(geometry); +} + } // namespace Wayland wl_input_device * Wayland::Compositor::defaultInputDevice() diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.h b/src/qt-compositor/wayland_wrapper/wlcompositor.h index fd88df0..6f357ab 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.h +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.h @@ -107,6 +107,7 @@ public: QList<struct wl_client *> clients() const; void setScreenOrientation(qint32 orientationInDegrees); + void setOutputGeometry(const QRect &geometry); bool isDragging() const; void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface); @@ -117,6 +118,7 @@ signals: private slots: void processWaylandEvents(); + void windowPropertyChanged(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value); private: Display *m_display; diff --git a/src/qt-compositor/wayland_wrapper/wloutput.cpp b/src/qt-compositor/wayland_wrapper/wloutput.cpp index fbc3ec2..ba3e45a 100644 --- a/src/qt-compositor/wayland_wrapper/wloutput.cpp +++ b/src/qt-compositor/wayland_wrapper/wloutput.cpp @@ -50,7 +50,7 @@ void output_post_geometry(struct wl_client *client, struct wl_object *global, ui Q_UNUSED(version); Output *output = wayland_cast<Output *>(global); - wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, 0, 0, + wl_client_post_event(client, global, WL_OUTPUT_GEOMETRY, output->x(), output->y(), output->size().width(), output->size().height(),0,"",""); wl_client_post_event(client,global,WL_OUTPUT_MODE, 0,output->size().width(),output->size().height()); @@ -62,7 +62,12 @@ Output::Output() , m_numQueued(0) { QScreen *screen = QGuiApplication::primaryScreen(); - m_size = screen->availableGeometry().size(); + m_geometry = QRect(QPoint(0, 0), screen->availableGeometry().size()); } +void Output::setGeometry(const QRect &geometry) +{ + m_geometry = geometry; } + +} // namespace Wayland diff --git a/src/qt-compositor/wayland_wrapper/wloutput.h b/src/qt-compositor/wayland_wrapper/wloutput.h index cd899a5..cf64955 100644 --- a/src/qt-compositor/wayland_wrapper/wloutput.h +++ b/src/qt-compositor/wayland_wrapper/wloutput.h @@ -43,7 +43,7 @@ #include "waylandobject.h" -#include <QtCore/QSize> +#include <QtCore/QRect> namespace Wayland { @@ -52,10 +52,14 @@ class Output : public Object<struct wl_object> public: Output(); - QSize size() const { return m_size; } + void setGeometry(const QRect &geometry); + + int x() const { return m_geometry.x(); } + int y() const { return m_geometry.y(); } + QSize size() const { return m_geometry.size(); } private: - QSize m_size; + QRect m_geometry; int m_displayId; int m_numQueued; }; diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.cpp b/src/qt-compositor/wayland_wrapper/wlsurface.cpp index 6621882..f8862ee 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.cpp +++ b/src/qt-compositor/wayland_wrapper/wlsurface.cpp @@ -124,6 +124,7 @@ public: struct wl_buffer *directRenderBuffer; qint64 processId; QByteArray authenticationToken; + QVariantMap windowProperties; QPoint lastMousePos; @@ -292,6 +293,27 @@ QByteArray Surface::authenticationToken() const return WindowManagerServerIntegration::instance()->managedClient(d->client)->authenticationToken(); } +QVariantMap Surface::windowProperties() const +{ + Q_D(const Surface); + return d->windowProperties; +} + +QVariant Surface::windowProperty(const QString &propertyName) const +{ + Q_D(const Surface); + QVariantMap props = d->windowProperties; + return props.value(propertyName); +} + +void Surface::setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient) +{ + Q_D(Surface); + d->windowProperties.insert(name, value); + if (writeUpdateToClient) + WindowManagerServerIntegration::instance()->setWindowProperty(d->client, base(), name, value); +} + uint32_t toWaylandButton(Qt::MouseButton button) { #ifndef BTN_LEFT @@ -425,7 +447,7 @@ void Surface::sendOnScreenVisibilityChange(bool visible) { #ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT Q_D(Surface); - WindowManagerServerIntegration::instance()->changeScreenVisibility(d->client, visible ? 1 : 0); + WindowManagerServerIntegration::instance()->setVisibilityOnScreen(d->client, visible); #endif } diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.h b/src/qt-compositor/wayland_wrapper/wlsurface.h index 61f1a21..31e10c7 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.h +++ b/src/qt-compositor/wayland_wrapper/wlsurface.h @@ -106,6 +106,10 @@ public: QByteArray authenticationToken() const; void setAuthenticationToken(const QByteArray &authenticationToken); + QVariantMap windowProperties() const; + QVariant windowProperty(const QString &propertyName) const; + void setWindowProperty(const QString &name, const QVariant &value, bool writeUpdateToClient = true); + void setSurfaceCreationFinished(bool isCreated); QPoint lastMousePos() const; diff --git a/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-protocol.c b/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-protocol.c index fcafacd..1d231f5 100644 --- a/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-protocol.c +++ b/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-protocol.c @@ -1,38 +1,29 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - - #include <stdlib.h> #include <stdint.h> #include "wayland-util.h" +extern const struct wl_interface wl_surface_interface; + +static const struct wl_interface *types[] = { + NULL, + &wl_surface_interface, + NULL, + NULL, + &wl_surface_interface, + NULL, + NULL, +}; + static const struct wl_message wl_windowmanager_requests[] = { - { "map_client_to_process", "u", NULL }, - { "authenticate_with_token", "s", NULL }, + { "map_client_to_process", "u", types + 0 }, + { "authenticate_with_token", "s", types + 0 }, + { "update_generic_property", "osa", types + 1 }, }; static const struct wl_message wl_windowmanager_events[] = { - { "client_onscreen_visibility", "i", NULL }, - { "set_screen_rotation", "i", NULL }, + { "client_onscreen_visibility", "i", types + 0 }, + { "set_screen_rotation", "i", types + 0 }, + { "set_generic_property", "osa", types + 4 }, }; WL_EXPORT const struct wl_interface wl_windowmanager_interface = { diff --git a/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-server-protocol.h b/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-server-protocol.h index acc94ec..e1e55e8 100644 --- a/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-server-protocol.h +++ b/src/qt-compositor/windowmanagerprotocol/wayland-windowmanager-server-protocol.h @@ -1,26 +1,3 @@ -/* - * Copyright © 2010 Kristian Høgsberg - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting documentation, and - * that the name of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The copyright holders make no representations - * about the suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - - #ifndef WAYLAND_WINDOWMANAGER_SERVER_PROTOCOL_H #define WAYLAND_WINDOWMANAGER_SERVER_PROTOCOL_H @@ -45,10 +22,16 @@ struct wl_windowmanager_interface { void (*authenticate_with_token)(struct wl_client *client, struct wl_windowmanager *wl_windowmanager, const char *processid); + void (*update_generic_property)(struct wl_client *client, + struct wl_windowmanager *wl_windowmanager, + struct wl_surface *surface, + const char *name, + struct wl_array *value); }; #define WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY 0 #define WL_WINDOWMANAGER_SET_SCREEN_ROTATION 1 +#define WL_WINDOWMANAGER_SET_GENERIC_PROPERTY 2 #ifdef __cplusplus } diff --git a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp index 5fb9ea0..3d47173 100644 --- a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp +++ b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.cpp @@ -61,19 +61,22 @@ public: void mapClientToProcess(wl_client *client, uint32_t processId) { - //qDebug() << "COMPOSITOR:" << Q_FUNC_INFO << client << processId; WindowManagerServerIntegration::instance()->mapClientToProcess(client, processId); } void authenticateWithToken(wl_client *client, const char *authenticationToken) { - //qDebug() << "COMPOSITOR:" << Q_FUNC_INFO << client << authenticationToken; WindowManagerServerIntegration::instance()->authenticateWithToken(client, authenticationToken); } void changeScreenVisibility(wl_client *client, int visible) { - WindowManagerServerIntegration::instance()->changeScreenVisibility(client, visible); + WindowManagerServerIntegration::instance()->setVisibilityOnScreen(client, visible); + } + + void updateWindowProperty(wl_client *client, wl_surface *surface, const char *name, struct wl_array *value) + { + WindowManagerServerIntegration::instance()->updateWindowProperty(client, surface, name, value); } }; @@ -88,9 +91,15 @@ void authenticate_with_token(wl_client *client, struct wl_windowmanager *windowM reinterpret_cast<WindowManagerObject *>(windowMgr)->authenticateWithToken(client, wl_authentication_token); } +void update_generic_property(wl_client *client, struct wl_windowmanager *windowMgr, wl_surface *surface, const char *name, struct wl_array *value) +{ + reinterpret_cast<WindowManagerObject *>(windowMgr)->updateWindowProperty(client, surface, name, value); +} + const static struct wl_windowmanager_interface windowmanager_interface = { map_client_to_process, - authenticate_with_token + authenticate_with_token, + update_generic_property }; WindowManagerServerIntegration *WindowManagerServerIntegration::m_instance = 0; @@ -133,12 +142,17 @@ void WindowManagerServerIntegration::authenticateWithToken(wl_client *client, co emit clientAuthenticated(client); } -void WindowManagerServerIntegration::changeScreenVisibility(wl_client *client, int visible) +void WindowManagerServerIntegration::setVisibilityOnScreen(wl_client *client, bool visible) { - m_managedClients[client]->m_isVisibleOnScreen = visible != 0; + wl_client_post_event(client, m_windowManagerObject->base(), + WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY, visible ? 1 : 0); +} +void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, qint32 orientationInDegrees) +{ + m_orientationInDegrees = orientationInDegrees; wl_client_post_event(client, m_windowManagerObject->base(), - WL_WINDOWMANAGER_CLIENT_ONSCREEN_VISIBILITY, visible); + WL_WINDOWMANAGER_SET_SCREEN_ROTATION, orientationInDegrees); } void WindowManagerServerIntegration::updateOrientation(wl_client *client) @@ -146,11 +160,30 @@ void WindowManagerServerIntegration::updateOrientation(wl_client *client) setScreenOrientation(client, m_orientationInDegrees); } -void WindowManagerServerIntegration::setScreenOrientation(wl_client *client, qint32 orientationInDegrees) +// client -> server +void WindowManagerServerIntegration::updateWindowProperty(wl_client *client, wl_surface *surface, const char *name, struct wl_array *value) { - m_orientationInDegrees = orientationInDegrees; + QVariant variantValue; + QByteArray byteValue((const char*)value->data, value->size); + QDataStream ds(&byteValue, QIODevice::ReadOnly); + ds >> variantValue; + + emit windowPropertyChanged(client, surface, QString(name), variantValue); +} + +// server -> client +void WindowManagerServerIntegration::setWindowProperty(wl_client *client, wl_surface *surface, const QString &name, const QVariant &value) +{ + QByteArray byteValue; + QDataStream ds(&byteValue, QIODevice::WriteOnly); + ds << value; + wl_array data; + data.size = byteValue.size(); + data.data = (void*) byteValue.constData(); + data.alloc = 0; + wl_client_post_event(client, m_windowManagerObject->base(), - WL_WINDOWMANAGER_SET_SCREEN_ROTATION, orientationInDegrees); + WL_WINDOWMANAGER_SET_GENERIC_PROPERTY, surface, name.toLatin1().constData(), &data); } WaylandManagedClient *WindowManagerServerIntegration::managedClient(wl_client *client) const diff --git a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h index be7c609..1692688 100644 --- a/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h +++ b/src/qt-compositor/windowmanagerprotocol/waylandwindowmanagerintegration.h @@ -47,7 +47,7 @@ #include <QObject> #include <QMap> - +#include <QVariant> struct wl_client; @@ -69,13 +69,16 @@ public: WaylandManagedClient *managedClient(wl_client *client) const; - void changeScreenVisibility(wl_client *client, int visible); + void setVisibilityOnScreen(wl_client *client, bool visible); void setScreenOrientation(wl_client *client, qint32 orientationInDegrees); void updateOrientation(wl_client *client); + void updateWindowProperty(wl_client *client, struct wl_surface *surface, const char *name, struct wl_array *value); + void setWindowProperty(wl_client *client, struct wl_surface *surface, const QString &name, const QVariant &value); signals: void clientAuthenticated(wl_client *client); + void windowPropertyChanged(wl_client *client, struct wl_surface *surface, const QString &name, const QVariant &value); private: void mapClientToProcess(wl_client *client, uint32_t processId); @@ -97,13 +100,10 @@ public: WaylandManagedClient(); qint64 processId() const; QByteArray authenticationToken() const; - bool isVisibleOnScreen() const { return m_isVisibleOnScreen; } - qint32 orientation() const; private: qint64 m_processId; QByteArray m_authenticationToken; - bool m_isVisibleOnScreen; friend class WindowManagerServerIntegration; }; diff --git a/src/qt-compositor/windowmanagerprotocol/windowmanager.xml b/src/qt-compositor/windowmanagerprotocol/windowmanager.xml index 7356e42..f69f658 100644 --- a/src/qt-compositor/windowmanagerprotocol/windowmanager.xml +++ b/src/qt-compositor/windowmanagerprotocol/windowmanager.xml @@ -28,5 +28,19 @@ <event name="set_screen_rotation"> <arg name="rotation" type="int"/> </event> + + <!--sends a generic property to the client --> + <event name="set_generic_property"> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="name" type="string"/> + <arg name="value" type="array"/> + </event> + + <!-- update generic property from client to server --> + <request name="update_generic_property"> + <arg name="surface" type="object" interface="wl_surface"/> + <arg name="name" type="string"/> + <arg name="value" type="array"/> + </request> </interface> </protocol> |