fix(zephr): correct window name in gnome's sidebar

This commit is contained in:
2024-01-05 23:59:35 +02:00
parent bba2f8a189
commit 66be747922
+18 -3
View File
@@ -596,15 +596,30 @@ int x11_create_window(const char* title, int window_width, int window_height, co
XSetWMProtocols(x11_display, x11_window, &wm_delete_window, 1); XSetWMProtocols(x11_display, x11_window, &wm_delete_window, 1);
zephr_ctx->window_delete_atom = wm_delete_window; zephr_ctx->window_delete_atom = wm_delete_window;
// BUG: window title is broken on gnome's sidebar but works on the window itself. // set window name
// sidebar shows "Unknown" {
Atom UTF8_STRING = XInternAtom(x11_display, "UTF8_STRING", False);
XStoreName(x11_display, x11_window, title); XStoreName(x11_display, x11_window, title);
XTextProperty text_property; XTextProperty text_property;
text_property.value = (unsigned char *)title; text_property.value = (unsigned char *)title;
text_property.format = 8; text_property.format = 8;
text_property.encoding = XA_STRING; text_property.encoding = UTF8_STRING;
text_property.nitems = strlen(title); text_property.nitems = strlen(title);
XSetWMName(x11_display, x11_window, &text_property); XSetWMName(x11_display, x11_window, &text_property);
Atom net_wm_name = XInternAtom(x11_display, "_NET_WM_NAME", False);
Atom wm_class = XInternAtom(x11_display, "WM_CLASS", False);
XChangeProperty(x11_display, x11_window, net_wm_name, UTF8_STRING, 8, PropModeReplace, (unsigned char *)title, strlen(title));
XChangeProperty(x11_display, x11_window, wm_class, XA_STRING, 8, PropModeReplace, (unsigned char *)title, strlen(title));
XClassHint *class_hint = XAllocClassHint();
if (class_hint)
{
class_hint->res_name = class_hint->res_class = (char *)title;
XSetClassHint(x11_display, x11_window, class_hint);
XFree(class_hint);
}
}
XMapWindow(x11_display, x11_window); XMapWindow(x11_display, x11_window);