http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / hacks / screenhack.h
1 /* xscreensaver, Copyright (c) 1992-2008 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 #ifndef __SCREENHACK_H__
13 #define __SCREENHACK_H__
14
15 #include "screenhackI.h"
16
17 /* In an Xlib world, we define two global symbols here:
18    a struct in `MODULENAME_xscreensaver_function_table',
19    and a pointer to that in `xscreensaver_function_table'.
20
21    In a Cocoa world, we only define the prefixed symbol;
22    the un-prefixed symbol does not exist.
23  */
24 #ifdef HAVE_COCOA
25 # define XSCREENSAVER_LINK(NAME)
26 #else
27 # define XSCREENSAVER_LINK(NAME) \
28    struct xscreensaver_function_table *xscreensaver_function_table = &NAME;
29 #endif
30
31
32 #if defined(HAVE_COCOA) && !defined(__XLOCKMORE_INTERNAL_H__)
33   /* this is one enormous kludge... */
34 # undef ya_rand_init
35   static void
36   xscreensaver_common_setup(struct xscreensaver_function_table *xsft, void *a)
37   { ya_rand_init(0); }
38 #else
39 # define xscreensaver_common_setup 0
40 #endif
41
42
43 #define XSCREENSAVER_MODULE_2(CLASS,NAME,PREFIX)                \
44   struct xscreensaver_function_table                            \
45          NAME ## _xscreensaver_function_table = {               \
46            CLASS,                                               \
47            PREFIX ## _defaults,                                 \
48            PREFIX ## _options,                                  \
49            xscreensaver_common_setup, 0,                        \
50            PREFIX ## _init,                                     \
51            PREFIX ## _draw,                                     \
52            PREFIX ## _reshape,                                  \
53            PREFIX ## _event,                                    \
54            PREFIX ## _free,                                     \
55            0, 0, 0 };                                           \
56   XSCREENSAVER_LINK (NAME ## _xscreensaver_function_table)
57
58 #define XSCREENSAVER_MODULE(CLASS,PREFIX)                       \
59       XSCREENSAVER_MODULE_2(CLASS,PREFIX,PREFIX)
60
61 #endif /* __SCREENHACK_H__ */