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 XButtonRelease(int w, int client_data, int call_data, int continue_to_dispatch) { display.hideToolTip(); XButtonEvent xEvent = new XButtonEvent(); OS.memmove(xEvent, call_data, XButtonEvent.sizeof); /* * Forward the mouse event to the parent. * This is necessary so that mouse 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. */ int[] argList = {OS.XmNx, 0, OS.XmNy, 0}; OS.XtGetValues(handle, argList, argList.length / 2); xEvent.window = OS.XtWindow(parent.handle); xEvent.x += argList[1]; xEvent.y += argList[3]; OS.memmove(call_data, xEvent, XButtonEvent.sizeof); int result = parent.XButtonRelease(w, client_data, call_data, continue_to_dispatch); xEvent.x -= argList[1]; xEvent.y -= argList[3]; if (result == 0 && xEvent.button == 1) { int[] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0}; OS.XtGetValues(handle, argList2, argList2.length / 2); int width = argList2[1], height = argList2[3]; if (0 <= xEvent.x && xEvent.x < width && 0 <= xEvent.y && xEvent.y < height) { click(xEvent.x > width - 12, xEvent.state); } setDrawPressed(set); } return result; }