Bug 454947 - Cannot map buttons due to incorrect xsetwacom invocation
Summary: Cannot map buttons due to incorrect xsetwacom invocation
Status: RESOLVED FIXED
Alias: None
Product: wacomtablet
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Valerii Malov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-06 21:59 UTC by Tomasz Lemiech
Modified: 2022-11-27 14:49 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Lemiech 2022-06-06 21:59:24 UTC
Commit dd97e6ab6a0a91d01d54a02131685e5d1fc78c05 ("Fix Qt 5.15 obsoletions") introduced the new syntax of QProcess.start() routine in xsetwacomadaptor.cpp (modified further in 88422002167f941e1457695a0e9fa3b1212c32f3). It requires command arguments to be passed as a QStringList rather than as a single QString. Unfortunately this broke the ability to map express buttons because the resulting xsetwacom command line string is built incorrectly.

The current invocation in XsetwacomAdaptor::setParameter():

setConf.start(QString::fromLatin1("xsetwacom"), QStringList() << QString::fromLatin1("set") << device << param);

results in the following execve() call for button mappings:

execve("/usr/bin/xsetwacom", ["/usr/bin/xsetwacom", "set", "Wacom Intuos4 4x6 Pad pad", "Button 1", "key ctrl shift e"], 0x7ffe783a6088 /* 74 vars */ <unfinished ...>

This is incorrect, because xsetwacom expects "Button" and the button number to be in separate arguments, while the above call passes it as one. Executing the above command string manually yields the following error:

$ "/usr/bin/xsetwacom" "set" "Wacom Intuos4 4x6 Pad pad" "Button 1" "key ctrl shift e"
Parameter 'Button 1' is no longer in use. It was replaced with 'Button'.

The old way of doing this was:

    cmd = QString::fromLatin1( "xsetwacom set \"%1\" %2 \"%3\"" ).arg( device ).arg( param ).arg( value );
    QProcess setConf;
    setConf.start( cmd );

which produced this:

execve("/usr/bin/xsetwacom", ["/usr/bin/xsetwacom", "set", "Wacom Intuos4 4x6 Pad pad", "Button", "1", "key ctrl shift e"], 0x7ffcfd4ad278 /* 75 vars */ <unfinished ...>

and this works fine, because %2 is not enclosed in quotes, so "Button 1" gets split in two arguments.

Further changes to the xsetwacom launching code introduced in commit 88422002167f941e1457695a0e9fa3b1212c32f3 did not fix the problem.

STEPS TO REPRODUCE
1. Install wacomtablet.so from current git master
2. Try to map some buttons in the Express Buttons GUI
3. Apply the changes or replug the tablet

OBSERVED RESULT

Mappings are set according to the settings entered in the GUI

EXPECTED RESULT

Mappings are kept at their defaults.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Gentoo 
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
Comment 1 oioi555x 2022-06-28 06:07:34 UTC
I think we should refresh the old format code as you pointed out.
But this project is apparently not maintained.
It is sad that there is a good Krita project in the same KDE.
It still works fine on my Manjaro.
Qt5.15.5
I don't know why, but there may have been a fix.
Comment 2 Bug Janitor Service 2022-11-14 01:57:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/wacomtablet/-/merge_requests/19
Comment 3 Luigi Toscano 2022-11-26 15:34:30 UTC
(In reply to Bug Janitor Service from comment #2)
> A possibly relevant merge request was started @
> https://invent.kde.org/system/wacomtablet/-/merge_requests/19

Can please anyone with the appropriate hardware test this fix and report back on the review?
Comment 4 Tomasz Lemiech 2022-11-27 14:15:57 UTC
PR tested on Intuos 4. Works OK.
Comment 5 Nicolas Fella 2022-11-27 14:49:04 UTC
Git commit 32c78782b3061bab2a3b1457133faf77b6d9ed2a by Nicolas Fella.
Committed on 27/11/2022 at 14:45.
Pushed by nicolasfella into branch 'master'.

Fix incorrect xsetwacom call

When param is e.g. 'Button 1' the 'Button' and '1' need to be passed as separate arguments

M  +11   -3    src/kded/xsetwacomadaptor.cpp

https://invent.kde.org/system/wacomtablet/commit/32c78782b3061bab2a3b1457133faf77b6d9ed2a