summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/global/qwaylandclientextension.h2
-rw-r--r--src/client/hardwareintegration/qwaylandclientbufferintegration_p.h4
-rw-r--r--src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp2
-rw-r--r--src/client/qwaylandcursor.cpp4
-rw-r--r--src/client/qwaylanddatadevice.cpp4
-rw-r--r--src/client/qwaylanddisplay.cpp22
-rw-r--r--src/client/qwaylandinputdevice.cpp142
-rw-r--r--src/client/qwaylandinputdevice_p.h52
-rw-r--r--src/client/qwaylandintegration.cpp4
-rw-r--r--src/client/qwaylandscreen.cpp2
-rw-r--r--src/client/qwaylandshmbackingstore.cpp10
-rw-r--r--src/client/qwaylandwindow.cpp45
-rw-r--r--src/client/qwaylandwindow_p.h8
-rw-r--r--src/client/qwaylandwlshellintegration.cpp2
-rw-r--r--src/client/qwaylandwlshellsurface.cpp4
-rw-r--r--src/client/qwaylandwlshellsurface_p.h2
-rw-r--r--src/client/qwaylandxdgshellintegration.cpp2
-rw-r--r--src/client/qwaylandxdgsurface.cpp4
-rw-r--r--src/client/shellintegration/qwaylandshellintegrationfactory.cpp2
19 files changed, 194 insertions, 123 deletions
diff --git a/src/client/global/qwaylandclientextension.h b/src/client/global/qwaylandclientextension.h
index 37debc513..98272e571 100644
--- a/src/client/global/qwaylandclientextension.h
+++ b/src/client/global/qwaylandclientextension.h
@@ -95,7 +95,7 @@ public:
return T::interface();
}
- void bind(struct ::wl_registry *registry, int id, int ver)
+ void bind(struct ::wl_registry *registry, int id, int ver) override
{
T* instance = static_cast<T *>(this);
// Make sure lowest version is used of the supplied version from the
diff --git a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h
index f1f0cf932..7776c6158 100644
--- a/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h
+++ b/src/client/hardwareintegration/qwaylandclientbufferintegration_p.h
@@ -86,8 +86,8 @@ public:
EglConfig,
EglContext
};
- virtual void *nativeResource(NativeResource /*resource*/) { return Q_NULLPTR; }
- virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return Q_NULLPTR; }
+ virtual void *nativeResource(NativeResource /*resource*/) { return nullptr; }
+ virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return nullptr; }
};
}
diff --git a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp
index 94eca3262..8f573064e 100644
--- a/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp
+++ b/src/client/inputdeviceintegration/qwaylandinputdeviceintegrationfactory.cpp
@@ -90,7 +90,7 @@ QWaylandInputDeviceIntegration *QWaylandInputDeviceIntegrationFactory::create(co
if (QWaylandInputDeviceIntegration *ret = qLoadPlugin<QWaylandInputDeviceIntegration, QWaylandInputDeviceIntegrationPlugin>(loader(), name, args))
return ret;
#endif
- return Q_NULLPTR;
+ return nullptr;
}
}
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp
index 7caa247e5..bd820e28e 100644
--- a/src/client/qwaylandcursor.cpp
+++ b/src/client/qwaylandcursor.cpp
@@ -92,7 +92,7 @@ struct wl_cursor_image *QWaylandCursor::cursorImage(Qt::CursorShape newShape)
waylandCursor = requestCursor((WaylandCursor)newShape);
} else if (newShape == Qt::BitmapCursor) {
// cannot create a wl_cursor_image for a CursorShape
- return Q_NULLPTR;
+ return nullptr;
} else {
//TODO: Custom cursor logic (for resize arrows)
}
@@ -119,7 +119,7 @@ QSharedPointer<QWaylandBuffer> QWaylandCursor::cursorBitmapImage(const QCursor *
const QImage &img = cursor->pixmap().toImage();
QSharedPointer<QWaylandShmBuffer> buffer(new QWaylandShmBuffer(mDisplay, img.size(), img.format()));
- memcpy(buffer->image()->bits(), img.bits(), img.byteCount());
+ memcpy(buffer->image()->bits(), img.bits(), img.sizeInBytes());
return buffer;
}
diff --git a/src/client/qwaylanddatadevice.cpp b/src/client/qwaylanddatadevice.cpp
index 33068c5e9..66f36f75b 100644
--- a/src/client/qwaylanddatadevice.cpp
+++ b/src/client/qwaylanddatadevice.cpp
@@ -97,7 +97,7 @@ void QWaylandDataDevice::setSelectionSource(QWaylandDataSource *source)
{
if (source)
connect(source, &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::selectionSourceCancelled);
- set_selection(source ? source->object() : Q_NULLPTR, m_inputDevice->serial());
+ set_selection(source ? source->object() : nullptr, m_inputDevice->serial());
m_selectionSource.reset(source);
}
@@ -160,7 +160,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
m_dragWindow = QWaylandWindow::fromWlSurface(surface)->window();
m_dragPoint = calculateDragPosition(x, y, m_dragWindow);
- QMimeData *dragData = Q_NULLPTR;
+ QMimeData *dragData = nullptr;
Qt::DropActions supportedActions;
m_dragOffer.reset(static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id)));
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index 86cfe1a0d..02b1fd9a9 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -97,7 +97,7 @@ struct ::wl_region *QWaylandDisplay::createRegion(const QRegion &qregion)
{
struct ::wl_region *region = mCompositor.create_region();
- Q_FOREACH (const QRect &rect, qregion.rects())
+ for (const QRect &rect : qregion)
wl_region_add(region, rect.x(), rect.y(), rect.width(), rect.height());
return region;
@@ -136,8 +136,8 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
, mLastInputSerial(0)
, mLastInputDevice(0)
, mLastInputWindow(0)
- , mLastKeyboardFocus(Q_NULLPTR)
- , mSyncCallback(Q_NULLPTR)
+ , mLastKeyboardFocus(nullptr)
+ , mSyncCallback(nullptr)
{
qRegisterMetaType<uint32_t>("uint32_t");
@@ -157,6 +157,9 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
QWaylandDisplay::~QWaylandDisplay(void)
{
+ if (mSyncCallback)
+ wl_callback_destroy(mSyncCallback);
+
qDeleteAll(mInputDevices);
mInputDevices.clear();
@@ -343,6 +346,15 @@ sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
bool *done = static_cast<bool *>(data);
*done = true;
+
+ // If the wl_callback done event is received after the condition check in the while loop in
+ // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+ // forever if no more events are posted (eventhough the callback is handled in response to the
+ // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+ // (QTBUG-64696)
+ if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+ dispatcher->wakeUp();
+
wl_callback_destroy(callback);
}
@@ -446,7 +458,7 @@ void QWaylandDisplay::handleWaylandSync()
// This callback is used to set the window activation because we may get an activate/deactivate
// pair, and the latter one would be lost in the QWindowSystemInterface queue, if we issue the
// handleWindowActivated() calls immediately.
- QWindow *activeWindow = mActiveWindows.empty() ? Q_NULLPTR : mActiveWindows.last()->window();
+ QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
if (activeWindow != QGuiApplication::focusWindow())
QWindowSystemInterface::handleWindowActivated(activeWindow);
}
@@ -456,7 +468,7 @@ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
Q_UNUSED(time);
wl_callback_destroy(callback);
QWaylandDisplay *display = static_cast<QWaylandDisplay *>(data);
- display->mSyncCallback = Q_NULLPTR;
+ display->mSyncCallback = nullptr;
display->handleWaylandSync();
}
};
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index 4def0de8f..b34504a1f 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -70,19 +70,16 @@
#include <QtGui/QGuiApplication>
+#if QT_CONFIG(xkbcommon_evdev)
+#include <xkbcommon/xkbcommon-compose.h>
+#endif
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
QWaylandInputDevice::Keyboard::Keyboard(QWaylandInputDevice *p)
: mParent(p)
- , mFocus(0)
-#if QT_CONFIG(xkbcommon_evdev)
- , mXkbContext(0)
- , mXkbMap(0)
- , mXkbState(0)
-#endif
- , mNativeModifiers(0)
{
connect(&mRepeatTimer, SIGNAL(timeout()), this, SLOT(repeatKey()));
}
@@ -113,6 +110,7 @@ bool QWaylandInputDevice::Keyboard::createDefaultKeyMap()
qWarning() << "xkb_map_new_from_names failed, no key input";
return false;
}
+ createComposeState();
return true;
}
@@ -125,15 +123,45 @@ void QWaylandInputDevice::Keyboard::releaseKeyMap()
if (mXkbContext)
xkb_context_unref(mXkbContext);
}
+
+void QWaylandInputDevice::Keyboard::createComposeState()
+{
+ static const char *locale = nullptr;
+ if (!locale) {
+ locale = getenv("LC_ALL");
+ if (!locale)
+ locale = getenv("LC_CTYPE");
+ if (!locale)
+ locale = getenv("LANG");
+ if (!locale)
+ locale = "C";
+ }
+
+ mXkbComposeTable = xkb_compose_table_new_from_locale(mXkbContext, locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
+ if (mXkbComposeTable)
+ mXkbComposeState = xkb_compose_state_new(mXkbComposeTable, XKB_COMPOSE_STATE_NO_FLAGS);
+}
+
+void QWaylandInputDevice::Keyboard::releaseComposeState()
+{
+ if (mXkbComposeState)
+ xkb_compose_state_unref(mXkbComposeState);
+ if (mXkbComposeTable)
+ xkb_compose_table_unref(mXkbComposeTable);
+ mXkbComposeState = nullptr;
+ mXkbComposeTable = nullptr;
+}
+
#endif
QWaylandInputDevice::Keyboard::~Keyboard()
{
#if QT_CONFIG(xkbcommon_evdev)
+ releaseComposeState();
releaseKeyMap();
#endif
if (mFocus)
- QWindowSystemInterface::handleWindowActivated(0);
+ QWindowSystemInterface::handleWindowActivated(nullptr);
if (mParent->mVersion >= 3)
wl_keyboard_release(object());
else
@@ -147,16 +175,6 @@ void QWaylandInputDevice::Keyboard::stopRepeat()
QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *p)
: mParent(p)
- , mFocus(0)
- , mEnterSerial(0)
-#if QT_CONFIG(cursor)
- , mCursorSerial(0)
-#endif
- , mButtons(0)
-#if QT_CONFIG(cursor)
- , mCursorBuffer(nullptr)
- , mCursorShape(Qt::BitmapCursor)
-#endif
{
}
@@ -170,7 +188,6 @@ QWaylandInputDevice::Pointer::~Pointer()
QWaylandInputDevice::Touch::Touch(QWaylandInputDevice *p)
: mParent(p)
- , mFocus(0)
{
}
@@ -188,17 +205,6 @@ QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version,
, mQDisplay(display)
, mDisplay(display->wl_display())
, mVersion(qMin(version, 4))
- , mCaps(0)
-#if QT_CONFIG(wayland_datadevice)
- , mDataDevice(0)
-#endif
- , mKeyboard(0)
- , mPointer(0)
- , mTouch(0)
- , mTextInput(0)
- , mTime(0)
- , mSerial(0)
- , mTouchDevice(0)
{
#if QT_CONFIG(wayland_datadevice)
if (mQDisplay->dndSelectionHandler()) {
@@ -227,7 +233,7 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps)
mKeyboard->init(get_keyboard());
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && mKeyboard) {
delete mKeyboard;
- mKeyboard = 0;
+ mKeyboard = nullptr;
}
if (caps & WL_SEAT_CAPABILITY_POINTER && !mPointer) {
@@ -236,7 +242,7 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps)
pointerSurface = mQDisplay->createSurface(this);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && mPointer) {
delete mPointer;
- mPointer = 0;
+ mPointer = nullptr;
}
if (caps & WL_SEAT_CAPABILITY_TOUCH && !mTouch) {
@@ -251,7 +257,7 @@ void QWaylandInputDevice::seat_capabilities(uint32_t caps)
}
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && mTouch) {
delete mTouch;
- mTouch = 0;
+ mTouch = nullptr;
}
}
@@ -272,14 +278,8 @@ QWaylandInputDevice::Touch *QWaylandInputDevice::createTouch(QWaylandInputDevice
void QWaylandInputDevice::handleWindowDestroyed(QWaylandWindow *window)
{
- if (mPointer && window == mPointer->mFocus)
- mPointer->mFocus = 0;
- if (mKeyboard && window == mKeyboard->mFocus) {
- mKeyboard->mFocus = 0;
+ if (mKeyboard && window == mKeyboard->mFocus)
mKeyboard->stopRepeat();
- }
- if (mTouch && window == mTouch->mFocus)
- mTouch->mFocus = 0;
}
void QWaylandInputDevice::handleEndDrag()
@@ -321,17 +321,17 @@ void QWaylandInputDevice::removeMouseButtonFromState(Qt::MouseButton button)
QWaylandWindow *QWaylandInputDevice::pointerFocus() const
{
- return mPointer ? mPointer->mFocus : 0;
+ return mPointer ? mPointer->mFocus : nullptr;
}
QWaylandWindow *QWaylandInputDevice::keyboardFocus() const
{
- return mKeyboard ? mKeyboard->mFocus : 0;
+ return mKeyboard ? mKeyboard->mFocus : nullptr;
}
QWaylandWindow *QWaylandInputDevice::touchFocus() const
{
- return mTouch ? mTouch->mFocus : 0;
+ return mTouch ? mTouch->mFocus : nullptr;
}
Qt::KeyboardModifiers QWaylandInputDevice::modifiers() const
@@ -411,7 +411,7 @@ void QWaylandInputDevice::setCursor(struct wl_buffer *buffer, const QPoint &hotS
/* Hide cursor */
if (!buffer)
{
- mPointer->set_cursor(mPointer->mEnterSerial, NULL, 0, 0);
+ mPointer->set_cursor(mPointer->mEnterSerial, nullptr, 0, 0);
return;
}
@@ -434,7 +434,7 @@ class EnterEvent : public QWaylandPointerEvent
{
public:
EnterEvent(const QPointF &l, const QPointF &g)
- : QWaylandPointerEvent(QWaylandPointerEvent::Enter, 0, l, g, 0, Qt::NoModifier)
+ : QWaylandPointerEvent(QWaylandPointerEvent::Enter, 0, l, g, nullptr, Qt::NoModifier)
{}
};
@@ -474,7 +474,7 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
QWaylandWindow *window = QWaylandWindow::fromWlSurface(surface);
window->handleMouseLeave(mParent);
}
- mFocus = 0;
+ mFocus = nullptr;
mButtons = Qt::NoButton;
mParent->mTime = time;
@@ -493,7 +493,7 @@ void QWaylandInputDevice::Pointer::pointer_motion(uint32_t time, wl_fixed_t surf
{
QWaylandWindow *window = mFocus;
- if (window == NULL) {
+ if (!window) {
// We destroyed the pointer focus surface, but the server
// didn't get the message yet.
return;
@@ -595,7 +595,7 @@ void QWaylandInputDevice::Pointer::pointer_axis(uint32_t time, uint32_t axis, in
QPoint pixelDelta;
QPoint angleDelta;
- if (window == NULL) {
+ if (!window) {
// We destroyed the pointer focus surface, but the server
// didn't get the message yet.
return;
@@ -624,7 +624,7 @@ void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t format, int32_t fd,
return;
}
- char *map_str = (char *)mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
+ char *map_str = static_cast<char *>(mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0));
if (map_str == MAP_FAILED) {
close(fd);
return;
@@ -632,14 +632,17 @@ void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t format, int32_t fd,
// Release the old keymap resources in the case they were already created in
// the key event or when the compositor issues a new map
+ releaseComposeState();
releaseKeyMap();
- mXkbContext = xkb_context_new(xkb_context_flags(0));
- mXkbMap = xkb_map_new_from_string(mXkbContext, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, (xkb_keymap_compile_flags)0);
+ mXkbContext = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
+ mXkbMap = xkb_map_new_from_string(mXkbContext, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
munmap(map_str, size);
close(fd);
mXkbState = xkb_state_new(mXkbMap);
+ createComposeState();
+
#else
Q_UNUSED(format);
Q_UNUSED(fd);
@@ -672,7 +675,7 @@ void QWaylandInputDevice::Keyboard::keyboard_leave(uint32_t time, struct wl_surf
window->unfocus();
}
- mFocus = NULL;
+ mFocus = nullptr;
mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
@@ -703,7 +706,7 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
{
QWaylandWindow *window = mFocus;
uint32_t code = key + 8;
- bool isDown = state != 0;
+ bool isDown = state != WL_KEYBOARD_KEY_STATE_RELEASED;
QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease;
QString text;
int qtkey = key + 8; // qt-compositor substracts 8 for some reason
@@ -723,12 +726,37 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time,
return;
}
- const xkb_keysym_t sym = xkb_state_key_get_one_sym(mXkbState, code);
+ QString composedText;
+ xkb_keysym_t sym = xkb_state_key_get_one_sym(mXkbState, code);
+ if (mXkbComposeState) {
+ if (isDown)
+ xkb_compose_state_feed(mXkbComposeState, sym);
+ xkb_compose_status status = xkb_compose_state_get_status(mXkbComposeState);
+
+ switch (status) {
+ case XKB_COMPOSE_COMPOSED: {
+ int size = xkb_compose_state_get_utf8(mXkbComposeState, nullptr, 0);
+ QVarLengthArray<char, 32> buffer(size + 1);
+ xkb_compose_state_get_utf8(mXkbComposeState, buffer.data(), buffer.size());
+ composedText = QString::fromUtf8(buffer.constData());
+ sym = xkb_compose_state_get_one_sym(mXkbComposeState);
+ xkb_compose_state_reset(mXkbComposeState);
+ } break;
+ case XKB_COMPOSE_COMPOSING:
+ case XKB_COMPOSE_CANCELLED:
+ return;
+ case XKB_COMPOSE_NOTHING:
+ break;
+ }
+ }
Qt::KeyboardModifiers modifiers = mParent->modifiers();
std::tie(qtkey, text) = QWaylandXkb::keysymToQtKey(sym, modifiers);
+ if (!composedText.isNull())
+ text = composedText;
+
sendKey(window->window(), time, type, qtkey, modifiers, code, sym, mNativeModifiers, text);
#else
// Generic fallback for single hard keys: Assume 'key' is a Qt key code.
@@ -817,7 +845,7 @@ void QWaylandInputDevice::Touch::touch_up(uint32_t serial, uint32_t time, int32_
{
Q_UNUSED(serial);
Q_UNUSED(time);
- mFocus = 0;
+ mFocus = nullptr;
mParent->handleTouchPoint(id, 0, 0, Qt::TouchPointReleased);
// As of Weston 1.5.90 there is no touch_frame after the last touch_up
@@ -843,7 +871,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
if (touchExt)
touchExt->touchCanceled();
- QWindowSystemInterface::handleTouchCancelEvent(0, mParent->mTouchDevice);
+ QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
}
void QWaylandInputDevice::handleTouchPoint(int id, double x, double y, Qt::TouchPointState state)
@@ -928,7 +956,7 @@ void QWaylandInputDevice::Touch::touch_frame()
return;
}
- QWindow *window = mFocus ? mFocus->window() : 0;
+ QWindow *window = mFocus ? mFocus->window() : nullptr;
if (mFocus) {
const QWindowSystemInterface::TouchPoint &tp = mTouchPoints.last();
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index 9e3d1d1f4..8a02769e3 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -71,11 +71,17 @@
#endif
#include <QtCore/QDebug>
+#include <QPointer>
#if QT_CONFIG(cursor)
struct wl_cursor_image;
#endif
+#if QT_CONFIG(xkbcommon_evdev)
+struct xkb_compose_state;
+struct xkb_compose_table;
+#endif
+
QT_BEGIN_NAMESPACE
namespace QtWaylandClient {
@@ -141,27 +147,27 @@ private:
struct wl_display *mDisplay;
int mVersion;
- uint32_t mCaps;
+ uint32_t mCaps = 0;
struct wl_surface *pointerSurface;
#if QT_CONFIG(wayland_datadevice)
- QWaylandDataDevice *mDataDevice;
+ QWaylandDataDevice *mDataDevice = nullptr;
#endif
- Keyboard *mKeyboard;
- Pointer *mPointer;
- Touch *mTouch;
+ Keyboard *mKeyboard = nullptr;
+ Pointer *mPointer = nullptr;
+ Touch *mTouch = nullptr;
- QWaylandTextInput *mTextInput;
+ QWaylandTextInput *mTextInput = nullptr;
- uint32_t mTime;
- uint32_t mSerial;
+ uint32_t mTime = 0;
+ uint32_t mSerial = 0;
void seat_capabilities(uint32_t caps) override;
void handleTouchPoint(int id, double x, double y, Qt::TouchPointState state);
- QTouchDevice *mTouchDevice;
+ QTouchDevice *mTouchDevice = nullptr;
QSharedPointer<QWaylandBuffer> mPixmapCursor;
@@ -202,13 +208,15 @@ public:
uint32_t group) override;
QWaylandInputDevice *mParent;
- QWaylandWindow *mFocus;
+ QPointer<QWaylandWindow> mFocus;
#if QT_CONFIG(xkbcommon_evdev)
- xkb_context *mXkbContext;
- xkb_keymap *mXkbMap;
- xkb_state *mXkbState;
+ xkb_context *mXkbContext = nullptr;
+ xkb_keymap *mXkbMap = nullptr;
+ xkb_state *mXkbState = nullptr;
+ xkb_compose_table *mXkbComposeTable = nullptr;
+ xkb_compose_state *mXkbComposeState = nullptr;
#endif
- uint32_t mNativeModifiers;
+ uint32_t mNativeModifiers = 0;
int mRepeatKey;
uint32_t mRepeatCode;
@@ -228,6 +236,8 @@ private:
#if QT_CONFIG(xkbcommon_evdev)
bool createDefaultKeyMap();
void releaseKeyMap();
+ void createComposeState();
+ void releaseComposeState();
#endif
};
@@ -253,17 +263,17 @@ public:
void releaseButtons();
QWaylandInputDevice *mParent;
- QWaylandWindow *mFocus;
- uint32_t mEnterSerial;
+ QPointer<QWaylandWindow> mFocus;
+ uint32_t mEnterSerial = 0;
#if QT_CONFIG(cursor)
- uint32_t mCursorSerial;
+ uint32_t mCursorSerial = 0;
#endif
QPointF mSurfacePos;
QPointF mGlobalPos;
- Qt::MouseButtons mButtons;
+ Qt::MouseButtons mButtons = Qt::NoButton;
#if QT_CONFIG(cursor)
- wl_buffer *mCursorBuffer;
- Qt::CursorShape mCursorShape;
+ wl_buffer *mCursorBuffer = nullptr;
+ Qt::CursorShape mCursorShape = Qt::BitmapCursor;
#endif
};
@@ -293,7 +303,7 @@ public:
void releasePoints();
QWaylandInputDevice *mParent;
- QWaylandWindow *mFocus;
+ QPointer<QWaylandWindow> mFocus;
QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
};
diff --git a/src/client/qwaylandintegration.cpp b/src/client/qwaylandintegration.cpp
index bffadf29a..f0182218f 100644
--- a/src/client/qwaylandintegration.cpp
+++ b/src/client/qwaylandintegration.cpp
@@ -122,7 +122,7 @@ public:
QWaylandIntegration::QWaylandIntegration()
: mClientBufferIntegration(0)
- , mInputDeviceIntegration(Q_NULLPTR)
+ , mInputDeviceIntegration(nullptr)
, mFontDb(new QGenericUnixFontDatabase())
, mNativeInterface(new QWaylandNativeInterface(this))
#if QT_CONFIG(accessibility)
@@ -397,7 +397,7 @@ void QWaylandIntegration::initializeShellIntegration()
"please specify the shell using QT_WAYLAND_SHELL_INTEGRATION instead";
preferredShells << QLatin1String("xdg-shell-v5");
}
- preferredShells << QLatin1String("wl-shell");
+ preferredShells << QLatin1String("wl-shell") << QLatin1String("ivi-shell");
}
Q_FOREACH (QString preferredShell, preferredShells) {
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
index 5b43428d9..b6336f2e6 100644
--- a/src/client/qwaylandscreen.cpp
+++ b/src/client/qwaylandscreen.cpp
@@ -147,7 +147,7 @@ void QWaylandScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
{
foreach (QWindow *window, QGuiApplication::allWindows()) {
QWaylandWindow *w = static_cast<QWaylandWindow *>(window->handle());
- if (w && w->screen() == this)
+ if (w && w->waylandScreen() == this)
w->setOrientationMask(mask);
}
}
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp
index 2085bc597..a13a5f764 100644
--- a/src/client/qwaylandshmbackingstore.cpp
+++ b/src/client/qwaylandshmbackingstore.cpp
@@ -125,7 +125,7 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void)
{
delete mMarginsImage;
if (mImage.constBits())
- munmap((void *) mImage.constBits(), mImage.byteCount());
+ munmap((void *) mImage.constBits(), mImage.sizeInBytes());
if (mShmPool)
wl_shm_pool_destroy(mShmPool);
}
@@ -171,7 +171,7 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window)
QWaylandShmBackingStore::~QWaylandShmBackingStore()
{
if (QWaylandWindow *w = waylandWindow())
- w->setBackingStore(Q_NULLPTR);
+ w->setBackingStore(nullptr);
// if (mFrontBuffer == waylandWindow()->attached())
// waylandWindow()->attach(0);
@@ -287,10 +287,10 @@ void QWaylandShmBackingStore::resize(const QSize &size)
buffer = getBuffer(sizeWithMargins);
}
- int oldSize = mBackBuffer ? mBackBuffer->image()->byteCount() : 0;
+ qsizetype oldSize = mBackBuffer ? mBackBuffer->image()->sizeInBytes() : 0;
// mBackBuffer may have been deleted here but if so it means its size was different so we wouldn't copy it anyway
- if (mBackBuffer != buffer && oldSize == buffer->image()->byteCount()) {
- memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->byteCount());
+ if (mBackBuffer != buffer && oldSize == buffer->image()->sizeInBytes()) {
+ memcpy(buffer->image()->bits(), mBackBuffer->image()->constBits(), buffer->image()->sizeInBytes());
}
mBackBuffer = buffer;
// ensure the new buffer is at the beginning of the list so next time getBuffer() will pick
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 6661d8e7e..2e709440f 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -80,7 +80,7 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = 0;
QWaylandWindow::QWaylandWindow(QWindow *window)
: QObject()
, QPlatformWindow(window)
- , mDisplay(screen()->display())
+ , mDisplay(waylandScreen()->display())
, mShellSurface(0)
, mSubSurfaceWindow(0)
, mWindowDecoration(0)
@@ -95,7 +95,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window)
, mScale(1)
, mState(Qt::WindowNoState)
, mMask()
- , mBackingStore(Q_NULLPTR)
+ , mBackingStore(nullptr)
, mUpdateRequested(false)
{
static WId id = 1;
@@ -128,6 +128,12 @@ QWaylandWindow::~QWaylandWindow()
}
}
+void QWaylandWindow::ensureSize()
+{
+ if (mBackingStore)
+ mBackingStore->ensureSize();
+}
+
void QWaylandWindow::initWindow()
{
if (window()->type() == Qt::Desktop)
@@ -194,12 +200,11 @@ void QWaylandWindow::initWindow()
}
}
- mScale = screen()->scale();
+ mScale = waylandScreen()->scale();
// Enable high-dpi rendering. Scale() returns the screen scale factor and will
// typically be integer 1 (normal-dpi) or 2 (high-dpi). Call set_buffer_scale()
// to inform the compositor that high-resolution buffers will be provided.
- //FIXME this needs to be changed when the screen changes along with a resized backing store
if (mDisplay->compositorVersion() >= 3)
set_buffer_scale(scale());
@@ -241,7 +246,7 @@ bool QWaylandWindow::shouldCreateShellSurface() const
bool QWaylandWindow::shouldCreateSubSurface() const
{
- return QPlatformWindow::parent() != Q_NULLPTR;
+ return QPlatformWindow::parent() != nullptr;
}
void QWaylandWindow::reset(bool sendDestroyEvent)
@@ -369,7 +374,7 @@ void QWaylandWindow::closePopups(QWaylandWindow *parent)
QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
{
- return mScreens.isEmpty() ? screen() : mScreens.first();
+ return mScreens.isEmpty() ? waylandScreen() : mScreens.first();
}
void QWaylandWindow::setVisible(bool visible)
@@ -523,7 +528,7 @@ void QWaylandWindow::surface_enter(wl_output *output)
QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents();
if (oldScreen != newScreen) //currently this will only happen if the first wl_surface.enter is for a non-primary screen
- QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+ handleScreenChanged();
}
void QWaylandWindow::surface_leave(wl_output *output)
@@ -540,7 +545,7 @@ void QWaylandWindow::surface_leave(wl_output *output)
QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents();
if (oldScreen != newScreen)
- QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+ handleScreenChanged();
}
void QWaylandWindow::handleScreenRemoved(QScreen *qScreen)
@@ -550,7 +555,7 @@ void QWaylandWindow::handleScreenRemoved(QScreen *qScreen)
if (wasRemoved) {
QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents();
if (oldScreen != newScreen)
- QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+ handleScreenChanged();
}
}
@@ -590,8 +595,7 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
return;
attachOffset(buffer);
- const QVector<QRect> rects = damage.rects();
- for (const QRect &rect: rects)
+ for (const QRect &rect: damage)
wl_surface::damage(rect.x(), rect.y(), rect.width(), rect.height());
wl_surface::commit();
}
@@ -603,6 +607,7 @@ const wl_callback_listener QWaylandWindow::callbackListener = {
void QWaylandWindow::frameCallback(void *data, struct wl_callback *callback, uint32_t time)
{
Q_UNUSED(time);
+ Q_UNUSED(callback);
QWaylandWindow *self = static_cast<QWaylandWindow*>(data);
self->mWaitingForFrameSync = false;
@@ -642,7 +647,7 @@ QWaylandSubSurface *QWaylandWindow::subSurfaceWindow() const
return mSubSurfaceWindow;
}
-QWaylandScreen *QWaylandWindow::screen() const
+QWaylandScreen *QWaylandWindow::waylandScreen() const
{
return static_cast<QWaylandScreen *>(QPlatformWindow::screen());
}
@@ -913,10 +918,24 @@ void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDe
}
}
+void QWaylandWindow::handleScreenChanged()
+{
+ QWaylandScreen *newScreen = calculateScreenFromSurfaceEvents();
+ QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+
+ int scale = newScreen->scale();
+ if (scale != mScale) {
+ mScale = scale;
+ if (isInitialized() && mDisplay->compositorVersion() >= 3)
+ set_buffer_scale(mScale);
+ ensureSize();
+ }
+}
+
#if QT_CONFIG(cursor)
void QWaylandWindow::setMouseCursor(QWaylandInputDevice *device, const QCursor &cursor)
{
- device->setCursor(cursor, screen());
+ device->setCursor(cursor, waylandScreen());
}
void QWaylandWindow::restoreMouseCursor(QWaylandInputDevice *device)
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 961b7881d..fca96f30d 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -110,6 +110,7 @@ public:
~QWaylandWindow();
virtual WindowType windowType() const = 0;
+ virtual void ensureSize();
WId winId() const override;
void setVisible(bool visible) override;
void setParent(const QPlatformWindow *parent) override;
@@ -142,7 +143,7 @@ public:
QWaylandDisplay *display() const { return mDisplay; }
QWaylandShellSurface *shellSurface() const;
QWaylandSubSurface *subSurfaceWindow() const;
- QWaylandScreen *screen() const;
+ QWaylandScreen *waylandScreen() const;
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override;
void setOrientationMask(Qt::ScreenOrientations mask);
@@ -263,6 +264,7 @@ private:
QWaylandScreen *calculateScreenFromSurfaceEvents() const;
void handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e);
+ void handleScreenChanged();
bool mUpdateRequested;
@@ -285,8 +287,8 @@ inline QPoint QWaylandWindow::attachOffset() const
return mOffset;
}
-QT_END_NAMESPACE
-
}
+QT_END_NAMESPACE
+
#endif // QWAYLANDWINDOW_H
diff --git a/src/client/qwaylandwlshellintegration.cpp b/src/client/qwaylandwlshellintegration.cpp
index e945745e2..e51637108 100644
--- a/src/client/qwaylandwlshellintegration.cpp
+++ b/src/client/qwaylandwlshellintegration.cpp
@@ -55,7 +55,7 @@ QWaylandWlShellIntegration *QWaylandWlShellIntegration::create(QWaylandDisplay *
}
QWaylandWlShellIntegration::QWaylandWlShellIntegration(QWaylandDisplay *display)
- : m_wlShell(Q_NULLPTR)
+ : m_wlShell(nullptr)
{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("wl_shell")) {
diff --git a/src/client/qwaylandwlshellsurface.cpp b/src/client/qwaylandwlshellsurface.cpp
index 92223f45e..185cfc4a9 100644
--- a/src/client/qwaylandwlshellsurface.cpp
+++ b/src/client/qwaylandwlshellsurface.cpp
@@ -58,7 +58,7 @@ QWaylandWlShellSurface::QWaylandWlShellSurface(struct ::wl_shell_surface *shell_
, m_window(window)
, m_maximized(false)
, m_fullscreen(false)
- , m_extendedWindow(Q_NULLPTR)
+ , m_extendedWindow(nullptr)
{
if (window->display()->windowExtension())
m_extendedWindow = new QWaylandExtendedSurface(window);
@@ -192,7 +192,7 @@ void QWaylandWlShellSurface::updateTransientParent(QWindow *parent)
flags);
}
-void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial)
+void QWaylandWlShellSurface::setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial)
{
QWaylandWindow *parent_wayland_window = parent;
if (!parent_wayland_window) {
diff --git a/src/client/qwaylandwlshellsurface_p.h b/src/client/qwaylandwlshellsurface_p.h
index 94e3417a4..62583949b 100644
--- a/src/client/qwaylandwlshellsurface_p.h
+++ b/src/client/qwaylandwlshellsurface_p.h
@@ -102,7 +102,7 @@ private:
void setTopLevel();
void updateTransientParent(QWindow *parent);
- void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial);
+ void setPopup(QWaylandWindow *parent, QWaylandInputDevice *device, uint serial);
QWaylandWindow *m_window;
bool m_maximized;
diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/client/qwaylandxdgshellintegration.cpp
index 04b8e8048..7c40d2dd7 100644
--- a/src/client/qwaylandxdgshellintegration.cpp
+++ b/src/client/qwaylandxdgshellintegration.cpp
@@ -57,7 +57,7 @@ QWaylandXdgShellIntegration *QWaylandXdgShellIntegration::create(QWaylandDisplay
}
QWaylandXdgShellIntegration::QWaylandXdgShellIntegration(QWaylandDisplay *display)
- : m_xdgShell(Q_NULLPTR)
+ : m_xdgShell(nullptr)
{
Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) {
if (global.interface == QLatin1String("xdg_shell")) {
diff --git a/src/client/qwaylandxdgsurface.cpp b/src/client/qwaylandxdgsurface.cpp
index fe8761e5b..60266af68 100644
--- a/src/client/qwaylandxdgsurface.cpp
+++ b/src/client/qwaylandxdgsurface.cpp
@@ -61,7 +61,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, QWaylandWindow *
, m_minimized(false)
, m_fullscreen(false)
, m_active(false)
- , m_extendedWindow(Q_NULLPTR)
+ , m_extendedWindow(nullptr)
{
if (window->display()->windowExtension())
m_extendedWindow = new QWaylandExtendedSurface(window);
@@ -105,7 +105,7 @@ void QWaylandXdgSurface::setMaximized()
void QWaylandXdgSurface::setFullscreen()
{
if (!m_fullscreen)
- set_fullscreen(Q_NULLPTR);
+ set_fullscreen(nullptr);
}
void QWaylandXdgSurface::setNormal()
diff --git a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
index 09c62339b..c5a505bbe 100644
--- a/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
+++ b/src/client/shellintegration/qwaylandshellintegrationfactory.cpp
@@ -90,7 +90,7 @@ QWaylandShellIntegration *QWaylandShellIntegrationFactory::create(const QString
if (QWaylandShellIntegration *ret = qLoadPlugin<QWaylandShellIntegration, QWaylandShellIntegrationPlugin>(loader(), name, args))
return ret;
#endif
- return Q_NULLPTR;
+ return nullptr;
}
}