Merge remote-tracking branch 'origin/5.9' into dev

Change-Id: I7285dfeaac0d7963607930904aa017bedb1e48ab
This commit is contained in:
Liang Qi 2017-04-21 11:10:27 +02:00
commit d862329074
29 changed files with 165 additions and 101 deletions

View File

@ -26,9 +26,9 @@
"Files": "ivi-controller.xml ivi-application.xml",
"Description": "\"Wayland IVI Extension\" is forked from IVI Layer Management to define a common set of APIs by wayland style protocol and provide reference implementation which can be loaded on Weston.",
"Homepage": "http://projects.genivi.org/wayland-ivi-extension",
"Homepage": "https://at.projects.genivi.org/wiki/display/WIE/Wayland+IVI+Extension+Home",
"Version": "1.9.1",
"DownloadLocation": "http://git.projects.genivi.org/?p=wayland-ivi-extension.git;a=commit;h=44598504503eea5ac7f94c88477a5a78bda01f30",
"DownloadLocation": "https://github.com/GENIVI/wayland-ivi-extension/releases/tag/1.9.1",
"LicenseId": "MIT",
"License": "MIT License",
"LicenseFile": "MIT_LICENSE.txt",

View File

@ -23,7 +23,6 @@ QMAKE_USE += wayland-client
INCLUDEPATH += $$PWD/../shared
WAYLANDCLIENTSOURCES += \
../3rdparty/protocol/wayland.xml \
../extensions/surface-extension.xml \
../extensions/touch-extension.xml \
../extensions/qtkey-extension.xml \
@ -32,6 +31,9 @@ WAYLANDCLIENTSOURCES += \
../3rdparty/protocol/xdg-shell.xml \
../3rdparty/protocol/xdg-shell-unstable-v6.xml \
WAYLANDCLIENTSOURCES_SYSTEM += \
../3rdparty/protocol/wayland.xml \
SOURCES += qwaylandintegration.cpp \
qwaylandnativeinterface.cpp \
qwaylandshmbackingstore.cpp \
@ -40,9 +42,6 @@ SOURCES += qwaylandintegration.cpp \
qwaylandwindow.cpp \
qwaylandscreen.cpp \
qwaylandshmwindow.cpp \
qwaylanddataoffer.cpp \
qwaylanddatadevicemanager.cpp \
qwaylanddatasource.cpp \
qwaylandshellsurface.cpp \
qwaylandwlshellsurface.cpp \
qwaylandwlshellintegration.cpp \
@ -76,9 +75,6 @@ HEADERS += qwaylandintegration_p.h \
qwaylandinputdevice_p.h \
qwaylandbuffer_p.h \
qwaylandshmwindow_p.h \
qwaylanddataoffer_p.h \
qwaylanddatadevicemanager_p.h \
qwaylanddatasource_p.h \
qwaylandshellsurface_p.h \
qwaylandwlshellsurface_p.h \
qwaylandwlshellintegration_p.h \
@ -123,13 +119,25 @@ qtConfig(cursor) {
SOURCES += \
qwaylandcursor.cpp
}
qtConfig(wayland-datadevice) {
HEADERS += \
qwaylanddatadevice_p.h \
qwaylanddatadevicemanager_p.h \
qwaylanddataoffer_p.h \
qwaylanddatasource_p.h
SOURCES += \
qwaylanddatadevice.cpp \
qwaylanddatadevicemanager.cpp \
qwaylanddataoffer.cpp \
qwaylanddatasource.cpp
}
qtConfig(draganddrop) {
HEADERS += \
qwaylanddnd_p.h \
qwaylanddatadevice_p.h
qwaylanddnd_p.h
SOURCES += \
qwaylanddnd.cpp \
qwaylanddatadevice.cpp
qwaylanddnd.cpp
}
CONFIG += generated_privates

View File

@ -76,13 +76,17 @@
"condition": "!config.win32 && libs.wayland-client && libs.wayland-cursor && tests.wayland-scanner",
"output": [ "privateFeature" ]
},
"wayland-datadevice": {
"condition": "features.draganddrop || features.clipboard",
"output": [ "privateFeature" ]
},
"wayland-egl": {
"label": "EGL",
"condition": "features.wayland-client && features.opengl && features.egl && libs.wayland-egl",
"output": [ "privateFeature" ]
},
"wayland-brcm": {
"label": "Rasberry Pi",
"label": "Raspberry Pi",
"condition": "features.wayland-client && features.eglfs_brcm",
"output": [ "privateFeature" ]
},

