From http://www.jwz.org/xscreensaver/xscreensaver-5.39.tar.gz
[xscreensaver] / hacks / screenhack.h
1 /* xscreensaver, Copyright (c) 1992-2015 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/Android world, we only define the prefixed symbol;
22    the un-prefixed symbol does not exist.
23  */
24 #ifdef HAVE_JWXYZ
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_JWXYZ) && !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 #ifdef HAVE_JWXYZ
44 # define SCREENHACK_VISUAL DEFAULT_VISUAL
45 #else /* !HAVE_JWXYZ */
46 # define SCREENHACK_VISUAL 0, 0
47 #endif /* !HAVE_JWXYZ */
48
49 #define XSCREENSAVER_MODULE_2(CLASS,NAME,PREFIX)                \
50   struct xscreensaver_function_table                            \
51          NAME ## _xscreensaver_function_table = {               \
52            CLASS,                                               \
53            PREFIX ## _defaults,                                 \
54            PREFIX ## _options,                                  \
55            xscreensaver_common_setup, 0,                        \
56            PREFIX ## _init,                                     \
57            PREFIX ## _draw,                                     \
58            PREFIX ## _reshape,                                  \
59            PREFIX ## _event,                                    \
60            PREFIX ## _free,                                     \
61            0, SCREENHACK_VISUAL };                                      \
62   XSCREENSAVER_LINK (NAME ## _xscreensaver_function_table)
63
64 #define XSCREENSAVER_MODULE(CLASS,PREFIX)                       \
65       XSCREENSAVER_MODULE_2(CLASS,PREFIX,PREFIX)
66
67 #endif /* __SCREENHACK_H__ */