qRegisterMetaType<WaylandSurface*>("WaylandSurface*");
#endif
m_compositor->initializeHardwareIntegration();
+ m_compositor->initializeWindowManagerProtocol();
}
WaylandCompositor::~WaylandCompositor()
return d->surface;
}
+qint64 WaylandSurface::processId() const
+{
+ Q_D(const WaylandSurface);
+ return d->surface->processId();
+}
+
void WaylandSurface::sendMousePressEvent(const QPoint &pos, Qt::MouseButton button)
{
Q_D(WaylandSurface);
void setInputFocus();
Wayland::Surface *handle() const;
+ qint64 processId() const;
signals:
void mapped(const QRect &rect);
include ($$PWD/wayland_wrapper/wayland_wrapper.pri)
include ($$PWD/hardware_integration/hardware_integration.pri)
include ($$PWD/compositor_api/compositor_api.pri)
+include ($$PWD/windowmanagerprotocol/windowmanagerprotocol.pri)
#include <wayland-server.h>
#include "hardware_integration/graphicshardwareintegration.h"
+#include "waylandwindowmanagerintegration.h"
namespace Wayland {
#if defined (QT_COMPOSITOR_WAYLAND_GL)
m_graphics_hw_integration = GraphicsHardwareIntegration::createGraphicsHardwareIntegration(qt_compositor);
#endif
+ m_windowManagerWaylandProtocol = new WindowManagerServerIntegration(this);
if (wl_compositor_init(base(), &compositor_interface, m_display->handle())) {
fprintf(stderr, "Fatal: Error initializing compositor\n");
addClientResource(client, &surface->base()->resource, id, &wl_surface_interface,
&surface_interface, destroy_surface);
+ quint32 processId = m_windowManagerWaylandProtocol->pidForClient(client);
+ // if there is no PID, the client does not support the protocol.
+ surface->setProcessId(processId);
m_qt_compositor->surfaceCreated(surface->handle());
QList<struct wl_client *> prevClientList = clients();
{
wl_client *client = surface->base()->client;
- if (client)
+ if (client) {
+ m_windowManagerWaylandProtocol->removeClient(client);
wl_client_destroy(client);
+ }
}
void Compositor::setInputFocus(Surface *surface)
#endif
}
+void Compositor::initializeWindowManagerProtocol()
+{
+ m_windowManagerWaylandProtocol->initialize(m_display);
+}
+
bool Compositor::setDirectRenderSurface(Surface *surface)
{
#ifdef QT_COMPOSITOR_WAYLAND_GL
class WaylandCompositor;
class GraphicsHardwareIntegration;
class QWidget;
+class WindowManagerServerIntegration;
namespace Wayland {
GraphicsHardwareIntegration *graphicsHWIntegration() const;
void initializeHardwareIntegration();
+ void initializeWindowManagerProtocol();
bool setDirectRenderSurface(Surface *surface);
Surface *directRenderSurface() const {return m_directRenderSurface;}
#ifdef QT_COMPOSITOR_WAYLAND_GL
GraphicsHardwareIntegration *m_graphics_hw_integration;
#endif
+ WindowManagerServerIntegration *m_windowManagerWaylandProtocol;
};
}
, needsMap(false)
, textureCreatedForBuffer(false)
, directRenderBuffer(0)
+ , processId(0)
, surfaceBuffer(0)
, surfaceType(WaylandSurface::Invalid)
{
bool needsMap;
bool textureCreatedForBuffer;
wl_buffer *directRenderBuffer;
+ qint64 processId;
private:
struct wl_buffer *surfaceBuffer;
return d->qtSurface;
}
+wl_client *Surface::clientHandle() const
+{
+ Q_D(const Surface);
+ return d->client;
+}
+
+qint64 Surface::processId() const
+{
+ Q_D(const Surface);
+ return d->processId;
+}
+
+void Surface::setProcessId(qint64 processId)
+{
+ Q_D(Surface);
+ d->processId = processId;
+}
+
uint32_t toWaylandButton(Qt::MouseButton button)
{
switch (button) {
void setInputFocus();
WaylandSurface *handle() const;
+ wl_client *clientHandle() const;
+ qint64 processId() const;
+ void setProcessId(qint64 processId);
+ void setSurfaceCreationFinished(bool isCreated);
+
protected:
QScopedPointer<SurfacePrivate> d_ptr;
private:
--- /dev/null
+/*
+ * 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"
+
+static const struct wl_message wl_windowmanager_requests[] = {
+ { "map_client_to_process", "u", NULL },
+};
+
+WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
+ "wl_windowmanager", 1,
+ ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests,
+ 0, NULL,
+};
--- /dev/null
+/*
+ * 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
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-util.h"
+
+struct wl_client;
+
+struct wl_windowmanager;
+
+extern const struct wl_interface wl_windowmanager_interface;
+
+struct wl_windowmanager_interface {
+ void (*map_client_to_process)(struct wl_client *client,
+ struct wl_windowmanager *wl_windowmanager,
+ uint32_t processid);
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "waylandwindowmanagerintegration.h"
+
+#include "waylandobject.h"
+#include "wayland_wrapper/wldisplay.h"
+#include "wayland_wrapper/wlcompositor.h"
+
+#include "wayland-server.h"
+#include "wayland-windowmanager-server-protocol.h"
+
+#include <QtCore/QDebug>
+
+// the protocol files are generated with wayland-scanner, in the following manner:
+// wayland-scanner client-header < windowmanager.xml > wayland-windowmanager-client-protocol.h
+// wayland-scanner server-header < windowmanager.xml > wayland-windowmanager-server-protocol.h
+// wayland-scanner code < windowmanager.xml > wayland-windowmanager-protocol.c
+//
+// wayland-scanner can be found from wayland sources.
+
+class WindowManagerObject : public Wayland::Object<struct wl_object>
+{
+public:
+
+ void mapClientToProcess(wl_client *client, uint32_t processId)
+ {
+ WindowManagerServerIntegration::instance()->mapClientToProcess(client, processId);
+ }
+
+};
+
+void map_client_to_process(wl_client *client, struct wl_windowmanager *windowMgr, uint32_t processId)
+{
+ reinterpret_cast<WindowManagerObject *>(windowMgr)->mapClientToProcess(client, processId);
+}
+
+const static struct wl_windowmanager_interface windowmanager_interface = {
+ map_client_to_process
+};
+
+WindowManagerServerIntegration *WindowManagerServerIntegration::m_instance = 0;
+
+WindowManagerServerIntegration::WindowManagerServerIntegration(QObject *parent)
+ : QObject(parent)
+{
+ m_instance = this;
+}
+
+void WindowManagerServerIntegration::initialize(Wayland::Display *waylandDisplay)
+{
+ m_windowManagerObject = new WindowManagerObject();
+ waylandDisplay->addGlobalObject(m_windowManagerObject->base(),
+ &wl_windowmanager_interface, &windowmanager_interface, 0);
+}
+
+void WindowManagerServerIntegration::removeClient(wl_client *client)
+{
+ m_clientToProcessId.remove(client);
+}
+
+void WindowManagerServerIntegration::mapClientToProcess(wl_client *client, uint32_t processId)
+{
+ m_clientToProcessId.insert(client, processId);
+ emit clientMappedToProcess(client, processId);
+}
+
+
+qint64 WindowManagerServerIntegration::pidForClient(wl_client *client) const
+{
+ return m_clientToProcessId.value(client, 0);
+}
+
+WindowManagerServerIntegration *WindowManagerServerIntegration::instance()
+{
+ return m_instance;
+}
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Compositor.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WAYLANDWINDOWMANAGERINTEGRATION_H
+#define WAYLANDWINDOWMANAGERINTEGRATION_H
+
+#include <qwindowdefs.h>
+#include <stdint.h>
+#include "wayland_wrapper/wldisplay.h"
+
+#include <QObject>
+#include <QMap>
+
+
+struct wl_client;
+
+class WindowManagerObject;
+
+class WindowManagerServerIntegration : public QObject
+{
+ Q_OBJECT
+public:
+ WindowManagerServerIntegration(QObject *parent = 0);
+ static WindowManagerServerIntegration *instance();
+ void initialize(Wayland::Display *waylandDisplay);
+ void removeClient(wl_client *client);
+
+ qint64 pidForClient(wl_client *client) const;
+
+signals:
+ void clientMappedToProcess(wl_client *client, quint32 processId);
+
+private:
+ void mapClientToProcess(wl_client *client, uint32_t processId);
+
+private:
+ QMap<wl_client*, qint64> m_clientToProcessId;
+ static WindowManagerServerIntegration *m_instance;
+
+ WindowManagerObject *m_windowManagerObject;
+
+ friend class WindowManagerObject;
+};
+
+#endif // WAYLANDWINDOWMANAGERINTEGRATION_H
--- /dev/null
+<!--
+# /****************************************************************************
+# **
+# ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+# ** Contact: Nokia Corporation (qt-info@nokia.com)
+# **
+# ** This file is part of qt-compositor.
+# **
+# ****************************************************************************/
+-->
+<protocol name="wayland_windowmanager">
+ <interface name="wl_windowmanager" version="1">
+ <request name="map_client_to_process">
+ <arg name="processid" type="uint" />
+ </request>
+ </interface>
+
+</protocol>
--- /dev/null
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/waylandwindowmanagerintegration.h \
+ $$PWD/wayland-windowmanager-server-protocol.h
+
+SOURCES += \
+ $$PWD/waylandwindowmanagerintegration.cpp \
+ $$PWD/wayland-windowmanager-protocol.c
+
+