Added java debug to all of linux native code

This commit is contained in:
Elias Naur 2004-12-11 20:18:18 +00:00
parent 7e4fc4c3b9
commit d1fb731587
3 changed files with 32 additions and 33 deletions

View File

@ -59,10 +59,10 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_getTimerResolution
return 1000000;
}
static long queryTime(void) {
static long queryTime(JNIEnv *env) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1) {
printfDebug("Could not read current time\n");
printfDebugJava(env, "Could not read current time");
}
long result = tv.tv_sec * 1000000l + tv.tv_usec;
@ -81,7 +81,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebug(JNIEnv *env, jclass clazz, jb
JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
(JNIEnv * env, jclass clazz)
{
hires_timer = queryTime();
hires_timer = queryTime(env);
return (jlong) hires_timer;
}
@ -101,7 +101,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
// Reset scheduler to normal
sched_pri.sched_priority = 0;
if (sched_setscheduler(0, SCHED_OTHER, &sched_pri) != 0) {
printfDebug("Could not set realtime priority\n");
printfDebugJava(env, "Could not set realtime priority");
return;
}
}
@ -111,12 +111,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
min_pri = sched_get_priority_min(SCHED_FIFO);
max_pri = sched_get_priority_max(SCHED_FIFO);
if (min_pri == -1 || max_pri == -1) {
printfDebug("Failed to set realtime priority\n");
printfDebugJava(env, "Failed to set realtime priority");
return;
}
sched_pri.sched_priority = (max_pri + min_pri)/2;
if (sched_setscheduler(0, SCHED_FIFO, &sched_pri) != 0) {
printfDebug("Could not set realtime priority\n");
printfDebugJava(env, "Could not set realtime priority");
return;
}
return;
@ -134,7 +134,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
}
if (setpriority(PRIO_PROCESS, 0, linux_priority) == -1) {
printfDebug("Failed to set priority.\n");
printfDebugJava(env, "Failed to set priority.");
}
}
@ -143,7 +143,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jst
char * eMessageText = GetStringNativeChars(env, message);
char * cTitleBarText = GetStringNativeChars(env, title);
printfDebug("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
printfDebugJava(env, "*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
free(eMessageText);
free(cTitleBarText);

View File

@ -110,10 +110,10 @@ static void resetCursor(int x, int y) {
last_y = y;
}
static bool blankCursor(void) {
static bool blankCursor(JNIEnv *env) {
unsigned int best_width, best_height;
if (XQueryBestCursor(getDisplay(), getCurrentWindow(), 1, 1, &best_width, &best_height) == 0) {
printfDebug("Could not query best cursor size\n");
throwException(env, "Could not query best cursor size");
return false;
}
Pixmap mask = XCreatePixmap(getDisplay(), getCurrentWindow(), best_width, best_height, 1);
@ -259,9 +259,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createMouse
reset();
for (i = 0; i < NUM_BUTTONS; i++)
buttons[i] = 0;
if (!blankCursor()) {
if (!blankCursor(env)) {
decDisplay();
throwException(env, "Could not create blank cursor");
return;
}
current_cursor = None;
@ -367,7 +366,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_pollMouse(JNIEnv * env
int buttons_length = (*env)->GetDirectBufferCapacity(env, button_buffer_obj);
handleMessages(env);
if (coords_length < 3) {
printfDebug("ERROR: Not enough space in coords array: %d < 3\n", coords_length);
printfDebugJava(env, "ERROR: Not enough space in coords array: %d < 3", coords_length);
return;
}
if (isGrabbed()) {

View File

@ -115,7 +115,7 @@ bool checkXError(JNIEnv *env) {
if (env != NULL)
throwException(env, error_message);
else
printfDebug(error_message);
printfDebugJava(env, error_message);
return false;
} else
return true;
@ -145,7 +145,7 @@ Display *incDisplay(JNIEnv *env) {
if (env != NULL)
throwException(env, "Could not open X display connection");
else
printfDebug("Could not open X display connection\n");
printfDebugJava(env, "Could not open X display connection");
return NULL;
}
warp_atom = XInternAtom(display_connection, "_LWJGL_WARP", False);
@ -179,12 +179,12 @@ static void updateInputGrab(void) {
updateKeyboardGrab();
}
static void setRepeatMode(int mode) {
static void setRepeatMode(JNIEnv *env, int mode) {
XKeyboardControl repeat_mode;
repeat_mode.auto_repeat_mode = mode;
Display *disp = XOpenDisplay(NULL);
if (disp == NULL) {
printfDebug("Could not open display to set repeat mode\n");
printfDebugJava(env, "Could not open display to set repeat mode");
return;
}
XChangeKeyboardControl(disp, KBAutoRepeatMode, &repeat_mode);
@ -203,7 +203,7 @@ static bool releaseInput(JNIEnv *env) {
if (isLegacyFullscreen() || input_released)
return false;
input_released = true;
setRepeatMode(AutoRepeatModeDefault);
setRepeatMode(env, AutoRepeatModeDefault);
updateInputGrab();
if (current_window_mode == FULLSCREEN_NETWM) {
XIconifyWindow(getDisplay(), getCurrentWindow(), getCurrentScreen());
@ -216,7 +216,7 @@ static void acquireInput(JNIEnv *env) {
if (isLegacyFullscreen() || !input_released)
return;
input_released = false;
setRepeatMode(AutoRepeatModeOff);
setRepeatMode(env, AutoRepeatModeOff);
updateInputGrab();
if (current_window_mode == FULLSCREEN_NETWM) {
temporaryRestoreMode(env, getCurrentScreen());
@ -323,15 +323,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setTitle(JNIEnv * env,
free(title);
}
static void destroyWindow(void) {
static void destroyWindow(JNIEnv *env) {
if (USEGLX13)
glXDestroyWindow(getDisplay(), glx_window);
XDestroyWindow(getDisplay(), current_win);
XFreeColormap(getDisplay(), cmap);
setRepeatMode(AutoRepeatModeDefault);
setRepeatMode(env, AutoRepeatModeDefault);
}
static bool isNetWMFullscreenSupported() {
static bool isNetWMFullscreenSupported(JNIEnv *env) {
unsigned long nitems;
Atom actual_type;
int actual_format;
@ -340,7 +340,7 @@ static bool isNetWMFullscreenSupported() {
Atom netwm_supported_atom = XInternAtom(getDisplay(), "_NET_SUPPORTED", False);
int result = XGetWindowProperty(getDisplay(), RootWindow(getDisplay(), getCurrentScreen()), netwm_supported_atom, 0, 10000, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, (void *)&supported_list);
if (result != Success) {
printfDebug("Unable to query _NET_SUPPORTED window property\n");
printfDebugJava(env, "Unable to query _NET_SUPPORTED window property");
return false;
}
Atom fullscreen_atom = XInternAtom(getDisplay(), "_NET_WM_STATE_FULLSCREEN", False);
@ -392,7 +392,7 @@ static bool createWindow(JNIEnv* env, int x, int y, int width, int height) {
XFreeColormap(getDisplay(), cmap);
return false;
}
printfDebug("Created window\n");
printfDebugJava(env, "Created window");
current_win = win;
if (current_window_mode != WINDOWED || undecorated) {
// Use Motif decoration hint property and hope the window manager respects them
@ -416,9 +416,9 @@ static bool createWindow(JNIEnv* env, int x, int y, int width, int height) {
XMapRaised(getDisplay(), win);
waitMapped(win);
XClearWindow(getDisplay(), win);
setRepeatMode(AutoRepeatModeOff);
setRepeatMode(env, AutoRepeatModeOff);
if (!checkXError(env)) {
destroyWindow();
destroyWindow(env);
return false;
}
return true;
@ -575,7 +575,7 @@ static XVisualInfo *chooseVisualGLX(JNIEnv *env, jobject pixel_format) {
return glXChooseVisual(getDisplay(), getCurrentScreen(), attrib_list.attribs);
}
static void dumpVisualInfo(XVisualInfo *vis_info) {
static void dumpVisualInfo(JNIEnv *env, XVisualInfo *vis_info) {
int alpha, depth, stencil, r, g, b;
int sample_buffers = 0;
int samples = 0;
@ -589,7 +589,7 @@ static void dumpVisualInfo(XVisualInfo *vis_info) {
glXGetConfig(getDisplay(), vis_info, GLX_SAMPLE_BUFFERS_ARB, &sample_buffers);
glXGetConfig(getDisplay(), vis_info, GLX_SAMPLES_ARB, &samples);
}
printfDebug("Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d\n", r, g, b, alpha, depth, stencil, sample_buffers, samples);
printfDebugJava(env, "Pixel format info: r = %d, g = %d, b = %d, a = %d, depth = %d, stencil = %d, sample buffers = %d, samples = %d", r, g, b, alpha, depth, stencil, sample_buffers, samples);
}
static void destroyContext(void) {
@ -645,7 +645,7 @@ static bool initWindowGLX(JNIEnv *env, jobject pixel_format) {
return false;
}
if (isDebugEnabled())
dumpVisualInfo(vis_info);
dumpVisualInfo(env, vis_info);
context = glXCreateContext(getDisplay(), vis_info, NULL, True);
if (context == NULL) {
XFree(vis_info);
@ -726,7 +726,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyContext(JNIEnv
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createWindow(JNIEnv *env, jobject this, jobject mode, jboolean fullscreen, int x, int y) {
bool current_fullscreen = fullscreen == JNI_TRUE;
if (current_fullscreen) {
if (getCurrentDisplayModeExtension() == XRANDR && isNetWMFullscreenSupported())
if (getCurrentDisplayModeExtension() == XRANDR && isNetWMFullscreenSupported(env))
current_window_mode = FULLSCREEN_NETWM;
else
current_window_mode = FULLSCREEN_LEGACY;
@ -742,17 +742,17 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createWindow(JNIEnv *e
return;
}
if (isDebugEnabled())
dumpVisualInfo(vis_info);
dumpVisualInfo(env, vis_info);
if (USEGLX13)
glx_window = glXCreateWindow(getDisplay(), configs[0], getCurrentWindow(), NULL);
if (!makeCurrent() || !checkXError(env)) {
glXDestroyWindow(getDisplay(), glx_window);
destroyWindow();
destroyWindow(env);
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyWindow(JNIEnv *env, jobject this) {
destroyWindow();
destroyWindow(env);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_swapBuffers(JNIEnv * env, jobject this)