From ce1fc38396864c89110339601398678b995676aa Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 25 Feb 2023 08:56:55 -0800 Subject: Remove "All rights reserved" from Oracle copyright notices Oracle no longer includes this term in our copyright & license notices. Signed-off-by: Alan Coopersmith --- man/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/Makefile.am b/man/Makefile.am index f59d5b5..4af3a3e 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, Oracle and/or its affiliates. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), -- cgit v1.2.3 From 98316f44c03edaa55bf75c4ba2b3b9e3ec16efc6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 2 Dec 2023 14:45:19 -0800 Subject: configure: pass noyywrap to AC_PROG_LEX if using autoconf 2.70 or later Raises minimum autoconf version from 2.60 to 2.64 for m4_version_prereq Clears autoconf warning: configure.ac:47: warning: AC_PROG_LEX without either yywrap or noyywrap is obsolete ./lib/autoconf/programs.m4:743: _AC_PROG_LEX is expanded from... ./lib/autoconf/programs.m4:736: AC_PROG_LEX is expanded from... configure.ac:47: the top level Signed-off-by: Alan Coopersmith --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 692dc31..471dec7 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl dnl Process this file with autoconf to create configure. # Initialize Autoconf -AC_PREREQ([2.60]) +AC_PREREQ([2.64]) AC_INIT([twm], [1.0.12], [https://gitlab.freedesktop.org/xorg/app/twm/issues], [twm]) AC_CONFIG_SRCDIR([Makefile.am]) @@ -44,7 +44,7 @@ if test ! -f "$srcdir/gram.c"; then AC_MSG_ERROR([yacc not found - unable to compile gram.y]) fi fi -AC_PROG_LEX +m4_version_prereq([2.70], [AC_PROG_LEX(noyywrap)], [AC_PROG_LEX]) AC_CHECK_FUNCS([mkstemp]) -- cgit v1.2.3 From a752fdad02f5eba89c53a53e4a212cf31cbf4670 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Fix include guard names Names that begin with an underscore ('_') are reserved. Follow the usual practice of naming the include guard of file "foo.h" "FOO_H", as is already done in "icons.h". Signed-off-by: Tim Wiederhake --- src/add_window.h | 6 +++--- src/events.h | 6 +++--- src/gc.h | 6 +++--- src/iconmgr.h | 6 +++--- src/icons.h | 2 +- src/list.h | 6 +++--- src/menus.h | 6 +++--- src/parse.h | 6 +++--- src/resize.h | 6 +++--- src/screen.h | 6 +++--- src/session.h | 6 +++--- src/twm.h | 6 +++--- src/util.h | 6 +++--- src/version.h | 6 +++--- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/add_window.h b/src/add_window.h index df4e909..c96ce15 100644 --- a/src/add_window.h +++ b/src/add_window.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _ADD_WINDOW_ -#define _ADD_WINDOW_ +#ifndef ADD_WINDOW_H +#define ADD_WINDOW_H #include "iconmgr.h" @@ -82,4 +82,4 @@ extern int AddingY; extern int AddingW; extern int AddingH; -#endif /* _ADD_WINDOW_ */ +#endif /* ADD_WINDOW_H */ diff --git a/src/events.h b/src/events.h index 085439f..3778488 100644 --- a/src/events.h +++ b/src/events.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ -#ifndef _EVENTS_ -#define _EVENTS_ +#ifndef EVENTS_H +#define EVENTS_H #include "screen.h" #include "twm.h" @@ -127,4 +127,4 @@ extern unsigned int mods_used; extern int MovedFromKeyPress; -#endif /* _EVENTS_ */ +#endif /* EVENTS_H */ diff --git a/src/gc.h b/src/gc.h index 4065ded..6da0ab5 100644 --- a/src/gc.h +++ b/src/gc.h @@ -57,9 +57,9 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _GC_ -#define _GC_ +#ifndef GC_H +#define GC_H extern void CreateGCs(void); -#endif /* _GC_ */ +#endif /* GC_H */ diff --git a/src/iconmgr.h b/src/iconmgr.h index ae9214a..ad61239 100644 --- a/src/iconmgr.h +++ b/src/iconmgr.h @@ -31,8 +31,8 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ -#ifndef _ICONMGR_ -#define _ICONMGR_ +#ifndef ICONMGR_H +#define ICONMGR_H #include "twm.h" @@ -87,4 +87,4 @@ extern void PackIconManager(IconMgr *ip); extern void RemoveIconManager(TwmWindow *tmp_win); extern void SortIconManager(IconMgr *ip); -#endif /* _ICONMGR_ */ +#endif /* ICONMGR_H */ diff --git a/src/icons.h b/src/icons.h index 4bac87a..5b34e90 100644 --- a/src/icons.h +++ b/src/icons.h @@ -57,4 +57,4 @@ extern void AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy); extern void CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y); -#endif /* ICONS_H */ +#endif /* ICONS_H */ diff --git a/src/list.h b/src/list.h index d9a4acd..68ab374 100644 --- a/src/list.h +++ b/src/list.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _LIST_ -#define _LIST_ +#ifndef LIST_H +#define LIST_H #include #include @@ -75,4 +75,4 @@ extern char *LookInList(name_list * list_head, const char *name, XClassHint *class); extern char *LookInNameList(name_list * list_head, const char *name); -#endif /* _LIST_ */ +#endif /* LIST_H */ diff --git a/src/menus.h b/src/menus.h index 0692a27..5e188fc 100644 --- a/src/menus.h +++ b/src/menus.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ -#ifndef _MENUS_ -#define _MENUS_ +#ifndef MENUS_H +#define MENUS_H #include "twm.h" @@ -191,4 +191,4 @@ extern void SendDeleteWindowMessage(TwmWindow *tmp, Time timestamp); extern void SendSaveYourselfMessage(TwmWindow *tmp, Time timestamp); extern void SendTakeFocusMessage(TwmWindow *tmp, Time timestamp); -#endif /* _MENUS_ */ +#endif /* MENUS_H */ diff --git a/src/parse.h b/src/parse.h index 0d0500c..a208cc8 100644 --- a/src/parse.h +++ b/src/parse.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _PARSE_ -#define _PARSE_ +#ifndef PARSE_H +#define PARSE_H #include "list.h" @@ -149,4 +149,4 @@ extern int mods; #define D_EAST 3 #define D_WEST 4 -#endif /* _PARSE_ */ +#endif /* PARSE_H */ diff --git a/src/resize.h b/src/resize.h index a16a238..5ca8730 100644 --- a/src/resize.h +++ b/src/resize.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _RESIZE_ -#define _RESIZE_ +#ifndef RESIZE_H +#define RESIZE_H #include "twm.h" @@ -77,4 +77,4 @@ extern void SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw, extern void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw); extern void StartResize(XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar); -#endif /* _RESIZE_ */ +#endif /* RESIZE_H */ diff --git a/src/screen.h b/src/screen.h index 39603df..403ce18 100644 --- a/src/screen.h +++ b/src/screen.h @@ -31,8 +31,8 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ -#ifndef _SCREEN_ -#define _SCREEN_ +#ifndef SCREEN_H +#define SCREEN_H #include #include @@ -263,4 +263,4 @@ extern int FirstScreen; /* may eventually want an option for having the PPosition be the initial location for the drag lines */ -#endif /* _SCREEN_ */ +#endif /* SCREEN_H */ diff --git a/src/session.h b/src/session.h index c574a45..a76c52f 100644 --- a/src/session.h +++ b/src/session.h @@ -23,8 +23,8 @@ * dealings in this Software without prior written authorization from the * XFree86 Project. */ -#ifndef _SESSION_H -#define _SESSION_H +#ifndef SESSION_H +#define SESSION_H #include "twm.h" @@ -41,4 +41,4 @@ extern void ReadWinConfigFile(char *filename); extern SmcConn smcConn; -#endif +#endif /* SESSION_H */ diff --git a/src/twm.h b/src/twm.h index 3b0396a..6fb4d6d 100644 --- a/src/twm.h +++ b/src/twm.h @@ -58,8 +58,8 @@ from The Open Group. * 10-Oct-90 David M. Sternlicht Storing saved colors on root ***********************************************************************/ -#ifndef _TWM_ -#define _TWM_ +#ifndef TWM_H +#define TWM_H /* *INDENT-OFF* */ #ifdef HAVE_CONFIG_H @@ -451,4 +451,4 @@ extern int XrandrErrorBase; #define _XA_WM_WINDOW_ROLE TwmAtoms[10] /* *INDENT-ON* */ -#endif /* _TWM_ */ +#endif /* TWM_H */ diff --git a/src/util.h b/src/util.h index 448ed4d..6adeed9 100644 --- a/src/util.h +++ b/src/util.h @@ -57,8 +57,8 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ -#ifndef _UTIL_ -#define _UTIL_ +#ifndef UTIL_H +#define UTIL_H #include "twm.h" @@ -110,4 +110,4 @@ extern int HotX, HotY; #define XkbBI_MajorError 2 #endif -#endif /* _UTIL_ */ +#endif /* UTIL_H */ diff --git a/src/version.h b/src/version.h index 553b613..fb0d2d6 100644 --- a/src/version.h +++ b/src/version.h @@ -57,9 +57,9 @@ in this Software without prior written authorization from The Open Group. * **********************************************************************/ -#ifndef _VERSION_ -#define _VERSION_ +#ifndef VERSION_H +#define VERSION_H extern const char *Version; -#endif /* _VERSION_ */ +#endif /* VERSION_H */ -- cgit v1.2.3 From 9f68ff072905dba3197deae8d8b275bbacd3f728 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove disabled code Signed-off-by: Tim Wiederhake --- src/icons.c | 29 ----------------------------- src/menus.c | 24 ------------------------ 2 files changed, 53 deletions(-) diff --git a/src/icons.c b/src/icons.c index 6a04e7b..f4fde40 100644 --- a/src/icons.c +++ b/src/icons.c @@ -308,35 +308,6 @@ AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy) ir->entries->used = 0; } -#ifdef comment -void -FreeIconEntries(IconRegion *ir) -{ - IconEntry *ie, *tmp; - - for (ie = ir->entries; ie; ie = tmp) { - tmp = ie->next; - free(ie); - } -} - -void -FreeIconRegions(void) -{ - IconRegion *ir; - - for (ir = Scr->FirstRegion; ir != NULL;) { - IconRegion *tmp = ir; - - FreeIconEntries(ir); - ir = ir->next; - free(tmp); - } - Scr->FirstRegion = NULL; - Scr->LastRegion = NULL; -} -#endif - void CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) { diff --git a/src/menus.c b/src/menus.c index e27df43..4b5dd62 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1118,41 +1118,17 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) int lastx, lasty, bw2; XEvent event; -#if 0 - int namelen; - int width, height; - - namelen = strlen(tmp_win->name); -#endif bw2 = tmp_win->frame_bw * 2; AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; -#if 0 - width = (SIZE_HINDENT + MyFont_TextWidth(&Scr->SizeFont, - tmp_win->name, namelen)); - height = Scr->SizeFont.height + SIZE_VINDENT * 2; -#endif XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, &JunkBW, &JunkDepth); XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); -#if 0 - Scr->SizeStringOffset = width + MyFont_TextWidth(&Scr->SizeFont, ": ", 2); - XResizeWindow(dpy, Scr->SizeWindow, Scr->SizeStringOffset + - Scr->SizeStringWidth, height); - MyFont_DrawImageString(dpy, Scr->SizeWindow, &Scr->SizeFont, Scr->NormalGC, - width, SIZE_VINDENT + Scr->SizeFont.ascent, ": ", 2); -#endif lastx = -10000; lasty = -10000; -#if 0 - MoveOutline(Scr->Root, - origDragX - JunkBW, origDragY - JunkBW, - DragWidth * JunkBW, DragHeight * JunkBW, - tmp_win->frame_bw, tmp_win->title_height); -#endif MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight); while (TRUE) { XMaskEvent(dpy, ButtonPressMask | PointerMotionMask, &event); -- cgit v1.2.3 From f426fa565397b4df53f3f534d3c2bc7bc5857f59 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove always-true ifndef TOM Signed-off-by: Tim Wiederhake --- src/util.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util.c b/src/util.c index d89dcfe..d45a8a2 100644 --- a/src/util.c +++ b/src/util.c @@ -478,10 +478,8 @@ GetColor(int kind, Pixel *what, const char *name) Status stat = 0; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; -#ifndef TOM if (!Scr->FirstTime) return; -#endif if (Scr->Monochrome != kind) return; @@ -553,10 +551,8 @@ GetColorValue(int kind, XColor *what, const char *name) XColor junkcolor; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; -#ifndef TOM if (!Scr->FirstTime) return; -#endif if (Scr->Monochrome != kind) return; -- cgit v1.2.3 From 0ce52bc9ed32d7b6d1a588e5c0813fa1327bc690 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove support for xprint xprint is deprecated and was removed from xorg in 2008. Signed-off-by: Tim Wiederhake --- src/twm.c | 62 -------------------------------------------------------------- 1 file changed, 62 deletions(-) diff --git a/src/twm.c b/src/twm.c index 252bdf7..045622b 100644 --- a/src/twm.c +++ b/src/twm.c @@ -84,10 +84,6 @@ in this Software without prior written authorization from The Open Group. #include #include -#ifdef XPRINT -#include -#endif /* XPRINT */ - #ifdef HAVE_XRANDR #include #endif @@ -180,52 +176,10 @@ static char *atom_names[11] = { "WM_WINDOW_ROLE" }; -#ifdef XPRINT -/* |hasExtension()| and |IsPrintScreen()| have been stolen from - * xc/programs/xdpyinfo/xdpyinfo.c */ -static Bool -hasExtension(Display *dpy2, char *extname) -{ - int num_extensions, i; - char **extensions; - - extensions = XListExtensions(dpy2, &num_extensions); - for (i = 0; i < num_extensions && - (strcmp(extensions[i], extname) != 0); i++); - XFreeExtensionList(extensions); - return i != num_extensions; -} - -static Bool -IsPrintScreen(Screen *s) -{ - Display *dpy2 = XDisplayOfScreen(s); - - /* Check whether this is a screen of a print DDX */ - if (hasExtension(dpy2, XP_PRINTNAME)) { - Screen **pscreens; - int pscrcount; - int i; - - pscreens = XpQueryScreens(dpy2, &pscrcount); - for (i = 0; (i < pscrcount) && pscreens; i++) { - if (s == pscreens[i]) { - return True; - } - } - XFree(pscreens); - } - return False; -} -#endif /* XPRINT */ - static void usage(void) { fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v] [-V]" -#ifdef XPRINT - " [-noprint]" -#endif /* XPRINT */ " [-clientId id] [-restore file]\n", ProgramName); exit(EXIT_FAILURE); } @@ -289,13 +243,6 @@ main(int argc, char *argv[]) usage(); MultiScreen = FALSE; continue; -#ifdef XPRINT - case 'n': /* -noprint */ - if (!brief_opt(argv[i], "noprint")) - usage(); - NoPrintscreens = True; - continue; -#endif /* XPRINT */ case 'f': /* -file twmrcfilename */ if (!brief_opt(argv[i], "file")) usage(); @@ -427,15 +374,6 @@ main(int argc, char *argv[]) PreviousScreen = DefaultScreen(dpy); FirstScreen = TRUE; for (scrnum = firstscrn; scrnum <= lastscrn; scrnum++) { -#ifdef XPRINT - /* Ignore print screens to avoid that users accidentally warp on a - * print screen (which are not visible on video displays) */ - if ((!NoPrintscreens) && IsPrintScreen(XScreenOfDisplay(dpy, scrnum))) { - twmWarning("skipping print screen %d", scrnum); - continue; - } -#endif /* XPRINT */ - /* Make sure property priority colors is empty */ XChangeProperty(dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS, XA_CARDINAL, 32, PropModeReplace, NULL, 0); -- cgit v1.2.3 From 87a9086d4bce707d60ee6a024933686dee54fc6a Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove unused typedef SigProc Signed-off-by: Tim Wiederhake --- src/twm.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/twm.h b/src/twm.h index 6fb4d6d..57437cb 100644 --- a/src/twm.h +++ b/src/twm.h @@ -92,8 +92,6 @@ from The Open Group. #define PIXEL_ALREADY_TYPEDEFED /* for Xmu/Drawing.h */ -typedef void (*SigProc) (int); /* type of function returned by signal() */ - #define BW 2 /* border width */ #define BW2 4 /* border width * 2 */ -- cgit v1.2.3 From 5c3051ed5ef6475c84ada998e9c4344107e800c7 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove write to never-read variable in InstallWindowColormaps The variable `n` is written to every iteration of the loop, but never read. It is overwritten (and read) in the next loop though. Remove the dead store. Signed-off-by: Tim Wiederhake --- src/events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/events.c b/src/events.c index d940848..299ad56 100644 --- a/src/events.c +++ b/src/events.c @@ -2510,7 +2510,7 @@ InstallWindowColormaps(int type, TwmWindow *tmp) state = CM_INSTALLED; - for (i = n = 0; i < number_cwins; i++) { + for (i = 0; i < number_cwins; i++) { cwin = cwins[i]; cmap = cwin->colormap; cmap->state |= CM_INSTALLABLE; -- cgit v1.2.3 From baec4a82269adb3b07e5f60f410f104150331dbf Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Enable compiler warnings Signed-off-by: Tim Wiederhake --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 805eaf9..c0e7994 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,7 +35,7 @@ AM_CPPFLAGS = \ -DXORG_RELEASE=\"Release\ $(VERSION)\" \ -DSYSTEM_INIT_FILE=\"${rcdir}/system.twmrc\" -AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) +AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) $(CWARNFLAGS) twm_LDADD = $(TWM_LIBS) $(XRANDR_LIBS) twm_SOURCES = \ -- cgit v1.2.3 From 3cd3dd5b0b7cfe3888ae6f805a8f4c59f034834e Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Silence uninitialized variable warning Signed-off-by: Tim Wiederhake --- src/add_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add_window.c b/src/add_window.c index 3895729..39a9325 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -1388,7 +1388,7 @@ CreateTwmColormap(Colormap c) { TwmColormap *cmap; - cmap = malloc(sizeof(TwmColormap)); + cmap = calloc(1, sizeof(TwmColormap)); if (!cmap || XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) { if (cmap) free(cmap); -- cgit v1.2.3 From c7eeb055125892fdea94491e57bc26fa61258a71 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Silence old-style function definition warning in yywrap Signed-off-by: Tim Wiederhake --- src/lex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lex.l b/src/lex.l index d07a085..81be8e8 100644 --- a/src/lex.l +++ b/src/lex.l @@ -139,7 +139,7 @@ number [0-9]+ #ifndef yywrap int -yywrap() +yywrap(void) { return (1); } -- cgit v1.2.3 From f810178b1fae09be1ac15e223a84ddf2031eb93f Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Make atom_names const correct Silence some "initialization discards 'const' qualifier from pointer target type" warnings. Signed-off-by: Tim Wiederhake --- src/twm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/twm.c b/src/twm.c index 045622b..c3b002c 100644 --- a/src/twm.c +++ b/src/twm.c @@ -162,7 +162,7 @@ Atom TwmAtoms[11]; Bool use_fontset; /* use XFontSet-related functions or not */ /* don't change the order of these strings */ -static char *atom_names[11] = { +static const char *atom_names[11] = { "_MIT_PRIORITY_COLORS", "WM_CHANGE_STATE", "WM_STATE", @@ -348,7 +348,8 @@ main(int argc, char *argv[]) ScreenContext = XUniqueContext(); ColormapContext = XUniqueContext(); - (void) XInternAtoms(dpy, atom_names, sizeof TwmAtoms / sizeof TwmAtoms[0], + (void) XInternAtoms(dpy, (char **) atom_names, + sizeof TwmAtoms / sizeof TwmAtoms[0], False, TwmAtoms); /* Set up the per-screen global information. */ -- cgit v1.2.3 From d26411efbc69e5350d9ae7cebbdb2e91738e3b8e Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Remove redundant declaration of yylineno yylineno is already declared in (the generated) gram.h. This silences a "redundant redeclaration of 'yylineno'" warning. Signed-off-by: Tim Wiederhake --- src/lex.l | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lex.l b/src/lex.l index 81be8e8..13b85e6 100644 --- a/src/lex.l +++ b/src/lex.l @@ -71,7 +71,6 @@ in this Software without prior written authorization from The Open Group. #include "parse.h" #ifdef FLEX_SCANNER -int yylineno; #undef YY_INPUT #define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size))) -- cgit v1.2.3 From 3a4cc8b4b2baeb6b2e043c25495aede08a649641 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Remove redundant declaration of yyparse yyparse is already declared in (the generated) gram.h. This silences a "redundant redeclaration of 'yyparse'" warning. Signed-off-by: Tim Wiederhake --- src/twm.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/twm.h b/src/twm.h index 57437cb..a7793da 100644 --- a/src/twm.h +++ b/src/twm.h @@ -416,8 +416,6 @@ extern Bool RestartPreviousState; extern Bool GetWMState(Window w, int *statep, Window *iwp); -extern int -yyparse(void); extern int yylex(void); -- cgit v1.2.3 From dd6121dd4d9218b29f1544d244c2622f6a502a18 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Remove redundant declaration of yylex yylex is already declared in (the generated) lex.c. This silences a "redundant redeclaration of 'yylex'" warning. Signed-off-by: Tim Wiederhake --- src/gram.y | 1 + src/twm.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gram.y b/src/gram.y index 791e60f..a738f88 100644 --- a/src/gram.y +++ b/src/gram.y @@ -101,6 +101,7 @@ int mods = 0; unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); extern int yylineno; +extern int yylex(void); static void yyerror(const char *s); %} diff --git a/src/twm.h b/src/twm.h index a7793da..8786ad2 100644 --- a/src/twm.h +++ b/src/twm.h @@ -416,9 +416,6 @@ extern Bool RestartPreviousState; extern Bool GetWMState(Window w, int *statep, Window *iwp); -extern int -yylex(void); - extern void parseWarning(const char *, ...) GCC_PRINTFLIKE(1,2); extern Atom TwmAtoms[]; -- cgit v1.2.3 From 16ed4f51c297ab20c62273fb16e5346ec72f01d7 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Replace GCC_PRINTFLIKE with _X_ATTRIBUTE_PRINTF This silences all "function '...' might be a candidate for 'gnu_printf' format attribute" warnings. Signed-off-by: Tim Wiederhake --- src/twm.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/twm.h b/src/twm.h index 8786ad2..517451a 100644 --- a/src/twm.h +++ b/src/twm.h @@ -74,14 +74,6 @@ from The Open Group. #include #include -#ifndef GCC_PRINTFLIKE -#if defined(GCC_PRINTF) && !defined(printf) -#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) -#else -#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ -#endif -#endif - #ifndef GCC_NORETURN #define GCC_NORETURN _X_NORETURN #endif @@ -402,10 +394,10 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask); extern Pixmap CreateMenuIcon(int height, unsigned int *widthp, unsigned int *heightp); -extern void twmError(const char *, ...) GCC_PRINTFLIKE(1,2) GCC_NORETURN; -extern void twmWarning(const char *, ...) GCC_PRINTFLIKE(1,2); -extern void twmVerbose(const char *, ...) GCC_PRINTFLIKE(1,2); -extern void twmMessage(const char *, ...) GCC_PRINTFLIKE(1,2); +extern void twmError(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2) GCC_NORETURN; +extern void twmWarning(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void twmVerbose(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern void twmMessage(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); extern Bool ErrorOccurred; extern XErrorEvent LastErrorEvent; @@ -416,7 +408,7 @@ extern Bool RestartPreviousState; extern Bool GetWMState(Window w, int *statep, Window *iwp); -extern void parseWarning(const char *, ...) GCC_PRINTFLIKE(1,2); +extern void parseWarning(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); extern Atom TwmAtoms[]; -- cgit v1.2.3 From d3c1ede2480af93cc4cfefb8ba48798e6a4af8ea Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 1 Jan 2024 12:22:46 +0100 Subject: Replace GCC_NORETURN with _X_NORETURN This silences all "function might be candidate for attribute 'noreturn'" warnings. Add to HandleEvent as well, as that function never returns. Signed-off-by: Tim Wiederhake --- src/events.h | 2 +- src/twm.h | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/events.h b/src/events.h index 3778488..cbe2d2d 100644 --- a/src/events.h +++ b/src/events.h @@ -76,7 +76,7 @@ extern Bool StashEventTime(XEvent *ev); extern Window WindowOfEvent(XEvent *e); extern Bool DispatchEvent2(void); extern Bool DispatchEvent(void); -extern void HandleEvents(void); +extern void HandleEvents(void) _X_NORETURN; extern void HandleColormapNotify(void); extern void HandleVisibilityNotify(void); extern void HandleKeyPress(void); diff --git a/src/twm.h b/src/twm.h index 517451a..2263685 100644 --- a/src/twm.h +++ b/src/twm.h @@ -74,10 +74,6 @@ from The Open Group. #include #include -#ifndef GCC_NORETURN -#define GCC_NORETURN _X_NORETURN -#endif - #ifndef WithdrawnState #define WithdrawnState 0 #endif @@ -394,7 +390,7 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask); extern Pixmap CreateMenuIcon(int height, unsigned int *widthp, unsigned int *heightp); -extern void twmError(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2) GCC_NORETURN; +extern void twmError(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; extern void twmWarning(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); extern void twmVerbose(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); extern void twmMessage(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2); -- cgit v1.2.3 From 9e42567818fe26ed97e05cccc0f9b74a2f523ce6 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove now unused NoPrintscreens variable Support for xprint was removed in commit 0ce52bc9ed. Signed-off-by: Tim Wiederhake --- src/twm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/twm.c b/src/twm.c index c3b002c..b2c6e66 100644 --- a/src/twm.c +++ b/src/twm.c @@ -97,7 +97,6 @@ Display *dpy = NULL; /* which display are we talking to */ Window ResizeWindow; /* the window we are resizing */ int MultiScreen = TRUE; /* try for more than one screen? */ -int NoPrintscreens = False; /* ignore special handling of print screens? */ int NumScreens; /* number of screens in ScreenList */ int HasShape; /* server supports shape extension? */ @@ -639,8 +638,7 @@ main(int argc, char *argv[]) if (numManaged == 0) { if (MultiScreen && NumScreens > 0) { - twmError("unable to find any unmanaged %sscreens.\n", - NoPrintscreens ? "" : "video "); + twmError("unable to find any unmanaged video screens.\n"); } exit(EXIT_FAILURE); } -- cgit v1.2.3 From 90058211800fd45ee7cc8408278d3b200bdfd2e5 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Split up InitMenus Preparation for the removal of FirstScreen: Separate code that is executed for all screens from code that is executed for only the first screen. Signed-off-by: Tim Wiederhake --- src/menus.c | 22 ++++++++++++---------- src/menus.h | 1 + src/twm.c | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/menus.c b/src/menus.c index 4b5dd62..1e78a1a 100644 --- a/src/menus.c +++ b/src/menus.c @@ -133,7 +133,6 @@ void InitMenus(void) { int i, j, k; - FuncKey *key; for (i = 0; i < MAX_BUTTONS + 1; i++) for (j = 0; j < NUM_CONTEXTS; j++) @@ -144,18 +143,21 @@ InitMenus(void) Scr->DefaultFunction.func = 0; Scr->WindowFunction.func = 0; +} - if (FirstScreen) { - for (key = Scr->FuncKeyRoot.next; key != NULL;) { - FuncKey *tmp = key; +void +InitMenusFirst(void) +{ + FuncKey *key; - free(key->name); - key = key->next; - free(tmp); - } - Scr->FuncKeyRoot.next = NULL; - } + for (key = Scr->FuncKeyRoot.next; key != NULL;) { + FuncKey *tmp = key; + free(key->name); + key = key->next; + free(tmp); + } + Scr->FuncKeyRoot.next = NULL; } /** diff --git a/src/menus.h b/src/menus.h index 5e188fc..b30d596 100644 --- a/src/menus.h +++ b/src/menus.h @@ -161,6 +161,7 @@ extern int MenuDepth; #define COLORMAP_DEFAULT "default" extern void InitMenus(void); +extern void InitMenusFirst(void); extern Bool AddFuncKey(char *name, int cont, int mods, int func, char *win_name, char *action); extern int CreateTitleButton(const char *name, int func, const char *action, diff --git a/src/twm.c b/src/twm.c index b2c6e66..548f468 100644 --- a/src/twm.c +++ b/src/twm.c @@ -532,6 +532,8 @@ main(int argc, char *argv[]) InitVariables(); InitMenus(); + if (FirstScreen) + InitMenusFirst(); /* Parse it once for each screen. */ ParseTwmrc(InitFile); -- cgit v1.2.3 From b8fe4a7270502dd9242bd5585b67f3afbdbbbadb Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Make MultiScreen a local variable Signed-off-by: Tim Wiederhake --- src/screen.h | 1 - src/twm.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/screen.h b/src/screen.h index 403ce18..0cb307e 100644 --- a/src/screen.h +++ b/src/screen.h @@ -251,7 +251,6 @@ typedef struct ScreenInfo { FuncKey FuncKeyRoot; } ScreenInfo; -extern int MultiScreen; extern int NumScreens; extern ScreenInfo **ScreenList; extern ScreenInfo *Scr; diff --git a/src/twm.c b/src/twm.c index 548f468..4ca955a 100644 --- a/src/twm.c +++ b/src/twm.c @@ -96,7 +96,6 @@ XtSignalId si; Display *dpy = NULL; /* which display are we talking to */ Window ResizeWindow; /* the window we are resizing */ -int MultiScreen = TRUE; /* try for more than one screen? */ int NumScreens; /* number of screens in ScreenList */ int HasShape; /* server supports shape extension? */ @@ -219,6 +218,7 @@ main(int argc, char *argv[]) char *restore_filename = NULL; char *client_id = NULL; char *loc; + int MultiScreen = TRUE; /* try for more than one screen? */ ProgramName = argv[0]; Argc = argc; -- cgit v1.2.3 From d812d0884c926be4088a4e636807509e05d77a5f Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Make InitFile a local variable Signed-off-by: Tim Wiederhake --- src/twm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/twm.c b/src/twm.c index 4ca955a..d397879 100644 --- a/src/twm.c +++ b/src/twm.c @@ -118,7 +118,6 @@ static int CatchRedirectError(Display *dpy, XErrorEvent *event); /* for e static void sigHandler(int); char Info[INFO_LINES][INFO_SIZE]; /* info strings to print */ int InfoLines; -static char *InitFile = NULL; Cursor UpperLeftCursor; /* upper Left corner cursor */ Cursor RightButt; @@ -219,6 +218,7 @@ main(int argc, char *argv[]) char *client_id = NULL; char *loc; int MultiScreen = TRUE; /* try for more than one screen? */ + char *InitFile = NULL; ProgramName = argv[0]; Argc = argc; -- cgit v1.2.3 From cf9a35db8381f9b809465306aec3bcfe3bc1dc0d Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Make appContext a local variable Signed-off-by: Tim Wiederhake --- src/events.c | 2 +- src/events.h | 2 +- src/session.c | 2 +- src/session.h | 2 +- src/twm.c | 6 +++--- src/twm.h | 1 - 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/events.c b/src/events.c index 299ad56..a8c8fec 100644 --- a/src/events.c +++ b/src/events.c @@ -344,7 +344,7 @@ DispatchEvent(void) * handle X events */ void -HandleEvents(void) +HandleEvents(XtAppContext appContext) { while (TRUE) { if (enter_flag && !QLength(dpy)) { diff --git a/src/events.h b/src/events.h index cbe2d2d..8e3b806 100644 --- a/src/events.h +++ b/src/events.h @@ -76,7 +76,7 @@ extern Bool StashEventTime(XEvent *ev); extern Window WindowOfEvent(XEvent *e); extern Bool DispatchEvent2(void); extern Bool DispatchEvent(void); -extern void HandleEvents(void) _X_NORETURN; +extern void HandleEvents(XtAppContext) _X_NORETURN; extern void HandleColormapNotify(void); extern void HandleVisibilityNotify(void); extern void HandleKeyPress(void); diff --git a/src/session.c b/src/session.c index 94b4d63..2c2787a 100644 --- a/src/session.c +++ b/src/session.c @@ -878,7 +878,7 @@ ProcessIceMsgProc(XtPointer client_data, int *source _X_UNUSED, } void -ConnectToSessionManager(char *previous_id) +ConnectToSessionManager(char *previous_id, XtAppContext appContext) { char errorMsg[256]; unsigned long mask; diff --git a/src/session.h b/src/session.h index a76c52f..df91469 100644 --- a/src/session.h +++ b/src/session.h @@ -30,7 +30,7 @@ #include -extern void ConnectToSessionManager(char *previous_id); +extern void ConnectToSessionManager(char *previous_id, XtAppContext appContext); extern int GetWindowConfig(TwmWindow *theWindow, short *x, short *y, unsigned short *width, unsigned short *height, Bool *iconified, Bool *icon_info_present, diff --git a/src/twm.c b/src/twm.c index d397879..5b0c07d 100644 --- a/src/twm.c +++ b/src/twm.c @@ -90,7 +90,6 @@ in this Software without prior written authorization from The Open Group. static void InitVariables(void); -XtAppContext appContext; /* Xt application context */ XtSignalId si; Display *dpy = NULL; /* which display are we talking to */ @@ -219,6 +218,7 @@ main(int argc, char *argv[]) char *loc; int MultiScreen = TRUE; /* try for more than one screen? */ char *InitFile = NULL; + XtAppContext appContext; /* Xt application context */ ProgramName = argv[0]; Argc = argc; @@ -645,12 +645,12 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } - (void) ConnectToSessionManager(client_id); + (void) ConnectToSessionManager(client_id, appContext); RestartPreviousState = False; HandlingEvents = TRUE; InitEvents(); - HandleEvents(); + HandleEvents(appContext); exit(EXIT_SUCCESS); } diff --git a/src/twm.h b/src/twm.h index 2263685..1711eea 100644 --- a/src/twm.h +++ b/src/twm.h @@ -343,7 +343,6 @@ extern void ComputeWindowTitleOffsets(TwmWindow *tmp_win, int width, Bool squeeze); extern char *ProgramName; extern Display *dpy; -extern XtAppContext appContext; extern Window ResizeWindow; /* the window we are resizing */ extern int HasShape; /* this server supports Shape extension */ extern int HasSync; /* this server supports SYNC extension */ -- cgit v1.2.3 From 81cb173c5001f28ad178e9a9f59f521a13e66e92 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Make FirstScreen a local variable Signed-off-by: Tim Wiederhake --- src/screen.h | 1 - src/twm.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/screen.h b/src/screen.h index 0cb307e..3a1cb52 100644 --- a/src/screen.h +++ b/src/screen.h @@ -254,7 +254,6 @@ typedef struct ScreenInfo { extern int NumScreens; extern ScreenInfo **ScreenList; extern ScreenInfo *Scr; -extern int FirstScreen; #define PPOS_OFF 0 #define PPOS_ON 1 diff --git a/src/twm.c b/src/twm.c index 5b0c07d..c61d19c 100644 --- a/src/twm.c +++ b/src/twm.c @@ -109,7 +109,6 @@ int SyncEventBase, SyncErrorBase; ScreenInfo **ScreenList; /* structures for each screen */ ScreenInfo *Scr = NULL; /* the cur and prev screens */ int PreviousScreen; /* last screen that we were on */ -int FirstScreen; /* TRUE ==> first screen of display */ int message_level = 1; /* controls error messages */ static int RedirectError; /* TRUE ==> another window manager running */ static int TwmErrorHandler(Display *dpy, XErrorEvent *event); /* for setting RedirectError */ @@ -372,8 +371,9 @@ main(int argc, char *argv[]) } numManaged = 0; PreviousScreen = DefaultScreen(dpy); - FirstScreen = TRUE; for (scrnum = firstscrn; scrnum <= lastscrn; scrnum++) { + Bool FirstScreen = scrnum == firstscrn; + /* Make sure property priority colors is empty */ XChangeProperty(dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS, XA_CARDINAL, 32, PropModeReplace, NULL, 0); @@ -634,7 +634,6 @@ main(int argc, char *argv[]) XUngrabServer(dpy); - FirstScreen = FALSE; Scr->FirstTime = FALSE; } /* for */ -- cgit v1.2.3 From 0182535025b0864d6e0cf165ab14756bfbe6d015 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Make XtSignalId si static Signed-off-by: Tim Wiederhake --- src/twm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/twm.c b/src/twm.c index c61d19c..0b42bd2 100644 --- a/src/twm.c +++ b/src/twm.c @@ -90,7 +90,7 @@ in this Software without prior written authorization from The Open Group. static void InitVariables(void); -XtSignalId si; +static XtSignalId si; Display *dpy = NULL; /* which display are we talking to */ Window ResizeWindow; /* the window we are resizing */ -- cgit v1.2.3 From 895e0e6630eea3cea07d4e4f47f0264ea5263c8e Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in AddWindow twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/add_window.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 39a9325..9a526f7 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -432,29 +432,30 @@ AddWindow(Window w, int iconm, IconMgr *iconp) */ while (TRUE) { int stat; + Window root = None; + unsigned mask = 0; XUngrabServer(dpy); XSync(dpy, 0); XGrabServer(dpy); - JunkMask = 0; - if (!XQueryPointer(dpy, Scr->Root, &JunkRoot, + if (!XQueryPointer(dpy, Scr->Root, &root, &JunkChild, &JunkX, &JunkY, - &AddingX, &AddingY, &JunkMask)) - JunkMask = 0; + &AddingX, &AddingY, &mask)) + mask = 0; - JunkMask &= (Button1Mask | Button2Mask | Button3Mask | + mask &= (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask); /* * watch out for changing screens */ if (firsttime) { - if (JunkRoot != Scr->Root) { + if (root != Scr->Root) { register int scrnum; for (scrnum = 0; scrnum < NumScreens; scrnum++) { - if (JunkRoot == RootWindow(dpy, scrnum)) + if (root == RootWindow(dpy, scrnum)) break; } @@ -467,7 +468,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) /* * wait for buttons to come up; yuck */ - if (JunkMask != 0) + if (mask != 0) continue; /* -- cgit v1.2.3 From f6fb5b536cd2a96ef1ac26599fd48ef89a628a77 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in SetHighlightPixmap twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/add_window.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 9a526f7..1f5abe1 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -1347,15 +1347,18 @@ CreateWindowTitlebarButtons(TwmWindow *tmp_win) void SetHighlightPixmap(char *filename) { - Pixmap pm = GetBitmap(filename); + unsigned width = 0; + unsigned height = 0; + + Pixmap pm = FindBitmap(filename, &width, &height); if (pm) { if (Scr->hilitePm) { XFreePixmap(dpy, Scr->hilitePm); } Scr->hilitePm = pm; - Scr->hilite_pm_width = (int) JunkWidth; - Scr->hilite_pm_height = (int) JunkHeight; + Scr->hilite_pm_width = (int) width; + Scr->hilite_pm_height = (int) height; } } -- cgit v1.2.3 From b9f33162eaad31988e3595ddcd3efd97ee2da0aa Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in HandleButtonPress twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/events.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/events.c b/src/events.c index a8c8fec..9d82b81 100644 --- a/src/events.c +++ b/src/events.c @@ -1782,13 +1782,17 @@ HandleButtonPress(void) if (Tmp_win->list && RootFunction != 0 && (Event.xany.window == Tmp_win->list->w || Event.xany.window == Tmp_win->list->icon)) { + int x = 0; + int y = 0; + Tmp_win = Tmp_win->list->iconmgr->twm_win; + XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w, Event.xbutton.x, Event.xbutton.y, - &JunkX, &JunkY, &JunkChild); + &x, &y, &JunkChild); - Event.xbutton.x = JunkX; - Event.xbutton.y = JunkY - Tmp_win->title_height; + Event.xbutton.x = x; + Event.xbutton.y = y - Tmp_win->title_height; Event.xany.window = Tmp_win->w; Context = C_WINDOW; @@ -1844,6 +1848,8 @@ HandleButtonPress(void) * inside of a client that was getting button press events. */ XPointer context_data; + int x = 0; + int y = 0; XTranslateCoordinates(dpy, Scr->Root, Scr->Root, Event.xbutton.x, @@ -1863,10 +1869,10 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Scr->Root, Event.xany.window, Event.xbutton.x, - Event.xbutton.y, &JunkX, &JunkY, &JunkChild); + Event.xbutton.y, &x, &y, &JunkChild); - Event.xbutton.x = JunkX; - Event.xbutton.y = JunkY; + Event.xbutton.x = x; + Event.xbutton.y = y; Context = C_WINDOW; } -- cgit v1.2.3 From 9ad7b060e055f08ff39ee569f1cf40c7ac56e321 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in CreateIconManagers twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/iconmgr.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/iconmgr.c b/src/iconmgr.c index 7cbc7a7..4aad8fd 100644 --- a/src/iconmgr.c +++ b/src/iconmgr.c @@ -73,26 +73,25 @@ CreateIconManagers(void) } for (p = &Scr->iconmgr; p != NULL; p = p->next) { - int mask = XParseGeometry(p->geometry, &JunkX, &JunkY, + int x = 0; + int y = 0; + int mask = XParseGeometry(p->geometry, &x, &y, (unsigned int *) &p->width, (unsigned int *) &p->height); if (mask & XNegative) - JunkX = Scr->MyDisplayWidth - p->width - - (2 * Scr->BorderWidth) + JunkX; + x += Scr->MyDisplayWidth - p->width - (2 * Scr->BorderWidth); if (mask & YNegative) - JunkY = Scr->MyDisplayHeight - p->height - - (2 * Scr->BorderWidth) + JunkY; + y += Scr->MyDisplayHeight - p->height - (2 * Scr->BorderWidth); background = Scr->IconManagerC.back; GetColorFromList(Scr->IconManagerBL, p->name, (XClassHint *) NULL, &background); - p->w = XCreateSimpleWindow(dpy, Scr->Root, - JunkX, JunkY, (unsigned) p->width, - (unsigned) p->height, 1, Scr->Black, - background); + p->w = XCreateSimpleWindow(dpy, Scr->Root, x, y, + (unsigned) p->width, (unsigned) p->height, + 1, Scr->Black, background); snprintf(str, sizeof(str), "%s Icon Manager", p->name); snprintf(str1, sizeof(str1), "%s Icons", p->name); -- cgit v1.2.3 From 24bfa418612288c4847bcfe088aba05ce402d1d2 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in do_string_keyword twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/parse.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/parse.c b/src/parse.c index 48430b3..3a93806 100644 --- a/src/parse.c +++ b/src/parse.c @@ -747,6 +747,10 @@ do_single_keyword(int keyword) int do_string_keyword(int keyword, char *s) { + unsigned width = 0; + unsigned height = 0; + unsigned mask = 0; + switch (keyword) { case kws_UsePPosition: { @@ -797,20 +801,18 @@ do_string_keyword(int keyword, char *s) return 1; case kws_MaxWindowSize: - JunkMask = - (unsigned) XParseGeometry(s, &JunkX, &JunkY, &JunkWidth, - &JunkHeight); - if ((JunkMask & (WidthValue | HeightValue)) != + mask = (unsigned) XParseGeometry(s, &JunkX, &JunkY, &width, &height); + if ((mask & (WidthValue | HeightValue)) != (WidthValue | HeightValue)) { parseWarning("bad MaxWindowSize \"%s\"", s); return 0; } - if (JunkWidth <= 0 || JunkHeight <= 0) { + if (width <= 0 || height <= 0) { parseWarning("MaxWindowSize \"%s\" must be positive", s); return 0; } - Scr->MaxWindowWidth = (int) JunkWidth; - Scr->MaxWindowHeight = (int) JunkHeight; + Scr->MaxWindowWidth = (int) width; + Scr->MaxWindowHeight = (int) height; return 1; } -- cgit v1.2.3 From 7b24db53fc606a94067d90e8c64d8e7c8c75c12b Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in IconUp twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/icons.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/icons.c b/src/icons.c index f4fde40..296d3e3 100644 --- a/src/icons.c +++ b/src/icons.c @@ -173,12 +173,15 @@ IconUp(TwmWindow *tmp_win) return; if (tmp_win->icon_moved) { + unsigned width = 0; + unsigned height = 0; + if (!XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy, - &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) + &width, &height, &JunkBW, &JunkDepth)) return; - x = defx + ((int) JunkWidth) / 2; - y = defy + ((int) JunkHeight) / 2; + x = defx + ((int) width) / 2; + y = defy + ((int) height) / 2; for (ir = Scr->FirstRegion; ir; ir = ir->next) { if (x >= ir->x && x < (ir->x + ir->w) && -- cgit v1.2.3 From 08b916e7ab8ea54ee6c38c485f11c9d6da898355 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Rework dummy variable usage in ExecuteFunction twm defines several "junk" variables to use with functions like XQueryPointer or XGetGeometry. In some instances, the returned values are actually used, which makes the code confusing and hard to reason about. Use dedicated variables in those cases. Signed-off-by: Tim Wiederhake --- src/menus.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/menus.c b/src/menus.c index 1e78a1a..aa23a16 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1217,6 +1217,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int do_next_action = TRUE; int moving_icon = FALSE; Bool fromtitlebar = False; + unsigned bw = 0; RootFunction = 0; if (Cancel) @@ -1479,7 +1480,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, - &JunkBW, &JunkDepth); + &bw, &JunkDepth); origX = eventp->xbutton.x_root; origY = eventp->xbutton.y_root; @@ -1498,12 +1499,12 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, ConstMoveDir = MOVE_NONE; ConstMoveX = (int) ((unsigned) eventp->xbutton.x_root - (unsigned) DragX - - JunkBW); + bw); ConstMoveY = (int) ((unsigned) eventp->xbutton.y_root - (unsigned) DragY - - JunkBW); - width = (int) ((unsigned) DragWidth + 2 * JunkBW); - height = (int) ((unsigned) DragHeight + 2 * JunkBW); + bw); + width = (int) ((unsigned) DragWidth + 2 * bw); + height = (int) ((unsigned) DragHeight + 2 * bw); ConstMoveXL = ConstMoveX + width / 3; ConstMoveXR = ConstMoveX + 2 * (width / 3); ConstMoveYT = ConstMoveY + height / 3; @@ -1527,10 +1528,10 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, * MoveOutline's below. */ MoveOutline(rootw, - (int) ((unsigned) origDragX - JunkBW), - (int) ((unsigned) origDragY - JunkBW), - (int) ((unsigned) DragWidth + 2 * JunkBW), - (int) ((unsigned) DragHeight + 2 * JunkBW), + (int) ((unsigned) origDragX - bw), + (int) ((unsigned) origDragY - bw), + (int) ((unsigned) DragWidth + 2 * bw), + (int) ((unsigned) DragHeight + 2 * bw), tmp_win->frame_bw, moving_icon ? 0 : tmp_win->title_height); /* @@ -1660,13 +1661,13 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case MOVE_VERT: ConstMoveY = (int) ((unsigned) eventp->xmotion.y_root - - (unsigned) DragY - JunkBW); + (unsigned) DragY - bw); break; case MOVE_HORIZ: ConstMoveX = (int) ((unsigned) eventp->xmotion.x_root - - (unsigned) DragX - JunkBW); + (unsigned) DragX - bw); break; } @@ -1675,8 +1676,8 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, xl = ConstMoveX; yt = ConstMoveY; - w2 = (int) ((unsigned) DragWidth + 2 * JunkBW); - h = (int) ((unsigned) DragHeight + 2 * JunkBW); + w2 = (int) ((unsigned) DragWidth + 2 * bw); + h = (int) ((unsigned) DragHeight + 2 * bw); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { int xr = xl + w2; @@ -1707,16 +1708,16 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (!menuFromFrameOrWindowOrTitlebar) { xl = (int) ((unsigned) eventp->xmotion.x_root - - (unsigned) DragX - JunkBW); + (unsigned) DragX - bw); yt = (int) ((unsigned) eventp->xmotion.y_root - - (unsigned) DragY - JunkBW); + (unsigned) DragY - bw); } else { xl = (int) (eventp->xmotion.x_root - (DragWidth / 2)); yt = (int) (eventp->xmotion.y_root - (DragHeight / 2)); } - w2 = (int) ((unsigned) DragWidth + 2 * JunkBW); - h = (int) ((unsigned) DragHeight + 2 * JunkBW); + w2 = (int) ((unsigned) DragWidth + 2 * bw); + h = (int) ((unsigned) DragHeight + 2 * bw); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { int xr = xl + w2; -- cgit v1.2.3 From 6ea386bd98a737a9f54e2ca4216adf45868fd6e4 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkRoot, JunkChild Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/add_window.c | 9 +++++---- src/cursor.c | 5 +++-- src/events.c | 19 ++++++++++++------- src/icons.c | 12 +++++++----- src/menus.c | 30 +++++++++++++++++------------- src/session.c | 3 ++- src/twm.c | 5 ++--- src/twm.h | 2 -- src/util.c | 9 ++++++--- 9 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 1f5abe1..e451bfe 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -162,6 +162,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) Bool width_ever_changed_by_user; Bool height_ever_changed_by_user; char *name; + Window wdummy = None; #ifdef DEBUG fprintf(stderr, "AddWindow: w = 0x%lx\n", (unsigned long) w); @@ -440,7 +441,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) XGrabServer(dpy); if (!XQueryPointer(dpy, Scr->Root, &root, - &JunkChild, &JunkX, &JunkY, + &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &mask)) mask = 0; @@ -567,7 +568,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) continue; } - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); @@ -662,7 +663,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * using multiple GXxor lines so that we don't need to * grab the server. */ - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); @@ -765,7 +766,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * reparented, so we'll get a DestroyNotify for it. We won't have * gotten one for anything up to here, however. */ - if (XGetGeometry(dpy, tmp_win->w, &JunkRoot, &JunkX, &JunkY, + if (XGetGeometry(dpy, tmp_win->w, &wdummy, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) { free(tmp_win); XUngrabServer(dpy); diff --git a/src/cursor.c b/src/cursor.c index 84d3f0c..9cc26c7 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -149,6 +149,7 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) int sx, sy, mx, my; unsigned int sw, sh, mw, mh; Pixmap spm, mpm; + Window wdummy = None; spm = GetBitmap(source); if ((hotx = HotX) < 0) @@ -159,8 +160,8 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) /* make sure they are the same size */ - XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, spm, &wdummy, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, mpm, &wdummy, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); if (sw != mw || sh != mh) { twmWarning("cursor bitmaps \"%s\" and \"%s\" not the same size\n", source, mask); diff --git a/src/events.c b/src/events.c index 9d82b81..54f5bff 100644 --- a/src/events.c +++ b/src/events.c @@ -735,6 +735,7 @@ HandlePropertyNotify(void) char *name = NULL; XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; + Window wdummy = None; /* watch for standard colormap changes */ if (Event.xproperty.window == Scr->Root) { @@ -821,7 +822,7 @@ HandlePropertyNotify(void) // to a default icon */ int icon_x = 0, icon_y = 0; - XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot, + XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); XSelectInput(dpy, Tmp_win->icon_w, None); @@ -841,7 +842,7 @@ HandlePropertyNotify(void) * Try to find out where it is; if we succeed, move the new * window to where the old one is. */ - if (XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot, &icon_x, + if (XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) { /* @@ -899,7 +900,7 @@ HandlePropertyNotify(void) (Tmp_win->wmhints->flags & IconPixmapHint)) { unsigned long valuemask; /* mask for create windows */ - if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot, + if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &wdummy, &JunkX, &JunkY, (unsigned int *) &Tmp_win->icon_width, (unsigned int *) &Tmp_win->icon_height, &JunkBW, @@ -1016,12 +1017,14 @@ RedoIconName(void) void HandleClientMessage(void) { + Window wdummy = None; + if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { if (Tmp_win != NULL) { if (Event.xclient.data.l[0] == IconicState && !Tmp_win->icon) { XEvent button; - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &(button.xmotion.x_root), &(button.xmotion.y_root), &JunkX, &JunkY, &JunkMask); @@ -1466,10 +1469,11 @@ void HandleMotionNotify(void) { XPointer context_data; + Window wdummy = None; if (ResizeWindow != (Window) 0) { XQueryPointer(dpy, Event.xany.window, - &(Event.xmotion.root), &JunkChild, + &(Event.xmotion.root), &wdummy, &(Event.xmotion.x_root), &(Event.xmotion.y_root), &(Event.xmotion.x), &(Event.xmotion.y), &JunkMask); @@ -1697,6 +1701,7 @@ HandleButtonPress(void) { unsigned int modifier; Cursor cur; + Window wdummy = None; /* too much code relies on this assumption */ if (Event.xbutton.button > MAX_BUTTONS) @@ -1789,7 +1794,7 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w, Event.xbutton.x, Event.xbutton.y, - &x, &y, &JunkChild); + &x, &y, &wdummy); Event.xbutton.x = x; Event.xbutton.y = y - Tmp_win->title_height; @@ -1869,7 +1874,7 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Scr->Root, Event.xany.window, Event.xbutton.x, - Event.xbutton.y, &x, &y, &JunkChild); + Event.xbutton.y, &x, &y, &wdummy); Event.xbutton.x = x; Event.xbutton.y = y; diff --git a/src/icons.c b/src/icons.c index 296d3e3..4e406af 100644 --- a/src/icons.c +++ b/src/icons.c @@ -163,6 +163,7 @@ IconUp(TwmWindow *tmp_win) int x, y; int defx, defy; struct IconRegion *ir; + Window wdummy = None; /* * If the client specified a particular location, let's use it (this might @@ -176,7 +177,7 @@ IconUp(TwmWindow *tmp_win) unsigned width = 0; unsigned height = 0; - if (!XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy, + if (!XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &defx, &defy, &width, &height, &JunkBW, &JunkDepth)) return; @@ -319,6 +320,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; + Window wdummy = None; FB(tmp_win->iconc.fore, tmp_win->iconc.back); @@ -349,7 +351,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -375,7 +377,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) tmp_win->wmhints->flags & IconPixmapHint) { XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, - &JunkRoot, &JunkX, &JunkY, + &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -413,7 +415,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -475,7 +477,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint) { tmp_win->icon_w = tmp_win->wmhints->icon_window; if (tmp_win->forced || - XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &JunkX, &JunkY, (unsigned int *) &tmp_win->icon_w_width, (unsigned int *) &tmp_win->icon_w_height, &JunkBW, &JunkDepth) == 0) { diff --git a/src/menus.c b/src/menus.c index aa23a16..4ab2a30 100644 --- a/src/menus.c +++ b/src/menus.c @@ -469,6 +469,7 @@ UpdateMenu(void) int done; MenuItem *badItem = NULL; XPointer context_data; + Window wdummy = None; fromMenu = TRUE; @@ -506,7 +507,7 @@ UpdateMenu(void) continue; done = FALSE; - XQueryPointer(dpy, ActiveMenu->w, &JunkRoot, &JunkChild, + XQueryPointer(dpy, ActiveMenu->w, &wdummy, &wdummy, &x_root, &y_root, &x, &y, &JunkMask); /* if we haven't received the enter notify yet, wait */ @@ -1119,16 +1120,17 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) { int lastx, lasty, bw2; XEvent event; + Window wdummy = None; bw2 = tmp_win->frame_bw * 2; AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; - XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, + XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, &JunkBW, &JunkDepth); XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); - XQueryPointer(dpy, Scr->Root, &JunkRoot, - &JunkChild, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); + XQueryPointer(dpy, Scr->Root, &wdummy, + &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); lastx = -10000; lasty = -10000; MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight); @@ -1161,7 +1163,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) * using multiple GXxor lines so that we don't need to * grab the server. */ - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, + XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); if (lastx != AddingX || lasty != AddingY) { @@ -1218,6 +1220,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int moving_icon = FALSE; Bool fromtitlebar = False; unsigned bw = 0; + Window wdummy = None; RootFunction = 0; if (Cancel) @@ -1471,14 +1474,14 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XTranslateCoordinates(dpy, w, tmp_win->frame, eventp->xbutton.x, eventp->xbutton.y, - &DragX, &DragY, &JunkChild); + &DragX, &DragY, &wdummy); w = tmp_win->frame; } DragWindow = None; - XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, + XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, &bw, &JunkDepth); @@ -1513,7 +1516,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); - XQueryPointer(dpy, w, &JunkRoot, &JunkChild, + XQueryPointer(dpy, w, &wdummy, &wdummy, &JunkX, &JunkY, &DragX, &DragY, &JunkMask); } last_time = eventp->xbutton.time; @@ -1599,7 +1602,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, CurrentDragY = origY = Event.xbutton.y_root; XTranslateCoordinates(dpy, rootw, tmp_win->frame, - origX, origY, &DragX, &DragY, &JunkChild); + origX, origY, &DragX, &DragY, &wdummy); continue; } @@ -1628,7 +1631,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (Event.type != MotionNotify) continue; - XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &JunkChild, + XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &wdummy, &(eventp->xmotion.x_root), &(eventp->xmotion.y_root), &JunkX, &JunkY, &JunkMask); @@ -1654,7 +1657,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, eventp->xmotion.y_root > ConstMoveYB) ConstMoveDir = MOVE_VERT; - XQueryPointer(dpy, DragWindow, &JunkRoot, &JunkChild, + XQueryPointer(dpy, DragWindow, &wdummy, &wdummy, &JunkX, &JunkY, &DragX, &DragY, &JunkMask); break; @@ -2520,13 +2523,14 @@ Identify(TwmWindow *t) Window junk; int px, py, dummy; unsigned udummy; + Window wdummy = None; n = 0; snprintf(Info[n++], INFO_SIZE, "Twm version: %s", Version); Info[n++][0] = '\0'; if (t) { - XGetGeometry(dpy, t->w, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, t->w, &wdummy, &JunkX, &JunkY, &wwidth, &wheight, &bw, &depth); (void) XTranslateCoordinates(dpy, t->w, Scr->Root, 0, 0, &x, &y, &junk); snprintf(Info[n++], INFO_SIZE, @@ -2565,7 +2569,7 @@ Identify(TwmWindow *t) XUnmapWindow(dpy, Scr->InfoWindow); width += 10; /* some padding */ - if (XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, &px, &py, + if (XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &px, &py, &dummy, &dummy, &udummy)) { px -= (width / 2); py -= (height / 3); diff --git a/src/session.c b/src/session.c index 2c2787a..ce601ac 100644 --- a/src/session.c +++ b/src/session.c @@ -330,8 +330,9 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, if (theWindow->icon_w) { int icon_x, icon_y; + Window wdummy = None; - XGetGeometry(dpy, theWindow->icon_w, &JunkRoot, &icon_x, + XGetGeometry(dpy, theWindow->icon_w, &wdummy, &icon_x, &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); if (!write_short(configFile, (short) icon_x)) diff --git a/src/twm.c b/src/twm.c index 0b42bd2..881a29a 100644 --- a/src/twm.c +++ b/src/twm.c @@ -138,8 +138,6 @@ int ParseError; /* error parsing the .twmrc file */ int HandlingEvents = FALSE; /* are we handling events yet? */ -Window JunkRoot; /* junk window */ -Window JunkChild; /* junk window */ int JunkX; /* junk variable */ int JunkY; /* junk variable */ unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; @@ -823,8 +821,9 @@ RestoreWithdrawnLocation(TwmWindow *tmp) int gravx, gravy; unsigned int bw; XWindowChanges xwc; + Window wdummy = None; - if (XGetGeometry(dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y, + if (XGetGeometry(dpy, tmp->w, &wdummy, &xwc.x, &xwc.y, &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { unsigned mask; diff --git a/src/twm.h b/src/twm.h index 1711eea..b4ad9fa 100644 --- a/src/twm.h +++ b/src/twm.h @@ -372,8 +372,6 @@ extern int ParseError; extern int HandlingEvents; -extern Window JunkRoot; -extern Window JunkChild; extern int JunkX; extern int JunkY; extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; diff --git a/src/util.c b/src/util.c index d45a8a2..e634e7f 100644 --- a/src/util.c +++ b/src/util.c @@ -209,6 +209,7 @@ Zoom(Window wf, Window wt) long dx, dy, dw, dh; long z; int j; + Window wdummy = None; if (!Scr->DoZoom || Scr->ZoomCount < 1) return; @@ -216,8 +217,8 @@ Zoom(Window wf, Window wt) if (wf == None || wt == None) return; - XGetGeometry(dpy, wf, &JunkRoot, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, wt, &JunkRoot, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ @@ -278,8 +279,10 @@ ExpandFilename(const char *name) void GetUnknownIcon(const char *name) { + Window wdummy = None; + if ((Scr->UnknownPm = GetBitmap(name)) != None) { - XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &JunkX, &JunkY, (unsigned int *) &Scr->UnknownWidth, (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); } -- cgit v1.2.3 From c5a63751f8b4eab72794e56365ead929023f2b94 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkX, JunkY Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/add_window.c | 9 +++++---- src/events.c | 9 ++++++--- src/icons.c | 9 +++++---- src/menus.c | 14 ++++++++------ src/parse.c | 3 ++- src/twm.c | 5 ----- src/twm.h | 2 -- src/util.c | 3 ++- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index e451bfe..87cb51b 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -162,6 +162,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) Bool width_ever_changed_by_user; Bool height_ever_changed_by_user; char *name; + int dummy = 0; Window wdummy = None; #ifdef DEBUG @@ -441,7 +442,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) XGrabServer(dpy); if (!XQueryPointer(dpy, Scr->Root, &root, - &wdummy, &JunkX, &JunkY, + &wdummy, &dummy, &dummy, &AddingX, &AddingY, &mask)) mask = 0; @@ -569,7 +570,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) } XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, - &JunkX, &JunkY, &AddingX, &AddingY, + &dummy, &dummy, &AddingX, &AddingY, &JunkMask); if (Scr->DontMoveOff) { @@ -664,7 +665,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * grab the server. */ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, - &JunkX, &JunkY, &AddingX, &AddingY, + &dummy, &dummy, &AddingX, &AddingY, &JunkMask); if (lastx != AddingX || lasty != AddingY) { @@ -766,7 +767,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * reparented, so we'll get a DestroyNotify for it. We won't have * gotten one for anything up to here, however. */ - if (XGetGeometry(dpy, tmp_win->w, &wdummy, &JunkX, &JunkY, + if (XGetGeometry(dpy, tmp_win->w, &wdummy, &dummy, &dummy, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) { free(tmp_win); XUngrabServer(dpy); diff --git a/src/events.c b/src/events.c index 54f5bff..3fd74d2 100644 --- a/src/events.c +++ b/src/events.c @@ -735,6 +735,7 @@ HandlePropertyNotify(void) char *name = NULL; XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; + int dummy = 0; Window wdummy = None; /* watch for standard colormap changes */ @@ -901,7 +902,7 @@ HandlePropertyNotify(void) unsigned long valuemask; /* mask for create windows */ if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &wdummy, - &JunkX, &JunkY, + &dummy, &dummy, (unsigned int *) &Tmp_win->icon_width, (unsigned int *) &Tmp_win->icon_height, &JunkBW, &JunkDepth)) { @@ -1017,6 +1018,7 @@ RedoIconName(void) void HandleClientMessage(void) { + int dummy = 0; Window wdummy = None; if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { @@ -1027,7 +1029,7 @@ HandleClientMessage(void) XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &(button.xmotion.x_root), &(button.xmotion.y_root), - &JunkX, &JunkY, &JunkMask); + &dummy, &dummy, &JunkMask); ExecuteFunction(F_ICONIFY, NULLSTR, Event.xany.window, Tmp_win, &button, FRAME, FALSE); @@ -1701,6 +1703,7 @@ HandleButtonPress(void) { unsigned int modifier; Cursor cur; + int dummy = 0; Window wdummy = None; /* too much code relies on this assumption */ @@ -1859,7 +1862,7 @@ HandleButtonPress(void) XTranslateCoordinates(dpy, Scr->Root, Scr->Root, Event.xbutton.x, Event.xbutton.y, - &JunkX, &JunkY, &Event.xany.window); + &dummy, &dummy, &Event.xany.window); if (Event.xany.window == 0 || (XFindContext(dpy, Event.xany.window, TwmContext, diff --git a/src/icons.c b/src/icons.c index 4e406af..5b34245 100644 --- a/src/icons.c +++ b/src/icons.c @@ -320,6 +320,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; + int dummy = 0; Window wdummy = None; FB(tmp_win->iconc.fore, tmp_win->iconc.back); @@ -351,7 +352,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -377,7 +378,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) tmp_win->wmhints->flags & IconPixmapHint) { XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, - &wdummy, &JunkX, &JunkY, + &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -415,7 +416,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) } if (bm != None) { - XGetGeometry(dpy, bm, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, bm, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, (unsigned int *) &tmp_win->icon_height, &JunkBW, &JunkDepth); @@ -477,7 +478,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint) { tmp_win->icon_w = tmp_win->wmhints->icon_window; if (tmp_win->forced || - XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_w_width, (unsigned int *) &tmp_win->icon_w_height, &JunkBW, &JunkDepth) == 0) { diff --git a/src/menus.c b/src/menus.c index 4ab2a30..528fb54 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1120,6 +1120,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) { int lastx, lasty, bw2; XEvent event; + int dummy = 0; Window wdummy = None; bw2 = tmp_win->frame_bw * 2; @@ -1130,7 +1131,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) &JunkBW, &JunkDepth); XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); XQueryPointer(dpy, Scr->Root, &wdummy, - &wdummy, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); + &wdummy, &dummy, &dummy, &AddingX, &AddingY, &JunkMask); lastx = -10000; lasty = -10000; MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight); @@ -1164,7 +1165,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) * grab the server. */ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, - &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); + &dummy, &dummy, &AddingX, &AddingY, &JunkMask); if (lastx != AddingX || lasty != AddingY) { MenuDoResize(AddingX, AddingY, tmp_win); @@ -1220,6 +1221,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, int moving_icon = FALSE; Bool fromtitlebar = False; unsigned bw = 0; + int dummy = 0; Window wdummy = None; RootFunction = 0; @@ -1517,7 +1519,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); XQueryPointer(dpy, w, &wdummy, &wdummy, - &JunkX, &JunkY, &DragX, &DragY, &JunkMask); + &dummy, &dummy, &DragX, &DragY, &JunkMask); } last_time = eventp->xbutton.time; @@ -1633,7 +1635,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &wdummy, &(eventp->xmotion.x_root), &(eventp->xmotion.y_root), - &JunkX, &JunkY, &JunkMask); + &dummy, &dummy, &JunkMask); if (DragWindow == None && abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta && @@ -1658,7 +1660,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, ConstMoveDir = MOVE_VERT; XQueryPointer(dpy, DragWindow, &wdummy, &wdummy, - &JunkX, &JunkY, &DragX, &DragY, &JunkMask); + &dummy, &dummy, &DragX, &DragY, &JunkMask); break; case MOVE_VERT: @@ -2530,7 +2532,7 @@ Identify(TwmWindow *t) Info[n++][0] = '\0'; if (t) { - XGetGeometry(dpy, t->w, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, t->w, &wdummy, &dummy, &dummy, &wwidth, &wheight, &bw, &depth); (void) XTranslateCoordinates(dpy, t->w, Scr->Root, 0, 0, &x, &y, &junk); snprintf(Info[n++], INFO_SIZE, diff --git a/src/parse.c b/src/parse.c index 3a93806..eae817e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -750,6 +750,7 @@ do_string_keyword(int keyword, char *s) unsigned width = 0; unsigned height = 0; unsigned mask = 0; + int dummy = 0; switch (keyword) { case kws_UsePPosition: @@ -801,7 +802,7 @@ do_string_keyword(int keyword, char *s) return 1; case kws_MaxWindowSize: - mask = (unsigned) XParseGeometry(s, &JunkX, &JunkY, &width, &height); + mask = (unsigned) XParseGeometry(s, &dummy, &dummy, &width, &height); if ((mask & (WidthValue | HeightValue)) != (WidthValue | HeightValue)) { parseWarning("bad MaxWindowSize \"%s\"", s); diff --git a/src/twm.c b/src/twm.c index 881a29a..86c27e3 100644 --- a/src/twm.c +++ b/src/twm.c @@ -138,8 +138,6 @@ int ParseError; /* error parsing the .twmrc file */ int HandlingEvents = FALSE; /* are we handling events yet? */ -int JunkX; /* junk variable */ -int JunkY; /* junk variable */ unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; char *ProgramName; @@ -554,9 +552,6 @@ main(int argc, char *argv[]) XGrabServer(dpy); XSync(dpy, 0); - JunkX = 0; - JunkY = 0; - XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren); CreateIconManagers(); if (!Scr->NoIconManagers) diff --git a/src/twm.h b/src/twm.h index b4ad9fa..70992a9 100644 --- a/src/twm.h +++ b/src/twm.h @@ -372,8 +372,6 @@ extern int ParseError; extern int HandlingEvents; -extern int JunkX; -extern int JunkY; extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; extern XGCValues Gcv; extern int InfoLines; diff --git a/src/util.c b/src/util.c index e634e7f..edf93a9 100644 --- a/src/util.c +++ b/src/util.c @@ -279,10 +279,11 @@ ExpandFilename(const char *name) void GetUnknownIcon(const char *name) { + int dummy = 0; Window wdummy = None; if ((Scr->UnknownPm = GetBitmap(name)) != None) { - XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &dummy, &dummy, (unsigned int *) &Scr->UnknownWidth, (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); } -- cgit v1.2.3 From 783b31821d87ea551457f4700f796a51f359cfd1 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/add_window.c | 7 ++++--- src/cursor.c | 5 +++-- src/events.c | 17 ++++++++++------- src/icons.c | 20 +++++++++++--------- src/menus.c | 19 +++++++++++-------- src/session.c | 3 ++- src/twm.c | 5 ++--- src/twm.h | 1 - src/util.c | 12 ++++++++---- 9 files changed, 51 insertions(+), 38 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 87cb51b..8af8f73 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -163,6 +163,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) Bool height_ever_changed_by_user; char *name; int dummy = 0; + unsigned udummy = 0; Window wdummy = None; #ifdef DEBUG @@ -571,7 +572,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &dummy, &dummy, &AddingX, &AddingY, - &JunkMask); + &udummy); if (Scr->DontMoveOff) { int AddingR, AddingB; @@ -666,7 +667,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) */ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &dummy, &dummy, &AddingX, &AddingY, - &JunkMask); + &udummy); if (lastx != AddingX || lasty != AddingY) { DoResize(AddingX, AddingY, tmp_win); @@ -768,7 +769,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) * gotten one for anything up to here, however. */ if (XGetGeometry(dpy, tmp_win->w, &wdummy, &dummy, &dummy, - &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) { + &udummy, &udummy, &udummy, &udummy) == 0) { free(tmp_win); XUngrabServer(dpy); return (NULL); diff --git a/src/cursor.c b/src/cursor.c index 9cc26c7..297fc08 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -149,6 +149,7 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) int sx, sy, mx, my; unsigned int sw, sh, mw, mh; Pixmap spm, mpm; + unsigned udummy = 0; Window wdummy = None; spm = GetBitmap(source); @@ -160,8 +161,8 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask) /* make sure they are the same size */ - XGetGeometry(dpy, spm, &wdummy, &sx, &sy, &sw, &sh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, mpm, &wdummy, &mx, &my, &mw, &mh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, spm, &wdummy, &sx, &sy, &sw, &sh, &udummy, &udummy); + XGetGeometry(dpy, mpm, &wdummy, &mx, &my, &mw, &mh, &udummy, &udummy); if (sw != mw || sh != mh) { twmWarning("cursor bitmaps \"%s\" and \"%s\" not the same size\n", source, mask); diff --git a/src/events.c b/src/events.c index 3fd74d2..9b2daa9 100644 --- a/src/events.c +++ b/src/events.c @@ -736,6 +736,7 @@ HandlePropertyNotify(void) XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; int dummy = 0; + unsigned udummy = 0; Window wdummy = None; /* watch for standard colormap changes */ @@ -825,7 +826,7 @@ HandlePropertyNotify(void) XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, &icon_y, - &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); + &udummy, &udummy, &udummy, &udummy); XSelectInput(dpy, Tmp_win->icon_w, None); XDeleteContext(dpy, Tmp_win->icon_w, TwmContext); XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext); @@ -844,8 +845,8 @@ HandlePropertyNotify(void) * window to where the old one is. */ if (XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x, - &icon_y, &JunkWidth, &JunkHeight, &JunkBW, - &JunkDepth)) { + &icon_y, &udummy, &udummy, &udummy, + &udummy)) { /* * Move the new icon window to where the old one was. */ @@ -904,8 +905,8 @@ HandlePropertyNotify(void) if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &wdummy, &dummy, &dummy, (unsigned int *) &Tmp_win->icon_width, - (unsigned int *) &Tmp_win->icon_height, &JunkBW, - &JunkDepth)) { + (unsigned int *) &Tmp_win->icon_height, &udummy, + &udummy)) { return; } @@ -1019,6 +1020,7 @@ void HandleClientMessage(void) { int dummy = 0; + unsigned udummy = 0; Window wdummy = None; if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { @@ -1029,7 +1031,7 @@ HandleClientMessage(void) XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, &(button.xmotion.x_root), &(button.xmotion.y_root), - &dummy, &dummy, &JunkMask); + &dummy, &dummy, &udummy); ExecuteFunction(F_ICONIFY, NULLSTR, Event.xany.window, Tmp_win, &button, FRAME, FALSE); @@ -1471,13 +1473,14 @@ void HandleMotionNotify(void) { XPointer context_data; + unsigned udummy = 0; Window wdummy = None; if (ResizeWindow != (Window) 0) { XQueryPointer(dpy, Event.xany.window, &(Event.xmotion.root), &wdummy, &(Event.xmotion.x_root), &(Event.xmotion.y_root), - &(Event.xmotion.x), &(Event.xmotion.y), &JunkMask); + &(Event.xmotion.x), &(Event.xmotion.y), &udummy); /* Set WindowMoved appropriately so that f.deltastop will work with resize as well as move. */ diff --git a/src/icons.c b/src/icons.c index 5b34245..39a2097 100644 --- a/src/icons.c +++ b/src/icons.c @@ -163,6 +163,7 @@ IconUp(TwmWindow *tmp_win) int x, y; int defx, defy; struct IconRegion *ir; + unsigned udummy = 0; Window wdummy = None; /* @@ -178,7 +179,7 @@ IconUp(TwmWindow *tmp_win) unsigned height = 0; if (!XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &defx, &defy, - &width, &height, &JunkBW, &JunkDepth)) + &width, &height, &udummy, &udummy)) return; x = defx + ((int) width) / 2; @@ -321,6 +322,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; int dummy = 0; + unsigned udummy = 0; Window wdummy = None; FB(tmp_win->iconc.fore, tmp_win->iconc.back); @@ -354,8 +356,8 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (bm != None) { XGetGeometry(dpy, bm, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, - (unsigned int *) &tmp_win->icon_height, &JunkBW, - &JunkDepth); + (unsigned int *) &tmp_win->icon_height, &udummy, + &udummy); pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width, (unsigned) tmp_win->icon_height, @@ -380,8 +382,8 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, - (unsigned int *) &tmp_win->icon_height, &JunkBW, - &JunkDepth); + (unsigned int *) &tmp_win->icon_height, &udummy, + &udummy); pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width, @@ -418,8 +420,8 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (bm != None) { XGetGeometry(dpy, bm, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_width, - (unsigned int *) &tmp_win->icon_height, &JunkBW, - &JunkDepth); + (unsigned int *) &tmp_win->icon_height, &udummy, + &udummy); pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width, (unsigned) tmp_win->icon_height, @@ -480,8 +482,8 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (tmp_win->forced || XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &dummy, &dummy, (unsigned int *) &tmp_win->icon_w_width, - (unsigned int *) &tmp_win->icon_w_height, &JunkBW, - &JunkDepth) == 0) { + (unsigned int *) &tmp_win->icon_w_height, &udummy, + &udummy) == 0) { tmp_win->icon_w = None; tmp_win->wmhints->flags &= ~IconWindowHint; } diff --git a/src/menus.c b/src/menus.c index 528fb54..5450363 100644 --- a/src/menus.c +++ b/src/menus.c @@ -469,6 +469,7 @@ UpdateMenu(void) int done; MenuItem *badItem = NULL; XPointer context_data; + unsigned udummy = 0; Window wdummy = None; fromMenu = TRUE; @@ -508,7 +509,7 @@ UpdateMenu(void) done = FALSE; XQueryPointer(dpy, ActiveMenu->w, &wdummy, &wdummy, - &x_root, &y_root, &x, &y, &JunkMask); + &x_root, &y_root, &x, &y, &udummy); /* if we haven't received the enter notify yet, wait */ if (!ActiveMenu->entered) @@ -1121,6 +1122,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) int lastx, lasty, bw2; XEvent event; int dummy = 0; + unsigned udummy = 0; Window wdummy = None; bw2 = tmp_win->frame_bw * 2; @@ -1128,10 +1130,10 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, - &JunkBW, &JunkDepth); + &udummy, &udummy); XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); XQueryPointer(dpy, Scr->Root, &wdummy, - &wdummy, &dummy, &dummy, &AddingX, &AddingY, &JunkMask); + &wdummy, &dummy, &dummy, &AddingX, &AddingY, &udummy); lastx = -10000; lasty = -10000; MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight); @@ -1165,7 +1167,7 @@ resizeFromCenter(Window w, TwmWindow *tmp_win) * grab the server. */ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy, - &dummy, &dummy, &AddingX, &AddingY, &JunkMask); + &dummy, &dummy, &AddingX, &AddingY, &udummy); if (lastx != AddingX || lasty != AddingY) { MenuDoResize(AddingX, AddingY, tmp_win); @@ -1222,6 +1224,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, Bool fromtitlebar = False; unsigned bw = 0; int dummy = 0; + unsigned udummy = 0; Window wdummy = None; RootFunction = 0; @@ -1485,7 +1488,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XGetGeometry(dpy, w, &wdummy, &origDragX, &origDragY, (unsigned int *) &DragWidth, (unsigned int *) &DragHeight, - &bw, &JunkDepth); + &bw, &udummy); origX = eventp->xbutton.x_root; origY = eventp->xbutton.y_root; @@ -1519,7 +1522,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2); XQueryPointer(dpy, w, &wdummy, &wdummy, - &dummy, &dummy, &DragX, &DragY, &JunkMask); + &dummy, &dummy, &DragX, &DragY, &udummy); } last_time = eventp->xbutton.time; @@ -1635,7 +1638,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &wdummy, &(eventp->xmotion.x_root), &(eventp->xmotion.y_root), - &dummy, &dummy, &JunkMask); + &dummy, &dummy, &udummy); if (DragWindow == None && abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta && @@ -1660,7 +1663,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, ConstMoveDir = MOVE_VERT; XQueryPointer(dpy, DragWindow, &wdummy, &wdummy, - &dummy, &dummy, &DragX, &DragY, &JunkMask); + &dummy, &dummy, &DragX, &DragY, &udummy); break; case MOVE_VERT: diff --git a/src/session.c b/src/session.c index ce601ac..f2b2a6b 100644 --- a/src/session.c +++ b/src/session.c @@ -275,6 +275,7 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, { char **wm_command; int wm_command_count; + unsigned udummy = 0; if (!write_counted_string(configFile, clientId)) return 0; @@ -333,7 +334,7 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, Window wdummy = None; XGetGeometry(dpy, theWindow->icon_w, &wdummy, &icon_x, - &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); + &icon_y, &udummy, &udummy, &udummy, &udummy); if (!write_short(configFile, (short) icon_x)) return 0; diff --git a/src/twm.c b/src/twm.c index 86c27e3..564eeb0 100644 --- a/src/twm.c +++ b/src/twm.c @@ -138,8 +138,6 @@ int ParseError; /* error parsing the .twmrc file */ int HandlingEvents = FALSE; /* are we handling events yet? */ -unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; - char *ProgramName; int Argc; char **Argv; @@ -816,10 +814,11 @@ RestoreWithdrawnLocation(TwmWindow *tmp) int gravx, gravy; unsigned int bw; XWindowChanges xwc; + unsigned udummy = 0; Window wdummy = None; if (XGetGeometry(dpy, tmp->w, &wdummy, &xwc.x, &xwc.y, - &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { + &udummy, &udummy, &bw, &udummy)) { unsigned mask; GetGravityOffsets(tmp, &gravx, &gravy); diff --git a/src/twm.h b/src/twm.h index 70992a9..ed179aa 100644 --- a/src/twm.h +++ b/src/twm.h @@ -372,7 +372,6 @@ extern int ParseError; extern int HandlingEvents; -extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; extern XGCValues Gcv; extern int InfoLines; extern char Info[][INFO_SIZE]; diff --git a/src/util.c b/src/util.c index edf93a9..a3673e3 100644 --- a/src/util.c +++ b/src/util.c @@ -209,6 +209,7 @@ Zoom(Window wf, Window wt) long dx, dy, dw, dh; long z; int j; + unsigned udummy = 0; Window wdummy = None; if (!Scr->DoZoom || Scr->ZoomCount < 1) @@ -217,8 +218,8 @@ Zoom(Window wf, Window wt) if (wf == None || wt == None) return; - XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &udummy, &udummy); + XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &udummy, &udummy); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ @@ -280,12 +281,13 @@ void GetUnknownIcon(const char *name) { int dummy = 0; + unsigned udummy = 0; Window wdummy = None; if ((Scr->UnknownPm = GetBitmap(name)) != None) { XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &dummy, &dummy, (unsigned int *) &Scr->UnknownWidth, - (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); + (unsigned int *) &Scr->UnknownHeight, &udummy, &udummy); } } @@ -379,7 +381,9 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp) Pixmap GetBitmap(const char *name) { - return FindBitmap(name, &JunkWidth, &JunkHeight); + unsigned udummy = 0; + + return FindBitmap(name, &udummy, &udummy); } void -- cgit v1.2.3 From a0a4604cab350eb6a8bd3cc56cfb35d534fa344b Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Remove storage specifier 'register' 'register' is an optimization hint to the compiler that is generally not necessary and needlessly prevents using a c++ compiler to compile twm. Signed-off-by: Tim Wiederhake --- src/add_window.c | 14 +++++++------- src/events.c | 8 ++++---- src/gram.y | 6 +++--- src/menus.c | 12 ++++++------ src/parse.c | 2 +- src/util.c | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 8af8f73..d02a1c8 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -122,7 +122,7 @@ GetGravityOffsets(TwmWindow *tmp, int *xp, int *yp) { 0, 0 }, /* StaticGravity */ }; /* *INDENT-ON* */ - register int g = ((tmp->hints.flags & PWinGravity) + int g = ((tmp->hints.flags & PWinGravity) ? tmp->hints.win_gravity : NorthWestGravity); if (g < ForgetGravity || g > StaticGravity) { @@ -455,7 +455,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) */ if (firsttime) { if (root != Scr->Root) { - register int scrnum; + int scrnum; for (scrnum = 0; scrnum < NumScreens; scrnum++) { if (root == RootWindow(dpy, scrnum)) @@ -1217,13 +1217,13 @@ ComputeWindowTitleOffsets(TwmWindow *tmp_win, int width, Bool squeeze) * of the frame window. */ void -ComputeTitleLocation(register TwmWindow *tmp) +ComputeTitleLocation(TwmWindow *tmp) { tmp->title_x = -tmp->frame_bw; tmp->title_y = -tmp->frame_bw; if (tmp->squeeze_info) { - register SqueezeInfo *si = tmp->squeeze_info; + SqueezeInfo *si = tmp->squeeze_info; int basex; int maxwidth = tmp->frame_width; int tw = tmp->title_width; @@ -1373,8 +1373,8 @@ FetchWmProtocols(TwmWindow *tmp) int n; if (XGetWMProtocols(dpy, tmp->w, &protocols, &n)) { - register int i; - register Atom *ap; + int i; + Atom *ap; for (i = 0, ap = protocols; i < n; i++, ap++) { if (*ap == _XA_WM_TAKE_FOCUS) @@ -1467,7 +1467,7 @@ CreateColormapWindow(Window w, Bool creating_parent, Bool property_window) void FetchWmColormapWindows(TwmWindow *tmp) { - register int i, j; + int i, j; Window *cmap_windows = NULL; Bool can_free_cmap_windows = False; int number_cmap_windows = 0; diff --git a/src/events.c b/src/events.c index 9b2daa9..f80f6b5 100644 --- a/src/events.c +++ b/src/events.c @@ -1101,12 +1101,12 @@ HandleExpose(void) else if (Tmp_win->titlebuttons) { int i; Window w = Event.xany.window; - register TBWindow *tbw; + TBWindow *tbw; int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) { if (w == tbw->window) { - register TitleButton *tb = tbw->info; + TitleButton *tb = tbw->info; FB(Tmp_win->title.fore, Tmp_win->title.back); XCopyPlane(dpy, tb->bitmap, w, Scr->NormalGC, @@ -1759,8 +1759,8 @@ HandleButtonPress(void) /* check the title bar buttons */ if (Tmp_win && Tmp_win->title_height && Tmp_win->titlebuttons) { - register int i; - register TBWindow *tbw; + int i; + TBWindow *tbw; int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) { diff --git a/src/gram.y b/src/gram.y index a738f88..9de5935 100644 --- a/src/gram.y +++ b/src/gram.y @@ -667,9 +667,9 @@ yyerror(const char *s) static void RemoveDQuote(char *str) { - register char *i, *o; - register int n; - register int count; + char *i, *o; + int n; + int count; for (i = str + 1, o = str; *i && *i != '\"'; o++) { if (*i == '\\') { diff --git a/src/menus.c b/src/menus.c index 5450363..9903f75 100644 --- a/src/menus.c +++ b/src/menus.c @@ -254,7 +254,7 @@ CreateTitleButton(const char *name, int func, const char *action, Scr->TBInfo.head = tb; } else if (append && rightside) { /* 3 */ - register TitleButton *t; + TitleButton *t; /* SUPPRESS 530 */ for (t = Scr->TBInfo.head; t->next; t = t->next); @@ -262,7 +262,7 @@ CreateTitleButton(const char *name, int func, const char *action, tb->next = NULL; } else { /* 2 */ - register TitleButton *t, *prev = NULL; + TitleButton *t, *prev = NULL; for (t = Scr->TBInfo.head; t && !t->rightside; t = t->next) { prev = t; @@ -1105,8 +1105,8 @@ belongs_to_twm_window(TwmWindow *t, Window w) return True; if (t && t->titlebuttons) { - register TBWindow *tbw; - register int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; + TBWindow *tbw; + int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; for (tbw = t->titlebuttons; nb > 0; tbw++, nb--) { if (tbw->window == w) @@ -1983,7 +1983,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case F_WARPPREV: case F_WARPNEXT: { - register TwmWindow *t; + TwmWindow *t; TwmWindow *of, *l, *n; int c = 0; @@ -2029,7 +2029,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case F_WARPTO: { - register TwmWindow *t; + TwmWindow *t; int len; len = (int) strlen(action); diff --git a/src/parse.c b/src/parse.c index eae817e..0ad806e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -602,7 +602,7 @@ static int numkeywords = (sizeof(keytable) / sizeof(keytable[0])); int parse_keyword(char *s, int *nump) { - register int lower = 0, upper = numkeywords - 1; + int lower = 0, upper = numkeywords - 1; XmuCopyISOLatin1Lowered(s, s); while (lower <= upper) { diff --git a/src/util.c b/src/util.c index a3673e3..f77b0b6 100644 --- a/src/util.c +++ b/src/util.c @@ -96,7 +96,7 @@ MoveOutline(Window root, int x, int y, int width, int height, int bw, int th) int xl, xr, yt, yb, xinnerl, xinnerr, yinnert, yinnerb; int xthird, ythird; XSegment outline[18]; - register XSegment *r; + XSegment *r; if (x == lastx && y == lasty && width == lastWidth && height == lastHeight && lastBW == bw && th == lastTH) @@ -587,7 +587,7 @@ FindFontSet(MyFont *font, const char *fontname) int ascent; int descent; int fnum; - register int i; + int i; if (font->fontset != NULL) { XFreeFontSet(dpy, font->fontset); -- cgit v1.2.3 From 878117d8c70564983afddfb2bb26daa71f25b8c1 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename field 'delete' to 'remove' in TitlebarPixmaps 'delete' is a keyword in c++. Its usage confuses some tools that work with c and c++ source code. Signed-off-by: Tim Wiederhake --- src/screen.h | 2 +- src/twm.c | 2 +- src/util.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/screen.h b/src/screen.h index 3a1cb52..d8bf996 100644 --- a/src/screen.h +++ b/src/screen.h @@ -56,7 +56,7 @@ typedef struct _TitlebarPixmaps { Pixmap resize; Pixmap question; Pixmap menu; - Pixmap delete; + Pixmap remove; } TitlebarPixmaps; typedef struct ScreenInfo { diff --git a/src/twm.c b/src/twm.c index 564eeb0..57f50ad 100644 --- a/src/twm.c +++ b/src/twm.c @@ -522,7 +522,7 @@ main(int argc, char *argv[]) Scr->tbpm.resize = None; Scr->tbpm.question = None; Scr->tbpm.menu = None; - Scr->tbpm.delete = None; + Scr->tbpm.remove = None; InitVariables(); InitMenus(); diff --git a/src/util.c b/src/util.c index f77b0b6..baff6c8 100644 --- a/src/util.c +++ b/src/util.c @@ -919,11 +919,11 @@ CreateDotPixmap(unsigned *widthp, unsigned *heightp) if (!(h & 1)) h--; *widthp = *heightp = (unsigned int) h; - if (Scr->tbpm.delete == None) { + if (Scr->tbpm.remove == None) { GC gc; Pixmap pix; - pix = Scr->tbpm.delete = + pix = Scr->tbpm.remove = XCreatePixmap(dpy, Scr->Root, (unsigned) h, (unsigned) h, 1); gc = XCreateGC(dpy, pix, 0L, NULL); XSetLineAttributes(dpy, gc, (unsigned) h, LineSolid, CapRound, @@ -934,7 +934,7 @@ CreateDotPixmap(unsigned *widthp, unsigned *heightp) XDrawLine(dpy, pix, gc, h / 2, h / 2, h / 2, h / 2); XFreeGC(dpy, gc); } - return Scr->tbpm.delete; + return Scr->tbpm.remove; } #define questionmark_width 8 -- cgit v1.2.3 From 6e5c29e60d0acfeba32829f4aba7d6e7697ca8d1 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 TWMWinConfigEntry '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/session.c | 20 ++++++++++---------- src/twm.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/session.c b/src/session.c index f2b2a6b..1787d62 100644 --- a/src/session.c +++ b/src/session.c @@ -375,8 +375,8 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, entry->tag = 0; entry->client_id = NULL; entry->window_role = NULL; - entry->class.res_name = NULL; - entry->class.res_class = NULL; + entry->xclass.res_name = NULL; + entry->xclass.res_class = NULL; entry->wm_name = NULL; entry->wm_command = NULL; entry->wm_command_count = 0; @@ -388,9 +388,9 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, goto give_up; if (!entry->window_role) { - if (!read_counted_string(configFile, &entry->class.res_name)) + if (!read_counted_string(configFile, &entry->xclass.res_name)) goto give_up; - if (!read_counted_string(configFile, &entry->class.res_class)) + if (!read_counted_string(configFile, &entry->xclass.res_class)) goto give_up; if (!read_counted_string(configFile, &entry->wm_name)) goto give_up; @@ -460,10 +460,10 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, free(entry->client_id); if (entry->window_role) free(entry->window_role); - if (entry->class.res_name) - free(entry->class.res_name); - if (entry->class.res_class) - free(entry->class.res_class); + if (entry->xclass.res_name) + free(entry->xclass.res_name); + if (entry->xclass.res_class) + free(entry->xclass.res_class); if (entry->wm_name) free(entry->wm_name); if (entry->wm_command_count && entry->wm_command) { @@ -558,9 +558,9 @@ GetWindowConfig(TwmWindow *theWindow, */ if (strcmp(theWindow->class.res_name, - ptr->class.res_name) == 0 && + ptr->xclass.res_name) == 0 && strcmp(theWindow->class.res_class, - ptr->class.res_class) == 0 && + ptr->xclass.res_class) == 0 && (ptr->wm_name == NULL || strcmp(theWindow->name, ptr->wm_name) == 0)) { if (clientId) { diff --git a/src/twm.h b/src/twm.h index ed179aa..b360d35 100644 --- a/src/twm.h +++ b/src/twm.h @@ -303,7 +303,7 @@ typedef struct TWMWinConfigEntry { int tag; char *client_id; char *window_role; - XClassHint class; + XClassHint xclass; char *wm_name; int wm_command_count; char **wm_command; -- cgit v1.2.3 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 From 7ef32a37be9e293fde3c2a18e043a2d4bc9d1eed Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename argument 'class' to 'xclass' in LookInList '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/list.c | 10 +++++----- src/list.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/list.c b/src/list.c index 4422cc9..2597471 100644 --- a/src/list.c +++ b/src/list.c @@ -111,10 +111,10 @@ AddToList(name_list ** list_head, char *name, char *ptr) * * \param list a pointer to the head of a list * \param name a pointer to the name to look for - * \param class a pointer to the class to look for + * \param xclass a pointer to the class to look for */ char * -LookInList(name_list * list_head, const char *name, XClassHint *class) +LookInList(name_list * list_head, const char *name, XClassHint *xclass) { name_list *nptr; @@ -123,15 +123,15 @@ LookInList(name_list * list_head, const char *name, XClassHint *class) if (strcmp(name, nptr->name) == 0) return (nptr->ptr); - if (class) { + if (xclass) { /* look for the res_name next */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) - if (strcmp(class->res_name, nptr->name) == 0) + if (strcmp(xclass->res_name, nptr->name) == 0) return (nptr->ptr); /* finally look for the res_class */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) - if (strcmp(class->res_class, nptr->name) == 0) + if (strcmp(xclass->res_class, nptr->name) == 0) return (nptr->ptr); } return (NULL); diff --git a/src/list.h b/src/list.h index 68ab374..15b4fef 100644 --- a/src/list.h +++ b/src/list.h @@ -72,7 +72,7 @@ extern void FreeList(name_list ** list); extern int GetColorFromList(name_list * list_head, const char *name, XClassHint *class, Pixel *ptr); extern char *LookInList(name_list * list_head, const char *name, - XClassHint *class); + XClassHint *xclass); extern char *LookInNameList(name_list * list_head, const char *name); #endif /* LIST_H */ -- cgit v1.2.3 From ea79e73344dfa09a6ed3dd34c4f1383add924b12 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename argument 'class' to 'xclass' in GetColorFromList '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/list.c | 10 +++++----- src/list.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/list.c b/src/list.c index 2597471..f7fa724 100644 --- a/src/list.c +++ b/src/list.c @@ -151,11 +151,11 @@ LookInNameList(name_list * list_head, const char *name) * * \param list a pointer to the head of a list * \param name a pointer to the name to look for - * \param class a pointer to the class to look for + * \param xclass a pointer to the class to look for * \param[out] ptr fill in the list value if the name was found */ int -GetColorFromList(name_list * list_head, const char *name, XClassHint *class, +GetColorFromList(name_list * list_head, const char *name, XClassHint *xclass, Pixel *ptr) { int save; @@ -170,9 +170,9 @@ GetColorFromList(name_list * list_head, const char *name, XClassHint *class, return (TRUE); } - if (class) { + if (xclass) { for (nptr = list_head; nptr != NULL; nptr = nptr->next) - if (strcmp(class->res_name, nptr->name) == 0) { + if (strcmp(xclass->res_name, nptr->name) == 0) { save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(Scr->Monochrome, ptr, nptr->ptr); @@ -181,7 +181,7 @@ GetColorFromList(name_list * list_head, const char *name, XClassHint *class, } for (nptr = list_head; nptr != NULL; nptr = nptr->next) - if (strcmp(class->res_class, nptr->name) == 0) { + if (strcmp(xclass->res_class, nptr->name) == 0) { save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(Scr->Monochrome, ptr, nptr->ptr); diff --git a/src/list.h b/src/list.h index 15b4fef..bc9c16c 100644 --- a/src/list.h +++ b/src/list.h @@ -70,7 +70,7 @@ extern void AddToList(name_list ** list_head, char *name, char *ptr); extern void FreeList(name_list ** list); extern int GetColorFromList(name_list * list_head, const char *name, - XClassHint *class, Pixel *ptr); + XClassHint *xclass, Pixel *ptr); extern char *LookInList(name_list * list_head, const char *name, XClassHint *xclass); extern char *LookInNameList(name_list * list_head, const char *name); -- cgit v1.2.3 From abd6ec6e468a067ea072fee9e8ba0303c1e95a2e Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename variable 'new' to 'entry' in splitEntry 'new' is a keyword in c++. Its usage confuses some tools that work with c and c++ source code. Signed-off-by: Tim Wiederhake --- src/icons.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/icons.c b/src/icons.c index 493eb7e..47ff670 100644 --- a/src/icons.c +++ b/src/icons.c @@ -50,7 +50,7 @@ static void mergeEntries(IconEntry *old, IconEntry *ie); static void splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h) { - IconEntry *new; + IconEntry *entry; switch (grav1) { case D_NORTH: @@ -58,21 +58,21 @@ splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h) if (w != ie->w) splitEntry(ie, grav2, grav1, w, ie->h); if (h != ie->h) { - new = malloc(sizeof(IconEntry)); - new->twm_win = 0; - new->used = 0; - new->next = ie->next; - ie->next = new; - new->x = ie->x; - new->h = (ie->h - h); - new->w = ie->w; + entry = malloc(sizeof(IconEntry)); + entry->twm_win = 0; + entry->used = 0; + entry->next = ie->next; + ie->next = entry; + entry->x = ie->x; + entry->h = (ie->h - h); + entry->w = ie->w; ie->h = h; if (grav1 == D_SOUTH) { - new->y = ie->y; - ie->y = new->y + new->h; + entry->y = ie->y; + ie->y = entry->y + entry->h; } else - new->y = ie->y + ie->h; + entry->y = ie->y + ie->h; } break; case D_EAST: @@ -80,21 +80,21 @@ splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h) if (h != ie->h) splitEntry(ie, grav2, grav1, ie->w, h); if (w != ie->w) { - new = malloc(sizeof(IconEntry)); - new->twm_win = 0; - new->used = 0; - new->next = ie->next; - ie->next = new; - new->y = ie->y; - new->w = (ie->w - w); - new->h = ie->h; + entry = malloc(sizeof(IconEntry)); + entry->twm_win = 0; + entry->used = 0; + entry->next = ie->next; + ie->next = entry; + entry->y = ie->y; + entry->w = (ie->w - w); + entry->h = ie->h; ie->w = w; if (grav1 == D_EAST) { - new->x = ie->x; - ie->x = new->x + new->w; + entry->x = ie->x; + ie->x = entry->x + entry->w; } else - new->x = ie->x + ie->w; + entry->x = ie->x + ie->w; } break; } -- cgit v1.2.3 From 7fe0acdb259c7dd9f3b6214ba16f272da81beadb Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Accomodate different field names when compiling with c++ Signed-off-by: Tim Wiederhake --- src/events.c | 4 ++++ src/twm.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/events.c b/src/events.c index f8a5207..585ae16 100644 --- a/src/events.c +++ b/src/events.c @@ -391,7 +391,11 @@ HandleColormapNotify(void) cmap = cwin->colormap; +#if defined(__cplusplus) || defined(c_plusplus) + if (cevent->c_new) { +#else if (cevent->new) { +#endif if (XFindContext(dpy, cevent->colormap, ColormapContext, &context_data) == XCNOENT) cwin->colormap = CreateTwmColormap(cevent->colormap); diff --git a/src/twm.c b/src/twm.c index 57f50ad..1c1e522 100644 --- a/src/twm.c +++ b/src/twm.c @@ -474,7 +474,11 @@ main(int argc, char *argv[]) if (DisplayCells(dpy, scrnum) < 3) Scr->Monochrome = MONOCHROME; +#if defined(__cplusplus) || defined(c_plusplus) + else if (DefaultVisual(dpy, scrnum)->c_class == GrayScale) +#else else if (DefaultVisual(dpy, scrnum)->class == GrayScale) +#endif Scr->Monochrome = GRAYSCALE; else Scr->Monochrome = COLOR; -- cgit v1.2.3 From 365a94b62df6144ad016e587f3756d974b6e2018 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Add explicit cast after memory allocation Still valid c, but now also valid c++. Signed-off-by: Tim Wiederhake --- src/add_window.c | 20 +++++++++++--------- src/iconmgr.c | 4 ++-- src/icons.c | 8 ++++---- src/list.c | 2 +- src/menus.c | 16 ++++++++-------- src/parse.c | 6 +++--- src/session.c | 11 ++++++----- src/twm.c | 8 +++++--- src/util.c | 7 ++++--- 9 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/add_window.c b/src/add_window.c index 009d8f8..3caf15b 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -171,7 +171,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) #endif /* allocate space for the twm window */ - tmp_win = calloc(1, sizeof(TwmWindow)); + tmp_win = (TwmWindow *) calloc(1, sizeof(TwmWindow)); if (tmp_win == NULL) { twmWarning("Unable to allocate memory to manage window ID %lx.", w); return NULL; @@ -359,7 +359,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp) if (LookInList(Scr->StartIconified, tmp_win->full_name, &tmp_win->xclass)) { if (!tmp_win->wmhints) { - tmp_win->wmhints = malloc(sizeof(XWMHints)); + tmp_win->wmhints = (XWMHints *) malloc(sizeof(XWMHints)); tmp_win->wmhints->flags = 0; } tmp_win->wmhints->initial_state = IconicState; @@ -1304,7 +1304,8 @@ CreateWindowTitlebarButtons(TwmWindow *tmp_win) tmp_win->titlebuttons = NULL; nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; if (nb > 0) { - tmp_win->titlebuttons = malloc((size_t) nb * sizeof(TBWindow)); + tmp_win->titlebuttons = (TBWindow *) + malloc((size_t) nb * sizeof(TBWindow)); if (!tmp_win->titlebuttons) { twmWarning("unable to allocate %d titlebuttons", nb); } @@ -1395,7 +1396,7 @@ CreateTwmColormap(Colormap c) { TwmColormap *cmap; - cmap = calloc(1, sizeof(TwmColormap)); + cmap = (TwmColormap *) calloc(1, sizeof(TwmColormap)); if (!cmap || XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) { if (cmap) free(cmap); @@ -1416,7 +1417,7 @@ CreateColormapWindow(Window w, Bool creating_parent, Bool property_window) TwmColormap *cmap; XWindowAttributes attributes; - cwin = malloc(sizeof(ColormapWindow)); + cwin = (ColormapWindow *) malloc(sizeof(ColormapWindow)); if (cwin) { if (!XGetWindowAttributes(dpy, w, &attributes) || XSaveContext(dpy, w, ColormapContext, (XPointer) cwin)) { @@ -1497,7 +1498,7 @@ FetchWmColormapWindows(TwmWindow *tmp) break; } if (i == number_cmap_windows) { /* not in list */ - Window *new_cmap_windows = + Window *new_cmap_windows = (Window *) malloc(sizeof(Window) * (size_t) (number_cmap_windows + 1)); if (!new_cmap_windows) { @@ -1516,7 +1517,8 @@ FetchWmColormapWindows(TwmWindow *tmp) number_cmap_windows++; } - cwins = malloc(sizeof(ColormapWindow *) * (size_t) number_cmap_windows); + cwins = (ColormapWindow **) + malloc(sizeof(ColormapWindow *) * (size_t) number_cmap_windows); if (cwins) { for (i = 0; i < number_cmap_windows; i++) { @@ -1565,7 +1567,7 @@ FetchWmColormapWindows(TwmWindow *tmp) number_cmap_windows = 1; - cwins = malloc(sizeof(ColormapWindow *)); + cwins = (ColormapWindow **) malloc(sizeof(ColormapWindow *)); if (XFindContext(dpy, tmp->w, ColormapContext, (XPointer *) &cwins[0]) == XCNOENT) { cwins[0] = @@ -1585,7 +1587,7 @@ FetchWmColormapWindows(TwmWindow *tmp) tmp->cmaps.cwins = cwins; tmp->cmaps.number_cwins = number_cmap_windows; if (number_cmap_windows > 1) - tmp->cmaps.scoreboard = + tmp->cmaps.scoreboard = (char *) calloc(1, ColormapsScoreboardLength(&tmp->cmaps)); if (previously_installed) diff --git a/src/iconmgr.c b/src/iconmgr.c index 87749b7..5af92ad 100644 --- a/src/iconmgr.c +++ b/src/iconmgr.c @@ -133,7 +133,7 @@ AllocateIconManager(char *name, char *icon_name, char *geom, int columns) if (Scr->NoIconManagers) return NULL; - p = malloc(sizeof(IconMgr)); + p = (IconMgr *) malloc(sizeof(IconMgr)); p->name = name; p->icon_name = icon_name; p->geometry = geom; @@ -370,7 +370,7 @@ AddIconManager(TwmWindow *tmp_win) &tmp_win->xclass)) == NULL) ip = &Scr->iconmgr; - tmp = malloc(sizeof(WList)); + tmp = (WList *) malloc(sizeof(WList)); tmp->iconmgr = ip; tmp->next = NULL; tmp->active = FALSE; diff --git a/src/icons.c b/src/icons.c index 47ff670..3ebb4b2 100644 --- a/src/icons.c +++ b/src/icons.c @@ -58,7 +58,7 @@ splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h) if (w != ie->w) splitEntry(ie, grav2, grav1, w, ie->h); if (h != ie->h) { - entry = malloc(sizeof(IconEntry)); + entry = (IconEntry *) malloc(sizeof(IconEntry)); entry->twm_win = 0; entry->used = 0; entry->next = ie->next; @@ -80,7 +80,7 @@ splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h) if (h != ie->h) splitEntry(ie, grav2, grav1, ie->w, h); if (w != ie->w) { - entry = malloc(sizeof(IconEntry)); + entry = (IconEntry *) malloc(sizeof(IconEntry)); entry->twm_win = 0; entry->used = 0; entry->next = ie->next; @@ -275,7 +275,7 @@ AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy) IconRegion *ir; int mask; - ir = malloc(sizeof(IconRegion)); + ir = (IconRegion *) malloc(sizeof(IconRegion)); ir->next = NULL; if (Scr->LastRegion) Scr->LastRegion->next = ir; @@ -303,7 +303,7 @@ AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy) if (mask & YNegative) ir->y += Scr->MyDisplayHeight - ir->h; - ir->entries = malloc(sizeof(IconEntry)); + ir->entries = (IconEntry *) malloc(sizeof(IconEntry)); ir->entries->next = 0; ir->entries->x = ir->x; ir->entries->y = ir->y; diff --git a/src/list.c b/src/list.c index f7fa724..cceba24 100644 --- a/src/list.c +++ b/src/list.c @@ -90,7 +90,7 @@ AddToList(name_list ** list_head, char *name, char *ptr) if (!list_head) return; /* ignore empty inserts */ - nptr = malloc(sizeof(name_list)); + nptr = (name_list *) malloc(sizeof(name_list)); if (nptr == NULL) { parseWarning("unable to allocate %lu bytes for name_list", (unsigned long) sizeof(name_list)); diff --git a/src/menus.c b/src/menus.c index 39d6d34..44e0904 100644 --- a/src/menus.c +++ b/src/menus.c @@ -194,7 +194,7 @@ AddFuncKey(char *name, int cont, int mods2, int func, char *win_name, } if (tmp == NULL) { - tmp = malloc(sizeof(FuncKey)); + tmp = (FuncKey *) malloc(sizeof(FuncKey)); tmp->next = Scr->FuncKeyRoot.next; Scr->FuncKeyRoot.next = tmp; } @@ -215,7 +215,7 @@ int CreateTitleButton(const char *name, int func, const char *action, MenuRoot *menuroot, Bool rightside, Bool append) { - TitleButton *tb = malloc(sizeof(TitleButton)); + TitleButton *tb = (TitleButton *) malloc(sizeof(TitleButton)); if (!tb) { twmWarning("unable to allocate %lu bytes for title button", @@ -606,7 +606,7 @@ NewMenuRoot(const char *name) #define UNUSED_PIXEL ((unsigned long) (~0)) /* more than 24 bits */ - tmp = malloc(sizeof(MenuRoot)); + tmp = (MenuRoot *) malloc(sizeof(MenuRoot)); tmp->hi_fore = UNUSED_PIXEL; tmp->hi_back = UNUSED_PIXEL; tmp->name = name; @@ -665,7 +665,7 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action, item, action ? action : "", sub, func); #endif - tmp = malloc(sizeof(MenuItem)); + tmp = (MenuItem *) malloc(sizeof(MenuItem)); tmp->root = menu; if (menu->first == NULL) { @@ -955,7 +955,7 @@ PopUpMenu(MenuRoot *menu, int x, int y, Bool center) if (WindowNameCount != 0) { int i; - WindowNames = + WindowNames = (TwmWindow **) malloc(sizeof(TwmWindow *) * (size_t) WindowNameCount); WindowNames[0] = Scr->TwmRoot.next; @@ -2309,7 +2309,7 @@ Execute(const char *s) colon = strrchr(ds, ':'); if (colon) { /* if host[:]:dpy */ size_t need = sizeof(display_eqls) + strlen(ds) + 10; - char *update = malloc(need); + char *update = (char *) malloc(need); if (update != NULL) { char *dot1; @@ -2333,7 +2333,7 @@ Execute(const char *s) if (restorevar) { size_t need = sizeof(display_eqls) + strlen(oldDisplay); - char *update = malloc(need); + char *update = (char *) malloc(need); if (update != NULL) { (void) snprintf(update, need, "%s%s", display_eqls, oldDisplay); @@ -2685,7 +2685,7 @@ BumpWindowColormap(TwmWindow *tmp, int inc) return; if (inc && tmp->cmaps.number_cwins > 0) { - cwins = + cwins = (ColormapWindow **) malloc(sizeof(ColormapWindow *) * (size_t) tmp->cmaps.number_cwins); if (cwins) { int i; diff --git a/src/parse.c b/src/parse.c index 0ad806e..4ffc4aa 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1037,7 +1037,7 @@ do_var_savecolor(int key) Cptr cptrav, cpnew; if (!chead) { - chead = malloc(sizeof(Cnode)); + chead = (Cnode *) malloc(sizeof(Cnode)); chead->i = key; chead->next = NULL; } @@ -1046,7 +1046,7 @@ do_var_savecolor(int key) while (cptrav->next != NULL) { cptrav = cptrav->next; } - cpnew = malloc(sizeof(Cnode)); + cpnew = (Cnode *) malloc(sizeof(Cnode)); cpnew->i = key; cpnew->next = NULL; cptrav->next = cpnew; @@ -1155,7 +1155,7 @@ do_squeeze_entry(name_list ** list, char *name, int justify, int num, int denom) if (HasShape) { SqueezeInfo *sinfo; - sinfo = malloc(sizeof(SqueezeInfo)); + sinfo = (SqueezeInfo *) malloc(sizeof(SqueezeInfo)); if (!sinfo) { parseWarning("unable to allocate %lu bytes for squeeze info", diff --git a/src/session.c b/src/session.c index 77e0d3a..92b25bb 100644 --- a/src/session.c +++ b/src/session.c @@ -216,7 +216,7 @@ read_counted_string(FILE *file, char **stringp) data = 0; } else { - data = malloc((unsigned) len + 1); + data = (char *) malloc((unsigned) len + 1); if (!data) return 0; if (fread(data, (int) sizeof(char), (int) len, file) != len) { @@ -368,7 +368,7 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, unsigned char byte; int i; - *pentry = entry = malloc(sizeof(TWMWinConfigEntry)); + *pentry = entry = (TWMWinConfigEntry *) malloc(sizeof(TWMWinConfigEntry)); if (!*pentry) return 0; @@ -402,8 +402,8 @@ ReadWinConfigEntry(FILE *configFile, unsigned short version, if (entry->wm_command_count == 0) entry->wm_command = NULL; else { - entry->wm_command = malloc((size_t) entry->wm_command_count * - sizeof(char *)); + entry->wm_command = (char **) + malloc((size_t) entry->wm_command_count * sizeof(char *)); if (!entry->wm_command) goto give_up; @@ -773,7 +773,8 @@ SaveYourselfPhase2CB(SmcConn smcConn2, SmPointer clientData _X_UNUSED) prop1.name = strdup(SmRestartCommand); prop1.type = strdup(SmLISTofARRAY8); - prop1.vals = malloc((size_t) (Argc + 4) * sizeof(SmPropValue)); + prop1.vals = (SmPropValue *) + malloc((size_t) (Argc + 4) * sizeof(SmPropValue)); if (!prop1.vals) { success = False; diff --git a/src/twm.c b/src/twm.c index 1c1e522..78a425c 100644 --- a/src/twm.c +++ b/src/twm.c @@ -359,7 +359,8 @@ main(int argc, char *argv[]) InfoLines = 0; /* for simplicity, always allocate NumScreens ScreenInfo struct pointers */ - ScreenList = calloc((size_t) NumScreens, sizeof(ScreenInfo *)); + ScreenList = (ScreenInfo **) + calloc((size_t) NumScreens, sizeof(ScreenInfo *)); if (ScreenList == NULL) { twmError("Unable to allocate memory for screen list, exiting"); } @@ -394,7 +395,7 @@ main(int argc, char *argv[]) numManaged++; /* Note: ScreenInfo struct is calloc'ed to initialize to zero. */ - Scr = ScreenList[scrnum] = calloc(1, sizeof(ScreenInfo)); + Scr = ScreenList[scrnum] = (ScreenInfo *) calloc(1, sizeof(ScreenInfo)); if (Scr == NULL) { twmWarning ("unable to allocate memory for ScreenInfo structure for screen %d.", @@ -442,7 +443,8 @@ main(int argc, char *argv[]) XSaveContext(dpy, Scr->Root, ScreenContext, (XPointer) Scr); Scr->TwmRoot.cmaps.number_cwins = 1; - Scr->TwmRoot.cmaps.cwins = malloc(sizeof(ColormapWindow *)); + Scr->TwmRoot.cmaps.cwins = (ColormapWindow **) + malloc(sizeof(ColormapWindow *)); Scr->TwmRoot.cmaps.cwins[0] = CreateColormapWindow(Scr->Root, True, False); Scr->TwmRoot.cmaps.cwins[0]->visibility = VisibilityPartiallyObscured; diff --git a/src/util.c b/src/util.c index baff6c8..5671fad 100644 --- a/src/util.c +++ b/src/util.c @@ -259,7 +259,7 @@ ExpandFilename(const char *name) if (name[0] != '~') return strdup(name); - newname = malloc((size_t) HomeLen + strlen(name) + 2); + newname = (char *) malloc((size_t) HomeLen + strlen(name) + 2); if (!newname) { twmWarning("unable to allocate %lu bytes to expand filename %s/%s", (unsigned long) HomeLen + (unsigned long) strlen(name) + 2, @@ -358,7 +358,8 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp) /* * Attempt to find icon in old IconDirectory (now obsolete) */ - bigname = malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); + bigname = (char *) + malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); if (!bigname) { twmWarning("unable to allocate memory for \"%s/%s\"", Scr->IconDirectory, name); @@ -399,7 +400,7 @@ InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps, Bool replace) } if (!sc) { /* no existing, allocate new */ - sc = malloc(sizeof(StdCmap)); + sc = (StdCmap *) malloc(sizeof(StdCmap)); if (!sc) { twmWarning("unable to allocate %lu bytes for StdCmap", (unsigned long) sizeof(StdCmap)); -- cgit v1.2.3 From 4b01408715cd10e3bf02eb1e87531917a09c2645 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 5 Mar 2024 03:43:57 -0500 Subject: include "gram.h" only from "parse.h" all of the users of (generated) gram.h rely upon (custom) parse.h, and the order of those headers affects portability. Signed-off-by: Thomas E. Dickey --- src/events.c | 1 - src/icons.c | 1 - src/lex.l | 1 - src/list.c | 2 +- src/menus.c | 1 - src/parse.c | 1 - src/parse.h | 1 + src/twm.c | 1 - src/util.c | 2 +- 9 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/events.c b/src/events.c index 585ae16..4b3f1c6 100644 --- a/src/events.c +++ b/src/events.c @@ -66,7 +66,6 @@ in this Software without prior written authorization from The Open Group. #include "events.h" #include "resize.h" #include "parse.h" -#include "gram.h" #include "util.h" #include "screen.h" #include "icons.h" diff --git a/src/icons.c b/src/icons.c index 3ebb4b2..4957e51 100644 --- a/src/icons.c +++ b/src/icons.c @@ -35,7 +35,6 @@ in this Software without prior written authorization from The Open Group. #include "twm.h" #include "screen.h" #include "icons.h" -#include "gram.h" #include "parse.h" #include "util.h" diff --git a/src/lex.l b/src/lex.l index 13b85e6..8bb5d19 100644 --- a/src/lex.l +++ b/src/lex.l @@ -66,7 +66,6 @@ in this Software without prior written authorization from The Open Group. /* #include */ /* lex already includes stdio.h */ #include "twm.h" -#include "gram.h" #include "list.h" #include "parse.h" diff --git a/src/list.c b/src/list.c index cceba24..3ddf078 100644 --- a/src/list.c +++ b/src/list.c @@ -61,7 +61,7 @@ in this Software without prior written authorization from The Open Group. #include #include "twm.h" #include "screen.h" -#include "gram.h" +#include "parse.h" #include "util.h" struct name_list_struct { diff --git a/src/menus.c b/src/menus.c index 44e0904..ed06453 100644 --- a/src/menus.c +++ b/src/menus.c @@ -70,7 +70,6 @@ in this Software without prior written authorization from The Open Group. #include "events.h" #include "util.h" #include "parse.h" -#include "gram.h" #include "screen.h" #include "menus.h" #include "iconmgr.h" diff --git a/src/parse.c b/src/parse.c index 4ffc4aa..c659e53 100644 --- a/src/parse.c +++ b/src/parse.c @@ -66,7 +66,6 @@ in this Software without prior written authorization from The Open Group. #include "screen.h" #include "menus.h" #include "util.h" -#include "gram.h" #include "parse.h" #include diff --git a/src/parse.h b/src/parse.h index a208cc8..2327ab1 100644 --- a/src/parse.h +++ b/src/parse.h @@ -61,6 +61,7 @@ in this Software without prior written authorization from The Open Group. #define PARSE_H #include "list.h" +#include "gram.h" extern void assign_var_savecolor(void); extern int do_single_keyword(int keyword); diff --git a/src/twm.c b/src/twm.c index 78a425c..a5e93bc 100644 --- a/src/twm.c +++ b/src/twm.c @@ -72,7 +72,6 @@ in this Software without prior written authorization from The Open Group. #include "menus.h" #include "events.h" #include "util.h" -#include "gram.h" #include "screen.h" #include "parse.h" #include "session.h" diff --git a/src/util.c b/src/util.c index 5671fad..9a04ac1 100644 --- a/src/util.c +++ b/src/util.c @@ -59,7 +59,7 @@ in this Software without prior written authorization from The Open Group. #include "twm.h" #include "util.h" -#include "gram.h" +#include "parse.h" #include "screen.h" #include #include -- cgit v1.2.3 From cebd6e2bab56c12d48ed3aa3c562bf9661595394 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 5 Mar 2024 04:10:29 -0500 Subject: amend yylineno change A recent change removed the declaration of yylineno from lex.l, making the program depend on the version of flex. Restore the declaration with an ifdef. Also, remove unused declaration in parse.c Signed-off-by: Thomas E. Dickey --- src/gram.y | 1 - src/lex.l | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gram.y b/src/gram.y index 9de5935..cf46d35 100644 --- a/src/gram.y +++ b/src/gram.y @@ -100,7 +100,6 @@ static int color; int mods = 0; unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); -extern int yylineno; extern int yylex(void); static void yyerror(const char *s); diff --git a/src/lex.l b/src/lex.l index 8bb5d19..2d6ef0c 100644 --- a/src/lex.l +++ b/src/lex.l @@ -70,6 +70,9 @@ in this Software without prior written authorization from The Open Group. #include "parse.h" #ifdef FLEX_SCANNER +#if (YY_FLEX_MINOR_VERSION == 5) && (YY_FLEX_SUBMINOR_VERSION < 20) +int yylineno; +#endif #undef YY_INPUT #define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size))) -- cgit v1.2.3 From c2833e0c97f491a1acc87abe09adcd2b3f937688 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 5 Mar 2024 04:17:19 -0500 Subject: improve declaration of yylex() Replace the extern declaration of yylex() in gram.y with a definition/use in parse.h, improving portability. Signed-off-by: Thomas E. Dickey --- src/gram.y | 1 - src/parse.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gram.y b/src/gram.y index cf46d35..7394e81 100644 --- a/src/gram.y +++ b/src/gram.y @@ -100,7 +100,6 @@ static int color; int mods = 0; unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); -extern int yylex(void); static void yyerror(const char *s); %} diff --git a/src/parse.h b/src/parse.h index 2327ab1..f66bf06 100644 --- a/src/parse.h +++ b/src/parse.h @@ -63,6 +63,9 @@ in this Software without prior written authorization from The Open Group. #include "list.h" #include "gram.h" +#define YY_DECL int yylex (void) +YY_DECL; + extern void assign_var_savecolor(void); extern int do_single_keyword(int keyword); extern int do_string_keyword(int keyword, char *s); -- cgit v1.2.3 From 73c4cf88f3bf4094fd12cffec0147b957ad1e9c6 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 5 Mar 2024 05:24:05 -0500 Subject: improve portability for bison/byacc Provide declaration of yyparse(), and alternate declaration of yylex(). This works with bison and byacc, as well as different versions of flex. Signed-off-by: Thomas E. Dickey --- src/parse.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/parse.h b/src/parse.h index f66bf06..88b1118 100644 --- a/src/parse.h +++ b/src/parse.h @@ -63,8 +63,21 @@ in this Software without prior written authorization from The Open Group. #include "list.h" #include "gram.h" +/* + * POSIX does not say where yyparse() is declared. bison puts it in its + * generated header, while byacc does not. This chunk helps with portability. + */ +#if !(defined(YYDEBUG) && defined(YY_YY_GRAM_H_INCLUDED)) && !defined(YYBYACC) +extern int yyparse(void); +#endif + +/* + * Some versions of byacc and flex declare yylex(). This chunk fixes that. + */ +#if !(defined(YYBYACC) || defined(YYLEX_DECL)) #define YY_DECL int yylex (void) YY_DECL; +#endif extern void assign_var_savecolor(void); extern int do_single_keyword(int keyword); -- cgit v1.2.3 From 9b9c0087c906193e5ac549f8203713fd4eedbf2a Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 3 Mar 2024 12:55:11 +0100 Subject: Simplify default twmrc generation The logic to generate deftwmrc.c is currently split between Makefile.am and deftwmrc.sed. Consolidate into a single script. Signed-off-by: Tim Wiederhake --- src/Makefile.am | 12 ++---------- src/deftwmrc.sed | 4 ---- src/gen_deftwmrc.sh | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) delete mode 100644 src/deftwmrc.sed create mode 100755 src/gen_deftwmrc.sh diff --git a/src/Makefile.am b/src/Makefile.am index c0e7994..5da94ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,14 +74,6 @@ twm_SOURCES = \ BUILT_SOURCES = gram.h deftwmrc.c deftwmrc.c: system.twmrc - $(AM_V_at)rm -f $@ ; \ - echo '/* ' >>$@ ; \ - echo ' * This file is generated automatically from the default' >>$@ ; \ - echo ' * twm bindings file system.twmrc by the twm Makefile.' >>$@ ; \ - echo ' */' >>$@ ; \ - echo '' >>$@ ; \ - echo 'const unsigned char *defTwmrc[] = {' >>$@ ; \ - $(SED) -f ${srcdir}/deftwmrc.sed < ${srcdir}/system.twmrc >>$@ ; \ - echo ' (const unsigned char *) 0 };' >>$@ + $(srcdir)/gen_deftwmrc.sh $@ $< -EXTRA_DIST = deftwmrc.sed siconify.bm +EXTRA_DIST = siconify.bm diff --git a/src/deftwmrc.sed b/src/deftwmrc.sed deleted file mode 100644 index 30f8c27..0000000 --- a/src/deftwmrc.sed +++ /dev/null @@ -1,4 +0,0 @@ -/^#/d -s/"/\\"/g -s/^/ (const unsigned char *) "/ -s/$/",/ diff --git a/src/gen_deftwmrc.sh b/src/gen_deftwmrc.sh new file mode 100755 index 0000000..ec7188c --- /dev/null +++ b/src/gen_deftwmrc.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +rm -f ${1} +echo '/* ' >>${1} +echo ' * This file is generated automatically from the default' >>${1} +echo ' * twm bindings file system.twmrc by the twm Makefile.' >>${1} +echo ' */' >>${1} +echo '' >>${1} +echo 'const unsigned char *defTwmrc[] = {' >>${1} +sed \ + -e '/^#/d' \ + -e 's/"/\\"/g' \ + -e 's/^/ (const unsigned char *) "/' \ + -e 's/$/",/' \ + <${2} \ + >>${1} +echo ' (const unsigned char *) 0 };' >>${1} -- cgit v1.2.3 From b603079e08f085a6b23f2fdf3f7eef9ccec86424 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 3 Mar 2024 12:55:11 +0100 Subject: Remove version.c and version.h These files define only a single variable that is used in only one place. Signed-off-by: Tim Wiederhake --- src/Makefile.am | 2 -- src/events.c | 1 - src/menus.c | 4 ++-- src/version.c | 52 --------------------------------------------- src/version.h | 65 --------------------------------------------------------- 5 files changed, 2 insertions(+), 122 deletions(-) delete mode 100644 src/version.c delete mode 100644 src/version.h diff --git a/src/Makefile.am b/src/Makefile.am index 5da94ea..bb45b53 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -66,8 +66,6 @@ twm_SOURCES = \ twm.h \ util.c \ util.h \ - version.c \ - version.h \ gram.y \ lex.l diff --git a/src/events.c b/src/events.c index 4b3f1c6..12ba7ae 100644 --- a/src/events.c +++ b/src/events.c @@ -69,7 +69,6 @@ in this Software without prior written authorization from The Open Group. #include "util.h" #include "screen.h" #include "icons.h" -#include "version.h" #ifdef HAVE_XRANDR #include diff --git a/src/menus.c b/src/menus.c index ed06453..9b4ecd3 100644 --- a/src/menus.c +++ b/src/menus.c @@ -77,7 +77,6 @@ in this Software without prior written authorization from The Open Group. #include "icons.h" #include "session.h" #include -#include "version.h" #include #include @@ -2530,7 +2529,8 @@ Identify(TwmWindow *t) Window wdummy = None; n = 0; - snprintf(Info[n++], INFO_SIZE, "Twm version: %s", Version); + snprintf(Info[n++], INFO_SIZE, "Twm version: %s, %s", + XVENDORNAME, XORG_RELEASE); Info[n++][0] = '\0'; if (t) { diff --git a/src/version.c b/src/version.c deleted file mode 100644 index e7eae94..0000000 --- a/src/version.c +++ /dev/null @@ -1,52 +0,0 @@ -/*****************************************************************************/ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ -/** Salt Lake City, Utah **/ -/** Cambridge, Massachusetts **/ -/** **/ -/** All Rights Reserved **/ -/** **/ -/** Permission to use, copy, modify, and distribute this software and **/ -/** its documentation for any purpose and without fee is hereby **/ -/** granted, provided that the above copyright notice appear in all **/ -/** copies and that both that copyright notice and this permis- **/ -/** sion notice appear in supporting documentation, and that the **/ -/** name of Evans & Sutherland not be used in advertising **/ -/** in publicity pertaining to distribution of the software without **/ -/** specific, written prior permission. **/ -/** **/ -/** EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD **/ -/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ -/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND **/ -/** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ -/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ -/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ -/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ -/** OR PERFORMANCE OF THIS SOFTWARE. **/ -/*****************************************************************************/ - -const char *Version = XVENDORNAME ", " XORG_RELEASE; diff --git a/src/version.h b/src/version.h deleted file mode 100644 index fb0d2d6..0000000 --- a/src/version.h +++ /dev/null @@ -1,65 +0,0 @@ -/*****************************************************************************/ -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ -/** Salt Lake City, Utah **/ -/** Cambridge, Massachusetts **/ -/** **/ -/** All Rights Reserved **/ -/** **/ -/** Permission to use, copy, modify, and distribute this software and **/ -/** its documentation for any purpose and without fee is hereby **/ -/** granted, provided that the above copyright notice appear in all **/ -/** copies and that both that copyright notice and this permis- **/ -/** sion notice appear in supporting documentation, and that the **/ -/** name of Evans & Sutherland not be used in advertising **/ -/** in publicity pertaining to distribution of the software without **/ -/** specific, written prior permission. **/ -/** **/ -/** EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD **/ -/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ -/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND **/ -/** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ -/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ -/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ -/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ -/** OR PERFORMANCE OF THIS SOFTWARE. **/ -/*****************************************************************************/ - -/********************************************************************** - * - * TWM version externs - * - * 8-Apr-88 Tom LaStrange Initial Version. - * - **********************************************************************/ - -#ifndef VERSION_H -#define VERSION_H - -extern const char *Version; - -#endif /* VERSION_H */ -- cgit v1.2.3 From 451e1b036d3dd0fddcf54733b5616169ed5ad570 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 3 Mar 2024 12:55:11 +0100 Subject: Provide defaults for externally defined symbols AM_CPPFLAGS defines several symbols that do not have to be there. By providing default values in twm.h, this list can be reduced in size while still allowing to override these values. Signed-off-by: Tim Wiederhake --- src/Makefile.am | 6 +----- src/menus.c | 4 ++-- src/parse.c | 5 +---- src/twm.c | 2 +- src/twm.h | 20 ++++++++++++++++++++ 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index bb45b53..96fa621 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,12 +28,8 @@ rcdir = ${datadir}/X11/twm dist_rc_DATA = system.twmrc AM_CPPFLAGS = \ - -DAPP_NAME=\"twm\" \ - -DAPP_CLASS=\"twm\" \ -DAPP_VERSION=\"$(VERSION)\" \ - -DXVENDORNAME=\"The\ X.Org\ Foundation\" \ - -DXORG_RELEASE=\"Release\ $(VERSION)\" \ - -DSYSTEM_INIT_FILE=\"${rcdir}/system.twmrc\" + -DDATADIR=\"${datadir}\" AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) $(CWARNFLAGS) twm_LDADD = $(TWM_LIBS) $(XRANDR_LIBS) diff --git a/src/menus.c b/src/menus.c index 9b4ecd3..41f5bad 100644 --- a/src/menus.c +++ b/src/menus.c @@ -2529,8 +2529,8 @@ Identify(TwmWindow *t) Window wdummy = None; n = 0; - snprintf(Info[n++], INFO_SIZE, "Twm version: %s, %s", - XVENDORNAME, XORG_RELEASE); + snprintf(Info[n++], INFO_SIZE, "Twm version: %s, Release %s", + XVENDORNAME, APP_VERSION); Info[n++][0] = '\0'; if (t) { diff --git a/src/parse.c b/src/parse.c index c659e53..c841489 100644 --- a/src/parse.c +++ b/src/parse.c @@ -71,9 +71,6 @@ in this Software without prior written authorization from The Open Group. #include #include -#ifndef SYSTEM_INIT_FILE -#define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc" -#endif #define BUF_LEN 300 static FILE *twmrc; @@ -200,7 +197,7 @@ ParseTwmrc(char *filename) break; case 3: /* system.twmrc */ - cp = SYSTEM_INIT_FILE; + cp = DATADIR "/X11/twm/system.twmrc"; break; } diff --git a/src/twm.c b/src/twm.c index a5e93bc..4be177c 100644 --- a/src/twm.c +++ b/src/twm.c @@ -316,7 +316,7 @@ main(int argc, char *argv[]) si = XtAppAddSignal(appContext, Done, NULL); - if (!(dpy = XtOpenDisplay(appContext, display_name, "twm", "twm", + if (!(dpy = XtOpenDisplay(appContext, display_name, APP_NAME, APP_CLASS, NULL, 0, &zero, NULL))) { twmError("unable to open display \"%s\"", XDisplayName(display_name)); } diff --git a/src/twm.h b/src/twm.h index 46ddd2a..db55a32 100644 --- a/src/twm.h +++ b/src/twm.h @@ -74,6 +74,26 @@ from The Open Group. #include #include +#ifndef APP_NAME +#define APP_NAME "twm" +#endif + +#ifndef APP_CLASS +#define APP_CLASS "twm" +#endif + +#ifndef APP_VERSION +#define APP_VERSION "unknown" +#endif + +#ifndef DATADIR +#define DATADIR "/usr/local/share" +#endif + +#ifndef XVENDORNAME +#define XVENDORNAME "The X.Org Foundation" +#endif + #ifndef WithdrawnState #define WithdrawnState 0 #endif -- cgit v1.2.3 From 1ffcb516954add31a225d38675adad1df8fa5d21 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 3 Mar 2024 12:55:11 +0100 Subject: Add meson as alternative build system Add a note to the readme file to clarify that the default build system is still automake. Signed-off-by: Tim Wiederhake --- README.md | 5 ++++ man/meson.build | 24 ++++++++++++++++++ meson.build | 46 ++++++++++++++++++++++++++++++++++ src/meson.build | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 man/meson.build create mode 100644 meson.build create mode 100644 src/meson.build diff --git a/README.md b/README.md index 06b6607..e926c46 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,8 @@ For patch submission instructions, see: https://www.x.org/wiki/Development/Documentation/SubmittingPatches +To build, run: + ./autogen.sh + make + +The meson based build system is experimental. diff --git a/man/meson.build b/man/meson.build new file mode 100644 index 0000000..40287d5 --- /dev/null +++ b/man/meson.build @@ -0,0 +1,24 @@ +custom_target( + 'twm.1', + build_by_default: true, + capture: true, + input: files('twm.man'), + output: 'twm.1', + install: true, + install_dir: get_option('mandir'), + command: [ + find_program('sed'), + '@INPUT@', + '-e', 's#__appmansuffix__#1#g', + '-e', 's#__miscmansuffix__#7#g', + '-e', 's#__datadir__#@0@#g'.format( + get_option('prefix') / get_option('datadir') + ), + '-e', 's#__projectroot__#@0@#g'.format( + meson.project_source_root() + ), + '-e', 's#__xorgversion__#"twm @0@" "X Version 11"#g'.format( + meson.project_version() + ), + ], +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..b560add --- /dev/null +++ b/meson.build @@ -0,0 +1,46 @@ +project( + 'twm', + 'c', + default_options: [ + 'warning_level=3', + 'werror=true', + ], + version: '1.0.12', +) + +add_project_arguments( + '-DAPP_VERSION="@0@"'.format(meson.project_version()), + language: 'c', +) + +add_project_arguments( + '-DDATA_DIR="@0@"'.format(get_option('datadir')), + language: 'c', +) + +if meson.get_compiler('c').has_function('mkstemp') + add_project_arguments( + '-DHAVE_MKSTEMP=1', + language: 'c', + ) +endif + +twm_dependencies = [ + dependency('x11'), + dependency('xext'), + dependency('xt'), + dependency('xmu'), + dependency('ice'), + dependency('sm'), + dependency('xproto', version:'>=7.0.17'), +] + +xrandr = dependency('xrandr', required: false) +if xrandr.found() + twm_dependencies += xrandr + + add_project_arguments('-DHAVE_XRANDR', language: 'c') +endif + +subdir('src') +subdir('man') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..9c801df --- /dev/null +++ b/src/meson.build @@ -0,0 +1,78 @@ +deftwmrc = custom_target( + 'deftwmrc.c', + input: 'system.twmrc', + output: 'deftwmrc.c', + command: [ + find_program('gen_deftwmrc.sh'), + '@OUTPUT@', + '@INPUT@', + ], +) + +parser = custom_target( + 'gram.[ch]', + input: [ + 'gram.y', + ], + output: [ + 'gram.c', + 'gram.h' + ], + command: [ + find_program('bison'), + '-y', + '-d', + '-o', + '@OUTPUT0@', + '@INPUT@', + ], +) + +lexer = custom_target( + 'lex.c', + input: [ + 'lex.l', + parser[1], + ], + output: [ + 'lex.c', + ], + command: [ + find_program('flex'), + '-o', + '@OUTPUT@', + '@INPUT0@', + ], +) + +twm = executable( + 'twm', + [ + 'add_window.c', + 'cursor.c', + 'events.c', + 'gc.c', + 'iconmgr.c', + 'icons.c', + 'list.c', + 'menus.c', + 'parse.c', + 'resize.c', + 'session.c', + 'twm.c', + 'util.c', + deftwmrc, + parser, + lexer, + ], + dependencies: twm_dependencies, + install: true, +) + +configure_file( + input: 'system.twmrc', + output: 'system.twmrc', + copy: true, + install: true, + install_dir: get_option('datadir') / 'X11/twm/', +) -- cgit v1.2.3 From 79b0987e63daff97ce9ee1dce883df13668a80c6 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 10 Mar 2024 21:43:28 +0100 Subject: Add meson builds to CI Signed-off-by: Tim Wiederhake --- .gitlab-ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec9ea9b..694d842 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,8 +30,8 @@ variables: # The tag should be updated each time the list of packages is updated. # Changing a tag forces the associated image to be rebuilt. # Note: the tag has no meaning, we use a date format purely for readability - FDO_DISTRIBUTION_TAG: '2021-12-04.1' - FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake make flex bison xorg-util-macros xorgproto libx11 libxext libxt libxmu libice libsm libxrandr' + FDO_DISTRIBUTION_TAG: '2024-03-10.1' + FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf meson autoconf automake make flex bison xorg-util-macros xorgproto libx11 libxext libxt libxmu libice libsm libxrandr' # @@ -96,3 +96,14 @@ build: - make check - make distcheck - popd > /dev/null + +# +# Alternative build using meson. +# +build-meson: + stage: build + extends: + - .fdo.distribution-image@arch + script: + - meson setup build + - meson compile -C build -- cgit v1.2.3