From 4bf4a385f3d19e7aa08a402fd929a1f45ba0afc5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 23 Feb 2007 10:14:18 +0000 Subject: [PATCH] Linux: When creating a window don't loop waiting for the MapNotify event. Instead, make sure we don't immediately go from fullscreen to minimized by checking if the window has been focused at least once before minimizing (and resetting display mode). --- src/java/org/lwjgl/opengl/LinuxDisplay.java | 5 ++++- src/native/linux/org_lwjgl_opengl_Display.c | 8 -------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 4cbd59a4..7b399474 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -110,6 +110,7 @@ final class LinuxDisplay implements DisplayImplementation { private boolean minimized; private boolean dirty; private boolean close_requested; + private boolean focused_at_least_once; private long current_cursor; private long blank_cursor; @@ -398,6 +399,7 @@ final class LinuxDisplay implements DisplayImplementation { pointer_grabbed = false; keyboard_grabbed = false; close_requested = false; + focused_at_least_once = false; grab = false; minimized = false; dirty = true; @@ -750,8 +752,9 @@ final class LinuxDisplay implements DisplayImplementation { private void checkInput() { focused = nGetInputFocus(getDisplay()) == getWindow(); if (focused) { + focused_at_least_once = true; acquireInput(); - } else { + } else if (focused_at_least_once) { releaseInput(); } } diff --git a/src/native/linux/org_lwjgl_opengl_Display.c b/src/native/linux/org_lwjgl_opengl_Display.c index 7555a9c7..af8c4115 100644 --- a/src/native/linux/org_lwjgl_opengl_Display.c +++ b/src/native/linux/org_lwjgl_opengl_Display.c @@ -127,13 +127,6 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInternAtom(JNIEnv *e return atom; } -static void waitMapped(Display *disp, Window win) { - XEvent event; - do { - XMaskEvent(disp, StructureNotifyMask, &event); - } while ((event.type != MapNotify) || (event.xmap.event != win)); -} - static void __attribute__ ((destructor)) my_fini(void) { Display *disp = XOpenDisplay(NULL); if (disp == NULL) { @@ -294,7 +287,6 @@ static Window createWindow(JNIEnv* env, Display *disp, int screen, jint window_m XInternAtom(disp, "ATOM", False), 32, PropModeReplace, (const unsigned char*)&fullscreen_atom, 1); } XMapRaised(disp, win); - waitMapped(disp, win); if (!checkXError(env, disp)) { destroyWindow(env, disp, win); return 0;