| 66 | } |
| 67 | |
| 68 | void x11SendKey(Display *display, int keyCode, int modifiers) |
| 69 | { |
| 70 | |
| 71 | // Get the root window for the current display. |
| 72 | Window winRoot = XDefaultRootWindow(display); |
| 73 | if (winRoot==0) |
| 74 | return; |
| 75 | |
| 76 | // Find the window which has the current keyboard focus. |
| 77 | Window winFocus; |
| 78 | int revert; |
| 79 | XGetInputFocus(display, &winFocus, &revert); |
| 80 | |
| 81 | // Send a fake key press event to the window. |
| 82 | XKeyEvent event = createKeyEvent(display, winFocus, winRoot, true, keyCode, modifiers); |
| 83 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
| 84 | |
| 85 | // Send a fake key release event to the window. |
| 86 | event = createKeyEvent(display, winFocus, winRoot, false, keyCode, modifiers); |
| 87 | XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event); |
| 88 | |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | void traceKeyCodes() |
no test coverage detected