Linux: Moved Display state booleans to java side
This commit is contained in:
parent
2f957f816d
commit
a417b8f15c
|
@ -97,6 +97,9 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
private static boolean input_released;
|
private static boolean input_released;
|
||||||
private static boolean grab;
|
private static boolean grab;
|
||||||
private static boolean focused;
|
private static boolean focused;
|
||||||
|
private static boolean minimized;
|
||||||
|
private static boolean dirty;
|
||||||
|
private static boolean close_requested;
|
||||||
private static ByteBuffer current_cursor;
|
private static ByteBuffer current_cursor;
|
||||||
private static ByteBuffer blank_cursor;
|
private static ByteBuffer blank_cursor;
|
||||||
|
|
||||||
|
@ -372,7 +375,10 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
input_released = false;
|
input_released = false;
|
||||||
pointer_grabbed = false;
|
pointer_grabbed = false;
|
||||||
keyboard_grabbed = false;
|
keyboard_grabbed = false;
|
||||||
|
close_requested = false;
|
||||||
grab = false;
|
grab = false;
|
||||||
|
minimized = false;
|
||||||
|
dirty = true;
|
||||||
updateInputGrab();
|
updateInputGrab();
|
||||||
nSetRepeatMode(getDisplay(), AutoRepeatModeOff);
|
nSetRepeatMode(getDisplay(), AutoRepeatModeOff);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -548,41 +554,24 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
private static native void nSetTitle(String title);
|
private static native void nSetTitle(String title);
|
||||||
|
|
||||||
public boolean isCloseRequested() {
|
public boolean isCloseRequested() {
|
||||||
lockAWT();
|
boolean result = close_requested;
|
||||||
try {
|
close_requested = false;
|
||||||
return nIsCloseRequested();
|
return result;
|
||||||
} finally {
|
|
||||||
unlockAWT();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private static native boolean nIsCloseRequested();
|
|
||||||
|
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
lockAWT();
|
return !minimized;
|
||||||
try {
|
|
||||||
return nIsVisible();
|
|
||||||
} finally {
|
|
||||||
unlockAWT();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
private static native boolean nIsVisible();
|
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
lockAWT();
|
|
||||||
try {
|
|
||||||
return focused || isLegacyFullscreen();
|
return focused || isLegacyFullscreen();
|
||||||
} finally {
|
|
||||||
unlockAWT();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirty() {
|
public boolean isDirty() {
|
||||||
lockAWT();
|
boolean result = dirty;
|
||||||
boolean result = nIsDirty();
|
dirty = false;
|
||||||
unlockAWT();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private static native boolean nIsDirty();
|
|
||||||
|
|
||||||
public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
|
public PeerInfo createPeerInfo(PixelFormat pixel_format) throws LWJGLException {
|
||||||
peer_info = new LinuxDisplayPeerInfo(pixel_format);
|
peer_info = new LinuxDisplayPeerInfo(pixel_format);
|
||||||
|
@ -1001,4 +990,22 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
if (mouse != null)
|
if (mouse != null)
|
||||||
mouse.handleWarpEvent(x, y);
|
mouse.handleWarpEvent(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleExposeEvent() {
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleUnmapNotifyEvent() {
|
||||||
|
dirty = true;
|
||||||
|
minimized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleMapNotifyEvent() {
|
||||||
|
dirty = true;
|
||||||
|
minimized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleCloseEvent() {
|
||||||
|
close_requested = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,11 +79,6 @@ static Pixmap current_icon_pixmap;
|
||||||
|
|
||||||
static Visual *current_visual;
|
static Visual *current_visual;
|
||||||
|
|
||||||
static bool dirty;
|
|
||||||
static bool minimized;
|
|
||||||
static bool closerequested;
|
|
||||||
static bool grab;
|
|
||||||
|
|
||||||
static int current_screen;
|
static int current_screen;
|
||||||
static Display *display_connection = NULL;
|
static Display *display_connection = NULL;
|
||||||
static bool async_x_error;
|
static bool async_x_error;
|
||||||
|
@ -186,6 +181,18 @@ static void handleMessages(JNIEnv *env, jclass disp_class) {
|
||||||
jmethodID handleWarpEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleWarpEvent", "(II)V");
|
jmethodID handleWarpEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleWarpEvent", "(II)V");
|
||||||
if (handleWarpEvent_method == NULL)
|
if (handleWarpEvent_method == NULL)
|
||||||
return;
|
return;
|
||||||
|
jmethodID handleMapNotifyEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleMapNotifyEvent", "()V");
|
||||||
|
if (handleMapNotifyEvent_method == NULL)
|
||||||
|
return;
|
||||||
|
jmethodID handleUnmapNotifyEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleUnmapNotifyEvent", "()V");
|
||||||
|
if (handleUnmapNotifyEvent_method == NULL)
|
||||||
|
return;
|
||||||
|
jmethodID handleExposeEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleExposeEvent", "()V");
|
||||||
|
if (handleExposeEvent_method == NULL)
|
||||||
|
return;
|
||||||
|
jmethodID handleCloseEvent_method = (*env)->GetStaticMethodID(env, disp_class, "handleCloseEvent", "()V");
|
||||||
|
if (handleCloseEvent_method == NULL)
|
||||||
|
return;
|
||||||
while (!(*env)->ExceptionOccurred(env) && XPending(getDisplay()) > 0) {
|
while (!(*env)->ExceptionOccurred(env) && XPending(getDisplay()) > 0) {
|
||||||
XNextEvent(getDisplay(), &event);
|
XNextEvent(getDisplay(), &event);
|
||||||
if (XFilterEvent(&event, None) == True)
|
if (XFilterEvent(&event, None) == True)
|
||||||
|
@ -198,18 +205,16 @@ static void handleMessages(JNIEnv *env, jclass disp_class) {
|
||||||
if (event.xclient.message_type == warp_atom) {
|
if (event.xclient.message_type == warp_atom) {
|
||||||
(*env)->CallStaticVoidMethod(env, disp_class, handleWarpEvent_method, (jint)event.xclient.data.l[0], (jint)event.xclient.data.l[1]);
|
(*env)->CallStaticVoidMethod(env, disp_class, handleWarpEvent_method, (jint)event.xclient.data.l[0], (jint)event.xclient.data.l[1]);
|
||||||
} else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
|
} else if ((event.xclient.format == 32) && ((Atom)event.xclient.data.l[0] == delete_atom))
|
||||||
closerequested = true;
|
(*env)->CallStaticVoidMethod(env, disp_class, handleCloseEvent_method);
|
||||||
break;
|
break;
|
||||||
case MapNotify:
|
case MapNotify:
|
||||||
dirty = true;
|
(*env)->CallStaticVoidMethod(env, disp_class, handleMapNotifyEvent_method);
|
||||||
minimized = false;
|
|
||||||
break;
|
break;
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
dirty = true;
|
(*env)->CallStaticVoidMethod(env, disp_class, handleUnmapNotifyEvent_method);
|
||||||
minimized = true;
|
|
||||||
break;
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
dirty = true;
|
(*env)->CallStaticVoidMethod(env, disp_class, handleExposeEvent_method);
|
||||||
break;
|
break;
|
||||||
case ButtonPress: /* Fall through */
|
case ButtonPress: /* Fall through */
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
@ -308,10 +313,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env,
|
||||||
|
|
||||||
static bool createWindow(JNIEnv* env, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
|
static bool createWindow(JNIEnv* env, jint window_mode, X11PeerInfo *peer_info, int x, int y, int width, int height) {
|
||||||
bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
|
bool undecorated = getBooleanProperty(env, "org.lwjgl.opengl.Window.undecorated");
|
||||||
dirty = true;
|
|
||||||
minimized = false;
|
|
||||||
closerequested = false;
|
|
||||||
grab = false;
|
|
||||||
Window root_win;
|
Window root_win;
|
||||||
Window win;
|
Window win;
|
||||||
XSetWindowAttributes attribs;
|
XSetWindowAttributes attribs;
|
||||||
|
@ -413,25 +414,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv
|
||||||
destroyWindow(env);
|
destroyWindow(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsDirty
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
|
||||||
bool result = dirty;
|
|
||||||
dirty = false;
|
|
||||||
return result ? JNI_TRUE : JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsVisible
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
|
||||||
return minimized ? JNI_FALSE : JNI_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsCloseRequested
|
|
||||||
(JNIEnv *env, jclass clazz) {
|
|
||||||
bool saved = closerequested;
|
|
||||||
closerequested = false;
|
|
||||||
return saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nLockAWT(JNIEnv *env, jclass clazz) {
|
||||||
JAWT jawt;
|
JAWT jawt;
|
||||||
jawt.version = JAWT_VERSION_1_4;
|
jawt.version = JAWT_VERSION_1_4;
|
||||||
|
|
Loading…
Reference in New Issue