Skip to content

Commit

Permalink
Use fallback modifiers for tablet on Wayland
Browse files Browse the repository at this point in the history
Another platform where the modifiers in the tablet events are garbage
apparently, so we use the same workaround as we do on Android and
Emscripten.

Also include the platform into the tablet event log, since that's
relevant stuff for it.
  • Loading branch information
askmeaboutlo0m committed Nov 21, 2024
1 parent 376b178 commit 8ca4ec4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 10 additions & 0 deletions src/desktop/scene/canvasview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/desktop/scene/canvasview.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ private slots:
#ifdef __EMSCRIPTEN__
bool m_enableEraserOverride = false;
#endif
#ifdef Q_OS_LINUX
bool m_waylandWorkarounds;
#endif
};

}
Expand Down
10 changes: 10 additions & 0 deletions src/desktop/view/canvascontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions src/desktop/view/canvascontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ class CanvasController : public QObject {
bool m_saveInProgress = false;

bool m_hoveringOverHud = false;
#ifdef Q_OS_LINUX
bool m_waylandWorkarounds;
#endif
};

}
Expand Down

0 comments on commit 8ca4ec4

Please sign in to comment.