aboutsummaryrefslogtreecommitdiffstats
path: root/matchbox/mb-wm-util.h
blob: aa8e5339a866defe2f20daefefb7f14d3d1338c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef _MB_HAVE_UTIL_H
#define _MB_HAVE_UTIL_H

#include <matchbox/mb-wm-config.h>
#include <matchbox/mb-wm-types.h>

/* See http://rlove.org/log/2005102601 */
#if __GNUC__ >= 3
#if ! USE_GLIB_MAINLOOP
# define inline __attribute__ ((always_inline))
#endif
# define __pure__attribute__ ((pure))
# define __const__attribute__ ((const))
# define __noreturn__attribute__ ((noreturn))
# define __malloc__attribute__ ((malloc))
# define __must_check__attribute__ ((warn_unused_result))
# define __deprecated__attribute__ ((deprecated))
# define __used__attribute__ ((used))
# define __unused__attribute__ ((unused))
# define __packed__attribute__ ((packed))
# define LIKELY(x)__builtin_expect (!!(x), 1)
# define UNLIKELY(x)__builtin_expect (!!(x), 0)
#else
# define inline/* no inline */
# define __pure/* no pure */
# define __const/* no const */
# define __noreturn/* no noreturn */
# define __malloc/* no malloc */
# define __must_check/* no warn_unused_result */
# define __deprecated/* no deprecated */
# define __used/* no used */
# define __unused/* no unused */
# define __packed/* no packed */
# define LIKELY(x)(x)
# define UNLIKELY(x)(x)
#endif

#define streq(a,b)      (strcmp(a,b) == 0)
#define strcaseeq(a,b)  (strcasecmp(a,b) == 0)
#define unless(x)       if (!(x))

#define MBWMChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
#define MBWMButtonMask (ButtonPressMask|ButtonReleaseMask)
#define MBWMMouseMask (ButtonMask|PointerMotionMask)
#define MBWMKeyMask (KeyPressMask|KeyReleaseMask)

void*
mb_wm_util_malloc0(int size);

void
mb_wm_util_fatal_error(char *msg);

void
mb_wm_util_warn (const char *format, ...);

/*  Misc */

Bool  /* True if matching */
mb_geometry_compare (MBGeometry *g1, MBGeometry *g2);

Bool  /* True if overlaps */
mb_geometry_intersects (MBGeometry *g1, MBGeometry *g2);

/* XErrors */

void
mb_wm_util_trap_x_errors(void);

int
mb_wm_util_untrap_x_errors(void);

MBWMRgbaIcon *
mb_wm_rgba_icon_new ();

void
mb_wm_rgba_icon_free (MBWMRgbaIcon *icon);

#endif