Fixed some linux input focus issues

This commit is contained in:
Elias Naur 2003-05-02 13:41:40 +00:00
parent dc47138037
commit 86798e426f
3 changed files with 29 additions and 30 deletions

View File

@ -47,7 +47,7 @@
#include <stdlib.h>
#include <assert.h>
#include <jni.h>
#include <Window.h>
#include "Window.h"
#include "org_lwjgl_Window.h"
static Atom delete_atom;
@ -69,7 +69,7 @@ static void waitMapped(Display *disp, Window win) {
}
bool releaseInput(void) {
if (current_fullscreen)
if (current_fullscreen || input_released)
return false;
releaseKeyboard();
releasePointer();
@ -94,6 +94,9 @@ static void handleMessages(JNIEnv *env, jobject window_obj) {
if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
env->SetBooleanField(window_obj, env->GetFieldID(env->GetObjectClass(window_obj), "closeRequested", "Z"), JNI_TRUE);
break;
case FocusOut:
releaseInput();
break;
case FocusIn:
acquireInput();
break;

View File

@ -98,18 +98,6 @@ static void ungrabKeyboard(void) {
setRepeatMode(AutoRepeatModeDefault);
}
void acquireKeyboard(void) {
if (!created)
return;
should_grab = true;
}
void releaseKeyboard(void) {
if (!created)
return;
should_grab = false;
}
static void updateGrab(void) {
if (should_grab) {
if (!keyboard_grabbed)
@ -120,6 +108,16 @@ static void updateGrab(void) {
}
}
void acquireKeyboard(void) {
should_grab = true;
updateGrab();
}
void releaseKeyboard(void) {
should_grab = false;
updateGrab();
}
/*
* Class: org_lwjgl_input_Keyboard
* Method: nCreate

View File

@ -122,10 +122,11 @@ static int grabPointer(void) {
int result;
int mask = FocusChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
result = XGrabPointer(getCurrentDisplay(), getCurrentWindow(), False, mask, GrabModeAsync, GrabModeAsync, getCurrentWindow(), blank_cursor, CurrentTime);
XWarpPointer(getCurrentDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
XF86VidModeSetViewPort(getCurrentDisplay(), getCurrentScreen(), 0, 0); // make sure we have a centered window
if (result == GrabSuccess)
if (result == GrabSuccess) {
pointer_grabbed = true;
XWarpPointer(getCurrentDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, current_x, current_y);
XF86VidModeSetViewPort(getCurrentDisplay(), getCurrentScreen(), 0, 0); // make sure we have a centered window
}
return result;
}
@ -134,19 +135,6 @@ static void ungrabPointer(void) {
XUngrabPointer(getCurrentDisplay(), CurrentTime);
}
void acquirePointer(void) {
if (!created)
return;
should_grab = true;
}
void releasePointer(void) {
if (!created)
return;
should_grab = false;
}
static void updateGrab(void) {
if (should_grab) {
if (!pointer_grabbed)
@ -157,6 +145,16 @@ static void updateGrab(void) {
}
}
void acquirePointer(void) {
should_grab = true;
updateGrab();
}
void releasePointer(void) {
should_grab = false;
updateGrab();
}
/*
* Class: org_lwjgl_input_Mouse
* Method: nCreate