From 8154abe07323759a799b3dd9bf1df3c3178fd3e5 Mon Sep 17 00:00:00 2001 From: kappaOne Date: Sun, 27 Oct 2013 01:38:37 +0100 Subject: [PATCH] Set the WM_CLASS property on Linux as its needed for some WM to display the app name/class, currently its the same as the window title. --- src/native/linux/opengl/org_lwjgl_opengl_Display.c | 12 ++++++++++++ src/native/linux/opengles/org_lwjgl_opengl_Display.c | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/native/linux/opengl/org_lwjgl_opengl_Display.c b/src/native/linux/opengl/org_lwjgl_opengl_Display.c index b5209284..e1fc0e45 100644 --- a/src/native/linux/opengl/org_lwjgl_opengl_Display.c +++ b/src/native/linux/opengl/org_lwjgl_opengl_Display.c @@ -187,6 +187,17 @@ static void setWindowTitle(Display *disp, Window window, jlong title, jint len) len); } +static void setClassHint(Display *disp, Window window, jlong title) { + XClassHint* hint = XAllocClassHint(); + + hint->res_name = (const unsigned char *)(intptr_t)title; + hint->res_class = (const unsigned char *)(intptr_t)title; + + XSetClassHint(disp, window, hint); + + XFree(hint); +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) { return openDisplay(env); } @@ -213,6 +224,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; setWindowTitle(disp, window, title, len); + setClassHint(disp, window, title); } static void freeIconPixmap(Display *disp) { diff --git a/src/native/linux/opengles/org_lwjgl_opengl_Display.c b/src/native/linux/opengles/org_lwjgl_opengl_Display.c index 29e4ba7d..339e3770 100644 --- a/src/native/linux/opengles/org_lwjgl_opengl_Display.c +++ b/src/native/linux/opengles/org_lwjgl_opengl_Display.c @@ -184,6 +184,17 @@ static void setWindowTitle(Display *disp, Window window, jlong title, jint len) len); } +static void setClassHint(Display *disp, Window window, jlong title) { + XClassHint* hint = XAllocClassHint(); + + hint->res_name = (const unsigned char *)(intptr_t)title; + hint->res_class = (const unsigned char *)(intptr_t)title; + + XSetClassHint(disp, window, hint); + + XFree(hint); +} + JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) { return openDisplay(env); } @@ -207,6 +218,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nSetTitle(JNIEnv * env Display *disp = (Display *)(intptr_t)display; Window window = (Window)window_ptr; setWindowTitle(disp, window, title, len); + setClassHint(disp, window, title); } static void freeIconPixmap(Display *disp) {