9 #include "screenhackI.h"
14 #define PI 3.1415926535897932f
16 void drawXscreensaver();
19 int sWindowHeight = 0;
25 pthread_mutex_t mutg = PTHREAD_MUTEX_INITIALIZER;
27 extern struct xscreensaver_function_table *xscreensaver_function_table;
29 // if adding a table here, increase the magic number
30 struct xscreensaver_function_table
31 *hypertorus_xscreensaver_function_table,
32 *hilbert_xscreensaver_function_table,
33 *endgame_xscreensaver_function_table,
34 *stonerview_xscreensaver_function_table,
35 *sproingies_xscreensaver_function_table,
36 *blinkbox_xscreensaver_function_table,
37 *flipflop_xscreensaver_function_table,
38 *superquadrics_xscreensaver_function_table;
44 static XrmOptionDescRec default_options[] = {
45 {"-root", ".root", XrmoptionNoArg, "True"},
46 {"-window", ".root", XrmoptionNoArg, "False"},
47 {"-mono", ".mono", XrmoptionNoArg, "True"},
48 {"-install", ".installColormap", XrmoptionNoArg, "True"},
49 {"-noinstall", ".installColormap", XrmoptionNoArg, "False"},
50 {"-visual", ".visualID", XrmoptionSepArg, 0},
51 {"-window-id", ".windowID", XrmoptionSepArg, 0},
52 {"-fps", ".doFPS", XrmoptionNoArg, "True"},
53 {"-no-fps", ".doFPS", XrmoptionNoArg, "False"},
56 {"-pair", ".pair", XrmoptionNoArg, "True"},
57 #endif /* DEBUG_PAIR */
61 static char *default_defaults[] = {
63 "*geometry: 600x480", /* this should be .geometry, but nooooo... */
65 "*installColormap: false",
67 "*multiSample: false",
70 "*desktopGrabber: xscreensaver-getimage %s",
74 static XrmOptionDescRec *merged_options;
75 static int merged_options_size;
76 static char **merged_defaults;
80 struct xscreensaver_function_table *xsft;
87 const char *progclass;
90 struct running_hack rh[8];
91 // ^ magic number of hacks - TODO: remove magic number
101 JNIEXPORT void JNICALL
102 Java_org_jwz_xscreensaver_CallNative_nativeInit
104 JNIEXPORT void JNICALL
105 Java_org_jwz_xscreensaver_CallNative_nativeResize
106 (JNIEnv * env, jobject thiz, jint w, jint h);
107 JNIEXPORT void JNICALL
108 Java_org_jwz_xscreensaver_CallNative_nativeRender
110 JNIEXPORT void JNICALL
111 Java_org_jwz_xscreensaver_CallNative_nativeDone
113 JNIEXPORT void JNICALL
114 Java_org_jwz_xscreensaver_gen_SuperquadricsWallpaper_nativeSettings
115 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
117 JNIEXPORT void JNICALL
118 Java_org_jwz_xscreensaver_gen_StonerviewWallpaper_nativeSettings
119 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
121 JNIEXPORT void JNICALL
122 Java_org_jwz_xscreensaver_gen_SproingiesWallpaper_nativeSettings
123 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
125 JNIEXPORT void JNICALL
126 Java_org_jwz_xscreensaver_gen_HilbertWallpaper_nativeSettings
127 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
135 progname = "superquadrics";
136 rh[chosen].xsft = &superquadrics_xscreensaver_function_table;
137 //progname = "blinkbox";
138 //rh[chosen].xsft = &blinkbox_xscreensaver_function_table;
139 //progname = "flipflop";
140 //rh[chosen].xsft = &flipflop_xscreensaver_function_table;
141 //progname = "hypertorus";
142 //rh[chosen].xsft = &hypertorus_xscreensaver_function_table;
143 } else if (chosen == 1) {
144 progname = "stonerview";
145 rh[chosen].xsft = &stonerview_xscreensaver_function_table;
147 } else if (chosen == 2) {
148 progname = "sproingies";
149 rh[chosen].xsft = &sproingies_xscreensaver_function_table;
151 } else if (chosen == 3) {
152 progname = "hilbert";
153 rh[chosen].xsft = &hilbert_xscreensaver_function_table;
155 progname = "sproingies";
156 rh[chosen].xsft = &sproingies_xscreensaver_function_table;
159 rh[chosen].dpy = jwxyz_make_display(0, 0);
160 rh[chosen].window = XRootWindow(rh[chosen].dpy, 0);
161 // TODO: Zero looks right, but double-check that is the right number
163 progclass = rh[chosen].xsft->progclass;
165 if (rh[chosen].xsft->setup_cb)
166 rh[chosen].xsft->setup_cb(rh[chosen].xsft,
167 rh[chosen].xsft->setup_arg);
169 if (resetTried < 1) {
174 void *(*init_cb) (Display *, Window, void *) =
175 (void *(*)(Display *, Window, void *)) rh[chosen].xsft->init_cb;
178 init_cb(rh[chosen].dpy, rh[chosen].window,
179 rh[chosen].xsft->setup_arg);
184 JNIEXPORT void JNICALL
185 Java_org_jwz_xscreensaver_CallNative_nativeInit
191 if (!rh[chosen].dpy) {
194 rh[chosen].xsft->free_cb(rh[chosen].dpy, rh[chosen].window,
196 jwxyz_free_display(rh[chosen].dpy);
197 rh[chosen].dpy = NULL;
198 rh[chosen].window = NULL;
199 if (!rh[chosen].dpy) {
209 JNIEXPORT void JNICALL
210 Java_org_jwz_xscreensaver_CallNative_nativeResize
211 (JNIEnv * env, jobject thiz, jint w, jint h) {
216 if (!rh[chosen].dpy) {
220 jwxyz_window_resized(rh[chosen].dpy, rh[chosen].window, 0, 0, w, h, 0);
222 rh[chosen].xsft->reshape_cb(rh[chosen].dpy, rh[chosen].window,
223 rh[chosen].closure, w, h);
226 JNIEXPORT void JNICALL
227 Java_org_jwz_xscreensaver_CallNative_nativeRender
229 if (renderTried < 1) {
236 // TODO: Check Java side is calling this properly
237 JNIEXPORT void JNICALL
238 Java_org_jwz_xscreensaver_CallNative_nativeDone
241 rh[chosen].xsft->free_cb(rh[chosen].dpy, rh[chosen].window,
243 jwxyz_free_display(rh[chosen].dpy);
244 rh[chosen].dpy = NULL;
245 rh[chosen].window = NULL;
249 JNIEXPORT void JNICALL
250 Java_org_jwz_xscreensaver_gen_SuperquadricsWallpaper_nativeSettings
251 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
255 const char *chack = (*env)->GetStringUTFChars(env, hackPref, NULL);
256 char *hck = (char *) chack;
261 sq_speed = sscanf(hck, "%lf", &sqd);
262 setSuperquadricsSpeed(sqd);
268 JNIEXPORT void JNICALL
269 Java_org_jwz_xscreensaver_gen_StonerviewWallpaper_nativeSettings
270 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
274 const char *chack = (*env)->GetStringUTFChars(env, hackPref, NULL);
275 char *hck = (char *) chack;
278 setStonerviewTransparency(count);
286 JNIEXPORT void JNICALL
287 Java_org_jwz_xscreensaver_gen_SproingiesWallpaper_nativeSettings
288 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
292 const char *chack = (*env)->GetStringUTFChars(env, hackPref, NULL);
293 char *hck = (char *) chack;
296 setSproingiesCount(count);
302 JNIEXPORT void JNICALL
303 Java_org_jwz_xscreensaver_gen_HilbertWallpaper_nativeSettings
304 (JNIEnv * env, jobject thiz, jstring jhack, jstring hackPref,
306 const char *chack = (*env)->GetStringUTFChars(env, hackPref, NULL);
307 char *hck = (char *) chack;
316 void drawXscreensaver()
318 pthread_mutex_lock(&mutg);
319 rh[chosen].xsft->draw_cb(rh[chosen].dpy, rh[chosen].window,
321 pthread_mutex_unlock(&mutg);