diff --git a/src/plugins/platforms/wayland/client.pro b/src/plugins/platforms/wayland/client.pro index 08c184a5e59..29016c9c8ec 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 diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index 6bad56ae3f0..bda85c49c25 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -237,6 +237,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); @@ -369,6 +370,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 bbd0e871dda..9a7ad39ce82 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 @@ -156,7 +157,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: @@ -200,7 +201,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; diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 3b5e83481fb..76ae258696b 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 @@ -295,17 +299,18 @@ 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, "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 @@ -592,13 +597,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 }; @@ -759,7 +781,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(); 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); } diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 057515af02b..dc634f88bc9 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -58,7 +58,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) { } @@ -67,6 +67,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 e2acac4b3a3..3d38e30a8da 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen_p.h +++ b/src/plugins/platforms/wayland/qwaylandscreen_p.h @@ -52,6 +52,7 @@ public: QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id); ~QWaylandScreen(); + void init(); QWaylandDisplay *display() const; QRect geometry() const; 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"); }