Fixed a negative focus feedback loop

This commit is contained in:
Elias Naur 2003-08-05 14:21:59 +00:00
parent 35a1538f82
commit a62ebc2c3b
2 changed files with 13 additions and 6 deletions

View File

@ -79,8 +79,6 @@ static unsigned char buttons[NUM_BUTTONS];
static Cursor blank_cursor;
static Cursor current_cursor;
static int grab_mask = FocusChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
/*
* Class: org_lwjgl_input_Mouse
* Method: initIDs
@ -131,6 +129,7 @@ static void grabPointer(void) {
if (isFullscreen() || !native_cursor) {
if (!pointer_grabbed) {
int result;
int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
result = XGrabPointer(getCurrentDisplay(), getCurrentWindow(), False, grab_mask, GrabModeAsync,
GrabModeAsync, getCurrentWindow(), current_cursor, CurrentTime);
if (result == GrabSuccess) {

View File

@ -113,6 +113,8 @@ bool isFullscreen(void) {
static void handleMessages() {
XEvent event;
Window win;
int revert_mode;
while (XPending(current_disp) > 0) {
XNextEvent(current_disp, &event);
switch (event.type) {
@ -121,12 +123,18 @@ static void handleMessages() {
closerequested = true;
break;
case FocusOut:
releaseInput();
focused = false;
XGetInputFocus(current_disp, &win, &revert_mode);
if (win != current_win) {
releaseInput();
focused = false;
}
break;
case FocusIn:
acquireInput();
focused = true;
XGetInputFocus(current_disp, &win, &revert_mode);
if (win == current_win) {
acquireInput();
focused = true;
}
break;
case MapNotify:
dirty = true;