Linux: When parented, take focus on click
This commit is contained in:
parent
c5aa4d7b09
commit
b5c893d207
|
@ -50,6 +50,7 @@ import org.lwjgl.LWJGLUtil;
|
|||
|
||||
final class LinuxDisplay implements DisplayImplementation {
|
||||
/* X11 constants */
|
||||
public final static int CurrentTime = 0;
|
||||
public final static int GrabSuccess = 0;
|
||||
public final static int AutoRepeatModeOff = 0;
|
||||
public final static int AutoRepeatModeOn = 1;
|
||||
|
@ -620,7 +621,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
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() {
|
||||
while (LinuxEvent.getPending(getDisplay()) > 0) {
|
||||
|
@ -754,7 +755,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
|||
grabServer(getDisplay());
|
||||
try {
|
||||
if (nGetInputFocus(getDisplay()) == current_focus)
|
||||
setInputFocus(getDisplay(), getWindow());
|
||||
setInputFocus(getDisplay(), getWindow(), CurrentTime);
|
||||
} finally {
|
||||
ungrabServer(getDisplay());
|
||||
}
|
||||
|
|
|
@ -280,6 +280,8 @@ final class LinuxMouse {
|
|||
case LinuxEvent.ButtonPress: /* Fall through */
|
||||
case LinuxEvent.ButtonRelease:
|
||||
handleButtonEvent(grab, event.getButtonTime(), event.getButtonType(), (byte)event.getButtonButton());
|
||||
if (Display.getParent() != null)
|
||||
LinuxDisplay.setInputFocus(display, window, event.getButtonTime());
|
||||
return true;
|
||||
case LinuxEvent.MotionNotify:
|
||||
handlePointerMotion(grab, warp_pointer, event.getButtonTime(), event.getButtonRoot(), event.getButtonXRoot(), event.getButtonYRoot(), event.getButtonX(), event.getButtonY());
|
||||
|
|
|
@ -338,10 +338,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_ungrabServer(JNIEnv *e
|
|||
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;
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue