Linux: Made cursor handles longs instead of ByteBuffers
This commit is contained in:
parent
1802fa2d9d
commit
541ac859b1
|
@ -49,10 +49,11 @@ import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
final class LinuxDisplay implements DisplayImplementation {
|
final class LinuxDisplay implements DisplayImplementation {
|
||||||
/* X11 constants */
|
/* X11 constants */
|
||||||
private final static int GrabSuccess = 0;
|
public final static int GrabSuccess = 0;
|
||||||
private final static int AutoRepeatModeOff = 0;
|
private final static int AutoRepeatModeOff = 0;
|
||||||
private final static int AutoRepeatModeOn = 1;
|
private final static int AutoRepeatModeOn = 1;
|
||||||
private final static int AutoRepeatModeDefault = 2;
|
private final static int AutoRepeatModeDefault = 2;
|
||||||
|
public final static int None = 0;
|
||||||
|
|
||||||
/** Window mode enum */
|
/** Window mode enum */
|
||||||
private static final int FULLSCREEN_LEGACY = 1;
|
private static final int FULLSCREEN_LEGACY = 1;
|
||||||
|
@ -109,8 +110,8 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
private boolean minimized;
|
private boolean minimized;
|
||||||
private boolean dirty;
|
private boolean dirty;
|
||||||
private boolean close_requested;
|
private boolean close_requested;
|
||||||
private ByteBuffer current_cursor;
|
private long current_cursor;
|
||||||
private ByteBuffer blank_cursor;
|
private long blank_cursor;
|
||||||
|
|
||||||
private LinuxKeyboard keyboard;
|
private LinuxKeyboard keyboard;
|
||||||
private LinuxMouse mouse;
|
private LinuxMouse mouse;
|
||||||
|
@ -296,7 +297,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
static int getDefaultScreen() {
|
static int getDefaultScreen() {
|
||||||
return nGetDefaultScreen(getDisplay());
|
return nGetDefaultScreen(getDisplay());
|
||||||
}
|
}
|
||||||
private static native int nGetDefaultScreen(long display);
|
static native int nGetDefaultScreen(long display);
|
||||||
|
|
||||||
static long getWindow() {
|
static long getWindow() {
|
||||||
return current_window;
|
return current_window;
|
||||||
|
@ -308,7 +309,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
keyboard_grabbed = false;
|
keyboard_grabbed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native int nUngrabKeyboard(long display);
|
static native int nUngrabKeyboard(long display);
|
||||||
|
|
||||||
private void grabKeyboard() {
|
private void grabKeyboard() {
|
||||||
if (!keyboard_grabbed) {
|
if (!keyboard_grabbed) {
|
||||||
|
@ -317,11 +318,11 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
keyboard_grabbed = true;
|
keyboard_grabbed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native int nGrabKeyboard(long display, long window);
|
static native int nGrabKeyboard(long display, long window);
|
||||||
|
|
||||||
private void grabPointer() {
|
private void grabPointer() {
|
||||||
if (!pointer_grabbed) {
|
if (!pointer_grabbed) {
|
||||||
int result = nGrabPointer(getDisplay(), getWindow());
|
int result = nGrabPointer(getDisplay(), getWindow(), None);
|
||||||
if (result == GrabSuccess) {
|
if (result == GrabSuccess) {
|
||||||
pointer_grabbed = true;
|
pointer_grabbed = true;
|
||||||
// make sure we have a centered window
|
// make sure we have a centered window
|
||||||
|
@ -331,7 +332,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native int nGrabPointer(long display, long window);
|
static native int nGrabPointer(long display, long window, long cursor);
|
||||||
private static native void nSetViewPort(long display, long window, int screen);
|
private static native void nSetViewPort(long display, long window, int screen);
|
||||||
|
|
||||||
private void ungrabPointer() {
|
private void ungrabPointer() {
|
||||||
|
@ -340,7 +341,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
nUngrabPointer(getDisplay());
|
nUngrabPointer(getDisplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native int nUngrabPointer(long display);
|
static native int nUngrabPointer(long display);
|
||||||
|
|
||||||
private boolean isFullscreen() {
|
private boolean isFullscreen() {
|
||||||
return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM;
|
return current_window_mode == FULLSCREEN_LEGACY || current_window_mode == FULLSCREEN_NETWM;
|
||||||
|
@ -360,7 +361,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCursor() {
|
private void updateCursor() {
|
||||||
ByteBuffer cursor;
|
long cursor;
|
||||||
if (shouldGrab()) {
|
if (shouldGrab()) {
|
||||||
cursor = blank_cursor;
|
cursor = blank_cursor;
|
||||||
} else {
|
} else {
|
||||||
|
@ -368,7 +369,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
nDefineCursor(getDisplay(), getWindow(), cursor);
|
nDefineCursor(getDisplay(), getWindow(), cursor);
|
||||||
}
|
}
|
||||||
private static native void nDefineCursor(long display, long window, ByteBuffer cursor_handle);
|
private static native void nDefineCursor(long display, long window, long cursor_handle);
|
||||||
|
|
||||||
private boolean isLegacyFullscreen() {
|
private boolean isLegacyFullscreen() {
|
||||||
return current_window_mode == FULLSCREEN_LEGACY;
|
return current_window_mode == FULLSCREEN_LEGACY;
|
||||||
|
@ -391,7 +392,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
current_window_mode = getWindowMode(fullscreen);
|
current_window_mode = getWindowMode(fullscreen);
|
||||||
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
|
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y);
|
||||||
blank_cursor = createBlankCursor();
|
blank_cursor = createBlankCursor();
|
||||||
current_cursor = null;
|
current_cursor = None;
|
||||||
focused = true;
|
focused = true;
|
||||||
input_released = false;
|
input_released = false;
|
||||||
pointer_grabbed = false;
|
pointer_grabbed = false;
|
||||||
|
@ -429,7 +430,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
LWJGLUtil.log("Failed to reset cursor: " + e.getMessage());
|
LWJGLUtil.log("Failed to reset cursor: " + e.getMessage());
|
||||||
}
|
}
|
||||||
nDestroyCursor(getDisplay(), blank_cursor);
|
nDestroyCursor(getDisplay(), blank_cursor);
|
||||||
blank_cursor = null;
|
blank_cursor = None;
|
||||||
ungrabKeyboard();
|
ungrabKeyboard();
|
||||||
nDestroyWindow(getDisplay(), getWindow());
|
nDestroyWindow(getDisplay(), getWindow());
|
||||||
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
|
nSetRepeatMode(getDisplay(), AutoRepeatModeDefault);
|
||||||
|
@ -438,7 +439,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
unlockAWT();
|
unlockAWT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native void nDestroyWindow(long display, long window);
|
static native void nDestroyWindow(long display, long window);
|
||||||
|
|
||||||
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
|
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
|
@ -706,7 +707,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
public void createMouse() throws LWJGLException {
|
public void createMouse() throws LWJGLException {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
try {
|
try {
|
||||||
mouse = new LinuxMouse(getDisplay(), getWindow());
|
mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow());
|
||||||
} finally {
|
} finally {
|
||||||
unlockAWT();
|
unlockAWT();
|
||||||
}
|
}
|
||||||
|
@ -825,7 +826,7 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
|
private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
|
||||||
|
|
||||||
public void setNativeCursor(Object handle) throws LWJGLException {
|
public void setNativeCursor(Object handle) throws LWJGLException {
|
||||||
current_cursor = (ByteBuffer)handle;
|
current_cursor = getCursorHandle(handle);
|
||||||
lockAWT();
|
lockAWT();
|
||||||
try {
|
try {
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
@ -914,19 +915,20 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
return Keyboard.STATE_UNKNOWN;
|
return Keyboard.STATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
private static native ByteBuffer nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
private static native long nCreateCursor(long display, int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
|
||||||
|
|
||||||
private static ByteBuffer createBlankCursor() {
|
private static long createBlankCursor() {
|
||||||
return nCreateBlankCursor(getDisplay(), getWindow());
|
return nCreateBlankCursor(getDisplay(), getWindow());
|
||||||
}
|
}
|
||||||
private static native ByteBuffer nCreateBlankCursor(long display, long window);
|
static native long nCreateBlankCursor(long display, long window);
|
||||||
|
|
||||||
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
try {
|
try {
|
||||||
incDisplay();
|
incDisplay();
|
||||||
try {
|
try {
|
||||||
return nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
|
||||||
|
return new Long(cursor);
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
decDisplay();
|
decDisplay();
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -936,16 +938,20 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long getCursorHandle(Object cursor_handle) {
|
||||||
|
return cursor_handle != null ? ((Long)cursor_handle).longValue() : None;
|
||||||
|
}
|
||||||
|
|
||||||
public void destroyCursor(Object cursorHandle) {
|
public void destroyCursor(Object cursorHandle) {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
try {
|
try {
|
||||||
nDestroyCursor(getDisplay(), cursorHandle);
|
nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle));
|
||||||
decDisplay();
|
decDisplay();
|
||||||
} finally {
|
} finally {
|
||||||
unlockAWT();
|
unlockAWT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static native void nDestroyCursor(long display, Object cursorHandle);
|
static native void nDestroyCursor(long display, long cursorHandle);
|
||||||
|
|
||||||
public int getPbufferCapabilities() {
|
public int getPbufferCapabilities() {
|
||||||
lockAWT();
|
lockAWT();
|
||||||
|
|
|
@ -64,6 +64,7 @@ final class LinuxMouse {
|
||||||
|
|
||||||
private final long display;
|
private final long display;
|
||||||
private final long window;
|
private final long window;
|
||||||
|
private final long input_window;
|
||||||
private final long warp_atom;
|
private final long warp_atom;
|
||||||
private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4);
|
private final IntBuffer query_pointer_buffer = BufferUtils.createIntBuffer(4);
|
||||||
private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE);
|
private final ByteBuffer event_buffer = ByteBuffer.allocate(Mouse.EVENT_SIZE);
|
||||||
|
@ -77,15 +78,11 @@ final class LinuxMouse {
|
||||||
private EventQueue event_queue;
|
private EventQueue event_queue;
|
||||||
private long last_event_nanos;
|
private long last_event_nanos;
|
||||||
|
|
||||||
public LinuxMouse(long display, long window) throws LWJGLException {
|
public LinuxMouse(long display, long window, long input_window) throws LWJGLException {
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
LinuxDisplay.lockAWT();
|
this.input_window = input_window;
|
||||||
try {
|
this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
|
||||||
this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
|
|
||||||
} finally {
|
|
||||||
LinuxDisplay.unlockAWT();
|
|
||||||
}
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +135,7 @@ final class LinuxMouse {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWarpPointer(int center_x, int center_y) {
|
private void doWarpPointer(int center_x, int center_y) {
|
||||||
nSendWarpEvent(display, window, warp_atom, center_x, center_y);
|
nSendWarpEvent(display, input_window, warp_atom, center_x, center_y);
|
||||||
nWarpCursor(display, window, center_x, center_y);
|
nWarpCursor(display, window, center_x, center_y);
|
||||||
}
|
}
|
||||||
private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y);
|
private static native void nSendWarpEvent(long display, long window, long warp_atom, int center_x, int center_y);
|
||||||
|
|
|
@ -81,15 +81,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetMaxCursorSize
|
||||||
return width_return > height_return ? height_return : width_return;
|
return width_return > height_return ? height_return : width_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
|
||||||
(JNIEnv *env, jclass clazz, jlong display, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
|
(JNIEnv *env, jclass clazz, jlong display, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset)
|
||||||
{
|
{
|
||||||
Display *disp = (Display *)(intptr_t)display;
|
Display *disp = (Display *)(intptr_t)display;
|
||||||
jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(Cursor));
|
|
||||||
if (handle_buffer == NULL) {
|
|
||||||
throwException(env, "Could not allocate handle buffer");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
const int *delays = NULL;
|
const int *delays = NULL;
|
||||||
if (delay_buffer != NULL)
|
if (delay_buffer != NULL)
|
||||||
delays = (const int *)(*env)->GetDirectBufferAddress(env, delay_buffer) + delays_offset;
|
delays = (const int *)(*env)->GetDirectBufferAddress(env, delay_buffer) + delays_offset;
|
||||||
|
@ -98,7 +93,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
|
||||||
XcursorImages *cursor_images = XcursorImagesCreate(num_images);
|
XcursorImages *cursor_images = XcursorImagesCreate(num_images);
|
||||||
if (cursor_images == NULL) {
|
if (cursor_images == NULL) {
|
||||||
throwException(env, "Could not allocate cursor.");
|
throwException(env, "Could not allocate cursor.");
|
||||||
return NULL;
|
return None;
|
||||||
}
|
}
|
||||||
cursor_images->nimage = num_images;
|
cursor_images->nimage = num_images;
|
||||||
int i;
|
int i;
|
||||||
|
@ -111,16 +106,15 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateCursor
|
||||||
cursor_image->delay = delays[i];
|
cursor_image->delay = delays[i];
|
||||||
cursor_images->images[i] = cursor_image;
|
cursor_images->images[i] = cursor_image;
|
||||||
}
|
}
|
||||||
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, handle_buffer);
|
Cursor cursor = XcursorImagesLoadCursor(disp, cursor_images);
|
||||||
*cursor = XcursorImagesLoadCursor(disp, cursor_images);
|
|
||||||
XcursorImagesDestroy(cursor_images);
|
XcursorImagesDestroy(cursor_images);
|
||||||
return handle_buffer;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDestroyCursor
|
||||||
(JNIEnv *env, jclass clazz, jlong display, jobject cursor_handle_buffer)
|
(JNIEnv *env, jclass clazz, jlong display, jlong cursor_ptr)
|
||||||
{
|
{
|
||||||
Display *disp = (Display *)(intptr_t)display;
|
Display *disp = (Display *)(intptr_t)display;
|
||||||
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle_buffer);
|
Cursor cursor = (Cursor)cursor_ptr;
|
||||||
XFreeCursor(disp, *cursor);
|
XFreeCursor(disp, cursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,11 +423,12 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabKeyboard(JNIEnv *
|
||||||
return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
return XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
|
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGrabPointer(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
|
||||||
Display *disp = (Display *)(intptr_t)display_ptr;
|
Display *disp = (Display *)(intptr_t)display_ptr;
|
||||||
Window win = (Window)window_ptr;
|
Window win = (Window)window_ptr;
|
||||||
|
Cursor cursor = (Cursor)cursor_ptr;
|
||||||
int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
|
int grab_mask = PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, None, CurrentTime);
|
return XGrabPointer(disp, win, False, grab_mask, GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetViewPort(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jint screen) {
|
||||||
|
@ -444,25 +445,16 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabPointer(JNIEnv
|
||||||
return XUngrabPointer(disp, CurrentTime);
|
return XUngrabPointer(disp, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jobject cursor_handle) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nDefineCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr, jlong cursor_ptr) {
|
||||||
Display *disp = (Display *)(intptr_t)display_ptr;
|
Display *disp = (Display *)(intptr_t)display_ptr;
|
||||||
Window win = (Window)window_ptr;
|
Window win = (Window)window_ptr;
|
||||||
Cursor cursor;
|
Cursor cursor = (Cursor)cursor_ptr;
|
||||||
if (cursor_handle != NULL)
|
|
||||||
cursor = *((Cursor *)(*env)->GetDirectBufferAddress(env, cursor_handle));
|
|
||||||
else
|
|
||||||
cursor = None;
|
|
||||||
XDefineCursor(disp, win, cursor);
|
XDefineCursor(disp, win, cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(JNIEnv *env, jclass unused, jlong display_ptr, jlong window_ptr) {
|
||||||
Display *disp = (Display *)(intptr_t)display_ptr;
|
Display *disp = (Display *)(intptr_t)display_ptr;
|
||||||
Window win = (Window)window_ptr;
|
Window win = (Window)window_ptr;
|
||||||
jobject handle_buffer = newJavaManagedByteBuffer(env, sizeof(Cursor));
|
|
||||||
if (handle_buffer == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Cursor *cursor = (Cursor *)(*env)->GetDirectBufferAddress(env, handle_buffer);
|
|
||||||
unsigned int best_width, best_height;
|
unsigned int best_width, best_height;
|
||||||
if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
|
if (XQueryBestCursor(disp, win, 1, 1, &best_width, &best_height) == 0) {
|
||||||
throwException(env, "Could not query best cursor size");
|
throwException(env, "Could not query best cursor size");
|
||||||
|
@ -475,9 +467,9 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nCreateBlankCursor(
|
||||||
XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
|
XFillRectangle(disp, mask, gc, 0, 0, best_width, best_height);
|
||||||
XFreeGC(disp, gc);
|
XFreeGC(disp, gc);
|
||||||
XColor dummy_color;
|
XColor dummy_color;
|
||||||
*cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
|
Cursor cursor = XCreatePixmapCursor(disp, mask, mask, &dummy_color, &dummy_color, 0, 0);
|
||||||
XFreePixmap(disp, mask);
|
XFreePixmap(disp, mask);
|
||||||
return handle_buffer;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
|
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nGetInputFocus(JNIEnv *env, jclass unused, jlong display_ptr) {
|
||||||
|
|
Loading…
Reference in New Issue