diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 104598d2..3b9e3e30 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -962,8 +962,7 @@ final class LinuxDisplay implements DisplayImplementation { throw new UnsupportedOperationException(); } - private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) { - ByteBuffer icon_copy = BufferUtils.createByteBuffer(icon.capacity()); + private static void convertIcon(ByteBuffer icon, int width, int height, ByteBuffer icon_rgb, ByteBuffer icon_mask) { int x = 0; int y = 5; byte r,g,b,a; @@ -977,13 +976,14 @@ final class LinuxDisplay implements DisplayImplementation { b = icon.get((x*4)+(y*width*4)+2); a = icon.get((x*4)+(y*width*4)+3); - icon_copy.put((x*depth)+(y*width*depth), b); // blue - icon_copy.put((x*depth)+(y*width*depth)+1, g); // green - icon_copy.put((x*depth)+(y*width*depth)+2, r); - icon_copy.put((x*depth)+(y*width*depth)+3, a); + icon_rgb.put((x*depth)+(y*width*depth), b); // blue + icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green + icon_rgb.put((x*depth)+(y*width*depth)+2, r); + icon_mask.put((x*depth)+(y*width*depth), a); + icon_mask.put((x*depth)+(y*width*depth)+1, a); + icon_mask.put((x*depth)+(y*width*depth)+2, a); } } - return icon_copy; } /** @@ -1006,8 +1006,11 @@ final class LinuxDisplay implements DisplayImplementation { for (int i=0;iExceptionCheck(env)) + return; + current_icon_mask_pixmap = createPixmapFromBuffer(env, disp, window, mask_data, icon_size, width, height); + if ((*env)->ExceptionCheck(env)) { + freeIconPixmap(disp); + return; + } win_hints = XAllocWMHints(); if (win_hints == NULL) { @@ -383,8 +401,9 @@ static void setIcon(JNIEnv *env, Display *disp, Window window, char *data, int i return; } - win_hints->flags = IconPixmapHint; + win_hints->flags = IconPixmapHint | IconMaskHint; win_hints->icon_pixmap = current_icon_pixmap; + win_hints->icon_mask = current_icon_mask_pixmap; XSetWMHints(disp, window, win_hints); XFree(win_hints); @@ -392,13 +411,14 @@ static void setIcon(JNIEnv *env, Display *disp, Window window, char *data, int i } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon - (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject iconBuffer, jint icon_size, jint width, jint height) + (JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jobject icon_rgb_buffer, jobject icon_mask_buffer, jint icon_size, jint width, jint height) { Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; - char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer); + char *rgb_data= (char *)(*env)->GetDirectBufferAddress(env, icon_rgb_buffer); + char *mask_data= (char *)(*env)->GetDirectBufferAddress(env, icon_mask_buffer); - setIcon(env, disp, window, imgData, icon_size, width, height); + setIcon(env, disp, window, rgb_data, mask_data, icon_size, width, height); } JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUngrabKeyboard(JNIEnv *env, jclass unused, jlong display_ptr) {