View File

@ -211,7 +211,6 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
p.setRenderHint(QPainter::Antialiasing);
// Title bar
QPoint gradCenter(top.center()+ QPoint(30, 60));
QLinearGradient grad(top.topLeft(), top.bottomLeft());
QColor base(m_backgroundColor);
grad.setColorAt(0, base.lighter(100));

View File

@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
class QWaylandXCompositeEglClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin
class QWaylandXCompositeEglClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-egl.json")
@ -52,7 +52,7 @@ public:
QWaylandClientBufferIntegration *create(const QString&, const QStringList&) override;
};
QWaylandClientBufferIntegration *QWaylandXCompositeEglClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList)
QWaylandClientBufferIntegration *QWaylandXCompositeEglClientBufferPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
Q_UNUSED(system);

View File

@ -11,5 +11,5 @@ SOURCES += \
main.cpp
PLUGIN_TYPE = wayland-graphics-integration-client
PLUGIN_CLASS_NAME = QWaylandXCompositeEglClientBufferIntegrationPlugin
PLUGIN_CLASS_NAME = QWaylandXCompositeEglClientBufferPlugin
load(qt_plugin)

View File

@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
class QWaylandXCompositeGlxClientBufferIntegrationPlugin : public QWaylandClientBufferIntegrationPlugin
class QWaylandXCompositeGlxClientBufferPlugin : public QWaylandClientBufferIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QWaylandClientBufferIntegrationFactoryInterface_iid FILE "xcomposite-glx.json")
@ -52,7 +52,7 @@ public:
QWaylandClientBufferIntegration *create(const QString&, const QStringList&) override;
};
QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferIntegrationPlugin::create(const QString& system, const QStringList& paramList)
QWaylandClientBufferIntegration *QWaylandXCompositeGlxClientBufferPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
Q_UNUSED(system);

View File

@ -8,5 +8,5 @@ SOURCES += \
main.cpp
PLUGIN_TYPE = wayland-graphics-integration-client
PLUGIN_CLASS_NAME = QWaylandXCompositeGlxClientBufferIntegrationPlugin
PLUGIN_CLASS_NAME = QWaylandXCompositeGlxClientBufferPlugin
load(qt_plugin)

View File

@ -44,8 +44,6 @@
#include "qwaylanddatasource_p.h"
#include "qwaylanddatadevice_p.h"
#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -117,5 +115,3 @@ bool QWaylandClipboard::ownsMode(QClipboard::Mode mode) const
}
QT_END_NAMESPACE
#endif // draganddrop

View File

@ -57,7 +57,8 @@
#include <QtWaylandClient/qtwaylandclientglobal.h>
#if QT_CONFIG(draganddrop)
QT_REQUIRE_CONFIG(clipboard);
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -85,6 +86,4 @@ private:
QT_END_NAMESPACE
#endif // draganddrop
#endif // QWAYLANDCLIPBOARD_H

View File

@ -143,31 +143,6 @@ void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
mDisplay->setCursor(buffer, image);
}
void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
inputDevice->setCursor(buffer, image);
}
}
void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
inputDevice->setCursor(buffer, hotSpot);
}
}
QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
{
return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
}
void QWaylandCursor::pointerEvent(const QMouseEvent &event)
{
mLastPos = event.globalPos();

View File

@ -58,8 +58,6 @@
#include <qpa/qplatformdrag.h>
#include <qpa/qwindowsysteminterface.h>
#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -103,6 +101,7 @@ void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source)
m_selectionSource.reset(source);
}
#if QT_CONFIG(draganddrop)
QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
{
return m_dragOffer.data();
@ -124,12 +123,14 @@ void QWaylandDataDevice::cancelDrag()
{
m_dragSource.reset();
}
#endif
void QWaylandDataDevice::data_device_data_offer(struct ::wl_data_offer *id)
{
new QWaylandDataOffer(m_display, id);
}
#if QT_CONFIG(draganddrop)
void QWaylandDataDevice::data_device_drop()
{
QDrag *drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->currentDrag();
@ -229,6 +230,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, 0);
}
}
#endif // QT_CONFIG(draganddrop)
void QWaylandDataDevice::data_device_selection(wl_data_offer *id)
{
@ -250,6 +252,7 @@ void QWaylandDataDevice::selectionSourceCancelled()
#endif
}
#if QT_CONFIG(draganddrop)
void QWaylandDataDevice::dragSourceCancelled()
{
m_dragSource.reset();
@ -272,9 +275,8 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
}
return pnt;
}
#endif // QT_CONFIG(draganddrop)
}
QT_END_NAMESPACE
#endif // draganddrop

