diff --git a/src/java/org/lwjgl/opengl/DisplayImplementation.java b/src/java/org/lwjgl/opengl/DisplayImplementation.java index 9a17e1f3..24c7807e 100644 --- a/src/java/org/lwjgl/opengl/DisplayImplementation.java +++ b/src/java/org/lwjgl/opengl/DisplayImplementation.java @@ -242,5 +242,5 @@ public interface DisplayImplementation { * @param icons Array of icons in RGBA mode * @return number of icons used. */ - public int setIcon(ByteBuffer[] icons); + public int setIcon(ByteBuffer[] icons); } diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index 6b180642..c5864901 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -692,6 +692,27 @@ final class LinuxDisplay implements DisplayImplementation { throw new UnsupportedOperationException(); } + private static void convertIcon(ByteBuffer icon, int width, int height) { + int x = 0; + int y = 5; + byte r,g,b,a; + + int depth = 4; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + r = icon.get((x*4)+(y*width*4)); + g = icon.get((x*4)+(y*width*4)+1); + b = icon.get((x*4)+(y*width*4)+2); + a = icon.get((x*4)+(y*width*4)+3); + + icon.put((x*depth)+(y*width*depth), b); // blue + icon.put((x*depth)+(y*width*depth)+1, g); // green + icon.put((x*depth)+(y*width*depth)+2, r); + icon.put((x*depth)+(y*width*depth)+3, a); + } + } + } /** * Sets one or more icons for the Display. @@ -700,23 +721,36 @@ final class LinuxDisplay implements DisplayImplementation { *
  • Linux (and similar platforms) expect one 32x32 icon.
  • *
  • Mac OS X should be supplied one 128x128 icon
  • * - * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform. + * The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions necessary for the specific platform. * * @param icons Array of icons in RGBA mode * @return number of icons used. */ public int setIcon(ByteBuffer[] icons) { - for (int i=0;iflags = IconPixmapHint; - win_hints->icon_pixmap = icon_pixmap; + win_hints->flags = IconPixmapHint; + win_hints->icon_pixmap = current_icon_pixmap; XSetWMHints(getDisplay(), getCurrentWindow(), win_hints); XFree(win_hints); XFlush(getDisplay()); - - return 0; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon - (JNIEnv *env, jclass clazz, jobject iconBuffer) +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon + (JNIEnv *env, jclass clazz, jobject iconBuffer, jint icon_size, jint width, jint height) { char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer); - if (setIcon(imgData,32,32) == 0) - { - return 1; - } - - return 0; + setIcon(env, imgData, icon_size, width, height); }