From 1cee02688f71db37ca4ed9ab392c0f690aa0a31c Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Tue, 21 Apr 2015 13:16:53 +0300 Subject: [PATCH 01/10] Do not manually update the xkb state xkb_state_update_key() is not supposed to be used in apps with a master process, such as wayland clients, which use xkb_state_update_mask() with the state serialized by the master. Change-Id: Ie51a39ca0c567c54072b221d1ab8cf7b8ea15c55 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 3b5e83481fb..ca17d0be570 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -759,7 +759,6 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, } const xkb_keysym_t sym = xkb_state_key_get_one_sym(mXkbState, code); - xkb_state_update_key(mXkbState, code, isDown ? XKB_KEY_DOWN : XKB_KEY_UP); Qt::KeyboardModifiers modifiers = mParent->modifiers(); From 7efc7c3d4db066f871f0193f5ce9d51dfbd91447 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Tue, 21 Apr 2015 16:56:49 +0300 Subject: [PATCH 02/10] Use defines instead of hardcoded strings Change-Id: Id382a1e39f2c052fbfeb96caa9b01becb31e81c9 Reviewed-by: Pier Luigi Fiorini Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index ca17d0be570..8c896528024 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -297,15 +297,13 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const #ifndef QT_NO_WAYLAND_XKB xkb_state_component cstate = static_cast(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED); - if (xkb_state_mod_name_is_active(mXkbState, "Shift", cstate)) + if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_SHIFT, cstate)) ret |= Qt::ShiftModifier; - if (xkb_state_mod_name_is_active(mXkbState, "Control", cstate)) + if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_CTRL, cstate)) ret |= Qt::ControlModifier; - if (xkb_state_mod_name_is_active(mXkbState, "Alt", cstate)) + if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_ALT, cstate)) ret |= Qt::AltModifier; - if (xkb_state_mod_name_is_active(mXkbState, "Mod1", cstate)) - ret |= Qt::AltModifier; - if (xkb_state_mod_name_is_active(mXkbState, "Mod4", cstate)) + if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_LOGO, cstate)) ret |= Qt::MetaModifier; #endif From b8be7b93a12aaf4347d1355fdffc6c7728668704 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Tue, 21 Apr 2015 21:09:50 +0300 Subject: [PATCH 03/10] Use a FontSmoothingGamma value of 1.0 This is what the xcb plugin does, be consistent with it. Change-Id: I5befa2de3ff514ca0c9196eb7137682586cec126 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandintegration.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp index 050feba736b..9526aec4c4e 100644 --- a/src/plugins/platforms/wayland/qwaylandintegration.cpp +++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp @@ -226,6 +226,13 @@ QVariant QWaylandIntegration::styleHint(StyleHint hint) const if (hint == ShowIsFullScreen && mDisplay->windowManagerIntegration()) return mDisplay->windowManagerIntegration()->showIsFullScreen(); + switch (hint) { + case QPlatformIntegration::FontSmoothingGamma: + return qreal(1.0); + default: + break; + } + return QPlatformIntegration::styleHint(hint); } From d0740edb9c77bba7fb156dcda18459e2a23a6d04 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Fri, 1 May 2015 17:41:17 +0300 Subject: [PATCH 04/10] Fix crash on keyboard remove If the compositor sent a wl_keyboard.leave and a new wl_seat.capabilities without the keyboard bit we would end up deleting the Keyboard object with a roundtrip in flight, ending up using freed memory later. Destroy the callback when destroying the keyboard, and notify the window system the active window is active no more. Change-Id: Ie415ca62b46e0b8ef0fe4d09c8e7a8130928df90 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 8c896528024..b2268ae7888 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -118,6 +118,10 @@ QWaylandInputDevice::Keyboard::~Keyboard() #ifndef QT_NO_WAYLAND_XKB releaseKeyMap(); #endif + if (mFocus) + QWindowSystemInterface::handleWindowActivated(0); + if (mFocusCallback) + wl_callback_destroy(mFocusCallback); if (mParent->mVersion >= 3) wl_keyboard_release(object()); else From 9b5376cce1a1a2af01d7697fc4a25e8f508091fc Mon Sep 17 00:00:00 2001 From: Arnaud Vrac Date: Wed, 27 Nov 2013 23:19:06 +0100 Subject: [PATCH 05/10] Map more XKB key codes Change-Id: I0a2b56043235666bc57b46ae4ac78ca5e24e736d Reviewed-by: Giulio Camuffo --- .../platforms/wayland/qwaylandinputdevice.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index b2268ae7888..3ea9e927f24 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -594,13 +594,30 @@ static const uint32_t KeyTbl[] = { XKB_KEY_Mode_switch, Qt::Key_Mode_switch, XKB_KEY_script_switch, Qt::Key_Mode_switch, + XKB_KEY_XF86Back, Qt::Key_Back, + XKB_KEY_XF86Forward, Qt::Key_Forward, + XKB_KEY_XF86AudioPlay, Qt::Key_MediaTogglePlayPause, //there isn't a PlayPause keysym, however just play keys are not common XKB_KEY_XF86AudioPause, Qt::Key_MediaPause, XKB_KEY_XF86AudioStop, Qt::Key_MediaStop, XKB_KEY_XF86AudioPrev, Qt::Key_MediaPrevious, XKB_KEY_XF86AudioNext, Qt::Key_MediaNext, + XKB_KEY_XF86AudioRewind, Qt::Key_MediaPrevious, + XKB_KEY_XF86AudioForward, Qt::Key_MediaNext, XKB_KEY_XF86AudioRecord, Qt::Key_MediaRecord, + XKB_KEY_XF86AudioMute, Qt::Key_VolumeMute, + XKB_KEY_XF86AudioLowerVolume, Qt::Key_VolumeDown, + XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp, + + XKB_KEY_XF86AudioRandomPlay, Qt::Key_AudioRandomPlay, + XKB_KEY_XF86AudioRepeat, Qt::Key_AudioRepeat, + + XKB_KEY_XF86ZoomIn, Qt::Key_ZoomIn, + XKB_KEY_XF86ZoomOut, Qt::Key_ZoomOut, + + XKB_KEY_XF86Eject, Qt::Key_Eject, + 0, 0 }; From 679e14272c662a3eb9a9c79df0fea29d0ecbddff Mon Sep 17 00:00:00 2001 From: Arnaud Vrac Date: Fri, 13 Mar 2015 15:46:44 +0100 Subject: [PATCH 06/10] Track last input window with a QPointer in case it is destroyed Change-Id: I61d7aa4b6a37922eb3beefd983154ee267cae0ef Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 5 +++++ src/plugins/platforms/wayland/qwaylanddisplay_p.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index b985f10e5b6..e0155fc95b6 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -375,6 +375,11 @@ bool QWaylandDisplay::supportsWindowDecoration() const return integrationSupport; } +QWaylandWindow *QWaylandDisplay::lastInputWindow() const +{ + return mLastInputWindow.data(); +} + void QWaylandDisplay::setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *win) { mLastInputDevice = device; diff --git a/src/plugins/platforms/wayland/qwaylanddisplay_p.h b/src/plugins/platforms/wayland/qwaylanddisplay_p.h index 4549d52e6a6..7ba431d7c99 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay_p.h +++ b/src/plugins/platforms/wayland/qwaylanddisplay_p.h @@ -36,6 +36,7 @@ #include #include +#include #include @@ -157,7 +158,7 @@ public: uint32_t lastInputSerial() const { return mLastInputSerial; } QWaylandInputDevice *lastInputDevice() const { return mLastInputDevice; } - QWaylandWindow *lastInputWindow() const { return mLastInputWindow; } + QWaylandWindow *lastInputWindow() const; void setLastInputDevice(QWaylandInputDevice *device, uint32_t serial, QWaylandWindow *window); public slots: @@ -202,7 +203,7 @@ private: int mCompositorVersion; uint32_t mLastInputSerial; QWaylandInputDevice *mLastInputDevice; - QWaylandWindow *mLastInputWindow; + QPointer mLastInputWindow; void registry_global(uint32_t id, const QString &interface, uint32_t version) Q_DECL_OVERRIDE; void registry_global_remove(uint32_t id) Q_DECL_OVERRIDE; From 3822bac2b7617c6593c2d21ed6203d23aede0613 Mon Sep 17 00:00:00 2001 From: Arnaud Vrac Date: Tue, 16 Sep 2014 17:36:18 +0200 Subject: [PATCH 07/10] Reset wayland object pointer after destroy This allows calling init() on the wayland object again after destroy() Change-Id: I7856cc8ec676eee7575e15a5d1f81cf1b89537c8 Reviewed-by: Giulio Camuffo --- src/tools/qtwaylandscanner/qtwaylandscanner.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp index a0b4afcfaf2..784687d2649 100644 --- a/src/tools/qtwaylandscanner/qtwaylandscanner.cpp +++ b/src/tools/qtwaylandscanner/qtwaylandscanner.cpp @@ -88,6 +88,7 @@ struct WaylandArgument { struct WaylandEvent { bool request; QByteArray name; + QByteArray type; QList arguments; }; @@ -124,6 +125,7 @@ WaylandEvent readEvent(QXmlStreamReader &xml, bool request) WaylandEvent event; event.request = request; event.name = byteArrayValue(xml, "name"); + event.type = byteArrayValue(xml, "type"); while (xml.readNextStartElement()) { if (xml.name() == "arg") { WaylandArgument argument; @@ -998,6 +1000,8 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr } } printf(");\n"); + if (e.type == "destructor") + printf(" m_%s = 0;\n", interfaceName); printf(" }\n"); } From 022f452ed96f0b94dba3f07797fc5f8158815622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 15 May 2015 09:49:58 +0200 Subject: [PATCH 08/10] Add safety check in QWaylandInputDevice::Keyboard::modifiers() ::modifiers() might be invoked before being initialised. E.g. when a pointer button event is emitted before the keymap is sent. Change-Id: Ib95f9866d808b2a32ddfaa0862cdb3226fab1938 Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 3ea9e927f24..76ae258696b 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -299,6 +299,9 @@ Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers() const Qt::KeyboardModifiers ret = Qt::NoModifier; #ifndef QT_NO_WAYLAND_XKB + if (!mXkbState) + return ret; + xkb_state_component cstate = static_cast(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED); if (xkb_state_mod_name_is_active(mXkbState, XKB_MOD_NAME_SHIFT, cstate)) From f0a58486ef7e660ab73a92ae08f949c057796b40 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Thu, 23 Apr 2015 19:32:28 +0300 Subject: [PATCH 09/10] Fix crash when the wl_shm global comes after a wl_output one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-44503 Change-Id: I6932df57bb4560b6dceb72a5cb7c536cd090e92a Reviewed-by: Martin Gräßlin Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 1 + src/plugins/platforms/wayland/qwaylandscreen.cpp | 7 ++++++- src/plugins/platforms/wayland/qwaylandscreen_p.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index e0155fc95b6..c3925f5c446 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -239,6 +239,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin mScreens.append(screen); // We need to get the output events before creating surfaces forceRoundTrip(); + screen->init(); mWaylandIntegration->screenAdded(screen); } else if (interface == QStringLiteral("wl_compositor")) { mCompositorVersion = qMin((int)version, 3); diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index acd125c6275..8a01e366e78 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -60,7 +60,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin , mFormat(QImage::Format_ARGB32_Premultiplied) , mOutputName(QStringLiteral("Screen%1").arg(id)) , m_orientation(Qt::PrimaryOrientation) - , mWaylandCursor(new QWaylandCursor(this)) + , mWaylandCursor(0) { // handle case of output extension global being sent after outputs createExtendedOutput(); @@ -71,6 +71,11 @@ QWaylandScreen::~QWaylandScreen() delete mWaylandCursor; } +void QWaylandScreen::init() +{ + mWaylandCursor = new QWaylandCursor(this); +} + QWaylandDisplay * QWaylandScreen::display() const { return mWaylandDisplay; diff --git a/src/plugins/platforms/wayland/qwaylandscreen_p.h b/src/plugins/platforms/wayland/qwaylandscreen_p.h index 35adee34a5b..06389f7e440 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen_p.h +++ b/src/plugins/platforms/wayland/qwaylandscreen_p.h @@ -53,6 +53,7 @@ public: QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id); ~QWaylandScreen(); + void init(); QWaylandDisplay *display() const; QRect geometry() const; From f57dbc0358f523eabf6ce265e53f08f32edb3306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 20 May 2015 14:20:32 +0200 Subject: [PATCH 10/10] Fix that we pick up the generated headers in source packages Change-Id: If5ae8749ccbddfc878ae4e0adaa40f072527d425 Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/wayland/client.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/wayland/client.pro b/src/plugins/platforms/wayland/client.pro index 00e9cd04a97..0c13a4a9b68 100644 --- a/src/plugins/platforms/wayland/client.pro +++ b/src/plugins/platforms/wayland/client.pro @@ -8,6 +8,8 @@ MODULE_PLUGIN_TYPES = \ wayland-inputdevice-integration \ wayland-decoration-client +CONFIG += generated_privates + load(qt_module) # We have a bunch of C code with casts, so we can't have this option