From 2ec2bf4760009a9fe280813f9bb898e319e868c9 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 29 Jul 2011 17:48:06 +0200 Subject: [PATCH] Barwin: Replace simple functions by macros --- src/barwin.c | 71 --------------------------------------------------- src/structs.h | 5 ++-- src/wmfs.h | 23 ++++++++++++----- 3 files changed, 18 insertions(+), 81 deletions(-) diff --git a/src/barwin.c b/src/barwin.c index bb7630e..f692030 100644 --- a/src/barwin.c +++ b/src/barwin.c @@ -156,67 +156,6 @@ barwin_delete(BarWindow *bw) return; } -/** Delete the BarWindow sub windows - * \param bw BarWindow pointer -*/ -void -barwin_delete_subwin(BarWindow *bw) -{ - XDestroySubwindows(dpy, bw->win); - - return; -} - -/** Map a BarWindow - * \param bw BarWindow pointer -*/ -void -barwin_map(BarWindow *bw) -{ - XMapWindow(dpy, bw->win); - - bw->flags |= MappedFlag; - - return; -} - - -/** Map the subwindows of a BarWindow - * Use for the BarWindow special border... - * \param bw BarWindow pointer - */ -void -barwin_map_subwin(BarWindow *bw) -{ - XMapSubwindows(dpy, bw->win); - - return; -} - -/** Unmap a BarWindow - * \param bw BarWindow pointer -*/ -void -barwin_unmap(BarWindow *bw) -{ - XUnmapWindow(dpy, bw->win); - - bw->flags &= ~MappedFlag; - - return; -} - -/** Unmap the BarWindow sub windows - * \param bw BarWindow pointer -*/ -void -barwin_unmap_subwin(BarWindow *bw) -{ - XUnmapSubwindows(dpy, bw->win); - - return; -} - /** Move a BarWindow * \param bw BarWindow pointer * \param x X position @@ -300,13 +239,3 @@ barwin_refresh_color(BarWindow *bw) return; } -/** Refresh the BarWindow - * \param bw BarWindow pointer -*/ -void -barwin_refresh(BarWindow *bw) -{ - XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->geo.width, bw->geo.height, 0, 0); - - return; -} diff --git a/src/structs.h b/src/structs.h index 2dcd96a..08bc8a5 100644 --- a/src/structs.h +++ b/src/structs.h @@ -291,13 +291,12 @@ typedef struct } Layout; /* Systray Structure */ -typedef struct Systray Systray; -struct Systray +typedef struct Systray { Window win; Geo geo; SLIST_ENTRY(Systray) next; -}; +} Systray; /* Tag Structure */ typedef struct diff --git a/src/wmfs.h b/src/wmfs.h index 12b3e96..4e3efdc 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -113,7 +113,6 @@ #define ATOM(a) XInternAtom(dpy, (a), False) #define FRAMEW(w) ((w) + (BORDH << 1)) #define FRAMEH(h) ((h) + (BORDH + TBARH)) -#define ROUND(x) (float)((x > 0) ? x + (float)0.5 : x - (float)0.5) #define CHECK(x) if(!(x)) return #define LEN(x) (sizeof(x) / sizeof((x)[0])) #define MAXCLIST (64) @@ -128,6 +127,22 @@ ? (p == Left ? (g1.x == g2.x) : (g1.x + g1.width == g2.x + g2.width)) \ : (p == Top ? (g1.y == g2.y) : (g1.y + g1.height == g2.y + g2.height))) \ +/* Barwin define, wrappers for simple function */ +#define barwin_delete_subwin(bw) XDestroySubwindows(dpy, bw->win) +#define barwin_map_subwin(bw) XMapSubwindows(dpy, bw->win) +#define barwin_unmap_subwin(bw) XUnmapSubwindows(dpy, bw->win) +#define barwin_refresh(bw) XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->geo.width, bw->geo.height, 0, 0) +#define barwin_map(bw) \ + do { \ + XMapWindow(dpy, bw->win); \ + bw->flags |= MappedFlag; \ + } while(/* CONSTCOND */ 0) +#define barwin_unmap(bw) \ + do { \ + XUnmapWindow(dpy, bw->win); \ + bw->flags &= ~MappedFlag; \ + } while(/* CONSTCOND */ 0) + /* barwin.c */ BarWindow *barwin_create(Window parent, int x, int y, @@ -139,15 +154,9 @@ BarWindow *barwin_create(Window parent, void barwin_draw_text(BarWindow *bw, int x, int y, char *text); void barwin_color_set(BarWindow *bw, uint bg, char *fg); void barwin_delete(BarWindow *bw); -void barwin_delete_subwin(BarWindow *bw); -void barwin_map(BarWindow *bw); -void barwin_map_subwin(BarWindow *bw); -void barwin_unmap(BarWindow *bw); -void barwin_unmap_subwin(BarWindow *bw); void barwin_move(BarWindow *bw, int x, int y); void barwin_resize(BarWindow *bw, int w, int h); void barwin_refresh_color(BarWindow *bw); -void barwin_refresh(BarWindow *bw); /* draw.c */ void draw_text(Drawable d, int x, int y, char* fg, char *str);