View File

@ -52,14 +52,14 @@
// We mean it.
//
#include <qtwaylandclientglobal.h>
#include <qtwaylandclientglobal_p.h>
#include <QObject>
#include <QPointer>
#include <QPoint>
#include <QtWaylandClient/private/qwayland-wayland.h>
#if QT_CONFIG(draganddrop)
QT_REQUIRE_CONFIG(wayland_datadevice);
QT_BEGIN_NAMESPACE
@ -87,25 +87,35 @@ public:
QWaylandDataSource *selectionSource() const;
void setSelectionSource(QWaylandDataSource *source);
#if QT_CONFIG(draganddrop)
QWaylandDataOffer *dragOffer() const;
void startDrag(QMimeData *mimeData, QWaylandWindow *icon);
void cancelDrag();
#endif
protected:
void data_device_data_offer(struct ::wl_data_offer *id) override;
#if QT_CONFIG(draganddrop)
void data_device_drop() override;
void data_device_enter(uint32_t serial, struct ::wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct ::wl_data_offer *id) override;
void data_device_leave() override;
void data_device_motion(uint32_t time, wl_fixed_t x, wl_fixed_t y) override;
#endif
void data_device_selection(struct ::wl_data_offer *id) override;
private Q_SLOTS:
void selectionSourceCancelled();
#if QT_CONFIG(draganddrop)
void dragSourceCancelled();
void dragSourceTargetChanged(const QString &mimeType);
#endif
private:
#if QT_CONFIG(draganddrop)
QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
#endif
QWaylandDisplay *m_display;
QWaylandInputDevice *m_inputDevice;
@ -123,6 +133,4 @@ private:
QT_END_NAMESPACE
#endif // draganddrop
#endif // QWAYLANDDATADEVICE_H

View File

@ -46,8 +46,6 @@
#include <QtCore/QDebug>
#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -82,5 +80,3 @@ QWaylandDisplay *QWaylandDataDeviceManager::display() const
}
QT_END_NAMESPACE
#endif // draganddrop

View File

@ -51,10 +51,10 @@
// We mean it.
//
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
#if QT_CONFIG(draganddrop)
QT_REQUIRE_CONFIG(wayland_datadevice);
QT_BEGIN_NAMESPACE
@ -83,6 +83,4 @@ private:
QT_END_NAMESPACE
#endif // draganddrop
#endif // QWAYLANDDATADEVICEMANAGER_H

View File

@ -47,8 +47,6 @@
#include <QtCore/QDebug>
#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -183,5 +181,3 @@ int QWaylandMimeData::readData(int fd, QByteArray &data) const
}
QT_END_NAMESPACE
#endif // draganddrop

View File

@ -53,10 +53,11 @@
#include <QtGui/private/qdnd_p.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
#if QT_CONFIG(draganddrop)
QT_REQUIRE_CONFIG(wayland_datadevice);
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -106,5 +107,4 @@ private:
}
QT_END_NAMESPACE
#endif // draganddrop
#endif

View File

@ -50,8 +50,6 @@
#include <unistd.h>
#include <signal.h>
#if QT_CONFIG(draganddrop)
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@ -108,5 +106,3 @@ void QWaylandDataSource::data_source_target(const QString &mime_type)
}
QT_END_NAMESPACE
#endif // draganddrop

View File

@ -54,9 +54,9 @@
#include <QObject>
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
#if QT_CONFIG(draganddrop)
QT_REQUIRE_CONFIG(wayland_datadevice);
QT_BEGIN_NAMESPACE
@ -94,6 +94,4 @@ private:
QT_END_NAMESPACE
#endif // draganddrop
#endif // QWAYLANDDATASOURCE_H

View File

