event-handling - 有没有一种简单的方法来检测 Linux/Xorg/Qt4/Kde4 中的鼠标或键盘事件?

标签 event-handling keyboard mouse x11 xorg

有没有一种简单的方法来检测 Linux 或 Xorg 或 Qt4 或 Kde4 环境中的鼠标或键盘事件?显然不仅在特定窗口上,而且在整个 Xorg 桌面上。

最佳答案

您可以使用 XScreenSaver 扩展 (man Xss)。它可以使用函数 XScreenSaverQueryInfo 为您提供此结构中的值。 :

   typedef struct {
       Window window;                /∗ screen saver window */
       int state;                    /∗ ScreenSaver{Off,On,Disabled} */
       int kind;                     /∗ ScreenSaver{Blanked,Internal,External} */
       unsigned long til_or_since;   /∗ milliseconds */
       unsigned long idle;           /∗ milliseconds */
       unsigned long event_mask;     /∗ events */
   } XScreenSaverInfo;

The idle field specifies the number of milliseconds since the last input was received from the user on any of the input devices.



我不知道这个只有 Qt 的解决方案。

关于event-handling - 有没有一种简单的方法来检测 Linux/Xorg/Qt4/Kde4 中的鼠标或键盘事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/351185/

相关文章:

java - 如何移动(或使用)鼠标

javascript - AngularJS 事件处理程序不触发

C++ CLI GUI 事件处理

c# - 无论鼠标在哪里,如何访问 WPF 中的鼠标移动事件?

wpf - 在 WPF 中,如何复制旧的 WinForms OnKeyPressed 功能?

ios - 在 iOS 8 中显示隐藏键盘时编辑 UIView 的边界

c - Linux 内核替换 key

java - 为什么人们在他们的代码中使用消息/事件总线?

c# - 即使未能构造对象,也会调用本地事件监听器

java - 为什么使用匿名内部类,有哪些替代方案?