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

Conflicts:
	README
	src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri

Change-Id: I7cbbf39916821f0f1749e3ccab3151f68f4aa1ac
This commit is contained in:
Liang Qi 2018-12-22 18:53:35 +01:00
commit d2d02aa281
11 changed files with 128 additions and 52 deletions

View File

@ -15,8 +15,8 @@ use_gold_linker: CONFIG += no_linker_version_script
CONFIG -= precompile_header CONFIG -= precompile_header
CONFIG += link_pkgconfig wayland-scanner CONFIG += link_pkgconfig wayland-scanner
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon): \
QMAKE_USE_PRIVATE += xkbcommon_evdev QMAKE_USE_PRIVATE += xkbcommon
qtHaveModule(linuxaccessibility_support_private): \ qtHaveModule(linuxaccessibility_support_private): \
QT += linuxaccessibility_support_private QT += linuxaccessibility_support_private

View File

@ -2,8 +2,8 @@ QT += gui-private waylandclient-private
CONFIG += wayland-scanner CONFIG += wayland-scanner
QMAKE_USE += wayland-client QMAKE_USE += wayland-client
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon): \
QMAKE_USE_PRIVATE += xkbcommon_evdev QMAKE_USE_PRIVATE += xkbcommon
WAYLANDCLIENTSOURCES += \ WAYLANDCLIENTSOURCES += \
../../../3rdparty/protocol/wayland.xml ../../../3rdparty/protocol/wayland.xml

View File

@ -3,8 +3,8 @@ CONFIG += wayland-scanner
QMAKE_USE += wayland-client QMAKE_USE += wayland-client
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon): \
QMAKE_USE += xkbcommon_evdev QMAKE_USE += xkbcommon
HEADERS += \ HEADERS += \
qwaylandxdgpopupv5_p.h \ qwaylandxdgpopupv5_p.h \

View File

@ -2,8 +2,8 @@ QT += gui-private waylandclient-private
CONFIG += wayland-scanner CONFIG += wayland-scanner
QMAKE_USE += wayland-client QMAKE_USE += wayland-client
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon): \
QMAKE_USE_PRIVATE += xkbcommon_evdev QMAKE_USE_PRIVATE += xkbcommon
WAYLANDCLIENTSOURCES += \ WAYLANDCLIENTSOURCES += \
../../../3rdparty/protocol/xdg-shell-unstable-v6.xml ../../../3rdparty/protocol/xdg-shell-unstable-v6.xml

View File

@ -2,8 +2,8 @@ QT += gui-private waylandclient-private
CONFIG += wayland-scanner CONFIG += wayland-scanner
QMAKE_USE += wayland-client QMAKE_USE += wayland-client
qtConfig(xkbcommon-evdev): \ qtConfig(xkbcommon): \
QMAKE_USE_PRIVATE += xkbcommon_evdev QMAKE_USE_PRIVATE += xkbcommon
WAYLANDCLIENTSOURCES += \ WAYLANDCLIENTSOURCES += \
../../../3rdparty/protocol/xdg-decoration-unstable-v1.xml \ ../../../3rdparty/protocol/xdg-decoration-unstable-v1.xml \

View File