@ -47,7 +47,9 @@
#if QT_CONFIG(clipboard)
#include "qwaylandclipboard_p.h"
#endif
#if QT_CONFIG(wayland_datadevice)
#include "qwaylanddatadevicemanager_p.h"
#endif
#include "qwaylandhardwareintegration_p.h"
#include "qwaylandxdgshell_p.h"
#include "qwaylandxdgsurface_p.h"
@ -122,7 +124,7 @@ QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() co
QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
: mWaylandIntegration(waylandIntegration)
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
, mDndSelectionHandler(0)
#endif
, mWindowExtension(0)
@ -162,7 +164,7 @@ QWaylandDisplay::~QWaylandDisplay(void)
mWaylandIntegration->destroyScreen(screen);
}
mScreens.clear();
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
delete mDndSelectionHandler.take();
#endif
wl_display_disconnect(mDisplay);
@ -257,7 +259,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
} else if (interface == QStringLiteral("wl_seat")) {
QWaylandInputDevice *inputDevice = mWaylandIntegration->createInputDevice(this, version, id);
mInputDevices.append(inputDevice);
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
} else if (interface == QStringLiteral("wl_data_device_manager")) {
mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
#endif
@ -421,7 +423,14 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
if (mLastKeyboardFocus == keyboardFocus)
return;
mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
if (mWaylandIntegration->mShellIntegration) {
mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
} else {
if (keyboardFocus)
handleWindowActivated(keyboardFocus);
if (mLastKeyboardFocus)
handleWindowDeactivated(mLastKeyboardFocus);
}
mLastKeyboardFocus = keyboardFocus;
}
@ -461,6 +470,33 @@ void QWaylandDisplay::requestWaylandSync()
wl_callback_add_listener(mSyncCallback, &syncCallbackListener, this);
}
QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
{
return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
}
#if QT_CONFIG(cursor)
void QWaylandDisplay::setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
inputDevice->setCursor(buffer, image);
}
}
void QWaylandDisplay::setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot)
{
/* Qt doesn't tell us which input device we should set the cursor
* for, so set it for all devices. */
for (int i = 0; i < mInputDevices.count(); i++) {
QWaylandInputDevice *inputDevice = mInputDevices.at(i);
inputDevice->setCursor(buffer, hotSpot);
}
}
#endif // QT_CONFIG(cursor)
}
QT_END_NAMESPACE

View File

@ -61,7 +61,7 @@
#include <wayland-client.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
#include <QtWaylandClient/qtwaylandclientglobal.h>
#include <QtWaylandClient/private/qtwaylandclientglobal_p.h>
#include <QtWaylandClient/private/qwayland-xdg-shell.h>
#include <QtWaylandClient/private/qwaylandshm_p.h>
@ -123,10 +123,10 @@ public:
QWaylandClientBufferIntegration *clientBufferIntegration() const;
QWaylandWindowManagerIntegration *windowManagerIntegration() const;
#if QT_CONFIG(cursor)
void setCursor(struct wl_buffer *buffer, struct wl_cursor_image *image);
void setCursor(const QSharedPointer<QWaylandBuffer> &buffer, const QPoint &hotSpot);
#endif
struct wl_display *wl_display() const { return mDisplay; }
struct ::wl_registry *wl_registry() { return object(); }
@ -137,7 +137,7 @@ public:
QList<QWaylandInputDevice *> inputDevices() const { return mInputDevices; }
QWaylandInputDevice *defaultInputDevice() const;
QWaylandInputDevice *currentInputDevice() const { return defaultInputDevice(); }
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
QWaylandDataDeviceManager *dndSelectionHandler() const { return mDndSelectionHandler.data(); }
#endif
QtWayland::qt_surface_extension *windowExtension() const { return mWindowExtension.data(); }
@ -202,7 +202,7 @@ private:
QList<QWaylandInputDevice *> mInputDevices;
QList<Listener> mRegistryListeners;
QWaylandIntegration *mWaylandIntegration;
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
QScopedPointer<QWaylandDataDeviceManager> mDndSelectionHandler;
#endif
QScopedPointer<QtWayland::qt_surface_extension> mWindowExtension;

View File

