From 2838c7f33a0b2f40b026d00b3e00139f94c358e7 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 16 Aug 2019 12:54:56 +0200 Subject: Fix incorrect conversion to straight alpha pixel formats Previously, QWaylandSharedMemoryFormatHelper::fromWaylandShmFormat(WL_SHM_FORMAT_ARGB8888) would return Format_ARGB32, i.e. the non-premultiplied version, while, according to the wayland-devel mailing list (https://lists.freedesktop.org/archives/wayland-devel/2017-August/034791.html), all Wayland RGB-based pixel formats with alpha should have premultiplied alpha. This patch makes sure we return the premultiplied variants for ARGB8888, as well as for ABGR8888. Using a switch instead of the array also allows us more freedom to choose the preferred format in other cases where multiple QImage formats map to the same wl_shm format. While being wrapped and exported as QtWaylandClient::QWaylandShm::fromFormat (private API), this conversion function doesn't seem to be used anywhere, so this patch shouldn't cause any changes in behavior for projects that only use public API. Change-Id: Ie09f9a339b4540dd0383a72b3c951eb8c93e3ab4 Reviewed-by: Pier Luigi Fiorini --- src/shared/qwaylandsharedmemoryformathelper_p.h | 31 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/shared') diff --git a/src/shared/qwaylandsharedmemoryformathelper_p.h b/src/shared/qwaylandsharedmemoryformathelper_p.h index 85905c02f..72cc8401c 100644 --- a/src/shared/qwaylandsharedmemoryformathelper_p.h +++ b/src/shared/qwaylandsharedmemoryformathelper_p.h @@ -51,7 +51,26 @@ class QWaylandSharedMemoryFormatHelper { public: static inline wl_shm_format fromQImageFormat(QImage::Format format); - static inline QImage::Format fromWaylandShmFormat(wl_shm_format format); + static inline QImage::Format fromWaylandShmFormat(wl_shm_format format) + { + switch (format) { + case WL_SHM_FORMAT_XRGB8888: return QImage::Format_RGB32; + case WL_SHM_FORMAT_ARGB8888: return QImage::Format_ARGB32_Premultiplied; + case WL_SHM_FORMAT_RGB565: return QImage::Format_RGB16; + case WL_SHM_FORMAT_XRGB1555: return QImage::Format_RGB555; + case WL_SHM_FORMAT_RGB888: return QImage::Format_RGB888; + case WL_SHM_FORMAT_XRGB4444: return QImage::Format_RGB444; + case WL_SHM_FORMAT_ARGB4444: return QImage::Format_ARGB4444_Premultiplied; + case WL_SHM_FORMAT_XBGR8888: return QImage::Format_RGBX8888; + case WL_SHM_FORMAT_ABGR8888: return QImage::Format_RGBA8888_Premultiplied; + case WL_SHM_FORMAT_XBGR2101010: return QImage::Format_BGR30; + case WL_SHM_FORMAT_ABGR2101010: return QImage::Format_A2BGR30_Premultiplied; + case WL_SHM_FORMAT_XRGB2101010: return QImage::Format_RGB30; + case WL_SHM_FORMAT_ARGB2101010: return QImage::Format_A2RGB30_Premultiplied; + case WL_SHM_FORMAT_C8: return QImage::Format_Alpha8; + default: return QImage::Format_Invalid; + } + } static inline QVector supportedWaylandFormats(); private: @@ -108,16 +127,6 @@ wl_shm_format QWaylandSharedMemoryFormatHelper::fromQImageFormat(QImage::Format return array.data[format]; } -QImage::Format QWaylandSharedMemoryFormatHelper::fromWaylandShmFormat(wl_shm_format format) -{ - Array array = getData(); - for (size_t i = 0; i < array.size; i++) { - if (array.data[i] == format) - return QImage::Format(i); - } - return QImage::Format_Invalid; -} - QVector QWaylandSharedMemoryFormatHelper::supportedWaylandFormats() { QVector retFormats; -- cgit v1.2.3 From 70473e7d3b7820ba171ee67bc0098906a2a59fe4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 9 Jul 2019 13:15:20 +0200 Subject: Handle Key_Return explicitly instead of depending on the text When Key_Return is sent from Qt VirtualKeyboard it will send it as \n and not \r which means it will be interpreted as an unknown key. So since we know it will be able to map it in this case, we explicitly account for it so it can be mapped to the right key. Change-Id: Id5d8d9653e78975203f80790b7a3d332f0e011fa Reviewed-by: Johan Helsing --- src/shared/qwaylandxkb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/shared') diff --git a/src/shared/qwaylandxkb.cpp b/src/shared/qwaylandxkb.cpp index 3cfc4b074..2dff8a5b1 100644 --- a/src/shared/qwaylandxkb.cpp +++ b/src/shared/qwaylandxkb.cpp @@ -376,7 +376,7 @@ QVector QWaylandXkb::toKeysym(QKeyEvent *event) keysyms.append(XKB_KEY_KP_0 + (event->key() - Qt::Key_0)); else keysyms.append(toKeysymFromTable(event->key())); - } else if (!event->text().isEmpty()) { + } else if (!event->text().isEmpty() && event->key() != Qt::Key_Return) { // From libxkbcommon keysym-utf.c: // "We allow to represent any UCS character in the range U-00000000 to // U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff." -- cgit v1.2.3