From 899424e941d0fe5b71aecb0bb7aa225a00b62d10 Mon Sep 17 00:00:00 2001 From: Jianfeng Liu Date: Tue, 16 Aug 2022 20:21:06 +0800 Subject: [PATCH] xf_floatbar use XmbDrawString instead of XDrawString (#8127) * xf_floatbar use XmbDrawString instead of XDrawString * xf_floatbar fall back to XDrawString when fontSet is NULL Co-authored-by: Jianfeng Liu --- client/X11/xf_floatbar.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/client/X11/xf_floatbar.c b/client/X11/xf_floatbar.c index 2dad3dcc9..b87debb21 100644 --- a/client/X11/xf_floatbar.c +++ b/client/X11/xf_floatbar.c @@ -92,6 +92,7 @@ struct xf_floatbar BOOL created; Window root_window; char* title; + XFontSet fontSet; }; static xfFloatbarButton* xf_floatbar_new_button(xfFloatbar* floatbar, int type); @@ -334,6 +335,16 @@ xfFloatbar* xf_floatbar_new(xfContext* xfc, Window window, const char* name, DWO floatbar->xfc = xfc; floatbar->locked = flags & 0x0002; xf_floatbar_toggle_fullscreen(floatbar, FALSE); + char** missingList; + int missingCount; + char* defString; + floatbar->fontSet = XCreateFontSet(floatbar->xfc->display, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*", + &missingList, &missingCount, &defString); + if (floatbar->fontSet == NULL) + { + WLog_ERR(TAG, "Failed to create fontset"); + } + XFreeStringList(missingList); return floatbar; fail: xf_floatbar_free(floatbar); @@ -401,8 +412,16 @@ static void xf_floatbar_event_expose(xfFloatbar* floatbar) /* draw the host name connected to (limit to maximum file name) */ len = strnlen(floatbar->title, MAX_PATH); XSetForeground(display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND)); - XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15, floatbar->title, - len); + if (floatbar->fontSet != NULL) + { + XmbDrawString(display, floatbar->handle, floatbar->fontSet, gc, + floatbar->width / 2 - len * 2, 15, floatbar->title, len); + } + else + { + XDrawString(display, floatbar->handle, gc, floatbar->width / 2 - len * 2, 15, + floatbar->title, len); + } XFreeGC(display, gc); XFreeGC(display, shape_gc); }