During XGrabKey(board), discover which window had been focused

回眸只為那壹抹淺笑 提交于 2019-12-11 11:39:24

问题


  1. A program has called XGrabKey() to make a hotkey.
  2. The user presses that key combination (while another window is focused).
  3. The program receives control to do something in response to the key combination. Meanwhile, the program has been temporarily focused (because of the effects of XGrabKey (see man XGrabKey, man XGrabKeyboard)).

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?


回答1:


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.



来源:https://stackoverflow.com/questions/13504593/during-xgrabkeyboard-discover-which-window-had-been-focused

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!