c - 如何在 X11/Xlib 的根窗口中读取 KeyPress 和 ButtonPress 事件?
问题描述
我正在编写一个绘制到根窗口的 C 程序。(这部分有效)
我现在需要在根窗口上接受键盘和鼠标输入(在根窗口上单击和按键)。我试过这个:
XSelectInput(display, rootWindow, KeyPressMask);
XNextEvent(display, &event)
但是 KeyPress 永远不会出现。我也尝试过使用ButtonPressMask
,但这会产生错误:
X Error of failed request: BadAccess
是否可以在不必挂钩所有输入的情况下做到这一点?我在堆栈溢出中看到了这个想法:Detect modifier key release in X11 root window but it hooks into all input as far as I cantell.
我正在使用 i3wm,所以我没有任何东西作为我的默认根窗口。(如果这有帮助)
解决方案
推荐阅读
- google-api - Google NLP API 类别的稳定性如何?
- python - 我的函数缺少 1 个必需的位置参数:“请求”
- python - 用python列出所有ESXI的vm
- c++ - 如何为 c++ PBDS 制作自定义计算函数?
- java - Spring KafkaListener with topicPattern,分配所有主题的所有分区
- android - 如何在通知中播放有时声音
- docker - 在docker中运行命令时出现“没有这样的文件或目录/”错误
- php - symfony 5.1:如何将控制器定义为服务
- javascript - 将一个表情符号选择器中的表情符号插入两个不同的文本区域
- pandas - 计算熊猫中具有特定值的列数