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:
parent
85e5488e4d
commit
ee2a1c79a3
|
@ -787,9 +787,6 @@ final class LinuxDisplay implements DisplayImplementation {
|
||||||
} finally {
|
} finally {
|
||||||
unlockAWT();
|
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);
|
private static native void nSetTitle(long display, long window, long title, int len);
|
||||||
|
|
||||||
|
|
|
@ -174,15 +174,25 @@ static bool isLegacyFullscreen(jint window_mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setWindowTitle(Display *disp, Window window, jlong title, jint len) {
|
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.
|
// 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
|
// Set the UTF-8 encoded title
|
||||||
XChangeProperty(disp, window,
|
if ( _NET_WM_NAME )
|
||||||
XInternAtom(disp, "_NET_WM_NAME", False),
|
XChangeProperty(
|
||||||
XInternAtom(disp, "UTF8_STRING", False),
|
disp, window, _NET_WM_NAME, UTF8_STRING,
|
||||||
8, PropModeReplace, (const unsigned char *)(intptr_t)title,
|
8, PropModeReplace, (const unsigned char *)(intptr_t)title, len
|
||||||
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) {
|
static void setClassHint(Display *disp, Window window, jlong wm_name, jlong wm_class) {
|
||||||
|
|
Loading…
Reference in New Issue