aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/native/X11Display.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-12-31 08:14:21 +0100
committerSven Gothel <[email protected]>2013-12-31 08:14:21 +0100
commite7ffa68bce9bb707005be72530b207c732f62c31 (patch)
treedb1d2e73c89da355c8ff319febcf3c2cc2637a16 /src/newt/native/X11Display.c
parente7032ae9ca4b754bd9737f86d9496211e9155db4 (diff)
Bug 934, Bug 935: NEWT: Add support for custom Application/Window and Pointer Icons
- Utilizing JOGL's PNG decoder for all icons, if available. - Application/window icons: - Providing default application/window icons in 16x16 and 32x32 size - NewtFactory.setWindowIcons(..) or property 'newt.window.icons' maybe used to override default icons. - Using icons at application/window instantiation - Display.PointerIcons: - NativeWindow Win32 WindowClass no more references a default cursor in favor of fine grained cursor control [in NEWT] - Display provides create/destroy methods, where display destruction also releases open PointerIcon references. - Window.setPointerIcon(..) sets custom PointerIcon - Implemented Platforms - X11 - Windows - OSX - Manual Test: TestGearsES2NEWT (Press 'c')
Diffstat (limited to 'src/newt/native/X11Display.c')
-rw-r--r--src/newt/native/X11Display.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c
index e2392a113..19e733111 100644
--- a/src/newt/native/X11Display.c
+++ b/src/newt/native/X11Display.c
@@ -28,6 +28,8 @@
#include "X11Common.h"
+#include <X11/Xcursor/Xcursor.h>
+
// #include <X11/XKBlib.h> // XKB disabled for now
jclass X11NewtWindowClazz = NULL;
@@ -670,4 +672,54 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage
}
}
+/*
+ * Class: Java_jogamp_newt_driver_x11_DisplayDriver
+ * Method: createPointerIcon0
+ * Signature: (JJILjava/lang/Object;I)V
+ */
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerIcon0
+ (JNIEnv *env, jclass clazz, jlong display, jobject data, jint data_offset, jint width, jint height, jint hotX, jint hotY)
+{
+ Cursor c;
+
+ if( 0 != data ) {
+ Display * dpy = (Display *) (intptr_t) display;
+ char * data_ptr = (char *) (*env)->GetDirectBufferAddress(env, data) + data_offset;
+ XcursorImage ci;
+ ci.version = 1; // XCURSOR_IMAGE_VERSION;
+ ci.size = width; // nominal size (assume square ..)
+ ci.width = width;
+ ci.height = height;
+ ci.xhot = hotX;
+ ci.yhot = hotY;
+ ci.delay = 0;
+ ci.pixels = (XcursorPixel *)(intptr_t)data_ptr;
+
+ c = XcursorImageLoadCursor (dpy, &ci);
+
+ DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", data_ptr, width, height, hotX, hotY, (void *)c);
+
+ } else {
+ c = 0;
+ }
+ return (jlong) (intptr_t) c;
+}
+
+/*
+ * Class: Java_jogamp_newt_driver_x11_DisplayDriver
+ * Method: destroyPointerIcon0
+ * Signature: (JJILjava/lang/Object;I)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_destroyPointerIcon0
+ (JNIEnv *env, jclass clazz, jlong display, jlong handle)
+{
+ Display * dpy = (Display *) (intptr_t) display;
+
+ if( 0 != handle ) {
+ Cursor c = (Cursor) (intptr_t) handle;
+ DBG_PRINT( "X11: destroyPointerIcon0: %p\n", (void *)c);
+ XFreeCursor(dpy, c);
+ }
+}
+