diff options
author | Liang Qi <liang.qi@qt.io> | 2019-01-03 13:20:55 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-01-03 13:20:55 +0100 |
commit | 88af49bdfe4e87d1832240a65d842e9126b7bb63 (patch) | |
tree | ac58fee5006d11442b0bf4c2009c6831d10e5a3b | |
parent | f312eb3c05613a9ca988a92bf155264d619d8b6a (diff) | |
parent | 143a6ad82ea0ded69da482eff1750082fd5b2a6a (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
src/client/qwaylandinputdevice.cpp
Change-Id: I4f985d6e47b4199a940ff1cd40e65165c28e49b2
-rw-r--r-- | src/client/qwaylandabstractdecoration.cpp | 3 | ||||
-rw-r--r-- | src/client/qwaylandinputcontext.cpp | 23 | ||||
-rw-r--r-- | src/client/qwaylandinputdevice.cpp | 39 | ||||
-rw-r--r-- | src/client/qwaylandwindow.cpp | 2 |
4 files changed, 44 insertions, 23 deletions
diff --git a/src/client/qwaylandabstractdecoration.cpp b/src/client/qwaylandabstractdecoration.cpp index 503ad41f..3196af3b 100644 --- a/src/client/qwaylandabstractdecoration.cpp +++ b/src/client/qwaylandabstractdecoration.cpp @@ -100,6 +100,7 @@ void QWaylandAbstractDecoration::setWaylandWindow(QWaylandWindow *window) d->m_wayland_window = window; } +// \a size is without margins static QRegion marginsRegion(const QSize &size, const QMargins &margins) { QRegion r; @@ -123,7 +124,7 @@ const QImage &QWaylandAbstractDecoration::contentImage() d->m_decorationContentImage.fill(Qt::transparent); this->paint(&d->m_decorationContentImage); - QRegion damage = marginsRegion(window()->frameGeometry().size(), window()->frameMargins()); + QRegion damage = marginsRegion(window()->geometry().size(), window()->frameMargins()); for (QRect r : damage) waylandWindow()->damage(r); diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp index 58ad90d4..e85faaf8 100644 --- a/src/client/qwaylandinputcontext.cpp +++ b/src/client/qwaylandinputcontext.cpp @@ -417,6 +417,15 @@ void QWaylandInputContext::commit() textInput()->commit(); } +static ::wl_surface *surfaceForWindow(QWindow *window) +{ + if (!window || !window->handle()) + return nullptr; + + auto *waylandWindow = static_cast<QWaylandWindow *>(window->handle()); + return waylandWindow->wl_surface::object(); +} + void QWaylandInputContext::update(Qt::InputMethodQueries queries) { qCDebug(qLcQpaInputMethods) << Q_FUNC_INFO << queries; @@ -424,15 +433,15 @@ void QWaylandInputContext::update(Qt::InputMethodQueries queries) if (!QGuiApplication::focusObject() || !textInput()) return; - if (mCurrentWindow && mCurrentWindow->handle() && !inputMethodAccepted()) { - struct ::wl_surface *surface = static_cast<QWaylandWindow *>(mCurrentWindow->handle())->object(); - textInput()->disable(surface); + auto *currentSurface = surfaceForWindow(mCurrentWindow); + + if (currentSurface && !inputMethodAccepted()) { + textInput()->disable(currentSurface); mCurrentWindow.clear(); - } else if (!mCurrentWindow && inputMethodAccepted()) { + } else if (!currentSurface && inputMethodAccepted()) { QWindow *window = QGuiApplication::focusWindow(); - if (window && window->handle()) { - struct ::wl_surface *surface = static_cast<QWaylandWindow *>(window->handle())->object(); - textInput()->enable(surface); + if (auto *focusSurface = surfaceForWindow(window)) { + textInput()->enable(focusSurface); mCurrentWindow = window; } } diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp index 49f1ab24..2dff4b6c 100644 --- a/src/client/qwaylandinputdevice.cpp +++ b/src/client/qwaylandinputdevice.cpp @@ -501,10 +501,9 @@ public: void QWaylandInputDevice::Pointer::pointer_motion(uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) { QWaylandWindow *window = mFocus; - if (!window) { - // We destroyed the pointer focus surface, but the server - // didn't get the message yet. + // We destroyed the pointer focus surface, but the server didn't get the message yet... + // or the server didn't send an enter event first. In either case, ignore the event. return; } @@ -535,6 +534,12 @@ void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t time uint32_t button, uint32_t state) { QWaylandWindow *window = mFocus; + if (!window) { + // We destroyed the pointer focus surface, but the server didn't get the message yet... + // or the server didn't send an enter event first. In either case, ignore the event. + return; + } + Qt::MouseButton qt_button; // translate from kernel (input.h) 'button' to corresponding Qt:MouseButton. @@ -601,15 +606,15 @@ public: void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, int32_t value) { QWaylandWindow *window = mFocus; - QPoint pixelDelta; - QPoint angleDelta; - if (!window) { - // We destroyed the pointer focus surface, but the server - // didn't get the message yet. + // We destroyed the pointer focus surface, but the server didn't get the message yet... + // or the server didn't send an enter event first. In either case, ignore the event. return; } + QPoint pixelDelta; + QPoint angleDelta; + //normalize value and inverse axis int valueDelta = wl_fixed_to_int(value) * -12; @@ -714,6 +719,12 @@ static void sendKey(QWindow *tlw, ulong timestamp, QEvent::Type type, int key, Q void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { QWaylandWindow *window = mFocus; + if (!window) { + // We destroyed the keyboard focus surface, but the server didn't get the message yet... + // or the server didn't send an enter event first. In either case, ignore the event. + return; + } + uint32_t code = key + 8; bool isDown = state != WL_KEYBOARD_KEY_STATE_RELEASED; QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; @@ -721,12 +732,6 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, int qtkey = key + 8; // qt-compositor substracts 8 for some reason mParent->mSerial = serial; - if (!window) { - // We destroyed the keyboard focus surface, but the server - // didn't get the message yet. - return; - } - if (isDown) mParent->mQDisplay->setLastInputDevice(mParent, serial, window); @@ -793,6 +798,12 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, void QWaylandInputDevice::Keyboard::repeatKey() { + if (!mFocus) { + // We destroyed the keyboard focus surface, but the server didn't get the message yet... + // or the server didn't send an enter event first. + return; + } + mRepeatTimer.setInterval(mRepeatRate); sendKey(mFocus->window(), mRepeatTime, QEvent::KeyRelease, mRepeatKey, modifiers(), mRepeatCode, #if QT_CONFIG(xkbcommon) diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index a5eba5b2..17576ece 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -384,7 +384,7 @@ QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const void QWaylandWindow::setVisible(bool visible) { if (visible) { - if (window()->type() == Qt::Popup) + if (window()->type() & (Qt::Popup | Qt::ToolTip)) activePopups << this; initWindow(); mDisplay->flushRequests(); |