summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am22
-rw-r--r--src/add_window.c145
-rw-r--r--src/add_window.h6
-rw-r--r--src/cursor.c6
-rw-r--r--src/deftwmrc.sed4
-rw-r--r--src/events.c93
-rw-r--r--src/events.h8
-rw-r--r--src/gc.h6
-rwxr-xr-xsrc/gen_deftwmrc.sh17
-rw-r--r--src/gram.y7
-rw-r--r--src/iconmgr.c33
-rw-r--r--src/iconmgr.h6
-rw-r--r--src/icons.c124
-rw-r--r--src/icons.h2
-rw-r--r--src/lex.l5
-rw-r--r--src/list.c24
-rw-r--r--src/list.h10
-rw-r--r--src/menus.c171
-rw-r--r--src/menus.h7
-rw-r--r--src/meson.build78
-rw-r--r--src/parse.c31
-rw-r--r--src/parse.h23
-rw-r--r--src/resize.h6
-rw-r--r--src/screen.h10
-rw-r--r--src/session.c47
-rw-r--r--src/session.h8
-rw-r--r--src/twm.c120
-rw-r--r--src/twm.h55
-rw-r--r--src/util.c36
-rw-r--r--src/util.h6
-rw-r--r--src/version.c52
-rw-r--r--src/version.h65
32 files changed, 571 insertions, 662 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 805eaf9..96fa621 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,14 +28,10 @@ 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)
+AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) $(CWARNFLAGS)
twm_LDADD = $(TWM_LIBS) $(XRANDR_LIBS)
twm_SOURCES = \
@@ -66,22 +62,12 @@ twm_SOURCES = \
twm.h \
util.c \
util.h \
- version.c \
- version.h \
gram.y \
lex.l
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/add_window.c b/src/add_window.c
index 3895729..3caf15b 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) {
@@ -162,13 +162,16 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
Bool width_ever_changed_by_user;
Bool height_ever_changed_by_user;
char *name;
+ int dummy = 0;
+ unsigned udummy = 0;
+ Window wdummy = None;
#ifdef DEBUG
fprintf(stderr, "AddWindow: w = 0x%lx\n", (unsigned long) w);
#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;
@@ -185,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);
@@ -260,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)
@@ -320,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)
@@ -345,18 +348,18 @@ 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 = (XWMHints *) malloc(sizeof(XWMHints));
tmp_win->wmhints->flags = 0;
}
tmp_win->wmhints->initial_state = IconicState;
@@ -432,29 +435,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,
- &JunkChild, &JunkX, &JunkY,
- &AddingX, &AddingY, &JunkMask))
- JunkMask = 0;
+ if (!XQueryPointer(dpy, Scr->Root, &root,
+ &wdummy, &dummy, &dummy,
+ &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) {
- register int scrnum;
+ if (root != Scr->Root) {
+ int scrnum;
for (scrnum = 0; scrnum < NumScreens; scrnum++) {
- if (JunkRoot == RootWindow(dpy, scrnum))
+ if (root == RootWindow(dpy, scrnum))
break;
}
@@ -467,7 +471,7 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
/*
* wait for buttons to come up; yuck
*/
- if (JunkMask != 0)
+ if (mask != 0)
continue;
/*
@@ -566,9 +570,9 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
continue;
}
- XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &AddingX, &AddingY,
- &JunkMask);
+ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy,
+ &dummy, &dummy, &AddingX, &AddingY,
+ &udummy);
if (Scr->DontMoveOff) {
int AddingR, AddingB;
@@ -661,9 +665,9 @@ 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,
- &JunkX, &JunkY, &AddingX, &AddingY,
- &JunkMask);
+ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy,
+ &dummy, &dummy, &AddingX, &AddingY,
+ &udummy);
if (lastx != AddingX || lasty != AddingY) {
DoResize(AddingX, AddingY, tmp_win);
@@ -764,8 +768,8 @@ 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,
- &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) {
+ if (XGetGeometry(dpy, tmp_win->w, &wdummy, &dummy, &dummy,
+ &udummy, &udummy, &udummy, &udummy) == 0) {
free(tmp_win);
XUngrabServer(dpy);
return (NULL);
@@ -789,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 */
@@ -1213,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;
@@ -1300,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);
}
@@ -1346,15 +1351,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;
}
}
@@ -1366,8 +1374,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)
@@ -1388,7 +1396,7 @@ CreateTwmColormap(Colormap c)
{
TwmColormap *cmap;
- cmap = malloc(sizeof(TwmColormap));
+ cmap = (TwmColormap *) calloc(1, sizeof(TwmColormap));
if (!cmap || XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) {
if (cmap)
free(cmap);
@@ -1409,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)) {
@@ -1460,7 +1468,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;
@@ -1490,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) {
@@ -1509,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++) {
@@ -1558,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] =
@@ -1578,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/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/cursor.c b/src/cursor.c
index 84d3f0c..297fc08 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -149,6 +149,8 @@ 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);
if ((hotx = HotX) < 0)
@@ -159,8 +161,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, &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/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/events.c b/src/events.c
index d940848..12ba7ae 100644
--- a/src/events.c
+++ b/src/events.c
@@ -66,11 +66,9 @@ 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"
-#include "version.h"
#ifdef HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
@@ -344,7 +342,7 @@ DispatchEvent(void)
* handle X events
*/
void
-HandleEvents(void)
+HandleEvents(XtAppContext appContext)
{
while (TRUE) {
if (enter_flag && !QLength(dpy)) {
@@ -391,7 +389,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);
@@ -631,7 +633,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 +648,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,
@@ -735,6 +737,9 @@ HandlePropertyNotify(void)
char *name = NULL;
XSetWindowAttributes attributes; /* attributes for create windows */
Pixmap pm;
+ int dummy = 0;
+ unsigned udummy = 0;
+ Window wdummy = None;
/* watch for standard colormap changes */
if (Event.xproperty.window == Scr->Root) {
@@ -821,9 +826,9 @@ 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);
+ &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);
@@ -841,9 +846,9 @@ 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,
- &icon_y, &JunkWidth, &JunkHeight, &JunkBW,
- &JunkDepth)) {
+ if (XGetGeometry(dpy, Tmp_win->icon_w, &wdummy, &icon_x,
+ &icon_y, &udummy, &udummy, &udummy,
+ &udummy)) {
/*
* Move the new icon window to where the old one was.
*/
@@ -899,11 +904,11 @@ HandlePropertyNotify(void)
(Tmp_win->wmhints->flags & IconPixmapHint)) {
unsigned long valuemask; /* mask for create windows */
- if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot,
- &JunkX, &JunkY,
+ 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;
}
@@ -1016,15 +1021,19 @@ RedoIconName(void)
void
HandleClientMessage(void)
{
+ int dummy = 0;
+ unsigned udummy = 0;
+ 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);
+ &dummy, &dummy, &udummy);
ExecuteFunction(F_ICONIFY, NULLSTR, Event.xany.window,
Tmp_win, &button, FRAME, FALSE);
@@ -1094,12 +1103,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,
@@ -1225,8 +1234,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
@@ -1251,10 +1260,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);
@@ -1466,12 +1477,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), &JunkChild,
+ &(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. */
@@ -1697,6 +1710,8 @@ HandleButtonPress(void)
{
unsigned int modifier;
Cursor cur;
+ int dummy = 0;
+ Window wdummy = None;
/* too much code relies on this assumption */
if (Event.xbutton.button > MAX_BUTTONS)
@@ -1748,8 +1763,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++) {
@@ -1782,13 +1797,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, &wdummy);
- 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,11 +1863,13 @@ 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,
Event.xbutton.y,
- &JunkX, &JunkY, &Event.xany.window);
+ &dummy, &dummy, &Event.xany.window);
if (Event.xany.window == 0 ||
(XFindContext(dpy, Event.xany.window, TwmContext,
@@ -1863,10 +1884,10 @@ HandleButtonPress(void)
XTranslateCoordinates(dpy, Scr->Root, Event.xany.window,
Event.xbutton.x,
- Event.xbutton.y, &JunkX, &JunkY, &JunkChild);
+ Event.xbutton.y, &x, &y, &wdummy);
- Event.xbutton.x = JunkX;
- Event.xbutton.y = JunkY;
+ Event.xbutton.x = x;
+ Event.xbutton.y = y;
Context = C_WINDOW;
}
@@ -2510,7 +2531,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;
diff --git a/src/events.h b/src/events.h
index 085439f..8e3b806 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"
@@ -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(XtAppContext) _X_NORETURN;
extern void HandleColormapNotify(void);
extern void HandleVisibilityNotify(void);
extern void HandleKeyPress(void);
@@ -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/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}
diff --git a/src/gram.y b/src/gram.y
index 791e60f..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 yylineno;
static void yyerror(const char *s);
%}
@@ -666,9 +665,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/iconmgr.c b/src/iconmgr.c
index 7cbc7a7..5af92ad 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);
@@ -134,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;
@@ -362,16 +361,16 @@ 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));
+ tmp = (WList *) malloc(sizeof(WList));
tmp->iconmgr = ip;
tmp->next = NULL;
tmp->active = FALSE;
@@ -385,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/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.c b/src/icons.c
index 6a04e7b..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"
@@ -50,7 +49,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 +57,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 = (IconEntry *) 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 +79,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 = (IconEntry *) 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;
}
@@ -163,6 +162,8 @@ IconUp(TwmWindow *tmp_win)
int x, y;
int defx, defy;
struct IconRegion *ir;
+ unsigned udummy = 0;
+ Window wdummy = None;
/*
* If the client specified a particular location, let's use it (this might
@@ -173,12 +174,15 @@ IconUp(TwmWindow *tmp_win)
return;
if (tmp_win->icon_moved) {
- if (!XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy,
- &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth))
+ unsigned width = 0;
+ unsigned height = 0;
+
+ if (!XGetGeometry(dpy, tmp_win->icon_w, &wdummy, &defx, &defy,
+ &width, &height, &udummy, &udummy))
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) &&
@@ -270,7 +274,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;
@@ -298,7 +302,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;
@@ -308,35 +312,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)
{
@@ -345,6 +320,9 @@ 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;
+ unsigned udummy = 0;
+ Window wdummy = None;
FB(tmp_win->iconc.fore, tmp_win->iconc.back);
@@ -362,7 +340,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) {
@@ -375,10 +353,10 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y)
}
if (bm != None) {
- XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
+ 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,
@@ -401,10 +379,10 @@ 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, &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,
@@ -426,7 +404,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) {
@@ -439,10 +417,10 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y)
}
if (bm != None) {
- XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
+ 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,
@@ -501,10 +479,10 @@ 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, &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/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/lex.l b/src/lex.l
index d07a085..2d6ef0c 100644
--- a/src/lex.l
+++ b/src/lex.l
@@ -66,12 +66,13 @@ in this Software without prior written authorization from The Open Group.
/* #include <stdio.h> */ /* lex already includes stdio.h */
#include "twm.h"
-#include "gram.h"
#include "list.h"
#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)))
@@ -139,7 +140,7 @@ number [0-9]+
#ifndef yywrap
int
-yywrap()
+yywrap(void)
{
return (1);
}
diff --git a/src/list.c b/src/list.c
index 4422cc9..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 <stdio.h>
#include "twm.h"
#include "screen.h"
-#include "gram.h"
+#include "parse.h"
#include "util.h"
struct name_list_struct {
@@ -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));
@@ -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);
@@ -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 d9a4acd..bc9c16c 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 <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -70,9 +70,9 @@ 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 *class);
+ XClassHint *xclass);
extern char *LookInNameList(name_list * list_head, const char *name);
-#endif /* _LIST_ */
+#endif /* LIST_H */
diff --git a/src/menus.c b/src/menus.c
index 37c9a6e..4cbe751 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"
@@ -78,7 +77,6 @@ in this Software without prior written authorization from The Open Group.
#include "icons.h"
#include "session.h"
#include <X11/Xmu/CharSet.h>
-#include "version.h"
#include <X11/extensions/sync.h>
#include <X11/SM/SMlib.h>
@@ -133,7 +131,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 +141,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;
}
/**
@@ -192,7 +192,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;
}
@@ -213,7 +213,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",
@@ -252,7 +252,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);
@@ -260,7 +260,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;
@@ -467,6 +467,8 @@ UpdateMenu(void)
int done;
MenuItem *badItem = NULL;
XPointer context_data;
+ unsigned udummy = 0;
+ Window wdummy = None;
fromMenu = TRUE;
@@ -504,8 +506,8 @@ UpdateMenu(void)
continue;
done = FALSE;
- XQueryPointer(dpy, ActiveMenu->w, &JunkRoot, &JunkChild,
- &x_root, &y_root, &x, &y, &JunkMask);
+ XQueryPointer(dpy, ActiveMenu->w, &wdummy, &wdummy,
+ &x_root, &y_root, &x, &y, &udummy);
/* if we haven't received the enter notify yet, wait */
if (!ActiveMenu->entered)
@@ -602,7 +604,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;
@@ -661,7 +663,7 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action,
item, action ? action : "<null>", sub, func);
#endif
- tmp = malloc(sizeof(MenuItem));
+ tmp = (MenuItem *) malloc(sizeof(MenuItem));
tmp->root = menu;
if (menu->first == NULL) {
@@ -951,7 +953,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;
@@ -1101,8 +1103,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)
@@ -1117,42 +1119,21 @@ resizeFromCenter(Window w, TwmWindow *tmp_win)
{
int lastx, lasty, bw2;
XEvent event;
+ int dummy = 0;
+ unsigned udummy = 0;
+ Window wdummy = None;
-#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,
+ 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, &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
+ XQueryPointer(dpy, Scr->Root, &wdummy,
+ &wdummy, &dummy, &dummy, &AddingX, &AddingY, &udummy);
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);
@@ -1183,8 +1164,8 @@ 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,
- &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
+ XQueryPointer(dpy, Scr->Root, &wdummy, &wdummy,
+ &dummy, &dummy, &AddingX, &AddingY, &udummy);
if (lastx != AddingX || lasty != AddingY) {
MenuDoResize(AddingX, AddingY, tmp_win);
@@ -1239,6 +1220,10 @@ 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;
+ int dummy = 0;
+ unsigned udummy = 0;
+ Window wdummy = None;
RootFunction = 0;
if (Cancel)
@@ -1492,16 +1477,16 @@ 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,
- &JunkBW, &JunkDepth);
+ &bw, &udummy);
origX = eventp->xbutton.x_root;
origY = eventp->xbutton.y_root;
@@ -1520,12 +1505,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;
@@ -1534,8 +1519,8 @@ 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,
- &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
+ XQueryPointer(dpy, w, &wdummy, &wdummy,
+ &dummy, &dummy, &DragX, &DragY, &udummy);
}
last_time = eventp->xbutton.time;
@@ -1549,10 +1534,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);
/*
@@ -1620,7 +1605,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;
}
@@ -1649,9 +1634,9 @@ 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);
+ &dummy, &dummy, &udummy);
if (DragWindow == None &&
abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta &&
@@ -1675,20 +1660,20 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
eventp->xmotion.y_root > ConstMoveYB)
ConstMoveDir = MOVE_VERT;
- XQueryPointer(dpy, DragWindow, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
+ XQueryPointer(dpy, DragWindow, &wdummy, &wdummy,
+ &dummy, &dummy, &DragX, &DragY, &udummy);
break;
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;
}
@@ -1697,8 +1682,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;
@@ -1729,16 +1714,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;
@@ -1996,7 +1981,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;
@@ -2042,7 +2027,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);
@@ -2054,13 +2039,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;
}
@@ -2322,7 +2307,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;
@@ -2346,7 +2331,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);
@@ -2408,7 +2393,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,21 +2526,23 @@ 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);
+ snprintf(Info[n++], INFO_SIZE, "Twm version: %s, Release %s",
+ XVENDORNAME, APP_VERSION);
Info[n++][0] = '\0';
if (t) {
- XGetGeometry(dpy, t->w, &JunkRoot, &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,
"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);
@@ -2586,7 +2573,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);
@@ -2697,7 +2684,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/menus.h b/src/menus.h
index 0692a27..b30d596 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"
@@ -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,
@@ -191,4 +192,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/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/',
+)
diff --git a/src/parse.c b/src/parse.c
index 48430b3..c841489 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -66,15 +66,11 @@ 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 <X11/Xatom.h>
#include <X11/extensions/sync.h>
-#ifndef SYSTEM_INIT_FILE
-#define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc"
-#endif
#define BUF_LEN 300
static FILE *twmrc;
@@ -201,7 +197,7 @@ ParseTwmrc(char *filename)
break;
case 3: /* system.twmrc */
- cp = SYSTEM_INIT_FILE;
+ cp = DATADIR "/X11/twm/system.twmrc";
break;
}
@@ -602,7 +598,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) {
@@ -747,6 +743,11 @@ do_single_keyword(int keyword)
int
do_string_keyword(int keyword, char *s)
{
+ unsigned width = 0;
+ unsigned height = 0;
+ unsigned mask = 0;
+ int dummy = 0;
+
switch (keyword) {
case kws_UsePPosition:
{
@@ -797,20 +798,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, &dummy, &dummy, &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;
}
@@ -1034,7 +1033,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;
}
@@ -1043,7 +1042,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;
@@ -1152,7 +1151,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/parse.h b/src/parse.h
index 0d0500c..88b1118 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -57,10 +57,27 @@ in this Software without prior written authorization from The Open Group.
*
**********************************************************************/
-#ifndef _PARSE_
-#define _PARSE_
+#ifndef PARSE_H
+#define PARSE_H
#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);
@@ -149,4 +166,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..d8bf996 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 <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -56,7 +56,7 @@ typedef struct _TitlebarPixmaps {
Pixmap resize;
Pixmap question;
Pixmap menu;
- Pixmap delete;
+ Pixmap remove;
} TitlebarPixmaps;
typedef struct ScreenInfo {
@@ -251,11 +251,9 @@ typedef struct ScreenInfo {
FuncKey FuncKeyRoot;
} ScreenInfo;
-extern int MultiScreen;
extern int NumScreens;
extern ScreenInfo **ScreenList;
extern ScreenInfo *Scr;
-extern int FirstScreen;
#define PPOS_OFF 0
#define PPOS_ON 1
@@ -263,4 +261,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.c b/src/session.c
index 94b4d63..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) {
@@ -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;
@@ -283,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) {
/*
@@ -330,9 +331,10 @@ 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,
- &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
+ XGetGeometry(dpy, theWindow->icon_w, &wdummy, &icon_x,
+ &icon_y, &udummy, &udummy, &udummy, &udummy);
if (!write_short(configFile, (short) icon_x))
return 0;
@@ -366,15 +368,15 @@ 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;
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;
@@ -386,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;
@@ -400,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;
@@ -458,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) {
@@ -555,10 +557,10 @@ GetWindowConfig(TwmWindow *theWindow,
* changed in the previous session.
*/
- if (strcmp(theWindow->class.res_name,
- ptr->class.res_name) == 0 &&
- strcmp(theWindow->class.res_class,
- ptr->class.res_class) == 0 &&
+ if (strcmp(theWindow->xclass.res_name,
+ ptr->xclass.res_name) == 0 &&
+ strcmp(theWindow->xclass.res_class,
+ ptr->xclass.res_class) == 0 &&
(ptr->wm_name == NULL ||
strcmp(theWindow->name, ptr->wm_name) == 0)) {
if (clientId) {
@@ -771,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;
@@ -878,7 +881,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 c574a45..df91469 100644
--- a/src/session.h
+++ b/src/session.h
@@ -23,14 +23,14 @@
* 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"
#include <X11/SM/SMlib.h>
-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,
@@ -41,4 +41,4 @@ extern void ReadWinConfigFile(char *filename);
extern SmcConn smcConn;
-#endif
+#endif /* SESSION_H */
diff --git a/src/twm.c b/src/twm.c
index 252bdf7..4be177c 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"
@@ -84,24 +83,17 @@ in this Software without prior written authorization from The Open Group.
#include <X11/extensions/sync.h>
#include <X11/Xlocale.h>
-#ifdef XPRINT
-#include <X11/extensions/Print.h>
-#endif /* XPRINT */
-
#ifdef HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
static void InitVariables(void);
-XtAppContext appContext; /* Xt application context */
-XtSignalId si;
+static 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 NoPrintscreens = False; /* ignore special handling of print screens? */
int NumScreens; /* number of screens in ScreenList */
int HasShape; /* server supports shape extension? */
@@ -116,7 +108,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 */
@@ -124,7 +115,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;
@@ -147,12 +137,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;
-
char *ProgramName;
int Argc;
char **Argv;
@@ -166,7 +150,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",
@@ -180,52 +164,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);
}
@@ -266,6 +208,9 @@ main(int argc, char *argv[])
char *restore_filename = NULL;
char *client_id = NULL;
char *loc;
+ int MultiScreen = TRUE; /* try for more than one screen? */
+ char *InitFile = NULL;
+ XtAppContext appContext; /* Xt application context */
ProgramName = argv[0];
Argc = argc;
@@ -289,13 +234,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();
@@ -378,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));
}
@@ -401,7 +339,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. */
@@ -419,22 +358,15 @@ 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");
}
numManaged = 0;
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 */
+ Bool FirstScreen = scrnum == firstscrn;
/* Make sure property priority colors is empty */
XChangeProperty(dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS,
@@ -462,7 +394,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.",
@@ -510,7 +442,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;
@@ -542,7 +475,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;
@@ -590,10 +527,12 @@ 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();
+ if (FirstScreen)
+ InitMenusFirst();
/* Parse it once for each screen. */
ParseTwmrc(InitFile);
@@ -616,9 +555,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)
@@ -694,24 +630,22 @@ main(int argc, char *argv[])
XUngrabServer(dpy);
- FirstScreen = FALSE;
Scr->FirstTime = FALSE;
} /* for */
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);
}
- (void) ConnectToSessionManager(client_id);
+ (void) ConnectToSessionManager(client_id, appContext);
RestartPreviousState = False;
HandlingEvents = TRUE;
InitEvents();
- HandleEvents();
+ HandleEvents(appContext);
exit(EXIT_SUCCESS);
}
@@ -885,9 +819,11 @@ RestoreWithdrawnLocation(TwmWindow *tmp)
int gravx, gravy;
unsigned int bw;
XWindowChanges xwc;
+ unsigned udummy = 0;
+ Window wdummy = None;
- if (XGetGeometry(dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y,
- &JunkWidth, &JunkHeight, &bw, &JunkDepth)) {
+ if (XGetGeometry(dpy, tmp->w, &wdummy, &xwc.x, &xwc.y,
+ &udummy, &udummy, &bw, &udummy)) {
unsigned mask;
GetGravityOffsets(tmp, &gravx, &gravy);
diff --git a/src/twm.h b/src/twm.h
index 3b0396a..db55a32 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
@@ -74,16 +74,24 @@ from The Open Group.
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
-#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*/
+#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 GCC_NORETURN
-#define GCC_NORETURN _X_NORETURN
+#ifndef DATADIR
+#define DATADIR "/usr/local/share"
+#endif
+
+#ifndef XVENDORNAME
+#define XVENDORNAME "The X.Org Foundation"
#endif
#ifndef WithdrawnState
@@ -92,8 +100,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 */
@@ -261,7 +267,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
@@ -317,7 +323,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;
@@ -357,7 +363,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 */
@@ -387,11 +392,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;
extern XGCValues Gcv;
extern int InfoLines;
extern char Info[][INFO_SIZE];
@@ -404,10 +404,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) _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);
extern Bool ErrorOccurred;
extern XErrorEvent LastErrorEvent;
@@ -418,12 +418,7 @@ extern Bool RestartPreviousState;
extern Bool
GetWMState(Window w, int *statep, Window *iwp);
-extern int
-yyparse(void);
-extern int
-yylex(void);
-
-extern void parseWarning(const char *, ...) GCC_PRINTFLIKE(1,2);
+extern void parseWarning(const char *, ...) _X_ATTRIBUTE_PRINTF(1,2);
extern Atom TwmAtoms[];
@@ -451,4 +446,4 @@ extern int XrandrErrorBase;
#define _XA_WM_WINDOW_ROLE TwmAtoms[10]
/* *INDENT-ON* */
-#endif /* _TWM_ */
+#endif /* TWM_H */
diff --git a/src/util.c b/src/util.c
index a6bf902..236458d 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 <X11/Xos.h>
#include <X11/Xatom.h>
@@ -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)
@@ -209,6 +209,8 @@ 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)
return;
@@ -216,8 +218,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, &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 */
@@ -275,10 +277,14 @@ ExpandFilename(const char *name)
void
GetUnknownIcon(const char *name)
{
+ int dummy = 0;
+ unsigned udummy = 0;
+ Window wdummy = None;
+
if ((Scr->UnknownPm = GetBitmap(name)) != None) {
- XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY,
+ XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &dummy, &dummy,
(unsigned int *) &Scr->UnknownWidth,
- (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth);
+ (unsigned int *) &Scr->UnknownHeight, &udummy, &udummy);
}
}
@@ -371,7 +377,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
@@ -387,7 +395,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));
@@ -474,10 +482,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;
@@ -549,10 +555,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;
@@ -579,7 +583,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);
@@ -911,11 +915,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,
@@ -926,7 +930,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
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.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 553b613..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_
-#define _VERSION_
-
-extern const char *Version;
-
-#endif /* _VERSION_ */