Generic property support for platform windows
QPlatformNativeInterface can now contain generic window properties in a QVariantMap, to facilitate communication with the compositor and clients for certain platforms. When window properties change, a signal is emitted from the respective QPlatformNativeInterface instance. The properties are intended to be read/writable from both client and server. Change-Id: I7b42f7910d03c0d309add6c7dbb1c9b66ad22a3f Reviewed-on: http://codereview.qt.nokia.com/3956 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
74cf3bfc2c
commit
6fd75df288
@ -50,4 +50,45 @@ void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resour
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Contains generic window properties that the platform may utilize.
|
||||
*/
|
||||
QVariantMap QPlatformNativeInterface::windowProperties(QPlatformWindow *window) const
|
||||
{
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a window property with \a name.
|
||||
|
||||
If the property does not exist, returns a default-constructed value.
|
||||
*/
|
||||
QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
|
||||
{
|
||||
Q_UNUSED(window);
|
||||
Q_UNUSED(name);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a window property with \a name. If the value does not exist, defaultValue is returned.
|
||||
*/
|
||||
QVariant QPlatformNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
|
||||
{
|
||||
Q_UNUSED(window);
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(defaultValue);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets a window property with \a name to \a value.
|
||||
*/
|
||||
void QPlatformNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
|
||||
{
|
||||
Q_UNUSED(window);
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(value);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -43,6 +43,8 @@
|
||||
#define QPLATFORMNATIVEINTERFACE_QPA_H
|
||||
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@ -51,11 +53,22 @@ QT_BEGIN_NAMESPACE
|
||||
QT_MODULE(Gui)
|
||||
|
||||
class QWidget;
|
||||
class QPlatformWindow;
|
||||
|
||||
class Q_GUI_EXPORT QPlatformNativeInterface
|
||||
class Q_GUI_EXPORT QPlatformNativeInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
|
||||
|
||||
virtual QVariantMap windowProperties(QPlatformWindow *window) const;
|
||||
virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
|
||||
virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
|
||||
virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
|
||||
|
||||
Q_SIGNALS:
|
||||
void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName);
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -40,10 +40,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwaylandnativeinterface.h"
|
||||
|
||||
#include "qwaylanddisplay.h"
|
||||
#include "qwaylandwindow.h"
|
||||
|
||||
#include "windowmanager_integration/qwaylandwindowmanagerintegration.h"
|
||||
|
||||
#include <QtGui/private/qapplication_p.h>
|
||||
#include <QDebug>
|
||||
|
||||
void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
|
||||
{
|
||||
@ -70,3 +73,32 @@ QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widg
|
||||
}
|
||||
return screen;
|
||||
}
|
||||
|
||||
QVariantMap QWaylandNativeInterface::windowProperties(QPlatformWindow *window) const
|
||||
{
|
||||
return m_windowProperties.value(window);
|
||||
}
|
||||
|
||||
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
|
||||
{
|
||||
const QVariantMap properties = m_windowProperties.value(window);
|
||||
return properties.value(name);
|
||||
}
|
||||
|
||||
QVariant QWaylandNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
|
||||
{
|
||||
const QVariantMap properties = m_windowProperties.value(window);
|
||||
return properties.value(name, defaultValue);
|
||||
}
|
||||
|
||||
void QWaylandNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
|
||||
{
|
||||
QVariantMap props = m_windowProperties.value(window);
|
||||
props.insert(name, value);
|
||||
m_windowProperties.insert(window, props);
|
||||
|
||||
QWaylandWindow *wlWindow = static_cast<QWaylandWindow*>(window);
|
||||
QWaylandWindowManagerIntegration::instance()->setWindowProperty(wlWindow, name, value);
|
||||
|
||||
emit windowPropertyChanged(window, name);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define QWAYLANDNATIVEINTERFACE_H
|
||||
|
||||
#include "qwaylandscreen.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QtGui/QPlatformNativeInterface>
|
||||
|
||||
class QWaylandNativeInterface : public QPlatformNativeInterface
|
||||
@ -52,8 +52,16 @@ public:
|
||||
void *nativeResourceForWidget(const QByteArray &resourceString,
|
||||
QWidget *widget);
|
||||
|
||||
QVariantMap windowProperties(QPlatformWindow *window) const;
|
||||
QVariant windowProperty(QPlatformWindow *window, const QString &name) const;
|
||||
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const;
|
||||
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value);
|
||||
|
||||
private:
|
||||
static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget);
|
||||
|
||||
private:
|
||||
QHash<QPlatformWindow*, QVariantMap> m_windowProperties;
|
||||
};
|
||||
|
||||
|
||||
|
@ -147,6 +147,9 @@ void QWaylandWindow::newSurfaceCreated()
|
||||
// do not damage the surface here, as this leads to graphical corruptions in the compositor until
|
||||
// the first frame has been rendered
|
||||
}
|
||||
#ifdef QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||
QWaylandWindowManagerIntegration::instance()->flushPropertyChanges(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWaylandWindow::frameCallback(struct wl_surface *surface, void *data, uint32_t time)
|
||||
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* 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_CLIENT_PROTOCOL_H
|
||||
#define WAYLAND_WINDOWMANAGER_CLIENT_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_listener {
|
||||
void (*client_onscreen_visibility)(void *data,
|
||||
struct wl_windowmanager *wl_windowmanager,
|
||||
int visible);
|
||||
void (*set_screen_rotation)(void *data,
|
||||
struct wl_windowmanager *wl_windowmanager,
|
||||
int rotation);
|
||||
};
|
||||
|
||||
static inline int
|
||||
wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager,
|
||||
const struct wl_windowmanager_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
|
||||
#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
|
||||
|
||||
static inline struct wl_windowmanager *
|
||||
wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version)
|
||||
{
|
||||
wl_display_bind(display, id, "wl_windowmanager", version);
|
||||
|
||||
return (struct wl_windowmanager *)
|
||||
wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
|
||||
{
|
||||
wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -40,17 +40,44 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qwaylandwindowmanagerintegration.h"
|
||||
#include "qwaylandwindowmanager-client-protocol.h"
|
||||
#include "wayland-windowmanager-client-protocol.h"
|
||||
#include "qwaylandwindow.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtGui/QPlatformNativeInterface>
|
||||
#include <QtGui/QPlatformWindow>
|
||||
#include <QtGui/QtEvents>
|
||||
#include <QCoreApplication>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QApplication>
|
||||
|
||||
const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::mWindowManagerListener = {
|
||||
#include <QDebug>
|
||||
|
||||
class QWaylandWindowManagerIntegrationPrivate {
|
||||
public:
|
||||
QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay);
|
||||
bool m_blockPropertyUpdates;
|
||||
QWaylandDisplay *m_waylandDisplay;
|
||||
struct wl_windowmanager *m_waylandWindowManager;
|
||||
QHash<QWaylandWindow*,QVariantMap> m_queuedProperties;
|
||||
|
||||
};
|
||||
|
||||
QWaylandWindowManagerIntegrationPrivate::QWaylandWindowManagerIntegrationPrivate(QWaylandDisplay *waylandDisplay)
|
||||
: m_blockPropertyUpdates(false)
|
||||
, m_waylandDisplay(waylandDisplay)
|
||||
, m_waylandWindowManager(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::m_instance = 0;
|
||||
|
||||
const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::m_windowManagerListener = {
|
||||
QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange,
|
||||
QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange,
|
||||
QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange
|
||||
};
|
||||
|
||||
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
|
||||
@ -59,10 +86,11 @@ QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegr
|
||||
}
|
||||
|
||||
QWaylandWindowManagerIntegration::QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay)
|
||||
: mWaylandDisplay(waylandDisplay)
|
||||
, mWaylandWindowManager(0)
|
||||
: d_ptr(new QWaylandWindowManagerIntegrationPrivate(waylandDisplay))
|
||||
{
|
||||
wl_display_add_global_listener(mWaylandDisplay->wl_display(),
|
||||
m_instance = this;
|
||||
|
||||
wl_display_add_global_listener(d_ptr->m_waylandDisplay->wl_display(),
|
||||
QWaylandWindowManagerIntegration::wlHandleListenerGlobal,
|
||||
this);
|
||||
}
|
||||
@ -72,9 +100,15 @@ QWaylandWindowManagerIntegration::~QWaylandWindowManagerIntegration()
|
||||
|
||||
}
|
||||
|
||||
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
|
||||
{
|
||||
return mWaylandWindowManager;
|
||||
Q_D(const QWaylandWindowManagerIntegration);
|
||||
return d->m_waylandWindowManager;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
|
||||
@ -82,29 +116,95 @@ void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *displa
|
||||
Q_UNUSED(version);
|
||||
if (strcmp(interface, "wl_windowmanager") == 0) {
|
||||
QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
|
||||
integration->mWaylandWindowManager = wl_windowmanager_create(display, id, 1);
|
||||
|
||||
wl_windowmanager_add_listener(integration->mWaylandWindowManager, &mWindowManagerListener, integration);
|
||||
integration->d_ptr->m_waylandWindowManager = wl_windowmanager_create(display, id, 1);
|
||||
wl_windowmanager *windowManager = integration->d_ptr->m_waylandWindowManager;
|
||||
wl_windowmanager_add_listener(windowManager, &m_windowManagerListener, integration);
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::mapClientToProcess(long long processId)
|
||||
{
|
||||
if (mWaylandWindowManager)
|
||||
wl_windowmanager_map_client_to_process(mWaylandWindowManager, (uint32_t) processId);
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
if (d->m_waylandWindowManager)
|
||||
wl_windowmanager_map_client_to_process(d->m_waylandWindowManager, (uint32_t) processId);
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &token)
|
||||
{
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
QByteArray authToken = token;
|
||||
if (authToken.isEmpty())
|
||||
authToken = qgetenv("WL_AUTHENTICATION_TOKEN");
|
||||
|
||||
if (mWaylandWindowManager && !authToken.isEmpty()) {
|
||||
wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData());
|
||||
if (d->m_waylandWindowManager && !authToken.isEmpty()) {
|
||||
wl_windowmanager_authenticate_with_token(d->m_waylandWindowManager, authToken.constData());
|
||||
}
|
||||
}
|
||||
|
||||
static wl_array writePropertyValue(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;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue)
|
||||
{
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
if (d->m_blockPropertyUpdates)
|
||||
return;
|
||||
|
||||
if (window->wl_surface()) {
|
||||
wl_array data = writePropertyValue(propertyValue);
|
||||
wl_windowmanager_update_generic_property(d->m_waylandWindowManager, window->wl_surface(),
|
||||
propertyName.toLatin1().constData(),
|
||||
&data);
|
||||
} else {
|
||||
QVariantMap props = d->m_queuedProperties.value(window);
|
||||
props.insert(propertyName, propertyValue);
|
||||
d->m_queuedProperties.insert(window, props);
|
||||
// ### TODO we'll need to add listening to destroyed() of QWindow that owns QWaylandWindow
|
||||
// once refactor changes are in, and connect to removeQueuedPropertiesForWindow().
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::flushPropertyChanges(QWaylandWindow *windowToFlush)
|
||||
{
|
||||
// write all changes we got while we did not have a surface.
|
||||
// this can happen during startup, for example, or while the window is hidden.
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
|
||||
if (!windowToFlush)
|
||||
return;
|
||||
|
||||
QVariantMap properties = d->m_queuedProperties.value(windowToFlush);
|
||||
wl_surface *surface = windowToFlush->wl_surface();
|
||||
|
||||
QMapIterator<QString, QVariant> pIt(properties);
|
||||
while (pIt.hasNext()) {
|
||||
pIt.next();
|
||||
wl_array data = writePropertyValue(pIt.value());
|
||||
wl_windowmanager_update_generic_property(d->m_waylandWindowManager, surface, pIt.key().toLatin1().constData(), &data);
|
||||
}
|
||||
|
||||
d->m_queuedProperties.clear();
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::removeQueuedPropertiesForWindow()
|
||||
{
|
||||
// TODO enable this later once refactor changes are in.
|
||||
// Q_D(QWaylandWindowManagerIntegration);
|
||||
// QWaylandWindow *window = 0;
|
||||
// d->m_queuedProperties.remove(window);
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible)
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
@ -120,3 +220,45 @@ void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *dat
|
||||
QScreenOrientationChangeEvent event(screenOrientation);
|
||||
QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
|
||||
struct wl_surface *surface,
|
||||
const char *propertyName, struct wl_array *propertyValue)
|
||||
{
|
||||
// window manager changes a window property
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(wl_windowmanager);
|
||||
|
||||
QVariant variantValue;
|
||||
QByteArray baValue = QByteArray((const char*)propertyValue->data, propertyValue->size);
|
||||
QDataStream ds(&baValue, QIODevice::ReadOnly);
|
||||
ds >> variantValue;
|
||||
|
||||
QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
|
||||
QWaylandWindowManagerIntegration *inst = QWaylandWindowManagerIntegration::instance();
|
||||
|
||||
QWidgetList widgets = qApp->topLevelWidgets();
|
||||
foreach (QWidget *widget, widgets) {
|
||||
QPlatformWindow *platformWindowForWidget = widget->platformWindow();
|
||||
if (!platformWindowForWidget)
|
||||
continue;
|
||||
QWaylandWindow *window = static_cast<QWaylandWindow*>(platformWindowForWidget);
|
||||
wl_surface *windowSurface = (wl_surface*)nativeInterface->nativeResourceForWidget(QByteArray("surface"), widget);
|
||||
if (windowSurface == surface) {
|
||||
inst->handleWindowPropertyChange(window, QString(propertyName), variantValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandWindowManagerIntegration::handleWindowPropertyChange(QWaylandWindow *window,
|
||||
const QString &propertyName, const QVariant &propertyValue)
|
||||
{
|
||||
Q_D(QWaylandWindowManagerIntegration);
|
||||
d->m_blockPropertyUpdates = true;
|
||||
|
||||
QPlatformNativeInterface *nativeInterface = qApp->platformNativeInterface();
|
||||
nativeInterface->setWindowProperty(window, propertyName, propertyValue);
|
||||
|
||||
d->m_blockPropertyUpdates = false;
|
||||
}
|
||||
|
@ -42,21 +42,37 @@
|
||||
#ifndef QWAYLANDWINDOWMANAGERINTEGRATION_H
|
||||
#define QWAYLANDWINDOWMANAGERINTEGRATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QScopedPointer>
|
||||
|
||||
#include "wayland-client.h"
|
||||
#include "qwaylanddisplay.h"
|
||||
|
||||
class QWaylandWindowManagerIntegration
|
||||
class QWaylandWindow;
|
||||
|
||||
class QWaylandWindowManagerIntegrationPrivate;
|
||||
|
||||
class QWaylandWindowManagerIntegration : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QWaylandWindowManagerIntegration)
|
||||
public:
|
||||
explicit QWaylandWindowManagerIntegration(QWaylandDisplay *waylandDisplay);
|
||||
virtual ~QWaylandWindowManagerIntegration();
|
||||
static QWaylandWindowManagerIntegration *createIntegration(QWaylandDisplay *waylandDisplay);
|
||||
struct wl_windowmanager *windowManager() const;
|
||||
|
||||
static QWaylandWindowManagerIntegration *instance();
|
||||
|
||||
void mapSurfaceToProcess(struct wl_surface *surface, long long processId);
|
||||
void mapClientToProcess(long long processId);
|
||||
void authenticateWithToken(const QByteArray &token = QByteArray());
|
||||
void setWindowProperty(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
|
||||
|
||||
void flushPropertyChanges(QWaylandWindow *windowToFlush);
|
||||
|
||||
private slots:
|
||||
void removeQueuedPropertiesForWindow();
|
||||
|
||||
private:
|
||||
static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
|
||||
@ -64,12 +80,17 @@ private:
|
||||
|
||||
static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible);
|
||||
static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation);
|
||||
static void wlHandleWindowPropertyChange(void *data, struct wl_windowmanager *wl_windowmanager,
|
||||
struct wl_surface *surface,
|
||||
const char *propertyName, struct wl_array *propertyValue);
|
||||
|
||||
void handleWindowPropertyChange(QWaylandWindow *window, const QString &propertyName, const QVariant &propertyValue);
|
||||
|
||||
private:
|
||||
QScopedPointer<QWaylandWindowManagerIntegrationPrivate> d_ptr;
|
||||
static QWaylandWindowManagerIntegration *m_instance;
|
||||
|
||||
QWaylandDisplay *mWaylandDisplay;
|
||||
struct wl_windowmanager *mWaylandWindowManager;
|
||||
|
||||
static const struct wl_windowmanager_listener mWindowManagerListener;
|
||||
static const struct wl_windowmanager_listener m_windowManagerListener;
|
||||
};
|
||||
|
||||
#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H
|
||||
|
@ -0,0 +1,96 @@
|
||||
#ifndef WAYLAND_WINDOWMANAGER_CLIENT_PROTOCOL_H
|
||||
#define WAYLAND_WINDOWMANAGER_CLIENT_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_listener {
|
||||
void (*client_onscreen_visibility)(void *data,
|
||||
struct wl_windowmanager *wl_windowmanager,
|
||||
int32_t visible);
|
||||
void (*set_screen_rotation)(void *data,
|
||||
struct wl_windowmanager *wl_windowmanager,
|
||||
int32_t rotation);
|
||||
void (*set_generic_property)(void *data,
|
||||
struct wl_windowmanager *wl_windowmanager,
|
||||
struct wl_surface *surface,
|
||||
const char *name,
|
||||
struct wl_array *value);
|
||||
};
|
||||
|
||||
static inline int
|
||||
wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager,
|
||||
const struct wl_windowmanager_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
|
||||
#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
|
||||
#define WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY 2
|
||||
|
||||
static inline struct wl_windowmanager *
|
||||
wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version)
|
||||
{
|
||||
wl_display_bind(display, id, "wl_windowmanager", version);
|
||||
|
||||
return (struct wl_windowmanager *)
|
||||
wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
|
||||
{
|
||||
wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid);
|
||||
}
|
||||
|
||||
static inline void
|
||||
wl_windowmanager_update_generic_property(struct wl_windowmanager *wl_windowmanager, struct wl_surface *surface, const char *name, struct wl_array *value)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
|
||||
WL_WINDOWMANAGER_UPDATE_GENERIC_PROPERTY, surface, name, value);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -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 = {
|
||||
|
@ -3,7 +3,7 @@ DEFINES += QT_WAYLAND_WINDOWMANAGER_SUPPORT
|
||||
contains(DEFINES, QT_WAYLAND_WINDOWMANAGER_SUPPORT) {
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/qwaylandwindowmanager-client-protocol.h \
|
||||
$$PWD/wayland-windowmanager-client-protocol.h \
|
||||
$$PWD/qwaylandwindowmanagerintegration.h
|
||||
|
||||
SOURCES += \
|
||||
|
Loading…
Reference in New Issue
Block a user