【问题标题】:Input and fonts are mutually exclusive on EGLFS QPAEGLFS QPA 上的输入和字体是互斥的
【发布时间】:2018-04-21 06:42:35
【问题描述】:

我在 Ubuntu 16.04.3 LTS 上构建 Qt-5.9.2 并启用了 EGLFS QPA

我在 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

【问题讨论】:

    标签: c++ qt input qt5 eglfs


    【解决方案1】:

    Submitted as a bug。通过添加到input 组并删除QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 标志来解决。

    【讨论】:

      猜你喜欢
      • 2018-12-08
      • 2016-10-03
      • 1970-01-01
      • 1970-01-01
      • 2013-05-03
      • 1970-01-01
      • 1970-01-01
      • 2018-11-08
      • 1970-01-01
      相关资源
      最近更新 更多