Various linux fixes
This commit is contained in:
parent
24db98e43a
commit
a7ec7cda5b
|
@ -65,7 +65,6 @@ static XF86VidModeModeInfo **avail_modes;
|
|||
static XVisualInfo * vis_info;
|
||||
static Atom delete_atom;
|
||||
static bool gl_loaded = false;
|
||||
static JNIEnv *saved_env;
|
||||
static jclass saved_clazz;
|
||||
|
||||
extern void handlePointerMotion(XMotionEvent *);
|
||||
|
@ -229,14 +228,14 @@ static void acquireInput(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void handleMessages(void) {
|
||||
void handleMessages(JNIEnv *env) {
|
||||
XEvent event;
|
||||
while (XPending(disp) > 0) {
|
||||
XNextEvent(disp, &event);
|
||||
switch (event.type) {
|
||||
case ClientMessage:
|
||||
if ((event.xclient.format == 32) && (event.xclient.data.l[0] == delete_atom))
|
||||
saved_env->SetStaticBooleanField(saved_clazz, fid_close, JNI_TRUE);
|
||||
env->SetStaticBooleanField(saved_clazz, fid_close, JNI_TRUE);
|
||||
break;
|
||||
case FocusIn:
|
||||
acquireInput();
|
||||
|
@ -299,8 +298,8 @@ static int getDisplayModes(Display *disp, int screen, int *num_modes, XF86VidMod
|
|||
return 1;
|
||||
}
|
||||
|
||||
static bool isMinimized() {
|
||||
handleMessages();
|
||||
static bool isMinimized(JNIEnv *env, jclass clazz) {
|
||||
handleMessages(env);
|
||||
return current_minimized;
|
||||
}
|
||||
|
||||
|
@ -322,12 +321,19 @@ XVisualInfo *getVisualInfo(void) {
|
|||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_isMinimized(JNIEnv *env, jclass clazz) {
|
||||
return isMinimized() ? JNI_TRUE : JNI_FALSE;
|
||||
return isMinimized(env, clazz) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate(JNIEnv * env, jclass clazz, jint width, jint height, jint bpp, jint freq, jint alpha_bits, jint depth_bits, jint stencil_bits, jboolean fullscreen, jstring title) {
|
||||
saved_env = env;
|
||||
// Get a global class instance, just to be sure
|
||||
static jobject globalClassLock = NULL;
|
||||
|
||||
if (globalClassLock == NULL) {
|
||||
globalClassLock = env->NewGlobalRef(clazz);
|
||||
}
|
||||
|
||||
saved_clazz = clazz;
|
||||
|
||||
fid_close = env->GetStaticFieldID(clazz, "closeRequested", "Z");
|
||||
|
||||
Window root_win;
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
/**
|
||||
* $Id$
|
||||
*
|
||||
* Win32 controller handling.
|
||||
* Linux controller handling.
|
||||
*
|
||||
* @author Brian Matzon <brian@matzon.com>
|
||||
* @author Elias Naur <brian@matzon.com>
|
||||
* @version $Revision$
|
||||
*/
|
||||
#include <jni.h>
|
||||
|
|
|
@ -69,7 +69,7 @@ extern Display *disp;
|
|||
extern Window win;
|
||||
|
||||
extern bool releaseInput(void);
|
||||
extern void handleMessages(void);
|
||||
extern void handleMessages(JNIEnv *env);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_input_Keyboard
|
||||
|
@ -79,13 +79,6 @@ extern void handleMessages(void);
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
// Get a global class instance, just to be sure
|
||||
static jobject globalClassLock = NULL;
|
||||
|
||||
if (globalClassLock == NULL) {
|
||||
globalClassLock = env->NewGlobalRef(clazz);
|
||||
}
|
||||
|
||||
fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;");
|
||||
}
|
||||
|
||||
|
@ -267,7 +260,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll
|
|||
XEvent event;
|
||||
unsigned char state;
|
||||
|
||||
handleMessages();
|
||||
handleMessages(env);
|
||||
updateGrab();
|
||||
memcpy((unsigned char*)buf, key_buf, KEYBOARD_SIZE*sizeof(unsigned char));
|
||||
}
|
||||
|
@ -286,7 +279,7 @@ JNIEXPORT int JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
|||
int state;
|
||||
int num_events = 0;
|
||||
|
||||
handleMessages();
|
||||
handleMessages(env);
|
||||
updateGrab();
|
||||
while (buf_count < KEYBOARD_BUFFER_SIZE * 2 && (key_event = nextEventElement()) != NULL) {
|
||||
num_events++;
|
||||
|
|
|
@ -59,7 +59,7 @@ extern Window win;
|
|||
extern int screen;
|
||||
extern int getWindowWidth(void);
|
||||
extern int getWindowHeight(void);
|
||||
extern void handleMessages(void);
|
||||
extern void handleMessages(JNIEnv* env);
|
||||
|
||||
static bool pointer_grabbed;
|
||||
static bool created = false;
|
||||
|
@ -289,7 +289,7 @@ static void warpPointer(void) {
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll
|
||||
(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
handleMessages();
|
||||
handleMessages(env);
|
||||
updateGrab();
|
||||
int moved_x = current_x - last_x;
|
||||
int moved_y = current_y - last_y;
|
||||
|
|
|
@ -47,7 +47,7 @@ extern XVisualInfo * getVisualInfo(void);
|
|||
extern Window win;
|
||||
extern Display * disp;
|
||||
|
||||
extern void handleMessages();
|
||||
extern void handleMessages(JNIEnv* env);
|
||||
|
||||
static void makeCurrent(void) {
|
||||
glXMakeCurrent(disp, win, context);
|
||||
|
@ -115,7 +115,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_nDestroy
|
|||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_BaseGL_swapBuffers(JNIEnv * env, jobject obj)
|
||||
{
|
||||
handleMessages();
|
||||
handleMessages(env);
|
||||
glXSwapBuffers(disp, win);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue