|
|
452870 |
#ifndef COMMON_H
|
|
|
452870 |
#define COMMON_H
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
#include <stdio.h></stdio.h>
|
|
|
452870 |
#include <stdlib.h></stdlib.h>
|
|
|
452870 |
#include <assert.h></assert.h>
|
|
|
452870 |
|
|
|
452870 |
#include <xcb xcb.h=""></xcb>
|
|
|
452870 |
#include <xcb xcb_atom.h=""></xcb>
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
#define LOG(stream, prefix, suffix, result, ...) \
|
|
|
452870 |
( fputs(prefix, stream), fprintf(stream, __VA_ARGS__), fputs(suffix, stream), fflush(stream), dummy(result) )
|
|
|
452870 |
|
|
|
452870 |
#ifdef NDEBUG
|
|
|
452870 |
#define LOGDBG(...) dummy(1)
|
|
|
452870 |
#else
|
|
|
452870 |
#define LOGDBG(...) LOG(stdout, "DEBUG: ", "\n", 1, __VA_ARGS__)
|
|
|
452870 |
#endif
|
|
|
452870 |
|
|
|
452870 |
#define LOGINF(...) LOG(stdout, "INFO: ", "\n", 1, __VA_ARGS__)
|
|
|
452870 |
#define LOGWRN(...) LOG(stderr, "WARNING: ", "\n", 1, __VA_ARGS__)
|
|
|
452870 |
#define LOGERR(...) LOG(stderr, "ERROR: ", "\n", 0, __VA_ARGS__)
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
struct App;
|
|
|
452870 |
typedef struct App App;
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
static inline int dummy(int i) { return i; }
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
static inline void rectIntersect(int *x, int *y, int *w, int *h, int xx, int yy, int ww, int hh) {
|
|
|
452870 |
if (*x < xx) *w += *x - xx, *x = xx;
|
|
|
452870 |
if (*y < yy) *h += *y - yy, *y = xx;
|
|
|
452870 |
ww += xx; hh += yy;
|
|
|
452870 |
if (*x + *w > ww) *w = ww - *x;
|
|
|
452870 |
if (*y + *h > hh) *h = hh - *y;
|
|
|
452870 |
}
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
static inline void rectMerge(int *x, int *y, int *w, int *h, int xx, int yy, int ww, int hh) {
|
|
|
452870 |
if (ww <= 0 || hh <= 0)
|
|
|
452870 |
return;
|
|
|
452870 |
if (*w <= 0 || *h <= 0)
|
|
|
452870 |
{ *x = xx, *y = yy, *w = ww, *h = hh; return; }
|
|
|
452870 |
if (*x > xx) *w += *x - xx, *x = xx;
|
|
|
452870 |
if (*x > xx) *h += *y - yy, *y = yy;
|
|
|
452870 |
ww += xx; hh += yy;
|
|
|
452870 |
if (*x + *w < ww) *w = ww - *x;
|
|
|
452870 |
if (*y + *h < hh) *h = hh - *y;
|
|
|
452870 |
}
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
|
|
|
452870 |
#endif
|