@ -70,7 +70,7 @@
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon-compose.h> #include <xkbcommon/xkbcommon-compose.h>
#endif #endif
@ -84,7 +84,7 @@ QWaylandInputDevice::Keyboard::Keyboard(QWaylandInputDevice *p)
connect(&mRepeatTimer, SIGNAL(timeout()), this, SLOT(repeatKey())); connect(&mRepeatTimer, SIGNAL(timeout()), this, SLOT(repeatKey()));
} }
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
bool QWaylandInputDevice::Keyboard::createDefaultKeyMap() bool QWaylandInputDevice::Keyboard::createDefaultKeyMap()
{ {
if (mXkbContext && mXkbMap && mXkbState) { if (mXkbContext && mXkbMap && mXkbState) {
@ -156,7 +156,7 @@ void QWaylandInputDevice::Keyboard::releaseComposeState()
QWaylandInputDevice::Keyboard::~Keyboard() QWaylandInputDevice::Keyboard::~Keyboard()
{ {
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
releaseComposeState(); releaseComposeState();
releaseKeyMap(); releaseKeyMap();
#endif #endif
@ -343,7 +343,7 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const
{ {
Qt::KeyboardModifiers ret = Qt::NoModifier; Qt::KeyboardModifiers ret = Qt::NoModifier;
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
if (!mXkbState) if (!mXkbState)
return ret; return ret;
@ -627,7 +627,7 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in
void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t format, int32_t fd, uint32_t size) void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t format, int32_t fd, uint32_t size)
{ {
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
close(fd); close(fd);
return; return;
@ -730,7 +730,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
if (isDown) if (isDown)
mParent->mQDisplay->setLastInputDevice(mParent, serial, window); mParent->mQDisplay->setLastInputDevice(mParent, serial, window);
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
if (!createDefaultKeyMap()) { if (!createDefaultKeyMap()) {
return; return;
} }
@ -773,7 +773,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
#endif #endif
if (state == WL_KEYBOARD_KEY_STATE_PRESSED if (state == WL_KEYBOARD_KEY_STATE_PRESSED
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
&& xkb_keymap_key_repeats(mXkbMap, code) && xkb_keymap_key_repeats(mXkbMap, code)
#endif #endif
) { ) {
@ -781,7 +781,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
mRepeatCode = code; mRepeatCode = code;
mRepeatTime = time; mRepeatTime = time;
mRepeatText = text; mRepeatText = text;
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
mRepeatSym = sym; mRepeatSym = sym;
#endif #endif
mRepeatTimer.setInterval(mRepeatDelay); mRepeatTimer.setInterval(mRepeatDelay);
@ -795,7 +795,7 @@ void QWaylandInputDevice::Keyboard::repeatKey()
{ {
mRepeatTimer.setInterval(mRepeatRate); mRepeatTimer.setInterval(mRepeatRate);
sendKey(mFocus->window(), mRepeatTime, QEvent::KeyRelease, mRepeatKey, modifiers(), mRepeatCode, sendKey(mFocus->window(), mRepeatTime, QEvent::KeyRelease, mRepeatKey, modifiers(), mRepeatCode,
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
mRepeatSym, mNativeModifiers, mRepeatSym, mNativeModifiers,
#else #else
0, 0, 0, 0,
@ -803,7 +803,7 @@ void QWaylandInputDevice::Keyboard::repeatKey()
mRepeatText, true); mRepeatText, true);
sendKey(mFocus->window(), mRepeatTime, QEvent::KeyPress, mRepeatKey, modifiers(), mRepeatCode, sendKey(mFocus->window(), mRepeatTime, QEvent::KeyPress, mRepeatKey, modifiers(), mRepeatCode,
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
mRepeatSym, mNativeModifiers, mRepeatSym, mNativeModifiers,
#else #else
0, 0, 0, 0,
@ -818,7 +818,7 @@ void QWaylandInputDevice::Keyboard::keyboard_modifiers(uint32_t serial,
uint32_t group) uint32_t group)
{ {
Q_UNUSED(serial); Q_UNUSED(serial);
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
if (mXkbState) if (mXkbState)
xkb_state_update_mask(mXkbState, xkb_state_update_mask(mXkbState,
mods_depressed, mods_latched, mods_locked, mods_depressed, mods_latched, mods_locked,

View File

@ -63,7 +63,7 @@
#include <QtWaylandClient/private/qwayland-wayland.h> #include <QtWaylandClient/private/qwayland-wayland.h>
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-keysyms.h>
#endif #endif
@ -75,7 +75,7 @@
struct wl_cursor_image; struct wl_cursor_image;
#endif #endif
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
struct xkb_compose_state; struct xkb_compose_state;
struct xkb_compose_table; struct xkb_compose_table;
#endif #endif
@ -208,7 +208,7 @@ public:
QWaylandInputDevice *mParent = nullptr; QWaylandInputDevice *mParent = nullptr;
QPointer<QWaylandWindow> mFocus; QPointer<QWaylandWindow> mFocus;
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
xkb_context *mXkbContext = nullptr; xkb_context *mXkbContext = nullptr;
xkb_keymap *mXkbMap = nullptr; xkb_keymap *mXkbMap = nullptr;
xkb_state *mXkbState = nullptr; xkb_state *mXkbState = nullptr;
@ -223,7 +223,7 @@ public:
int mRepeatRate = 25; int mRepeatRate = 25;
int mRepeatDelay = 400; int mRepeatDelay = 400;
QString mRepeatText; QString mRepeatText;
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
xkb_keysym_t mRepeatSym; xkb_keysym_t mRepeatSym;
#endif #endif
QTimer mRepeatTimer; QTimer mRepeatTimer;
@ -234,7 +234,7 @@ private slots:
void repeatKey(); void repeatKey();
private: private:
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
bool createDefaultKeyMap(); bool createDefaultKeyMap();
void releaseKeyMap(); void releaseKeyMap();
void createComposeState(); void createComposeState();

View File

@ -356,6 +356,8 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
{ {
if (!(mShellSurface && mShellSurface->handleExpose(rect))) if (!(mShellSurface && mShellSurface->handleExpose(rect)))
QWindowSystemInterface::handleExposeEvent(window(), rect); QWindowSystemInterface::handleExposeEvent(window(), rect);
else
qCDebug(lcQpaWayland) << "sendExposeEvent: intercepted by shell extension, not sending";
mLastExposeGeometry = rect; mLastExposeGeometry = rect;
} }
@ -544,18 +546,11 @@ void QWaylandWindow::handleScreenRemoved(QScreen *qScreen)
void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y) void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
{ {
Q_ASSERT(!buffer->committed()); Q_ASSERT(!buffer->committed());
if (mFrameCallback) {
wl_callback_destroy(mFrameCallback);
mFrameCallback = nullptr;
}
if (buffer) { if (buffer) {
mFrameCallback = frame(); handleUpdate();
wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
mWaitingForFrameSync = true;
buffer->setBusy(); buffer->setBusy();
attach(buffer->buffer(), x, y); QtWayland::wl_surface::attach(buffer->buffer(), x, y);
} else { } else {
QtWayland::wl_surface::attach(nullptr, 0, 0); QtWayland::wl_surface::attach(nullptr, 0, 0);
} }
@ -620,11 +615,9 @@ void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uin
Q_UNUSED(callback); Q_UNUSED(callback);
QWaylandWindow *self = static_cast<QWaylandWindow*>(data); QWaylandWindow *self = static_cast<QWaylandWindow*>(data);
self->mWaitingForFrameSync = false; self->mWaitingForFrameCallback = false;
if (self->mUpdateRequested) { if (self->mUpdateRequested)
self->mUpdateRequested = false;
self->deliverUpdateRequest(); self->deliverUpdateRequest();
}
} }
QMutex QWaylandWindow::mFrameSyncMutex; QMutex QWaylandWindow::mFrameSyncMutex;
@ -632,10 +625,10 @@ QMutex QWaylandWindow::mFrameSyncMutex;
void QWaylandWindow::waitForFrameSync() void QWaylandWindow::waitForFrameSync()
{ {
QMutexLocker locker(&mFrameSyncMutex); QMutexLocker locker(&mFrameSyncMutex);
if (!mWaitingForFrameSync) if (!mWaitingForFrameCallback)
return; return;
mDisplay->flushRequests(); mDisplay->flushRequests();
while (mWaitingForFrameSync) while (mWaitingForFrameCallback)
mDisplay->blockingReadEvents(); mDisplay->blockingReadEvents();
} }
@ -1036,12 +1029,88 @@ QVariant QWaylandWindow::property(const QString &name, const QVariant &defaultVa
return m_properties.value(name, defaultValue); return m_properties.value(name, defaultValue);
} }
void QWaylandWindow::timerEvent(QTimerEvent *event)
{
if (event->timerId() == mFallbackUpdateTimerId) {
killTimer(mFallbackUpdateTimerId);
mFallbackUpdateTimerId = -1;
if (!isExposed()) {
qCDebug(lcWaylandBackingstore) << "Fallback update timer: Window not exposed,"
<< "not delivering update request.";
return;
}
if (mWaitingForUpdate && mUpdateRequested && !mWaitingForFrameCallback) {
qCWarning(lcWaylandBackingstore) << "Delivering update request through fallback timer,"
<< "may not be in sync with display";
deliverUpdateRequest();
}
}
}
void QWaylandWindow::requestUpdate() void QWaylandWindow::requestUpdate()
{ {
if (!mWaitingForFrameSync) if (mUpdateRequested)
QPlatformWindow::requestUpdate(); return;
else
mUpdateRequested = true; mUpdateRequested = true;
// If we have a frame callback all is good and will be taken care of there
if (mWaitingForFrameCallback)
return;
// If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
if (mWaitingForUpdate) {
// Ideally, we should just have returned here, but we're not guaranteed that the client
// will actually update, so start this timer to deliver another request update after a while
// *IF* the client doesn't update.
int fallbackTimeout = 100;
mFallbackUpdateTimerId = startTimer(fallbackTimeout);
return;
}
// Some applications (such as Qt Quick) depend on updates being delivered asynchronously,
// so use invokeMethod to delay the delivery a bit.
QMetaObject::invokeMethod(this, [this] {
// Things might have changed in the meantime
if (mUpdateRequested && !mWaitingForUpdate && !mWaitingForFrameCallback)
deliverUpdateRequest();
}, Qt::QueuedConnection);
}
// Should be called whenever we commit a buffer (directly through wl_surface.commit or indirectly
// with eglSwapBuffers) to know when it's time to commit the next one.
// Can be called from the render thread (without locking anything) so make sure to not make races in this method.
void QWaylandWindow::handleUpdate()
{
// TODO: Should sync subsurfaces avoid requesting frame callbacks?
if (mFrameCallback) {
wl_callback_destroy(mFrameCallback);
mFrameCallback = nullptr;
}
if (mFallbackUpdateTimerId != -1) {
// Ideally, we would stop the fallback timer here, but since we're on another thread,
// it's not allowed. Instead we set mFallbackUpdateTimer to -1 here, so we'll just
// ignore it if it times out before it's cleaned up by the invokeMethod call.
int id = mFallbackUpdateTimerId;
mFallbackUpdateTimerId = -1;
QMetaObject::invokeMethod(this, [=] { killTimer(id); }, Qt::QueuedConnection);
}
mFrameCallback = frame();
wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
mWaitingForFrameCallback = true;
mWaitingForUpdate = false;
}
void QWaylandWindow::deliverUpdateRequest()
{
mUpdateRequested = false;
mWaitingForUpdate = true;
QPlatformWindow::deliverUpdateRequest();
} }
void QWaylandWindow::addAttachOffset(const QPoint point) void QWaylandWindow::addAttachOffset(const QPoint point)

View File

@ -191,7 +191,10 @@ public:
bool startSystemMove(const QPoint &pos) override; bool startSystemMove(const QPoint &pos) override;
void timerEvent(QTimerEvent *event) override;
void requestUpdate() override; void requestUpdate() override;
void handleUpdate();
void deliverUpdateRequest() override;
public slots: public slots:
void applyConfigure(); void applyConfigure();
@ -211,10 +214,14 @@ protected:
Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton; Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
WId mWindowId; WId mWindowId;
bool mWaitingForFrameSync = false; bool mWaitingForFrameCallback = false;
struct ::wl_callback *mFrameCallback = nullptr; struct ::wl_callback *mFrameCallback = nullptr;
QWaitCondition mFrameSyncWait; QWaitCondition mFrameSyncWait;
// True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
bool mWaitingForUpdate = false;
int mFallbackUpdateTimerId = -1;
QMutex mResizeLock; QMutex mResizeLock;
bool mWaitingToApplyConfigure = false; bool mWaitingToApplyConfigure = false;
bool mCanResize = true; bool mCanResize = true;

View File

@ -43,13 +43,13 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QString> #include <QString>
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon-keysyms.h> #include <xkbcommon/xkbcommon-keysyms.h>
#endif #endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
static const uint32_t KeyTbl[] = { static const uint32_t KeyTbl[] = {
XKB_KEY_Escape, Qt::Key_Escape, XKB_KEY_Escape, Qt::Key_Escape,
XKB_KEY_Tab, Qt::Key_Tab, XKB_KEY_Tab, Qt::Key_Tab,
@ -297,7 +297,7 @@ static xkb_keysym_t toKeysymFromTable(uint32_t key)
std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers) std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers &modifiers)
{ {
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
QString text; QString text;
uint utf32 = xkb_keysym_to_utf32(keysym); uint utf32 = xkb_keysym_to_utf32(keysym);
if (utf32) if (utf32)
@ -339,7 +339,7 @@ std::pair<int, QString> QWaylandXkb::keysymToQtKey(xkb_keysym_t keysym, Qt::Keyb
Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state) Qt::KeyboardModifiers QWaylandXkb::modifiers(struct xkb_state *state)
{ {
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
Qt::KeyboardModifiers modifiers = Qt::NoModifier; Qt::KeyboardModifiers modifiers = Qt::NoModifier;
xkb_state_component cstate = static_cast<xkb_state_component>(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED); xkb_state_component cstate = static_cast<xkb_state_component>(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED);
@ -367,7 +367,7 @@ QEvent::Type QWaylandXkb::toQtEventType(uint32_t state)
QVector<xkb_keysym_t> QWaylandXkb::toKeysym(QKeyEvent *event) QVector<xkb_keysym_t> QWaylandXkb::toKeysym(QKeyEvent *event)
{ {
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
QVector<xkb_keysym_t> keysyms; QVector<xkb_keysym_t> keysyms;
if (event->key() >= Qt::Key_F1 && event->key() <= Qt::Key_F35) { if (event->key() >= Qt::Key_F1 && event->key() <= Qt::Key_F35) {
keysyms.append(XKB_KEY_F1 + (event->key() - Qt::Key_F1)); keysyms.append(XKB_KEY_F1 + (event->key() - Qt::Key_F1));

View File

@ -45,7 +45,7 @@
#include <Qt> #include <Qt>
#include <QEvent> #include <QEvent>
#if QT_CONFIG(xkbcommon_evdev) #if QT_CONFIG(xkbcommon)
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#else #else
typedef quint32 xkb_keysym_t; typedef quint32 xkb_keysym_t;