From ee2a1c79a3d0f0eff77b0d08a2ee09857e808f3e Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Tue, 30 Dec 2014 14:50:40 +0200 Subject: [PATCH] Improvements to setTitle on Linux WM_CLASS should not change after window creation. It's illegal (may only change while the window is in the Withdrawn state) and causes flickering issues on the taskbar. The native setTitle implementation has been changed to use a better fallback when XChangeProperty fails and _NET_WM_ICON_NAME is also set, in addition to _NET_WM_NAME. --- src/java/org/lwjgl/opengl/LinuxDisplay.java | 3 --- .../linux/opengl/org_lwjgl_opengl_Display.c | 22 ++++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/java/org/lwjgl/opengl/LinuxDisplay.java b/src/java/org/lwjgl/opengl/LinuxDisplay.java index c27f1e9e..3ce738a8 100644 --- a/src/java/org/lwjgl/opengl/LinuxDisplay.java +++ b/src/java/org/lwjgl/opengl/LinuxDisplay.java @@ -787,9 +787,6 @@ final class LinuxDisplay implements DisplayImplementation { } finally { unlockAWT(); } - - // also update the class hint value as some WM's use it for the window title - if (Display.isCreated()) setClassHint(title, wm_class); } private static native void nSetTitle(long display, long window, long title, int len); diff --git a/src/native/linux/opengl/org_lwjgl_opengl_Display.c b/src/native/linux/opengl/org_lwjgl_opengl_Display.c index e0a5721f..ba40f5ef 100644 --- a/src/native/linux/opengl/org_lwjgl_opengl_Display.c +++ b/src/native/linux/opengl/org_lwjgl_opengl_Display.c @@ -174,15 +174,25 @@ static bool isLegacyFullscreen(jint window_mode) { } static void setWindowTitle(Display *disp, Window window, jlong title, jint len) { + Atom UTF8_STRING = XInternAtom(disp, "UTF8_STRING", True); + Atom _NET_WM_NAME = XInternAtom(disp, "_NET_WM_NAME", True); + Atom _NET_WM_ICON_NAME = XInternAtom(disp, "_NET_WM_ICON_NAME", True); + // ASCII fallback if XChangeProperty fails. - XStoreName(disp, window, (const char *)(intptr_t)title); + XmbSetWMProperties(disp, window, (const char *)(intptr_t)title, (const char *)(intptr_t)title, NULL, 0, NULL, NULL, NULL); // Set the UTF-8 encoded title - XChangeProperty(disp, window, - XInternAtom(disp, "_NET_WM_NAME", False), - XInternAtom(disp, "UTF8_STRING", False), - 8, PropModeReplace, (const unsigned char *)(intptr_t)title, - len); + if ( _NET_WM_NAME ) + XChangeProperty( + disp, window, _NET_WM_NAME, UTF8_STRING, + 8, PropModeReplace, (const unsigned char *)(intptr_t)title, len + ); + + if ( _NET_WM_ICON_NAME ) + XChangeProperty( + disp, window, _NET_WM_ICON_NAME, UTF8_STRING, + 8, PropModeReplace, (const unsigned char *)(intptr_t)title, len + ); } static void setClassHint(Display *disp, Window window, jlong wm_name, jlong wm_class) {