int XKeyPress(int w, int client_data, int call_data, int continue_to_dispatch) { int result = 0; XKeyEvent xEvent = new XKeyEvent(); OS.memmove(xEvent, call_data, XKeyEvent.sizeof); int[] keysym = new int[1]; OS.XLookupString(xEvent, null, 0, keysym, null); keysym[0] &= 0xFFFF; switch (keysym[0]) { case OS.XK_space: click(false, xEvent.state); result = 1; break; case OS.XK_Down: if ((style & SWT.DROP_DOWN) != 0) { click(true, xEvent.state); result = 1; } break; } /* * Forward the key event to the parent. * This is necessary so that key listeners * in the parent will be called, despite the * fact that the event did not really occur * in X in the parent. This is done to be * compatible with Windows. */ xEvent.window = OS.XtWindow(parent.handle); // OS.memmove (callData, xEvent, XKeyEvent.sizeof); parent.XKeyPress(w, client_data, call_data, continue_to_dispatch); if (result == 1) { OS.memmove(continue_to_dispatch, new int[1], 4); } return result; }
int XKeyRelease(int w, int client_data, int call_data, int continue_to_dispatch) { XKeyEvent xEvent = new XKeyEvent(); OS.memmove(xEvent, call_data, XKeyEvent.sizeof); /* * Forward the key event to the parent. * This is necessary so that key listeners * in the parent will be called, despite the * fact that the event did not really occur * in X in the parent. This is done to be * compatible with Windows. */ xEvent.window = OS.XtWindow(parent.handle); // OS.memmove (callData, xEvent, XKeyEvent.sizeof); parent.XKeyRelease(w, client_data, call_data, continue_to_dispatch); return 0; }