@ -42,8 +42,10 @@
#include "qwaylandintegration_p.h"
#include "qwaylandwindow_p.h"
#include "qwaylandbuffer_p.h"
#if QT_CONFIG(wayland_datadevice)
#include "qwaylanddatadevice_p.h"
#include "qwaylanddatadevicemanager_p.h"
#endif
#include "qwaylandtouch_p.h"
#include "qwaylandscreen_p.h"
#include "qwaylandcursor_p.h"
@ -187,7 +189,9 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version,
, mDisplay(display->wl_display())
, mVersion(qMin(version, 4))
, mCaps(0)
#if QT_CONFIG(wayland_datadevice)
, mDataDevice(0)
#endif
, mKeyboard(0)
, mPointer(0)
, mTouch(0)
@ -196,7 +200,7 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version,
, mSerial(0)
, mTouchDevice(0)
{
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(wayland_datadevice)
if (mQDisplay->dndSelectionHandler()) {
mDataDevice = mQDisplay->dndSelectionHandler()->getDataDevice(this);
}
@ -286,6 +290,7 @@ void QWaylandInputDevice::handleEndDrag()
mPointer->releaseButtons();
}
#if QT_CONFIG(wayland_datadevice)
void QWaylandInputDevice::setDataDevice(QWaylandDataDevice *device)
{
mDataDevice = device;
@ -296,6 +301,7 @@ QWaylandDataDevice *QWaylandInputDevice::dataDevice() const
Q_ASSERT(mDataDevice);
return mDataDevice;
}
#endif
void QWaylandInputDevice::setTextInput(QWaylandTextInput *textInput)
{

View File

@ -111,8 +111,10 @@ public:
void handleWindowDestroyed(QWaylandWindow *window);
void handleEndDrag();
#if QT_CONFIG(wayland_datadevice)
void setDataDevice(QWaylandDataDevice *device);
QWaylandDataDevice *dataDevice() const;
#endif
void setTextInput(QWaylandTextInput *textInput);
QWaylandTextInput *textInput() const;
@ -143,7 +145,9 @@ private:
struct wl_surface *pointerSurface;
#if QT_CONFIG(wayland_datadevice)
QWaylandDataDevice *mDataDevice;
#endif
Keyboard *mKeyboard;
Pointer *mPointer;

View File

@ -90,7 +90,7 @@ public:
QWaylandShmBackingStore(QWindow *window);
~QWaylandShmBackingStore();
QPaintDevice *paintDevice();
QPaintDevice *paintDevice() override;
void flush(QWindow *window, const QRegion &region, const QPoint &offset) override;
void resize(const QSize &size, const QRegion &staticContents) override;
void resize(const QSize &size);

View File

@ -40,7 +40,6 @@
#include "qwaylandwindow_p.h"
#include "qwaylandbuffer_p.h"
#include "qwaylanddatadevice_p.h"
#include "qwaylanddisplay_p.h"
#include "qwaylandinputdevice_p.h"
#include "qwaylandscreen_p.h"
@ -54,6 +53,11 @@
#include "qwaylanddecorationfactory_p.h"
#include "qwaylandshmbackingstore_p.h"
#if QT_CONFIG(wayland_datadevice)
#include "qwaylanddatadevice_p.h"
#endif
#include <QtCore/QFileInfo>
#include <QtCore/QPointer>
#include <QtCore/QRegularExpression>
@ -95,6 +99,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
{
static WId id = 1;
mWindowId = id++;
initializeWlSurface();
}
QWaylandWindow::~QWaylandWindow()
@ -127,7 +132,7 @@ void QWaylandWindow::initWindow()
return;
if (!isInitialized())
init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this)));
initializeWlSurface();
if (shouldCreateSubSurface()) {
Q_ASSERT(!mSubSurfaceWindow);
@ -159,7 +164,9 @@ void QWaylandWindow::initWindow()
// when available.
if (!QGuiApplication::desktopFileName().isEmpty()) {
QString name = QGuiApplication::desktopFileName();
mShellSurface->setAppId(name.replace(QRegularExpression(QLatin1String("\\.desktop$")), QString()));
if (name.endsWith(QLatin1String(".desktop")))
name.chop(8);
mShellSurface->setAppId(name);
} else {
QFileInfo fi = QCoreApplication::instance()->applicationFilePath();
QStringList domainName =
@ -200,6 +207,11 @@ void QWaylandWindow::initWindow()
mFlags = window()->flags();
}
void QWaylandWindow::initializeWlSurface()
{
init(mDisplay->createSurface(static_cast<QtWayland::wl_surface *>(this)));
}
bool QWaylandWindow::shouldCreateShellSurface() const
{
if (shouldCreateSubSurface())
@ -225,7 +237,8 @@ void QWaylandWindow::reset()
mShellSurface = 0;
delete mSubSurfaceWindow;
mSubSurfaceWindow = 0;
destroy();
if (isInitialized())
destroy();
if (mFrameCallback)
wl_callback_destroy(mFrameCallback);
@ -360,8 +373,11 @@ void QWaylandWindow::setMask(const QRegion &mask)
mMask = mask;
if (!isInitialized())
return;
if (mMask.isEmpty()) {
set_input_region(0);
set_input_region(nullptr);
} else {
struct ::wl_region *region = mDisplay->createRegion(mMask);
set_input_region(region);
@ -813,7 +829,7 @@ void QWaylandWindow::requestActivateWindow()
void QWaylandWindow::unfocus()
{
#if QT_CONFIG(draganddrop)
#if QT_CONFIG(clipboard)
QWaylandInputDevice *inputDevice = mDisplay->currentInputDevice();
if (inputDevice && inputDevice->dataDevice()) {
inputDevice->dataDevice()->invalidateSelectionOffer();

View File

@ -248,6 +248,7 @@ private:
bool setWindowStateInternal(Qt::WindowStates flags);
void setGeometry_helper(const QRect &rect);
void initWindow();
void initializeWlSurface();
bool shouldCreateShellSurface() const;
bool shouldCreateSubSurface() const;
void reset();

View File

@ -199,6 +199,7 @@ void QWaylandXdgSurfaceV6::setPopup(QWaylandWindow *parent, QWaylandInputDevice
positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1);
positioner->set_anchor(QtWayland::zxdg_positioner_v6::anchor_top | QtWayland::zxdg_positioner_v6::anchor_left);
positioner->set_gravity(QtWayland::zxdg_positioner_v6::gravity_bottom | QtWayland::zxdg_positioner_v6::gravity_right);
positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
m_popup = new Popup(this, parentXdgSurface, positioner);
positioner->destroy();
delete positioner;

View File

@ -43,10 +43,13 @@
#include <QKeyEvent>
#include <QString>
#if QT_CONFIG(xkbcommon_evdev)
#include <xkbcommon/xkbcommon-keysyms.h>
#endif
QT_BEGIN_NAMESPACE
#if QT_CONFIG(xkbcommon_evdev)
static const uint32_t KeyTbl[] = {
XKB_KEY_Escape, Qt::Key_Escape,
XKB_KEY_Tab, Qt::Key_Tab,
@ -290,9 +293,11 @@ static xkb_keysym_t toKeysymFromTable(uint32_t key)
return 0;
}
#endif
std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers)
{
#if QT_CONFIG(xkbcommon_evdev)
QString text;
uint utf32 = xkb_keysym_to_utf32(keysym);
if (utf32)
@ -326,10 +331,15 @@ std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::Keyb
}
return { code, text };
#else
Q_UNUSED(modifiers)
return { keysym, "" };
#endif
}
Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state)
{
#if QT_CONFIG(xkbcommon_evdev)
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
xkb_state_component cstate = static_cast<xkb_state_component>(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED);
@ -344,6 +354,10 @@ Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state)
modifiers |= Qt::MetaModifier;
return modifiers;
#else
Q_UNUSED(state)
return Qt::NoModifier;
#endif
}
QEvent::Type QWaylandXkb::toQtEventType(uint32_t state)
@ -353,6 +367,7 @@ QEvent::Type QWaylandXkb::toQtEventType(uint32_t state)
QVector<xkb_keysym_t> QWaylandXkb::toKeysym(QKeyEvent *event)
{
#if QT_CONFIG(xkbcommon_evdev)
QVector<xkb_keysym_t> keysyms;
if (event->key() >= Qt::Key_F1 && event->key() <= Qt::Key_F35) {
keysyms.append(XKB_KEY_F1 + (event->key() - Qt::Key_F1));
@ -372,6 +387,9 @@ QVector<xkb_keysym_t> QWaylandXkb::toKeysym(QKeyEvent *event)
keysyms.append(toKeysymFromTable(event->key()));
}
return keysyms;
#else
return QVector<xkb_keysym_t>() << event->nativeScanCode();
#endif
}
QT_END_NAMESPACE

View File

@ -41,9 +41,16 @@
#ifndef QWAYLANDXKB_H
#define QWAYLANDXKB_H
#include <QtGui/private/qtguiglobal_p.h>
#include <Qt>
#include <QEvent>
#if QT_CONFIG(xkbcommon_evdev)
#include <xkbcommon/xkbcommon.h>
#else
typedef quint32 xkb_keysym_t;
struct xkb_state;
#endif
#include <utility>