Linux: Implemented AWT synchronization through JAWT. Needed because Xlib is not guaranteed thread safe

This commit is contained in:
Elias Naur 2005-01-11 15:22:12 +00:00
parent d1f039a1b0
commit ccd37148e1
9 changed files with 378 additions and 89 deletions

View File

@ -43,6 +43,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.io.IOException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
@ -50,12 +51,56 @@ final class LinuxDisplay implements DisplayImplementation {
private static final int CURSOR_HANDLE_SIZE = 8;
private static final int PBUFFER_HANDLE_SIZE = 24;
public native void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
public native void destroyWindow();
public native void switchDisplayMode(DisplayMode mode) throws LWJGLException;
public native void resetDisplayMode();
public native int getGammaRampLength();
public native void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements LockAWT and UnlockAWT(), to
* do just that.
*/
private native void lockAWT();
private native void unlockAWT();
public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException {
lockAWT();
nCreateWindow(mode, fullscreen, x, y);
unlockAWT();
}
public native void nCreateWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException;
public void destroyWindow() {
lockAWT();
nDestroyWindow();
unlockAWT();
}
public native void nDestroyWindow();
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
nSwitchDisplayMode(mode);
unlockAWT();
}
public native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException;
public void resetDisplayMode() {
lockAWT();
nResetDisplayMode();
unlockAWT();
}
public native void nResetDisplayMode();
public int getGammaRampLength() {
lockAWT();
int length = nGetGammaRampLength();
unlockAWT();
return length;
}
public native int nGetGammaRampLength();
public void setGammaRamp(FloatBuffer gammaRamp) throws LWJGLException {
lockAWT();
nSetGammaRamp(gammaRamp);
unlockAWT();
}
public native void nSetGammaRamp(FloatBuffer gammaRamp) throws LWJGLException;
public String getAdapter() {
return null;
@ -65,66 +110,288 @@ final class LinuxDisplay implements DisplayImplementation {
return null;
}
public native DisplayMode init();
public native void setTitle(String title);
public native boolean isCloseRequested();
public native boolean isVisible();
public native boolean isActive();
public native boolean isDirty();
public native void swapBuffers();
public native void makeCurrent() throws LWJGLException;
public native void createContext(PixelFormat pixel_format) throws LWJGLException;
public native void destroyContext();
public native void update();
public native void setVSyncEnabled(boolean sync);
public native void reshape(int x, int y, int width, int height);
public native DisplayMode[] getAvailableDisplayModes();
public DisplayMode init() {
lockAWT();
DisplayMode mode = nInit();
unlockAWT();
return mode;
}
public native DisplayMode nInit();
public void setTitle(String title) {
lockAWT();
nSetTitle(title);
unlockAWT();
}
public native void nSetTitle(String title);
public boolean isCloseRequested() {
lockAWT();
boolean result = nIsCloseRequested();
unlockAWT();
return result;
}
public native boolean nIsCloseRequested();
public boolean isVisible() {
lockAWT();
boolean result = nIsVisible();
unlockAWT();
return result;
}
public native boolean nIsVisible();
public boolean isActive() {
lockAWT();
boolean result = nIsActive();
unlockAWT();
return result;
}
public native boolean nIsActive();
public boolean isDirty() {
lockAWT();
boolean result = nIsDirty();
unlockAWT();
return result;
}
public native boolean nIsDirty();
public void swapBuffers() {
lockAWT();
nSwapBuffers();
unlockAWT();
}
public native void nSwapBuffers();
public void makeCurrent() throws LWJGLException {
lockAWT();
nMakeCurrent();
unlockAWT();
}
public native void nMakeCurrent() throws LWJGLException;
public void createContext(PixelFormat pixel_format) throws LWJGLException {
lockAWT();
nCreateContext(pixel_format);
unlockAWT();
}
public native void nCreateContext(PixelFormat pixel_format) throws LWJGLException;
public void destroyContext() {
lockAWT();
nDestroyContext();
unlockAWT();
}
public native void nDestroyContext();
public void update() {
lockAWT();
nUpdate();
unlockAWT();
}
public native void nUpdate();
public void setVSyncEnabled(boolean sync) {
lockAWT();
nSetVSyncEnabled(sync);
unlockAWT();
}
public native void nSetVSyncEnabled(boolean sync);
public void reshape(int x, int y, int width, int height) {
lockAWT();
nReshape(x, y, width, height);
unlockAWT();
}
public native void nReshape(int x, int y, int width, int height);
public DisplayMode[] getAvailableDisplayModes() {
lockAWT();
DisplayMode[] modes = nGetAvailableDisplayModes();
unlockAWT();
return modes;
}
public native DisplayMode[] nGetAvailableDisplayModes();
/* Mouse */
public boolean hasWheel() {
return true;
}
public native int getButtonCount();
public native void createMouse();
public native void destroyMouse();
public native void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
public native void enableMouseBuffer() throws LWJGLException;
public native int readMouse(IntBuffer buffer, int buffer_position);
public native void grabMouse(boolean grab);
public native int getNativeCursorCaps();
public native void setNativeCursor(Object handle) throws LWJGLException;
public native int getMinCursorSize();
public native int getMaxCursorSize();
public int getButtonCount() {
lockAWT();
int num_buttons = nGetButtonCount();
unlockAWT();
return num_buttons;
}
public native int nGetButtonCount();
public void createMouse() {
lockAWT();
nCreateMouse();
unlockAWT();
}
public native void nCreateMouse();
public void destroyMouse() {
lockAWT();
nDestroyMouse();
unlockAWT();
}
public native void nDestroyMouse();
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
lockAWT();
nPollMouse(coord_buffer, buttons);
unlockAWT();
}
public native void nPollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
public void enableMouseBuffer() throws LWJGLException {
lockAWT();
nEnableMouseBuffer();
unlockAWT();
}
public native void nEnableMouseBuffer() throws LWJGLException;
public int readMouse(IntBuffer buffer, int buffer_position) {
lockAWT();
int count = nReadMouse(buffer, buffer_position);
unlockAWT();
return count;
}
public native int nReadMouse(IntBuffer buffer, int buffer_position);
public void grabMouse(boolean grab) {
lockAWT();
nGrabMouse(grab);
unlockAWT();
}
public native void nGrabMouse(boolean grab);
public int getNativeCursorCaps() {
lockAWT();
int caps = nGetNativeCursorCaps();
unlockAWT();
return caps;
}
public native int nGetNativeCursorCaps();
public void setNativeCursor(Object handle) throws LWJGLException {
lockAWT();
nSetNativeCursor(handle);
unlockAWT();
}
public native void nSetNativeCursor(Object handle) throws LWJGLException;
public int getMinCursorSize() {
lockAWT();
int min_size = nGetMinCursorSize();
unlockAWT();
return min_size;
}
public native int nGetMinCursorSize();
public int getMaxCursorSize() {
lockAWT();
int max_size = nGetMaxCursorSize();
unlockAWT();
return max_size;
}
public native int nGetMaxCursorSize();
/* Keyboard */
public native void createKeyboard() throws LWJGLException;
public native void destroyKeyboard();
public native void pollKeyboard(ByteBuffer keyDownBuffer);
public native int readKeyboard(IntBuffer buffer, int buffer_position);
public native void enableTranslation() throws LWJGLException;
public native void enableKeyboardBuffer() throws LWJGLException;
public native int isStateKeySet(int key);
public void createKeyboard() throws LWJGLException {
lockAWT();
nCreateKeyboard();
unlockAWT();
}
public native void nCreateKeyboard() throws LWJGLException;
public void destroyKeyboard() {
lockAWT();
nDestroyKeyboard();
unlockAWT();
}
public native void nDestroyKeyboard();
public void pollKeyboard(ByteBuffer keyDownBuffer) {
lockAWT();
nPollKeyboard(keyDownBuffer);
unlockAWT();
}
public native void nPollKeyboard(ByteBuffer keyDownBuffer);
public int readKeyboard(IntBuffer buffer, int buffer_position) {
lockAWT();
int count = nReadKeyboard(buffer, buffer_position);
unlockAWT();
return count;
}
public native int nReadKeyboard(IntBuffer buffer, int buffer_position);
public void enableTranslation() throws LWJGLException {
lockAWT();
nEnableTranslation();
unlockAWT();
}
public native void nEnableTranslation() throws LWJGLException;
public void enableKeyboardBuffer() throws LWJGLException {
lockAWT();
nEnableKeyboardBuffer();
unlockAWT();
}
public native void nEnableKeyboardBuffer() throws LWJGLException;
public int isStateKeySet(int key) {
return Keyboard.STATE_UNKNOWN;
}
public native void nCreateCursor(ByteBuffer handle, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
lockAWT();
ByteBuffer handle = BufferUtils.createByteBuffer(CURSOR_HANDLE_SIZE);
nCreateCursor(handle, width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
unlockAWT();
return handle;
}
public native void destroyCursor(Object cursorHandle);
public native int getPbufferCaps();
public void destroyCursor(Object cursorHandle) {
lockAWT();
nDestroyCursor(cursorHandle);
unlockAWT();
}
public native void nDestroyCursor(Object cursorHandle);
public int getPbufferCaps() {
lockAWT();
int caps = nGetPbufferCaps();
unlockAWT();
return caps;
}
public native int nGetPbufferCaps();
public boolean isBufferLost(ByteBuffer handle) {
return false;
}
public native void makePbufferCurrent(ByteBuffer handle) throws LWJGLException;
public void makePbufferCurrent(ByteBuffer handle) throws LWJGLException {
lockAWT();
nMakePbufferCurrent(handle);
unlockAWT();
}
public native void nMakePbufferCurrent(ByteBuffer handle) throws LWJGLException;
public ByteBuffer createPbuffer(int width, int height, PixelFormat pixel_format,
IntBuffer pixelFormatCaps,
IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException {
lockAWT();
ByteBuffer handle = BufferUtils.createByteBuffer(PBUFFER_HANDLE_SIZE);
nCreatePbuffer(handle, width, height, pixel_format, pixelFormatCaps, pBufferAttribs, shared_pbuffer_handle);
unlockAWT();
return handle;
}
@ -132,7 +399,12 @@ final class LinuxDisplay implements DisplayImplementation {
IntBuffer pixelFormatCaps,
IntBuffer pBufferAttribs, ByteBuffer shared_pbuffer_handle) throws LWJGLException;
public native void destroyPbuffer(ByteBuffer handle);
public void destroyPbuffer(ByteBuffer handle) {
lockAWT();
nDestroyPbuffer(handle);
unlockAWT();
}
public native void nDestroyPbuffer(ByteBuffer handle);
public void setPbufferAttrib(ByteBuffer handle, int attrib, int value) {
throw new UnsupportedOperationException();

View File

@ -167,7 +167,7 @@ int copyEvents(event_queue_t *queue, jint *output_event_buffer, int buffer_size)
return num_events;
}
static void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) {
void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err) {
jclass cls;
if ((*env)->ExceptionCheck(env) == JNI_TRUE)

View File

@ -126,6 +126,7 @@ extern jstring getVersionString(JNIEnv *env);
extern void initEventQueue(event_queue_t *event_queue, int event_size);
extern int copyEvents(event_queue_t *event_queue, jint *output_event_buffer, int buffer_size);
extern bool putEvent(event_queue_t *queue, jint *event);
extern void throwGeneralException(JNIEnv * env, const char *exception_name, const char * err);
extern void throwException(JNIEnv *env, const char *msg);
extern void throwOpenALException(JNIEnv * env, const char * err);
extern void throwFMODException(JNIEnv * env, const char * err);

View File

@ -4,7 +4,7 @@ CC=gcc
LINKER=gcc
STRIP=strip
CFLAGS_LINK=-shared -Wall
LIBS=-L/usr/X11/lib -lX11 -lXext -lXxf86vm -lpthread -Wl,-static,-lXcursor,-lXrender,-lXrandr,-call_shared
LIBS=-L/usr/X11/lib -lX11 -lXext -lXxf86vm -lpthread -L/usr/lib/jvm/java-1.4.2-sun-1.4.2.05/jre/lib/i386/ -ljawt -Wl,-static,-lXcursor,-lXrender,-lXrandr,-call_shared
CFLAGS_O=-fPIC -O2 -D_X11 -Wall -pthread -c -I../common -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
SRC=$(wildcard *.c) $(wildcard ../common/*.c) $(wildcard ../common/arb/*.c) $(wildcard ../common/ati/*.c) $(wildcard ../common/ext/*.c) $(wildcard ../common/nv/*.c)
OBJECTS=$(subst .c,.o,$(SRC))

View File

@ -84,7 +84,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
XcursorImagesDestroy(cursor_images);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyCursor
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
(JNIEnv *env, jobject this, jobject cursor_handle_buffer)
{
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle_buffer);

View File

@ -120,7 +120,7 @@ static void setupIMEventMask() {
XSetICFocus(xic);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createKeyboard
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateKeyboard
(JNIEnv * env, jobject this)
{
Display *disp = incDisplay(env);
@ -172,7 +172,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createKeyboard
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyKeyboard
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyKeyboard
(JNIEnv * env, jobject this)
{
closeUnicodeStructs();
@ -285,27 +285,23 @@ void handleKeyEvent(XKeyEvent *event) {
bufferEvent(event);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_pollKeyboard(JNIEnv * env, jobject this, jobject buffer) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nPollKeyboard(JNIEnv * env, jobject this, jobject buffer) {
unsigned char *new_keyboard_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, buffer);
handleMessages(env);
memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char));
}
JNIEXPORT int JNICALL Java_org_lwjgl_opengl_LinuxDisplay_readKeyboard(JNIEnv * env, jobject this, jobject buffer, jint buffer_position) {
JNIEXPORT int JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReadKeyboard(JNIEnv * env, jobject this, jobject buffer, jint buffer_position) {
handleMessages(env);
jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer);
int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position;
return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_enableTranslation(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nEnableTranslation(JNIEnv *env, jobject this) {
translation_enabled = true;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_enableKeyboardBuffer(JNIEnv * env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nEnableKeyboardBuffer(JNIEnv * env, jobject this) {
buffer_enabled = true;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isStateKeySet(JNIEnv *env, jobject this, jint key) {
return org_lwjgl_input_Keyboard_STATE_UNKNOWN;
}

View File

@ -193,7 +193,7 @@ static void doWarpPointer(int center_x, int center_y) {
XWarpPointer(getDisplay(), None, getCurrentWindow(), 0, 0, 0, 0, center_x, center_y);
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getNativeCursorCaps
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetNativeCursorCaps
(JNIEnv *env, jobject this) {
int caps = 0;
Display *disp = incDisplay(env);
@ -209,7 +209,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getNativeCursorCaps
return caps;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setNativeCursor(JNIEnv *env, jobject this, jobject cursor_handle) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetNativeCursor(JNIEnv *env, jobject this, jobject cursor_handle) {
if (cursor_handle != NULL) {
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle);
current_cursor = *cursor;
@ -218,7 +218,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setNativeCursor(JNIEnv
updateCursor();
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getMinCursorSize
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMinCursorSize
(JNIEnv *env, jobject this)
{
unsigned int width_return = 0;
@ -227,7 +227,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getMinCursorSize
return width_return > height_return ? width_return : height_return;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getMaxCursorSize
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize
(JNIEnv *env, jobject this)
{
unsigned int width_return = 0;
@ -236,7 +236,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getMaxCursorSize
return width_return > height_return ? height_return : width_return;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getButtonCount(JNIEnv *env, jobject this) {
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetButtonCount(JNIEnv *env, jobject this) {
return NUM_BUTTONS;
}
@ -244,7 +244,7 @@ static void reset(void) {
initEventQueue(&event_queue, EVENT_SIZE);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createMouse
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateMouse
(JNIEnv * env, jobject this)
{
Display *disp = incDisplay(env);
@ -267,7 +267,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createMouse
initEventQueue(&event_queue, EVENT_SIZE);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyMouse
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyMouse
(JNIEnv * env, jobject this)
{
ungrabPointer();
@ -355,7 +355,7 @@ void handlePointerMotion(XMotionEvent *event) {
doHandlePointerMotion(event->x_root, event->y_root, event->x, event->y);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_pollMouse(JNIEnv * env, jobject this, jobject coord_buffer_obj, jobject button_buffer_obj) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nPollMouse(JNIEnv * env, jobject this, jobject coord_buffer_obj, jobject button_buffer_obj) {
int *coords = (int *)(*env)->GetDirectBufferAddress(env, coord_buffer_obj);
int coords_length = (*env)->GetDirectBufferCapacity(env, coord_buffer_obj);
unsigned char *buttons_buffer = (unsigned char *)(*env)->GetDirectBufferAddress(env, button_buffer_obj);
@ -382,18 +382,18 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_pollMouse(JNIEnv * env
buttons_buffer[i] = buttons[i];
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_enableMouseBuffer(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nEnableMouseBuffer(JNIEnv *env, jobject this) {
buffer_enabled = true;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_readMouse(JNIEnv *env, jobject this, jobject buffer, jint buffer_position) {
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReadMouse(JNIEnv *env, jobject this, jobject buffer, jint buffer_position) {
jint* buffer_ptr = (jint *)(*env)->GetDirectBufferAddress(env, buffer);
int buffer_size = ((*env)->GetDirectBufferCapacity(env, buffer))/sizeof(jint) - buffer_position;
handleMessages(env);
return copyEvents(&event_queue, buffer_ptr + buffer_position, buffer_size);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_grabMouse(JNIEnv * env, jobject this, jboolean new_grab) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabMouse(JNIEnv * env, jobject this, jboolean new_grab) {
Window root_return, child_return;
int root_x, root_y, win_x, win_y;
unsigned int mask_return;

View File

@ -46,6 +46,7 @@
#include <stdlib.h>
#include <assert.h>
#include <jni.h>
#include <jawt.h>
#include "common_tools.h"
#include "extgl.h"
#include "extgl_glx.h"
@ -317,7 +318,7 @@ static void setWindowTitle(const char *title) {
XStoreName(getDisplay(), current_win, title);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setTitle(JNIEnv * env, jobject this, jstring title_obj) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env, jobject this, jstring title_obj) {
char * title = GetStringNativeChars(env, title_obj);
setWindowTitle(title);
free(title);
@ -356,7 +357,7 @@ static bool isNetWMFullscreenSupported(JNIEnv *env) {
return supported;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_reshape(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jobject this, jint x, jint y, jint width, jint height) {
XMoveWindow(getDisplay(), getCurrentWindow(), x, y);
}
@ -436,7 +437,7 @@ int getWindowHeight(void) {
return current_height;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_update
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate
(JNIEnv *env, jobject this)
{
handleMessages(env);
@ -449,7 +450,7 @@ static bool makeCurrent(void) {
return glXMakeCurrent(getDisplay(), getCurrentWindow(), context) == True;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_makeCurrent
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nMakeCurrent
(JNIEnv *env, jobject this)
{
if (!makeCurrent())
@ -667,31 +668,31 @@ static bool initWindowGLX(JNIEnv *env, jobject pixel_format) {
return true;
}
JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getAvailableDisplayModes(JNIEnv *env, jobject this) {
JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetAvailableDisplayModes(JNIEnv *env, jobject this) {
return getAvailableDisplayModes(env, getCurrentScreen());
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_switchDisplayMode(JNIEnv *env, jobject this, jobject mode) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwitchDisplayMode(JNIEnv *env, jobject this, jobject mode) {
switchDisplayMode(env, mode, getCurrentScreen());
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_resetDisplayMode(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nResetDisplayMode(JNIEnv *env, jobject this) {
resetDisplayMode(env, getCurrentScreen(), false);
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getGammaRampLength(JNIEnv *env, jobject this) {
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetGammaRampLength(JNIEnv *env, jobject this) {
return (jint)getGammaRampLength(env, getCurrentScreen());
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetGammaRamp(JNIEnv *env, jobject this, jobject gamma_buffer) {
setGammaRamp(env, gamma_buffer, getCurrentScreen());
}
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_init(JNIEnv *env, jobject this) {
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nInit(JNIEnv *env, jobject this) {
return initDisplay(env, getCurrentScreen());
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createContext(JNIEnv *env, jobject this, jobject pixel_format) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateContext(JNIEnv *env, jobject this, jobject pixel_format) {
Display *disp = incDisplay(env);
if (disp == NULL) {
return;
@ -710,12 +711,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createContext(JNIEnv *
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyContext(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyContext(JNIEnv *env, jobject this) {
destroyContext();
decDisplay();
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createWindow(JNIEnv *env, jobject this, jobject mode, jboolean fullscreen, int x, int y) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateWindow(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(env)) {
@ -746,11 +747,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_createWindow(JNIEnv *e
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyWindow(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyWindow(JNIEnv *env, jobject this) {
destroyWindow(env);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_swapBuffers(JNIEnv * env, jobject this)
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSwapBuffers(JNIEnv * env, jobject this)
{
dirty = false;
if (USEGLX13)
@ -759,31 +760,31 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_swapBuffers(JNIEnv * e
glXSwapBuffers(getDisplay(), getCurrentWindow());
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isDirty
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsDirty
(JNIEnv *env, jobject this) {
bool result = dirty;
dirty = false;
return result ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isVisible
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsVisible
(JNIEnv *env, jobject this) {
return minimized ? JNI_FALSE : JNI_TRUE;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isCloseRequested
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsCloseRequested
(JNIEnv *env, jobject this) {
bool saved = closerequested;
closerequested = false;
return saved;
}
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_isActive
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nIsActive
(JNIEnv *env, jobject this) {
return focused || isLegacyFullscreen() ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setVSyncEnabled
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetVSyncEnabled
(JNIEnv *env, jobject this, jboolean sync)
{
if (extgl_Extensions.GLX_SGI_swap_control) {
@ -796,3 +797,22 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_setVSyncEnabled
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_lockAWT(JNIEnv *env, jobject this) {
JAWT jawt;
jawt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
throwGeneralException(env, "java/lang/RuntimeException", "GetAWT failed");
return;
}
jawt.Lock(env);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_unlockAWT(JNIEnv *env, jobject this) {
JAWT jawt;
jawt.version = JAWT_VERSION_1_4;
if (JAWT_GetAWT(env, &jawt) != JNI_TRUE) {
throwGeneralException(env, "java/lang/RuntimeException", "GetAWT failed");
return;
}
jawt.Unlock(env);
}

View File

@ -51,7 +51,7 @@ typedef struct _PbufferInfo {
GLXContext context;
} PbufferInfo;
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getPbufferCaps
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetPbufferCaps
(JNIEnv *env, jobject this)
{
// Only support the GLX 1.3 Pbuffers and ignore the GLX_SGIX_pbuffer extension
@ -158,7 +158,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreatePbuffer(JNIEnv
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_makePbufferCurrent
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nMakePbufferCurrent
(JNIEnv *env, jobject this, jobject handle_buffer)
{
PbufferInfo *buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, handle_buffer);
@ -169,7 +169,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_makePbufferCurrent
}
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_destroyPbuffer
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyPbuffer
(JNIEnv *env, jobject this, jobject handle_buffer)
{
PbufferInfo *buffer_info = (PbufferInfo *)(*env)->GetDirectBufferAddress(env, handle_buffer);