From f63f0a7416793f42030f56a79930b3f76c82a24d Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename field 'class' to 'xclass' in TwmWindow 'class' is a keyword in c++. Its usage confuses some tools that work with c and c++ source code. Signed-off-by: Tim Wiederhake --- src/add_window.c | 64 ++++++++++++++++++++++++++++---------------------------- src/events.c | 18 +++++++++------- src/iconmgr.c | 12 +++++------ src/icons.c | 4 ++-- src/menus.c | 10 ++++----- src/session.c | 8 +++---- src/twm.h | 2 +- 7 files changed, 60 insertions(+), 58 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index d02a1c8..009d8f8 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -188,8 +188,8 @@ AddWindow(Window w, int iconm, IconMgr *iconp) if (!I18N_FetchName(dpy, tmp_win->w, &name)) name = NULL; - tmp_win->class = NoClass; - XGetClassHint(dpy, tmp_win->w, &tmp_win->class); + tmp_win->xclass = NoClass; + XGetClassHint(dpy, tmp_win->w, &tmp_win->xclass); FetchWmProtocols(tmp_win); FetchWmColormapWindows(tmp_win); @@ -263,44 +263,44 @@ AddWindow(Window w, int iconm, IconMgr *iconp) tmp_win->transient = (short) Transient(tmp_win->w, &tmp_win->transientfor); tmp_win->nameChanged = 0; - if (tmp_win->class.res_name == NULL) - tmp_win->class.res_name = NoName; - if (tmp_win->class.res_class == NULL) - tmp_win->class.res_class = NoName; + if (tmp_win->xclass.res_name == NULL) + tmp_win->xclass.res_name = NoName; + if (tmp_win->xclass.res_class == NULL) + tmp_win->xclass.res_class = NoName; tmp_win->full_name = strdup(tmp_win->name); namelen = (int) strlen(tmp_win->name); tmp_win->highlight = Scr->Highlight && (!short_lookup LookInList(Scr->NoHighlight, tmp_win->full_name, - &tmp_win->class)); + &tmp_win->xclass)); tmp_win->stackmode = Scr->StackMode && (!short_lookup LookInList(Scr->NoStackModeL, tmp_win->full_name, - &tmp_win->class)); + &tmp_win->xclass)); tmp_win->titlehighlight = Scr->TitleHighlight && (!short_lookup LookInList(Scr->NoTitleHighlight, tmp_win->full_name, - &tmp_win->class)); + &tmp_win->xclass)); tmp_win->auto_raise = short_lookup LookInList(Scr->AutoRaise, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); if (tmp_win->auto_raise) Scr->NumAutoRaises++; if (Scr->IconifyByUnmapping) { tmp_win->iconify_by_unmapping = iconm ? FALSE : !short_lookup LookInList(Scr->DontIconify, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); } else { tmp_win->iconify_by_unmapping = Scr->IconifyByUnmapping; } tmp_win->iconify_by_unmapping |= short_lookup LookInList(Scr->IconifyByUn, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); - if (LookInList(Scr->WindowRingL, tmp_win->full_name, &tmp_win->class)) { + if (LookInList(Scr->WindowRingL, tmp_win->full_name, &tmp_win->xclass)) { if (Scr->Ring) { tmp_win->ring.next = Scr->Ring->ring.next; if (Scr->Ring->ring.next->ring.prev) @@ -323,10 +323,10 @@ AddWindow(Window w, int iconm, IconMgr *iconp) */ if (HasShape) { if (!LookInList(Scr->DontSqueezeTitleL, tmp_win->full_name, - &tmp_win->class)) { + &tmp_win->xclass)) { tmp_win->squeeze_info = (SqueezeInfo *) LookInList(Scr->SqueezeTitleL, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); if (!tmp_win->squeeze_info) { static SqueezeInfo default_squeeze = { J_LEFT, 0, 0 }; if (Scr->SqueezeTitle) @@ -348,16 +348,16 @@ AddWindow(Window w, int iconm, IconMgr *iconp) tmp_win->title_height = Scr->TitleHeight + tmp_win->frame_bw; if (Scr->NoTitlebar) tmp_win->title_height = 0; - if (LookInList(Scr->MakeTitle, tmp_win->full_name, &tmp_win->class)) + if (LookInList(Scr->MakeTitle, tmp_win->full_name, &tmp_win->xclass)) tmp_win->title_height = Scr->TitleHeight + tmp_win->frame_bw; - if (LookInList(Scr->NoTitle, tmp_win->full_name, &tmp_win->class)) + if (LookInList(Scr->NoTitle, tmp_win->full_name, &tmp_win->xclass)) tmp_win->title_height = 0; /* if it is a transient window, don't put a title on it */ if (tmp_win->transient && !Scr->DecorateTransients) tmp_win->title_height = 0; - if (LookInList(Scr->StartIconified, tmp_win->full_name, &tmp_win->class)) { + if (LookInList(Scr->StartIconified, tmp_win->full_name, &tmp_win->xclass)) { if (!tmp_win->wmhints) { tmp_win->wmhints = malloc(sizeof(XWMHints)); tmp_win->wmhints->flags = 0; @@ -793,22 +793,22 @@ AddWindow(Window w, int iconm, IconMgr *iconp) tmp_win->iconc.fore = Scr->IconC.fore; tmp_win->iconc.back = Scr->IconC.back; - GetColorFromList(Scr->BorderColorL, tmp_win->full_name, &tmp_win->class, - &tmp_win->border); - GetColorFromList(Scr->IconBorderColorL, tmp_win->full_name, &tmp_win->class, - &tmp_win->icon_border); + GetColorFromList(Scr->BorderColorL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->border); + GetColorFromList(Scr->IconBorderColorL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->icon_border); GetColorFromList(Scr->BorderTileForegroundL, tmp_win->full_name, - &tmp_win->class, &tmp_win->border_tile.fore); + &tmp_win->xclass, &tmp_win->border_tile.fore); GetColorFromList(Scr->BorderTileBackgroundL, tmp_win->full_name, - &tmp_win->class, &tmp_win->border_tile.back); - GetColorFromList(Scr->TitleForegroundL, tmp_win->full_name, &tmp_win->class, - &tmp_win->title.fore); - GetColorFromList(Scr->TitleBackgroundL, tmp_win->full_name, &tmp_win->class, - &tmp_win->title.back); - GetColorFromList(Scr->IconForegroundL, tmp_win->full_name, &tmp_win->class, - &tmp_win->iconc.fore); - GetColorFromList(Scr->IconBackgroundL, tmp_win->full_name, &tmp_win->class, - &tmp_win->iconc.back); + &tmp_win->xclass, &tmp_win->border_tile.back); + GetColorFromList(Scr->TitleForegroundL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->title.fore); + GetColorFromList(Scr->TitleBackgroundL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->title.back); + GetColorFromList(Scr->IconForegroundL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->iconc.fore); + GetColorFromList(Scr->IconBackgroundL, tmp_win->full_name, + &tmp_win->xclass, &tmp_win->iconc.back); /* create windows */ diff --git a/src/events.c b/src/events.c index f80f6b5..f8a5207 100644 --- a/src/events.c +++ b/src/events.c @@ -631,7 +631,7 @@ HandleKeyPress(void) for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL; Tmp_win = Tmp_win->next) { if (!strncmp - (key->win_name, Tmp_win->class.res_name, + (key->win_name, Tmp_win->xclass.res_name, (size_t) len)) { matched = TRUE; ExecuteFunction(key->func, key->action, @@ -646,7 +646,7 @@ HandleKeyPress(void) for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL; Tmp_win = Tmp_win->next) { if (!strncmp - (key->win_name, Tmp_win->class.res_class, + (key->win_name, Tmp_win->xclass.res_class, (size_t) len)) { matched = TRUE; ExecuteFunction(key->func, key->action, @@ -1232,8 +1232,8 @@ HandleDestroyNotify(void) * 2. name * 3. icon_name * 4. wmhints - * 5. class.res_name - * 6. class.res_class + * 5. xclass.res_name + * 6. xclass.res_class * 7. list * 8. iconmgrp * 9. cwins @@ -1258,10 +1258,12 @@ HandleDestroyNotify(void) free_window_names(Tmp_win, True, True, True); /* 1, 2, 3 */ if (Tmp_win->wmhints) /* 4 */ XFree(Tmp_win->wmhints); - if (Tmp_win->class.res_name && Tmp_win->class.res_name != NoName) /* 5 */ - XFree(Tmp_win->class.res_name); - if (Tmp_win->class.res_class && Tmp_win->class.res_class != NoName) /* 6 */ - XFree(Tmp_win->class.res_class); + if (Tmp_win->xclass.res_name && + Tmp_win->xclass.res_name != NoName) /* 5 */ + XFree(Tmp_win->xclass.res_name); + if (Tmp_win->xclass.res_class && + Tmp_win->xclass.res_class != NoName) /* 6 */ + XFree(Tmp_win->xclass.res_class); free_cwins(Tmp_win); /* 9 */ if (Tmp_win->titlebuttons) /* 10 */ free(Tmp_win->titlebuttons); diff --git a/src/iconmgr.c b/src/iconmgr.c index 4aad8fd..87749b7 100644 --- a/src/iconmgr.c +++ b/src/iconmgr.c @@ -361,13 +361,13 @@ AddIconManager(TwmWindow *tmp_win) if (tmp_win->iconmgr || tmp_win->transient || Scr->NoIconManagers) return NULL; - if (LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->class)) + if (LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->xclass)) return NULL; if (Scr->IconManagerDontShow && - !LookInList(Scr->IconMgrShow, tmp_win->full_name, &tmp_win->class)) + !LookInList(Scr->IconMgrShow, tmp_win->full_name, &tmp_win->xclass)) return NULL; if ((ip = (IconMgr *) LookInList(Scr->IconMgrs, tmp_win->full_name, - &tmp_win->class)) == NULL) + &tmp_win->xclass)) == NULL) ip = &Scr->iconmgr; tmp = malloc(sizeof(WList)); @@ -384,12 +384,12 @@ AddIconManager(TwmWindow *tmp_win) tmp->back = Scr->IconManagerC.back; tmp->highlight = Scr->IconManagerHighlight; - GetColorFromList(Scr->IconManagerFL, tmp_win->full_name, &tmp_win->class, + GetColorFromList(Scr->IconManagerFL, tmp_win->full_name, &tmp_win->xclass, &tmp->fore); - GetColorFromList(Scr->IconManagerBL, tmp_win->full_name, &tmp_win->class, + GetColorFromList(Scr->IconManagerBL, tmp_win->full_name, &tmp_win->xclass, &tmp->back); GetColorFromList(Scr->IconManagerHighlightL, tmp_win->full_name, - &tmp_win->class, &tmp->highlight); + &tmp_win->xclass, &tmp->highlight); h = Scr->IconManagerFont.height + 10; if (h < (siconify_height + 4)) diff --git a/src/icons.c b/src/icons.c index 39a2097..493eb7e 100644 --- a/src/icons.c +++ b/src/icons.c @@ -341,7 +341,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name); if (icon_name == NULL) icon_name = LookInList(Scr->IconNames, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); bm = None; if (icon_name != NULL) { @@ -405,7 +405,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name); if (icon_name == NULL) icon_name = LookInList(Scr->IconNames, tmp_win->full_name, - &tmp_win->class); + &tmp_win->xclass); bm = None; if (icon_name != NULL) { diff --git a/src/menus.c b/src/menus.c index 9903f75..39d6d34 100644 --- a/src/menus.c +++ b/src/menus.c @@ -2041,13 +2041,13 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, } if (!t) { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (!strncmp(action, t->class.res_name, (size_t) len)) + if (!strncmp(action, t->xclass.res_name, (size_t) len)) if (WarpThere(t)) break; } if (!t) { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (!strncmp(action, t->class.res_class, (size_t) len)) + if (!strncmp(action, t->xclass.res_class, (size_t) len)) if (WarpThere(t)) break; } @@ -2395,7 +2395,7 @@ DeIconify(TwmWindow *tmp_win) if (tmp_win->list) XUnmapWindow(dpy, tmp_win->list->icon); if ((Scr->WarpCursor || - LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->class)) && + LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->xclass)) && tmp_win->icon) WarpToWindow(tmp_win); tmp_win->icon = FALSE; @@ -2541,9 +2541,9 @@ Identify(TwmWindow *t) snprintf(Info[n++], INFO_SIZE, "Name = \"%s\"", t->full_name); snprintf(Info[n++], INFO_SIZE, - "Class.res_name = \"%s\"", t->class.res_name); + "Class.res_name = \"%s\"", t->xclass.res_name); snprintf(Info[n++], INFO_SIZE, - "Class.res_class = \"%s\"", t->class.res_class); + "Class.res_class = \"%s\"", t->xclass.res_class); Info[n++][0] = '\0'; snprintf(Info[n++], INFO_SIZE, "Geometry/root = %ux%u+%d+%d", wwidth, wheight, x, y); diff --git a/src/session.c b/src/session.c index 1787d62..77e0d3a 100644 --- a/src/session.c +++ b/src/session.c @@ -284,9 +284,9 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, return 0; if (!windowRole) { - if (!write_counted_string(configFile, theWindow->class.res_name)) + if (!write_counted_string(configFile, theWindow->xclass.res_name)) return 0; - if (!write_counted_string(configFile, theWindow->class.res_class)) + if (!write_counted_string(configFile, theWindow->xclass.res_class)) return 0; if (theWindow->nameChanged) { /* @@ -557,9 +557,9 @@ GetWindowConfig(TwmWindow *theWindow, * changed in the previous session. */ - if (strcmp(theWindow->class.res_name, + if (strcmp(theWindow->xclass.res_name, ptr->xclass.res_name) == 0 && - strcmp(theWindow->class.res_class, + strcmp(theWindow->xclass.res_class, ptr->xclass.res_class) == 0 && (ptr->wm_name == NULL || strcmp(theWindow->name, ptr->wm_name) == 0)) { diff --git a/src/twm.h b/src/twm.h index b360d35..46ddd2a 100644 --- a/src/twm.h +++ b/src/twm.h @@ -247,7 +247,7 @@ typedef struct TwmWindow { XSizeHints hints; /* normal hints */ XWMHints *wmhints; /* WM hints */ Window group; /* group ID */ - XClassHint class; + XClassHint xclass; struct WList *list; /*********************************************************************** * color definitions per window -- cgit v1.2.3