Linux: When parented, take focus on click

This commit is contained in:
Elias Naur 2008-04-09 18:09:15 +00:00
parent c5aa4d7b09
commit b5c893d207
3 changed files with 7 additions and 4 deletions

View File

@ -50,6 +50,7 @@ import org.lwjgl.LWJGLUtil;
final class LinuxDisplay implements DisplayImplementation { final class LinuxDisplay implements DisplayImplementation {
/* X11 constants */ /* X11 constants */
public final static int CurrentTime = 0;
public final static int GrabSuccess = 0; public final static int GrabSuccess = 0;
public final static int AutoRepeatModeOff = 0; public final static int AutoRepeatModeOff = 0;
public final static int AutoRepeatModeOn = 1; public final static int AutoRepeatModeOn = 1;
@ -620,7 +621,7 @@ final class LinuxDisplay implements DisplayImplementation {
return peer_info; return peer_info;
} }
private native static void setInputFocus(long display, long window); static native void setInputFocus(long display, long window, long time);
private void processEvents() { private void processEvents() {
while (LinuxEvent.getPending(getDisplay()) > 0) { while (LinuxEvent.getPending(getDisplay()) > 0) {
@ -754,7 +755,7 @@ final class LinuxDisplay implements DisplayImplementation {
grabServer(getDisplay()); grabServer(getDisplay());
try { try {
if (nGetInputFocus(getDisplay()) == current_focus) if (nGetInputFocus(getDisplay()) == current_focus)
setInputFocus(getDisplay(), getWindow()); setInputFocus(getDisplay(), getWindow(), CurrentTime);
} finally { } finally {
ungrabServer(getDisplay()); ungrabServer(getDisplay());
} }

View File

@ -280,6 +280,8 @@ final class LinuxMouse {
case LinuxEvent.ButtonPress: /* Fall through */ case LinuxEvent.ButtonPress: /* Fall through */
case LinuxEvent.ButtonRelease: case LinuxEvent.ButtonRelease:
handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton()); handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton());
if (Display.getParent() != null)
LinuxDisplay.setInputFocus(display, window, event.getButtonTime());
return true; return true;
case LinuxEvent.MotionNotify: case LinuxEvent.MotionNotify:
handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY()); handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY());

View File

@ -338,10 +338,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_ungrabServer(JNIEnv *e
XUngrabServer(disp); XUngrabServer(disp);
} }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr) { JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setInputFocus(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jlong time) {
Display *disp = (Display *)(intptr_t)display; Display *disp = (Display *)(intptr_t)display;
Window window = (Window)window_ptr; Window window = (Window)window_ptr;
XSetInputFocus(disp, window, RevertToParent, CurrentTime); XSetInputFocus(disp, window, RevertToParent, time);
} }
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) { JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(JNIEnv *env, jclass clazz, jlong display, jint screen, jobject peer_info_handle, jobject mode, jint window_mode, jint x, jint y, jboolean undecorated, jlong parent_handle) {