本文介绍了在 XGrabKey(board) 期间,发现哪个窗口被聚焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 一个程序调用了 XGrabKey() 来制作热键.
  2. 用户按下该组合键(同时聚焦另一个窗口).
  3. 程序接收控制以响应组合键执行某些操作.同时,程序暂时被聚焦(因为XGrabKey的作用(见man XGrabKeyman XGrabKeyboard)).

我希望程序为最初聚焦的窗口创建一个合成 X 事件(按键或鼠标单击).在某些情况下,这意味着我需要在发送事件之前聚焦该窗口(Firefox 在未聚焦时忽略合成事件),这意味着我需要知道它是哪个窗口.我怎样才能知道它是哪个窗口?

I want the program to create a synthetic X event (a keypress or mouse click) to the originally focused window. In some cases this means I need to focus that window before sending it the event (Firefox ignores synthetic events when it is not focused), which means I need to know which window it is. How can I find out which window it is?

推荐答案

等待下一个 FocusOut 事件,验证 mode 是否设置为 NotifyUngrab,使用 XGetInputFocus() 获取焦点,然后发送您的合成事件.

Wait for the next FocusOut event, verify that the mode is set to NotifyUngrab, get the focus with XGetInputFocus(), and send away your synthetic events.

这篇关于在 XGrabKey(board) 期间,发现哪个窗口被聚焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:37