我在 Ubuntu 16.04.3 LTS 上构建了 Qt-5.9.2 ,并启用了 EGLFS QPA 。< / p>
我在 Ctrl + Alt + F1 屏幕上切换到终端。然后我运行我的 Qt 应用程序app
( Qt Quick ,如果有问题的话):
# to debug input
export QT_LOGGING_RULES=qt.qpa.input=true
# to be able to close by Ctrl+C my application
export QT_QPA_ENABLE_TERMINAL_KEYBOARD=1
~/app -platform eglfs
到目前为止一切顺利:它正常启动,一切看起来都很好。但是 Qt 不处理触摸屏和鼠标输入。调试输出:
debug: libinput: opening input device '/dev/input/event1' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event1'.
debug: libinput: opening input device '/dev/input/event2' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event2'.
debug: libinput: opening input device '/dev/input/event0' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event0'.
debug: libinput: opening input device '/dev/input/event8' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event8'.
debug: libinput: opening input device '/dev/input/event3' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event3'.
debug: libinput: opening input device '/dev/input/event4' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event4'.
debug: libinput: opening input device '/dev/input/event7' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event7'.
debug: libinput: opening input device '/dev/input/event5' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event5'.
debug: libinput: opening input device '/dev/input/event6' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event6'.
debug: libinput: opening input device '/dev/input/event9' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event9'.
debug: libinput: opening input device '/dev/input/event10' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event10'.
debug: libinput: opening input device '/dev/input/event11' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event11'.
debug: libinput: opening input device '/dev/input/event12' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event12'.
debug: libinput: opening input device '/dev/input/event13' failed (Operation not permitted).
debug: libinput: failed to create input device '/dev/input/event13'.
debug: Using xkbcommon for key mapping
然后我按 Ctrl + C 。
下一步是检查设备文件的文件权限:
$ ll /dev/input/event*
crw-rw---- 1 root input 13, 64 ноя 8 17:53 /dev/input/event0
crw-rw---- 1 root input 13, 65 ноя 8 17:53 /dev/input/event1
crw-rw---- 1 root input 13, 74 ноя 8 17:53 /dev/input/event10
crw-rw---- 1 root input 13, 75 ноя 8 17:53 /dev/input/event11
crw-rw---- 1 root input 13, 76 ноя 8 17:53 /dev/input/event12
crw-rw---- 1 root input 13, 77 ноя 8 17:53 /dev/input/event13
crw-rw---- 1 root input 13, 66 ноя 8 17:53 /dev/input/event2
crw-rw---- 1 root input 13, 67 ноя 8 17:53 /dev/input/event3
crw-rw---- 1 root input 13, 68 ноя 8 18:38 /dev/input/event4
crw-rw---- 1 root input 13, 69 ноя 8 17:53 /dev/input/event5
crw-rw---- 1 root input 13, 70 ноя 8 17:53 /dev/input/event6
crw-rw---- 1 root input 13, 71 ноя 8 18:38 /dev/input/event7
crw-rw---- 1 root input 13, 72 ноя 8 17:53 /dev/input/event8
crw-rw---- 1 root input 13, 73 ноя 8 17:53 /dev/input/event9
好。我决定将当前用户添加到组input
:
sudo usermod -a -G input $USER
然后我重新登录 Ctrl + Alt + F1 屏幕。现在groups
命令的输出包含input
组。
我再次尝试运行我的应用程序:
~/app -platform eglfs
现在它对鼠标和触摸屏输入事件做出了正确的反应,但是没有渲染字体 - 甚至没有正确大小的矩形作为占位符而不是相应的字母。
我从群组input
中移除用户:
sudo deluser $USER input
然后(在重新登录之后)我尝试只更改输入设备的文件权限:
sudo chmod o=g /dev/input/event*
效果是一样的。回滚:
sudo chmod o= /dev/input/event*
这种行为的原因是什么?
为什么我不能同时使用 libinput 和字体?
解决方法是使用root权限运行应用程序,但这可能会导致严重的安全漏洞。
是否有libinput
的特定设置来解决问题?
提供ad-hoc字体也没有效果:
wget https://github.com/dejavu-fonts/dejavu-fonts/releases/download/version_2_37/dejavu-fonts-ttf-2.37.tar.bz2
sudo mkdir -p /usr/local/Qt-5.9.2/lib/fonts
sudo tar --extract --verbose --strip-components=2 -C /usr/local/Qt-5.9.2/lib/fonts --file dejavu-fonts-ttf-2.37.tar.bz2 dejavu-fonts-ttf-2.37/ttf/
export QT_QPA_FONTDIR=/usr/local/Qt-5.9.2/lib/fonts
答案 0 :(得分:0)
Submitted as a bug。通过添加到input
组并删除QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
标记来解决此问题。