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.
This commit is contained in:
Ioannis Tsakpinis 2014-12-30 14:50:40 +02:00
parent 85e5488e4d
commit ee2a1c79a3
2 changed files with 16 additions and 9 deletions

View File

@ -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);

View File

@ -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) {