From 2147b530b39e3bd0ac7b2cbd3ce3e2c49d134bb0 Mon Sep 17 00:00:00 2001 From: Kevin Glass Date: Wed, 6 Jul 2005 19:46:35 +0000 Subject: [PATCH] Added Linux native code for window icon setting. --- src/native/linux/org_lwjgl_opengl_Display.c | 66 +++++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/src/native/linux/org_lwjgl_opengl_Display.c b/src/native/linux/org_lwjgl_opengl_Display.c index 38e45482..6e3bfd40 100644 --- a/src/native/linux/org_lwjgl_opengl_Display.c +++ b/src/native/linux/org_lwjgl_opengl_Display.c @@ -78,6 +78,9 @@ static Window current_win; static window_mode current_window_mode; static int current_height; static int current_width; +static int current_depth; + +static Visual *current_visual; static bool input_released; @@ -404,6 +407,10 @@ static bool createWindow(JNIEnv* env, X11PeerInfo *peer_info, int x, int y, int attribs.override_redirect = True; } win = XCreateWindow(getDisplay(), root_win, x, y, width, height, 0, vis_info->depth, InputOutput, vis_info->visual, attribmask, &attribs); + + current_depth = vis_info->depth; + current_visual = vis_info->visual; + XFree(vis_info); if (!checkXError(env, getDisplay())) { XFreeColormap(getDisplay(), cmap); @@ -569,10 +576,61 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_unlockAWT(JNIEnv *env, jawt.Unlock(env); } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetWindowIcon - (JNIEnv *env, jclass clazz, jobject iconBuffer) -{ - +int setIcon(char *data,int width,int height) { + XWMHints* win_hints; + int x = 0; + int y = 5; + char r,g,b,a; + + int depth = 4; + + for (y=0;yflags = IconPixmapHint; + win_hints->icon_pixmap = 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) +{ + char *imgData = (char *)(*env)->GetDirectBufferAddress(env, iconBuffer); + + if (setIcon(imgData,32,32) == 0) + { + return 1; + } + return 0; }