diff options
author | Robert Griebl <robert.griebl@qt.io> | 2020-11-18 14:39:33 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2020-11-28 17:47:41 +0100 |
commit | 911ee1f92017f22f9aa1fd430b414ff28c7e0cbe (patch) | |
tree | 58ad194c55506ccb7792949914ccec2757d88ad3 /src/window-lib | |
parent | 6f8a53da17c04848319dcb5d58e70f12788ca9d7 (diff) | |
download | qtapplicationmanager-911ee1f92017f22f9aa1fd430b414ff28c7e0cbe.tar.gz |
Qt 6 port, part 1 .. without cmake
All C++ and QML unit-tests pass.
The QML "windowitem" test is very unstable though and often crashes
in the RHI layer.
Change-Id: Ia42fc71ad69d2ba74b8b631ded7569b48cf458ee
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'src/window-lib')
-rw-r--r-- | src/window-lib/touchemulation.cpp | 11 | ||||
-rw-r--r-- | src/window-lib/touchemulation.h | 1 | ||||
-rw-r--r-- | src/window-lib/touchemulation_x11.cpp | 17 | ||||
-rw-r--r-- | src/window-lib/touchemulation_x11_p.h | 6 | ||||
-rw-r--r-- | src/window-lib/waylandqtamserverextension.cpp | 3 | ||||
-rw-r--r-- | src/window-lib/window-lib.pro | 2 | ||||
-rw-r--r-- | src/window-lib/windowitem.cpp | 6 | ||||
-rw-r--r-- | src/window-lib/windowitem.h | 2 |
8 files changed, 33 insertions, 15 deletions
diff --git a/src/window-lib/touchemulation.cpp b/src/window-lib/touchemulation.cpp index c58d4b53..893a5a11 100644 --- a/src/window-lib/touchemulation.cpp +++ b/src/window-lib/touchemulation.cpp @@ -42,6 +42,7 @@ #include <QtAppManCommon/global.h> #include <QGuiApplication> +#include <QInputDevice> #include "touchemulation.h" #if defined(AM_ENABLE_TOUCH_EMULATION) # include "touchemulation_x11_p.h" @@ -83,6 +84,16 @@ bool TouchEmulation::isSupported() return false; } +bool QtAM::TouchEmulation::hasPhysicalTouchscreen() +{ + const auto devs = QInputDevice::devices(); + for (auto dev : devs) { + if (dev->type() == QInputDevice::DeviceType::TouchScreen) + return true; + } + return false; +} + QT_END_NAMESPACE_AM #include "moc_touchemulation.cpp" diff --git a/src/window-lib/touchemulation.h b/src/window-lib/touchemulation.h index caf967b1..c70bcc1d 100644 --- a/src/window-lib/touchemulation.h +++ b/src/window-lib/touchemulation.h @@ -63,6 +63,7 @@ public: static TouchEmulation *instance(); static bool isSupported(); + static bool hasPhysicalTouchscreen(); private: static TouchEmulation *s_instance; diff --git a/src/window-lib/touchemulation_x11.cpp b/src/window-lib/touchemulation_x11.cpp index 927f8e94..6a6c5562 100644 --- a/src/window-lib/touchemulation_x11.cpp +++ b/src/window-lib/touchemulation_x11.cpp @@ -46,7 +46,7 @@ #include <QGuiApplication> #include <QMouseEvent> -#include <QTouchDevice> +#include <QPointingDevice> #include <QWindow> #include <QTest> @@ -65,6 +65,10 @@ # define XCB_GE_GENERIC 35 #endif +#if defined None +# undef None +#endif + QT_BEGIN_NAMESPACE_AM using QTest::QTouchEventSequence; @@ -74,7 +78,7 @@ static Qt::MouseButton xcbButtonToQtMouseButton(xcb_button_t detail) { switch (detail) { case 1: return Qt::LeftButton; - case 2: return Qt::MidButton; + case 2: return Qt::MiddleButton; case 3: return Qt::RightButton; // don't care about the rest default: return Qt::NoButton; @@ -102,9 +106,10 @@ TouchEmulationX11::TouchEmulationX11() qGuiApp->installNativeEventFilter(this); // Create a fake touch device to deliver our synthesized events - m_touchDevice = new QTouchDevice; - m_touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(m_touchDevice); + m_touchDevice = new QPointingDevice(qSL("Fake Touch"), -1, QInputDevice::DeviceType::TouchScreen, + QPointingDevice::PointerType::Finger, + QInputDevice::Capability::None, 0, 0); + QWindowSystemInterface::registerInputDevice(m_touchDevice); queryForXInput2(); } @@ -123,7 +128,7 @@ void TouchEmulationX11::queryForXInput2() } } -bool TouchEmulationX11::nativeEventFilter(const QByteArray &eventType, void *message, long * /*result*/) +bool TouchEmulationX11::nativeEventFilter(const QByteArray &eventType, void *message, qintptr * /*result*/) { if (eventType != "xcb_generic_event_t") return false; // just ignore non-XCB-native events diff --git a/src/window-lib/touchemulation_x11_p.h b/src/window-lib/touchemulation_x11_p.h index 14657ac6..59bb610e 100644 --- a/src/window-lib/touchemulation_x11_p.h +++ b/src/window-lib/touchemulation_x11_p.h @@ -51,7 +51,7 @@ #include <QObject> #include <QWindow> -QT_FORWARD_DECLARE_CLASS(QTouchDevice) +QT_FORWARD_DECLARE_CLASS(QPointingDevice) QT_FORWARD_DECLARE_CLASS(QWindow) QT_BEGIN_NAMESPACE_AM @@ -60,7 +60,7 @@ class TouchEmulationX11 : public TouchEmulation, public QAbstractNativeEventFilt { public: TouchEmulationX11(); - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override; private: void queryForXInput2(); @@ -72,7 +72,7 @@ private: void backupEventData(void *event); void restoreEventData(void *event); - QTouchDevice *m_touchDevice = nullptr; + QPointingDevice *m_touchDevice = nullptr; bool m_haveXInput2 = false; bool m_leftButtonIsPressed = false; diff --git a/src/window-lib/waylandqtamserverextension.cpp b/src/window-lib/waylandqtamserverextension.cpp index f09e7110..58716398 100644 --- a/src/window-lib/waylandqtamserverextension.cpp +++ b/src/window-lib/waylandqtamserverextension.cpp @@ -42,6 +42,7 @@ #include "waylandqtamserverextension_p.h" +#include <QDataStream> #include <QtWaylandCompositor/QWaylandCompositor> #include <QtWaylandCompositor/QWaylandResource> #include <QtWaylandCompositor/QWaylandSurface> @@ -64,7 +65,7 @@ void WaylandQtAMServerExtension::setWindowProperty(QWaylandSurface *surface, con { if (setWindowPropertyHelper(surface, name, value)) { QByteArray byteValue; - QDataStream ds(&byteValue, QIODevice::WriteOnly); + QDataStream ds(&byteValue, QDataStream::WriteOnly); ds << value; Resource *target = resourceMap().value(surface->waylandClient()); diff --git a/src/window-lib/window-lib.pro b/src/window-lib/window-lib.pro index 918bbe34..f14738fc 100644 --- a/src/window-lib/window-lib.pro +++ b/src/window-lib/window-lib.pro @@ -36,6 +36,8 @@ multi-process:!headless { CONFIG *= wayland-scanner generated_privates private_headers.CONFIG += no_check_exists + + PKGCONFIG += wayland-server } !headless:HEADERS += \ diff --git a/src/window-lib/windowitem.cpp b/src/window-lib/windowitem.cpp index c4ec5ff4..ad456ea0 100644 --- a/src/window-lib/windowitem.cpp +++ b/src/window-lib/windowitem.cpp @@ -226,7 +226,7 @@ void WindowItem::createImpl(bool inProcess) #endif // AM_MULTI_PROCESS } -void WindowItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +void WindowItem::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) { m_contentItem->setWidth(newGeometry.width()); m_contentItem->setHeight(newGeometry.height()); @@ -234,7 +234,7 @@ void WindowItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo if (m_impl && newGeometry.isValid()) m_impl->updateSize(newGeometry.size()); - QQuickItem::geometryChanged(newGeometry, oldGeometry); + QQuickItem::geometryChange(newGeometry, oldGeometry); } bool WindowItem::primary() const @@ -418,8 +418,6 @@ void WindowItem::WaylandImpl::createWaylandItem() { m_waylandItem = new QWaylandQuickItem(q); - m_waylandItem->setSizeFollowsSurface(false); - connect(m_waylandItem, &QWaylandQuickItem::surfaceDestroyed, q, [this]() { // keep the buffer there to allow us to animate the window destruction m_waylandItem->setBufferLocked(true); diff --git a/src/window-lib/windowitem.h b/src/window-lib/windowitem.h index 3d7524ee..d6712070 100644 --- a/src/window-lib/windowitem.h +++ b/src/window-lib/windowitem.h @@ -93,7 +93,7 @@ public: static void contentItemData_clear(QQmlListProperty<QObject> *property); protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; signals: void windowChanged(); void primaryChanged(); |