Skip to content

Commit

Permalink
FvwmPager: Clean up DeskStyle initialization.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
somiaj committed Apr 20, 2024
1 parent 1ccbbd2 commit 03822a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
1 change: 1 addition & 0 deletions modules/FvwmPager/FvwmPager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 12 additions & 20 deletions modules/FvwmPager/init_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions modules/FvwmPager/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 03822a2

Please sign in to comment.