diff --git a/ChangeLog b/ChangeLog index 27aa4dede..7475d7844 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ Unreleased Version 2.2.2-pre * Fix: Don't default Android to fingerpaint when a pen is present. * Fix: Work around a crash on Android that sometimes occurs when putting your palm on the screen, which somehow leads to touch events with zero contact points. Thanks Mav for reporting. * Fix: Uncap aspect ratio on older Android versions. Thanks Molderche for reporting. + * Fix: Work around modifier keys not registering when using a tablet on Wayland. Thanks Absolute Goober for reporting. 2024-11-06 Version 2.2.2-beta.4 * Fix: Solve rendering glitches with selection outlines that happen on some systems. Thanks xxxx for reporting. diff --git a/src/desktop/mainwindow.cpp b/src/desktop/mainwindow.cpp index e2bbb4182..7abf5cbfc 100644 --- a/src/desktop/mainwindow.cpp +++ b/src/desktop/mainwindow.cpp @@ -2387,6 +2387,7 @@ void MainWindow::toggleTabletEventLog() DP_event_log_write_meta("Drawpile: %s", cmake_config::version()); DP_event_log_write_meta("Qt: %s", QT_VERSION_STR); DP_event_log_write_meta("OS: %s", qUtf8Printable(QSysInfo::prettyProductName())); + DP_event_log_write_meta("Platform: %s", qUtf8Printable(QGuiApplication::platformName())); DP_event_log_write_meta("Input: %s", tabletinput::current()); const desktop::settings::Settings &settings = dpApp().settings(); DP_event_log_write_meta("Tablet enabled: %d", settings.tabletEvents()); diff --git a/src/desktop/scene/canvasview.cpp b/src/desktop/scene/canvasview.cpp index 3e686182a..63076f284 100644 --- a/src/desktop/scene/canvasview.cpp +++ b/src/desktop/scene/canvasview.cpp @@ -194,6 +194,10 @@ CanvasView::CanvasView(QWidget *parent) , m_showTransformNotices(true) , m_hoveringOverHud{false} , m_renderSmooth(false) +#ifdef Q_OS_LINUX + , m_waylandWorkarounds( + QGuiApplication::platformName() == QStringLiteral("wayland")) +#endif { viewport()->setAcceptDrops(true); viewport()->setAttribute(Qt::WA_AcceptTouchEvents); @@ -2619,6 +2623,12 @@ CanvasView::getTabletModifiers(const QTabletEvent *tabev) const Q_UNUSED(tabev); return getFallbackModifiers(); #else +# ifdef Q_OS_LINUX + // Tablet event modifiers aren't reported properly on Wayland. + if(m_waylandWorkarounds) { + return getFallbackModifiers(); + } +# endif return tabev->modifiers(); #endif } diff --git a/src/desktop/scene/canvasview.h b/src/desktop/scene/canvasview.h index 0d02b55fc..04d11fd70 100644 --- a/src/desktop/scene/canvasview.h +++ b/src/desktop/scene/canvasview.h @@ -451,6 +451,9 @@ private slots: #ifdef __EMSCRIPTEN__ bool m_enableEraserOverride = false; #endif +#ifdef Q_OS_LINUX + bool m_waylandWorkarounds; +#endif }; } diff --git a/src/desktop/view/canvascontroller.cpp b/src/desktop/view/canvascontroller.cpp index 08461f583..3c6fa1101 100644 --- a/src/desktop/view/canvascontroller.cpp +++ b/src/desktop/view/canvascontroller.cpp @@ -168,6 +168,10 @@ CanvasController::CanvasController(CanvasScene *scene, QWidget *parent) , m_brushBlendMode(DP_BLEND_MODE_NORMAL) , m_touch(new TouchHandler(this)) , m_toolState(int(tools::ToolState::Normal)) +#ifdef Q_OS_LINUX + , m_waylandWorkarounds( + QGuiApplication::platformName() == QStringLiteral("wayland")) +#endif { desktop::settings::Settings &settings = dpApp().settings(); settings.bindCanvasViewBackgroundColor( @@ -2077,6 +2081,12 @@ CanvasController::getTabletModifiers(const QTabletEvent *event) const Q_UNUSED(event); return getFallbackModifiers(); #else +# ifdef Q_OS_LINUX + // Tablet event modifiers aren't reported properly on Wayland. + if(m_waylandWorkarounds) { + return getFallbackModifiers(); + } +# endif return event->modifiers(); #endif } diff --git a/src/desktop/view/canvascontroller.h b/src/desktop/view/canvascontroller.h index bc741dc1f..b39433517 100644 --- a/src/desktop/view/canvascontroller.h +++ b/src/desktop/view/canvascontroller.h @@ -422,6 +422,9 @@ class CanvasController : public QObject { bool m_saveInProgress = false; bool m_hoveringOverHud = false; +#ifdef Q_OS_LINUX + bool m_waylandWorkarounds; +#endif }; }