From ec9fd6bc0e7558c58e27692147f185bf5a596e2b Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 24 Feb 2017 19:36:08 -0800 Subject: vwm: split out helper macros into util.h In preparation for separating out the monitoring overlay code from being vwm-coupled, moving these into an independent header since they'll be used throughout. --- src/Makefile.am | 2 +- src/util.h | 21 +++++++++++++++++++++ src/vwm.h | 25 +++---------------------- 3 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 src/util.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index d345bbd..a65aa86 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = libvmon bin_PROGRAMS = vwm -vwm_SOURCES = clickety.c composite.c context.c desktop.c key.c launch.c logo.c overlay.c screen.c vwm.c window.c xevent.c xwindow.c clickety.h composite.h context.h desktop.h key.h launch.h list.h logo.h overlay.h screen.h vwm.h window.h xevent.h xwindow.h colors.def launchers.def +vwm_SOURCES = clickety.c composite.c context.c desktop.c key.c launch.c logo.c overlay.c screen.c vwm.c window.c xevent.c xwindow.c clickety.h composite.h context.h desktop.h key.h launch.h list.h logo.h overlay.h screen.h util.h vwm.h window.h xevent.h xwindow.h colors.def launchers.def vwm_LDADD = @VWM_LIBS@ libvmon/libvmon.a vwm_CPPFLAGS = @VWM_CFLAGS@ diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..9bd6a31 --- /dev/null +++ b/src/util.h @@ -0,0 +1,21 @@ +#ifndef _UTIL_H +#define _UTIL_H + +#include +#include + +#define VWM_ERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args) +#define VWM_PERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno)) +#define VWM_BUG(_fmt, _args...) fprintf(stderr, "BUG %s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno)) + +#ifdef TRACE +#define VWM_TRACE(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args) +#else +#define VWM_TRACE(_fmt, _args...) do { } while(0) +#endif + +#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b)) +#define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) +#define NELEMS(_a) (sizeof(_a) / sizeof(_a[0])) + +#endif diff --git a/src/vwm.h b/src/vwm.h index 6442faa..fb7ed65 100644 --- a/src/vwm.h +++ b/src/vwm.h @@ -1,15 +1,14 @@ -#ifndef _UTIL_H -#define _UTIL_H +#ifndef _VWM_H +#define _VWM_H -#include // #include // #include -#include #include #include #include "context.h" #include "list.h" +#include "util.h" #define WINDOW_BORDER_WIDTH 1 #define WM_GRAB_MODIFIER Mod1Mask /* the modifier for invoking vwm's controls */ @@ -23,24 +22,6 @@ #define CONSOLE_SESSION_STRING "_vwm_console.$DISPLAY" /* the unique console screen session identifier */ -#define VWM_ERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args) -#define VWM_PERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno)) -#define VWM_BUG(_fmt, _args...) fprintf(stderr, "BUG %s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno)) - -#ifdef TRACE -#define VWM_TRACE(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args) -#else -#define VWM_TRACE(_fmt, _args...) do { } while(0) -#endif - -#define VWM_XROOT(_vwm) RootWindow((_vwm)->display, (_vwm)->screen_num) -#define VWM_XVISUAL(_vwm) DefaultVisual((_vwm)->display, (_vwm)->screen_num) -#define VWM_XDEPTH(_vwm) DefaultDepth((_vwm)->display, (_vwm)->screen_num) - -#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b)) -#define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) -#define NELEMS(_a) (sizeof(_a) / sizeof(_a[0])) - typedef struct _vwm_window_t vwm_window_t; typedef struct _vwm_desktop_t vwm_desktop_t; -- cgit v1.2.3