From ec5c3def2816c0db025ba3376a34db352a1f5063 Mon Sep 17 00:00:00 2001 From: Oleh Nykyforchyn Date: Sat, 3 May 2025 17:18:34 +0300 Subject: [PATCH] FvwmPager: correct fonts initialization Prevent some weird FvwmPager crashes and balloons not showing up because fonts and boolean flags are not initialized an start. Also the functionallity of "Balloons" option without parameters is restored. FvwmPager: Move default fonts initialization to init_pager_window() function Correct a misprint and move fonts initialization to initialize_pager_size() Scan further for an optional argument to Balloons Balloon (null) is no more allowed Remove superfluous conditions and restore defaults --- modules/FvwmPager/FvwmPager.c | 1 + modules/FvwmPager/FvwmPager.h | 1 + modules/FvwmPager/init_pager.c | 45 +++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/modules/FvwmPager/FvwmPager.c b/modules/FvwmPager/FvwmPager.c index f540d5a33..70b673b6e 100644 --- a/modules/FvwmPager/FvwmPager.c +++ b/modules/FvwmPager/FvwmPager.c @@ -96,6 +96,7 @@ bool HilightDesks = true; bool HilightLabels = true; bool error_occured = false; bool use_desk_label = true; +bool use_window_label = true; bool WindowBorders3d = false; bool HideSmallWindows = false; bool SendCmdAfterMove = false; diff --git a/modules/FvwmPager/FvwmPager.h b/modules/FvwmPager/FvwmPager.h index b8b5811e5..88ea1ce4c 100644 --- a/modules/FvwmPager/FvwmPager.h +++ b/modules/FvwmPager/FvwmPager.h @@ -221,6 +221,7 @@ extern bool HilightDesks; extern bool HilightLabels; extern bool error_occured; extern bool use_desk_label; +extern bool use_window_label; extern bool WindowBorders3d; extern bool HideSmallWindows; extern bool SendCmdAfterMove; diff --git a/modules/FvwmPager/init_pager.c b/modules/FvwmPager/init_pager.c index 0c863061a..4b40a8ded 100644 --- a/modules/FvwmPager/init_pager.c +++ b/modules/FvwmPager/init_pager.c @@ -246,8 +246,14 @@ void initialize_fonts(void) /* Initialize fonts. */ FlocaleInit(LC_CTYPE, "", "", "FvwmPager"); - /* load a default font. */ - Scr.Ffont = FlocaleLoadFont(dpy, NULL, MyName); + /* load default fonts. */ + Scr.Ffont = NULL; + Scr.winFfont = NULL; + Balloon.Ffont = NULL; + + /* balloons are not shown by default */ + Balloon.show_in_pager = false; + Balloon.show_in_icon = false; /* init our Flocale window string */ FlocaleAllocateWinString(&FwinString); @@ -373,6 +379,12 @@ void initialize_pager_size(void) int VxPages = fp->virtual_scr.VxPages; int VyPages = fp->virtual_scr.VyPages; + if (use_window_label && !Scr.winFfont) + Scr.winFfont = FlocaleLoadFont(dpy, NULL, MyName); + + if ((use_desk_label || use_monitor_label) && !Scr.Ffont) + Scr.Ffont = FlocaleLoadFont(dpy, NULL, MyName); + /* Grid size */ if (Rows < 0) { @@ -1118,12 +1130,14 @@ void parse_options(void) icon_yneg = true; } } else if (StrEquals(resource, "Font")) { - if (strncasecmp(next, "none", 4) == 0) { + FlocaleUnloadFont(dpy, Scr.Ffont); + if (strncasecmp(next, "none", 4) != 0) + Scr.Ffont = FlocaleLoadFont( + dpy, next, MyName); + else { + Scr.Ffont = NULL; use_desk_label = false; use_monitor_label = false; - } else { - FlocaleUnloadFont(dpy, Scr.Ffont); - Scr.Ffont = FlocaleLoadFont(dpy, next, MyName); } } else if (StrEquals(resource, "Pixmap") || StrEquals(resource, "DeskPixmap")) @@ -1187,9 +1201,15 @@ void parse_options(void) StrEquals(resource, "SmallFont")) { FlocaleUnloadFont(dpy, Scr.winFfont); - if (strncasecmp(next, "none", 4) != 0) + if (strncasecmp(next, "none", 4) != 0) { Scr.winFfont = FlocaleLoadFont( dpy, next, MyName); + if (Scr.winFfont) + use_window_label=true; + } else { + Scr.winFfont = NULL; + use_window_label=false; + } } else if (StrEquals(resource, "Rows")) { sscanf(next, "%d", &Rows); } else if (StrEquals(resource, "Columns")) { @@ -1237,8 +1257,15 @@ void parse_options(void) Balloon.show_in_icon = true; } } else if (StrEquals(resource, "BalloonFont")) { - FlocaleUnloadFont(dpy, Balloon.Ffont); - Balloon.Ffont = FlocaleLoadFont(dpy, next, MyName); + FlocaleUnloadFont(dpy, Balloon.Ffont); + if (strncasecmp(next, "none", 4) != 0) { + Balloon.Ffont = FlocaleLoadFont( + dpy, next, MyName); + } else { + Balloon.Ffont = NULL; + Balloon.show_in_pager = false; + Balloon.show_in_icon = false; + } } else if (StrEquals(resource, "BalloonBorderWidth")) { sscanf(next, "%d", &(Balloon.border_width)); } else if (StrEquals(resource, "BalloonYOffset")) {