问题
- A program has called XGrabKey() to make a hotkey.
- The user presses that key combination (while another window is focused).
- 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