From 58d299e54e1198bfa64c39e49c2c0020f9f62b98 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Pereira de Andrade Date: Mon, 19 Jan 2009 19:49:37 -0200 Subject: Ansification and compile warning fixes. This also uses XORG_CHANGELOG and XORG_CWARNFLAGS, corrects make distcheck and all gcc 4.3 and sparse warnings. --- .gitignore | 3 + Makefile.am | 7 +-- configure.ac | 12 +++- xcompmgr.c | 176 +++++++++++++++++++++++++++++------------------------------ 4 files changed, 104 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 80ad9ea..9564fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ stamp-h1 xcompmgr *.o *~ +xcompmgr-*.tar.* +ChangeLog +tags diff --git a/Makefile.am b/Makefile.am index 4bc0ba3..3884d94 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,9 +1,8 @@ bin_PROGRAMS = xcompmgr man_MANS = xcompmgr.1 -xcompmgr_LDADD = @XCOMPMGR_LIBS@ -lm - -INCLUDES = @XCOMPMGR_CFLAGS@ +AM_CFLAGS = $(XCOMPMGR_CFLAGS) +xcompmgr_LDADD = $(XCOMPMGR_LIBS) -lm EXTRA_DIST = \ autogen.sh \ @@ -15,7 +14,7 @@ MAINTAINERCLEANFILES=ChangeLog .PHONY: ChangeLog ChangeLog: - (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) + $(CHANGELOG_CMD) dist-hook: ChangeLog diff --git a/configure.ac b/configure.ac index aa0a897..af9985a 100644 --- a/configure.ac +++ b/configure.ac @@ -6,10 +6,14 @@ AC_INIT([xcompmgr], [1.1.4], [xorg@freedesktop.org]) AC_CONFIG_SRCDIR([xcompmgr.c]) AM_INIT_AUTOMAKE([dist-bzip2 foreign]) AM_MAINTAINER_MODE +# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG +m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.2) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC +XORG_CWARNFLAGS # Checks for header files. AC_HEADER_STDC @@ -24,6 +28,10 @@ AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday localtime_r]) PKG_CHECK_MODULES(XCOMPMGR, xcomposite xfixes xdamage xrender) +XCOMPMGR_CFLAGS="$CWARNFLAGS $XCOMPMGR_CFLAGS" +AC_SUBST(XCOMPMGR_CFLAGS) +AC_SUBST(XCOMPMGR_LIBS) -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT +XORG_CHANGELOG + +AC_OUTPUT([Makefile]) diff --git a/xcompmgr.c b/xcompmgr.c index ad076a5..5a38cf1 100644 --- a/xcompmgr.c +++ b/xcompmgr.c @@ -104,41 +104,41 @@ typedef struct _fade { Bool gone; } fade; -win *list; -fade *fades; -Display *dpy; -int scr; -Window root; -Picture rootPicture; -Picture rootBuffer; -Picture blackPicture; -Picture transBlackPicture; -Picture rootTile; -XserverRegion allDamage; -Bool clipChanged; +static win *list; +static fade *fades; +static Display *dpy; +static int scr; +static Window root; +static Picture rootPicture; +static Picture rootBuffer; +static Picture blackPicture; +static Picture transBlackPicture; +static Picture rootTile; +static XserverRegion allDamage; +static Bool clipChanged; #if HAS_NAME_WINDOW_PIXMAP -Bool hasNamePixmap; +static Bool hasNamePixmap; #endif -int root_height, root_width; -ignore *ignore_head, **ignore_tail = &ignore_head; -int xfixes_event, xfixes_error; -int damage_event, damage_error; -int composite_event, composite_error; -int render_event, render_error; -Bool synchronize; -int composite_opcode; +static int root_height, root_width; +static ignore *ignore_head, **ignore_tail = &ignore_head; +static int xfixes_event, xfixes_error; +static int damage_event, damage_error; +static int composite_event, composite_error; +static int render_event, render_error; +static Bool synchronize; +static int composite_opcode; /* find these once and be done with it */ -Atom opacityAtom; -Atom winTypeAtom; -Atom winDesktopAtom; -Atom winDockAtom; -Atom winToolbarAtom; -Atom winMenuAtom; -Atom winUtilAtom; -Atom winSplashAtom; -Atom winDialogAtom; -Atom winNormalAtom; +static Atom opacityAtom; +static Atom winTypeAtom; +static Atom winDesktopAtom; +static Atom winDockAtom; +static Atom winToolbarAtom; +static Atom winMenuAtom; +static Atom winUtilAtom; +static Atom winSplashAtom; +static Atom winDialogAtom; +static Atom winNormalAtom; /* opacity property name; sometime soon I'll write up an EWMH spec for it */ #define OPACITY_PROP "_NET_WM_WINDOW_OPACITY" @@ -146,7 +146,7 @@ Atom winNormalAtom; #define TRANSLUCENT 0xe0000000 #define OPAQUE 0xffffffff -conv *gaussianMap; +static conv *gaussianMap; #define WINDOW_SOLID 0 #define WINDOW_TRANS 1 @@ -176,30 +176,30 @@ get_opacity_percent(Display *dpy, win *w, double def); static XserverRegion win_extents (Display *dpy, win *w); -CompMode compMode = CompSimple; +static CompMode compMode = CompSimple; -int shadowRadius = 12; -int shadowOffsetX = -15; -int shadowOffsetY = -15; -double shadowOpacity = .75; +static int shadowRadius = 12; +static int shadowOffsetX = -15; +static int shadowOffsetY = -15; +static double shadowOpacity = .75; -double fade_in_step = 0.028; -double fade_out_step = 0.03; -int fade_delta = 10; -int fade_time = 0; -Bool fadeWindows = False; -Bool excludeDockShadows = False; -Bool fadeTrans = False; +static double fade_in_step = 0.028; +static double fade_out_step = 0.03; +static int fade_delta = 10; +static int fade_time = 0; +static Bool fadeWindows = False; +static Bool excludeDockShadows = False; +static Bool fadeTrans = False; -Bool autoRedirect = False; +static Bool autoRedirect = False; /* For shadow precomputation */ -int Gsize = -1; -unsigned char *shadowCorner = NULL; -unsigned char *shadowTop = NULL; +static int Gsize = -1; +static unsigned char *shadowCorner = NULL; +static unsigned char *shadowTop = NULL; -int -get_time_in_milliseconds () +static int +get_time_in_milliseconds (void) { struct timeval tv; @@ -207,7 +207,7 @@ get_time_in_milliseconds () return tv.tv_sec * 1000 + tv.tv_usec / 1000; } -fade * +static fade * find_fade (win *w) { fade *f; @@ -217,10 +217,10 @@ find_fade (win *w) if (f->w == w) return f; } - return 0; + return NULL; } -void +static void dequeue_fade (Display *dpy, fade *f) { fade **prev; @@ -236,7 +236,7 @@ dequeue_fade (Display *dpy, fade *f) } } -void +static void cleanup_fade (Display *dpy, win *w) { fade *f = find_fade (w); @@ -244,7 +244,7 @@ cleanup_fade (Display *dpy, win *w) dequeue_fade (dpy, f); } -void +static void enqueue_fade (Display *dpy, fade *f) { if (!fades) @@ -264,7 +264,7 @@ set_fade (Display *dpy, win *w, double start, double finish, double step, if (!f) { f = malloc (sizeof (fade)); - f->next = 0; + f->next = NULL; f->w = w; f->cur = start; enqueue_fade (dpy, f); @@ -302,7 +302,7 @@ set_fade (Display *dpy, win *w, double start, double finish, double step, } } -int +static int fade_timeout (void) { int now; @@ -317,7 +317,7 @@ fade_timeout (void) return delta; } -void +static void run_fades (Display *dpy) { int now = get_time_in_milliseconds(); @@ -537,7 +537,7 @@ make_shadow (Display *dpy, double opacity, int width, int height) int opacity_int = (int)(opacity * 25); data = malloc (swidth * sheight * sizeof (unsigned char)); if (!data) - return 0; + return NULL; ximage = XCreateImage (dpy, DefaultVisual(dpy, DefaultScreen(dpy)), 8, @@ -548,7 +548,7 @@ make_shadow (Display *dpy, double opacity, int width, int height) if (!ximage) { free (data); - return 0; + return NULL; } /* * Build the gaussian in sections @@ -646,21 +646,21 @@ shadow_picture (Display *dpy, double opacity, Picture alpha_pict, int width, int shadowPicture = XRenderCreatePicture (dpy, shadowPixmap, XRenderFindStandardFormat (dpy, PictStandardA8), - 0, 0); + 0, NULL); if (!shadowPicture) { XDestroyImage (shadowImage); XFreePixmap (dpy, shadowPixmap); - return None; + return (Picture)None; } - gc = XCreateGC (dpy, shadowPixmap, 0, 0); + gc = XCreateGC (dpy, shadowPixmap, 0, NULL); if (!gc) { XDestroyImage (shadowImage); XFreePixmap (dpy, shadowPixmap); XRenderFreePicture (dpy, shadowPicture); - return None; + return (Picture)None; } XPutImage (dpy, shadowPixmap, gc, shadowImage, 0, 0, 0, 0, @@ -674,7 +674,7 @@ shadow_picture (Display *dpy, double opacity, Picture alpha_pict, int width, int return shadowPicture; } -Picture +static Picture solid_picture (Display *dpy, Bool argb, double a, double r, double g, double b) { Pixmap pixmap; @@ -706,7 +706,7 @@ solid_picture (Display *dpy, Bool argb, double a, double r, double g, double b) return picture; } -void +static void discard_ignore (Display *dpy, unsigned long sequence) { while (ignore_head) @@ -724,19 +724,19 @@ discard_ignore (Display *dpy, unsigned long sequence) } } -void +static void set_ignore (Display *dpy, unsigned long sequence) { ignore *i = malloc (sizeof (ignore)); if (!i) return; i->sequence = sequence; - i->next = 0; + i->next = NULL; *ignore_tail = i; ignore_tail = &i->next; } -int +static int should_ignore (Display *dpy, unsigned long sequence) { discard_ignore (dpy, sequence); @@ -751,13 +751,13 @@ find_win (Display *dpy, Window id) for (w = list; w; w = w->next) if (w->id == id) return w; - return 0; + return NULL; } static const char *backgroundProps[] = { "_XROOTPMAP_ID", "_XSETROOT_ID", - 0, + NULL, }; static Picture @@ -906,7 +906,7 @@ static void paint_all (Display *dpy, XserverRegion region) { win *w; - win *t = 0; + win *t = NULL; if (!region) { @@ -927,7 +927,7 @@ paint_all (Display *dpy, XserverRegion region) rootBuffer = XRenderCreatePicture (dpy, rootPixmap, XRenderFindVisualFormat (dpy, DefaultVisual (dpy, scr)), - 0, 0); + 0, NULL); XFreePixmap (dpy, rootPixmap); } #endif @@ -1021,7 +1021,7 @@ paint_all (Display *dpy, XserverRegion region) } if (!w->borderClip) { - w->borderClip = XFixesCreateRegion (dpy, 0, 0); + w->borderClip = XFixesCreateRegion (dpy, NULL, 0); XFixesCopyRegion (dpy, w->borderClip, region); } w->prev_trans = t; @@ -1147,7 +1147,7 @@ repair_win (Display *dpy, win *w) else { XserverRegion o; - parts = XFixesCreateRegion (dpy, 0, 0); + parts = XFixesCreateRegion (dpy, NULL, 0); set_ignore (dpy, NextRequest (dpy)); XDamageSubtract (dpy, w->damage, None, parts); XFixesTranslateRegion (dpy, parts, @@ -1155,7 +1155,7 @@ repair_win (Display *dpy, win *w) w->a.y + w->a.border_width); if (compMode == CompServerShadows) { - o = XFixesCreateRegion (dpy, 0, 0); + o = XFixesCreateRegion (dpy, NULL, 0); XFixesCopyRegion (dpy, o, parts); XFixesTranslateRegion (dpy, o, w->shadow_dx, w->shadow_dy); XFixesUnionRegion (dpy, parts, parts, o); @@ -1193,7 +1193,7 @@ map_win (Display *dpy, Window id, unsigned long sequence, Bool fade) w->damaged = 0; if (fade && fadeWindows) - set_fade (dpy, w, 0, get_opacity_percent (dpy, w, 1.0), fade_in_step, 0, False, True, True); + set_fade (dpy, w, 0, get_opacity_percent (dpy, w, 1.0), fade_in_step, NULL, False, True, True); } static void @@ -1324,7 +1324,7 @@ get_wintype_prop(Display * dpy, Window w) XA_ATOM, &actual, &format, &n, &left, &data); - if (result == Success && data != None) + if (result == Success && data != (unsigned char *)None) { Atom a; memcpy (&a, data, sizeof (Atom)); @@ -1355,7 +1355,7 @@ determine_mode(Display *dpy, win *w) if (w->a.class == InputOnly) { - format = 0; + format = NULL; } else { @@ -1378,7 +1378,7 @@ determine_mode(Display *dpy, win *w) if (w->extents) { XserverRegion damage; - damage = XFixesCreateRegion (dpy, 0, 0); + damage = XFixesCreateRegion (dpy, NULL, 0); XFixesCopyRegion (dpy, damage, w->extents); add_damage (dpy, damage); } @@ -1471,7 +1471,7 @@ add_win (Display *dpy, Window id, Window prev) new->opacity = OPAQUE; new->borderClip = None; - new->prev_trans = 0; + new->prev_trans = NULL; new->windowType = determine_wintype (dpy, new->id); @@ -1481,7 +1481,7 @@ add_win (Display *dpy, Window id, Window prev) map_win (dpy, id, new->damage_sequence - 1, True); } -void +static void restack_win (Display *dpy, win *w, Window new_above) { Window old_above; @@ -1535,7 +1535,7 @@ configure_win (Display *dpy, XConfigureEvent *ce) if (w->usable) #endif { - damage = XFixesCreateRegion (dpy, 0, 0); + damage = XFixesCreateRegion (dpy, NULL, 0); if (w->extents != None) XFixesCopyRegion (dpy, damage, w->extents); } @@ -1741,7 +1741,7 @@ static int error (Display *dpy, XErrorEvent *ev) { int o; - const char *name = 0; + const char *name = NULL; if (should_ignore (dpy, ev->serial)) return 0; @@ -1842,7 +1842,7 @@ ev_window (XEvent *ev) } #endif -void +static void usage (char *program) { fprintf (stderr, "%s v1.1.4\n", program); @@ -1894,13 +1894,13 @@ main (int argc, char **argv) unsigned int nchildren; int i; XRenderPictureAttributes pa; - XRectangle *expose_rects = 0; + XRectangle *expose_rects = NULL; int size_expose = 0; int n_expose = 0; struct pollfd ufd; int p; int composite_major, composite_minor; - char *display = 0; + char *display = NULL; int o; while ((o = getopt (argc, argv, "D:I:O:d:r:o:l:t:scnfFCaS")) != -1) @@ -2163,7 +2163,7 @@ main (int argc, char **argv) { if (fadeTrans) set_fade (dpy, w, w->opacity*1.0/OPAQUE, get_opacity_percent (dpy, w, 1.0), - fade_out_step, 0, False, True, False); + fade_out_step, NULL, False, True, False); else { w->opacity = get_opacity_prop(dpy, w, OPAQUE); -- cgit v1.2.3