From 03822a2cc51ced68e452256342688f40c89c7bab Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Fri, 19 Apr 2024 21:03:05 -0600 Subject: [PATCH] FvwmPager: Clean up DeskStyle initialization. * Initialize new DeskStyle GC's when they are created. There is a dummy window available at this time for this, no need to wait. * Don't put fonts in DeskStyle GC's, fonts are done with FwinString, which doesn't use these GCs. * Fix a typo in the balloon colorset initialization, which would cause a crash trying to access a non allocated colorset. This fixes #1014. --- modules/FvwmPager/FvwmPager.c | 1 + modules/FvwmPager/init_pager.c | 32 ++++++++++++-------------------- modules/FvwmPager/messages.c | 7 ------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/modules/FvwmPager/FvwmPager.c b/modules/FvwmPager/FvwmPager.c index 077bfac9c..5ad602fef 100644 --- a/modules/FvwmPager/FvwmPager.c +++ b/modules/FvwmPager/FvwmPager.c @@ -408,6 +408,7 @@ DeskStyle *FindDeskStyle(int desk) style->desk = desk; xasprintf(&style->label, "Desk %d", desk); + initialize_desk_style_gcs(style); TAILQ_INSERT_TAIL(&desk_style_q, style, entry); return style; diff --git a/modules/FvwmPager/init_pager.c b/modules/FvwmPager/init_pager.c index 260d85d58..36477a4f0 100644 --- a/modules/FvwmPager/init_pager.c +++ b/modules/FvwmPager/init_pager.c @@ -68,14 +68,16 @@ void init_fvwm_pager(void) initialize_transient(); initialize_pager_window(); - /* Initialize DeskStyle GCs */ + /* Update styles with user configurations. */ + TAILQ_FOREACH(style, &desk_style_q, entry) { + if (style->desk == -1) + continue; + update_desk_style_gcs(style); + } + /* Initialize any non configured desks. */ for (i = 0; i < ndesks; i++) { - /* Create any missing DeskStyles. */ style = FindDeskStyle(i); } - TAILQ_FOREACH(style, &desk_style_q, entry) { - initialize_desk_style_gcs(style); - } /* After DeskStyles are initialized, initialize desk windows. */ for (i = 0; i < ndesks; i++) { @@ -201,7 +203,7 @@ void initialize_colorset(DeskStyle *style) } if (style->balloon_cs >= 0) { style->balloon_fg = Colorset[style->balloon_cs].fg; - style->balloon_bg = Colorset[style->balloon_bg].bg; + style->balloon_bg = Colorset[style->balloon_cs].bg; } } @@ -531,14 +533,8 @@ void initialize_desk_style_gcs(DeskStyle *style) /* Desk labels GC. */ gcv.foreground = style->fg; - if (Scr.Ffont && Scr.Ffont->font) { - gcv.font = Scr.Ffont->font->fid; - style->label_gc = fvwmlib_XCreateGC( - dpy, Scr.pager_w, GCForeground | GCFont, &gcv); - } else { - style->label_gc = fvwmlib_XCreateGC( - dpy, Scr.pager_w, GCForeground, &gcv); - } + style->label_gc = fvwmlib_XCreateGC( + dpy, Scr.pager_w, GCForeground, &gcv); /* Hilight GC, used for monitors and labels backgrounds. */ gcv.foreground = (Pdepth < 2) ? style->bg : style->hi_bg; @@ -547,12 +543,8 @@ void initialize_desk_style_gcs(DeskStyle *style) /* create the hilight desk title drawing GC */ gcv.foreground = (Pdepth < 2) ? style->fg : style->hi_fg; - if (Scr.Ffont && Scr.Ffont->font) - style->hi_fg_gc = fvwmlib_XCreateGC( - dpy, Scr.pager_w, GCForeground | GCFont, &gcv); - else - style->hi_fg_gc = fvwmlib_XCreateGC( - dpy, Scr.pager_w, GCForeground, &gcv); + style->hi_fg_gc = fvwmlib_XCreateGC( + dpy, Scr.pager_w, GCForeground, &gcv); /* create the virtual page boundary GC */ gcv.foreground = style->fg; diff --git a/modules/FvwmPager/messages.c b/modules/FvwmPager/messages.c index 3dc504c43..298d2bc89 100644 --- a/modules/FvwmPager/messages.c +++ b/modules/FvwmPager/messages.c @@ -444,13 +444,6 @@ void process_new_desk(unsigned long *body) /* Update the current desk. */ desk_i = newDesk; style = FindDeskStyle(newDesk); - /* Create and update GCs if needed. */ - if (oldDesk != newDesk) { - if (style->label_gc) - update_desk_style_gcs(style); - else - initialize_desk_style_gcs(style); - } /* Keep monitors in sync when tracking is global. */ if (monitor_mode == MONITOR_TRACKING_G)