diff options
Diffstat (limited to 'uisimulator/x11/screenhack.c')
-rw-r--r-- | uisimulator/x11/screenhack.c | 236 |
1 files changed, 117 insertions, 119 deletions
diff --git a/uisimulator/x11/screenhack.c b/uisimulator/x11/screenhack.c index 75a7ed4d93..d7f21a60ce 100644 --- a/uisimulator/x11/screenhack.c +++ b/uisimulator/x11/screenhack.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #include <X11/keysym.h> | 41 | #include <X11/keysym.h> |
42 | 42 | ||
43 | #ifdef __sgi | 43 | #ifdef __sgi |
44 | # include <X11/SGIScheme.h> /* for SgiUseSchemes() */ | 44 | # include <X11/SGIScheme.h> /* for SgiUseSchemes() */ |
45 | #endif /* __sgi */ | 45 | #endif /* __sgi */ |
46 | 46 | ||
47 | #ifdef HAVE_XMU | 47 | #ifdef HAVE_XMU |
@@ -128,31 +128,31 @@ XtAppContext app; | |||
128 | Bool mono_p; | 128 | Bool mono_p; |
129 | 129 | ||
130 | static XrmOptionDescRec default_options [] = { | 130 | static XrmOptionDescRec default_options [] = { |
131 | { "-root", ".root", XrmoptionNoArg, "True" }, | 131 | { "-root", ".root", XrmoptionNoArg, "True" }, |
132 | { "-window", ".root", XrmoptionNoArg, "False" }, | 132 | { "-window", ".root", XrmoptionNoArg, "False" }, |
133 | { "-mono", ".mono", XrmoptionNoArg, "True" }, | 133 | { "-mono", ".mono", XrmoptionNoArg, "True" }, |
134 | { "-install", ".installColormap", XrmoptionNoArg, "True" }, | 134 | { "-install", ".installColormap", XrmoptionNoArg, "True" }, |
135 | { "-noinstall",".installColormap", XrmoptionNoArg, "False" }, | 135 | { "-noinstall", ".installColormap", XrmoptionNoArg, "False" }, |
136 | { "-visual", ".visualID", XrmoptionSepArg, 0 }, | 136 | { "-visual", ".visualID", XrmoptionSepArg, 0 }, |
137 | { "-window-id", ".windowID", XrmoptionSepArg, 0 }, | 137 | { "-window-id", ".windowID", XrmoptionSepArg, 0 }, |
138 | { 0, 0, 0, 0 } | 138 | { 0, 0, 0, 0 } |
139 | }; | 139 | }; |
140 | 140 | ||
141 | static char *default_defaults[] = { | 141 | static char *default_defaults[] = { |
142 | ".root: false", | 142 | ".root: false", |
143 | #define GEOMETRY_POSITION 1 | 143 | #define GEOMETRY_POSITION 1 |
144 | "*geometry: " | 144 | "*geometry: " |
145 | #ifdef HAVE_LCD_BITMAP | 145 | #ifdef HAVE_LCD_BITMAP |
146 | "120x68" | 146 | "120x68" |
147 | #else | 147 | #else |
148 | "280x132" /* A bit larger that necessary */ | 148 | "280x132" /* A bit larger that necessary */ |
149 | #endif | 149 | #endif |
150 | , /* this should be .geometry, but nooooo... */ | 150 | , /* this should be .geometry, but nooooo... */ |
151 | "*mono: false", | 151 | "*mono: false", |
152 | "*installColormap: false", | 152 | "*installColormap: false", |
153 | "*visualID: default", | 153 | "*visualID: default", |
154 | "*windowID: ", | 154 | "*windowID: ", |
155 | 0 | 155 | 0 |
156 | }; | 156 | }; |
157 | 157 | ||
158 | extern Display* dpy; | 158 | extern Display* dpy; |
@@ -261,71 +261,70 @@ int screenhack_handle_event(Display *dpy, XEvent *event, | |||
261 | *repeat = false; | 261 | *repeat = false; |
262 | 262 | ||
263 | switch (event->xany.type) { | 263 | switch (event->xany.type) { |
264 | case KeyPress: | 264 | case KeyPress: |
265 | { | 265 | { |
266 | KeySym keysym; | 266 | KeySym keysym; |
267 | unsigned char c = 0; | 267 | unsigned char c = 0; |
268 | XLookupString (&event->xkey, &c, 1, &keysym, 0); | 268 | XLookupString (&event->xkey, &c, 1, &keysym, 0); |
269 | key = keysym; | 269 | key = keysym; |
270 | #if 0 | 270 | #if 0 |
271 | DEBUGF("Got keypress: %02x %x, time %lx\n", c, | 271 | DEBUGF("Got keypress: %02x %x, time %lx\n", c, |
272 | event->xkey.keycode, | 272 | event->xkey.keycode, |
273 | event->xkey.time); | 273 | event->xkey.time); |
274 | #endif | 274 | #endif |
275 | if(lastkeycode == event->xkey.keycode) | 275 | if(lastkeycode == event->xkey.keycode) |
276 | *repeat = checkrepeat(lasttime, event->xkey.time); | 276 | *repeat = checkrepeat(lasttime, event->xkey.time); |
277 | lasttime = event->xkey.time; | 277 | lasttime = event->xkey.time; |
278 | lastkeycode = event->xkey.keycode; | 278 | lastkeycode = event->xkey.keycode; |
279 | } | 279 | } |
280 | break; | 280 | break; |
281 | case KeyRelease: | 281 | case KeyRelease: |
282 | { | 282 | { |
283 | KeySym keysym; | 283 | KeySym keysym; |
284 | unsigned char c = 0; | 284 | unsigned char c = 0; |
285 | XLookupString (&event->xkey, &c, 1, &keysym, 0); | 285 | XLookupString (&event->xkey, &c, 1, &keysym, 0); |
286 | key = keysym; | 286 | key = keysym; |
287 | #if 0 | 287 | #if 0 |
288 | DEBUGF("Got keyrelease: %c (%02x) %x\n", c, c, | 288 | DEBUGF("Got keyrelease: %c (%02x) %x\n", c, c, |
289 | event->xkey.keycode); | 289 | event->xkey.keycode); |
290 | #endif | 290 | #endif |
291 | if(lastkeycode == event->xkey.keycode) | 291 | if(lastkeycode == event->xkey.keycode) |
292 | *repeat = checkrepeat(lasttime, event->xkey.time); | 292 | *repeat = checkrepeat(lasttime, event->xkey.time); |
293 | lasttime = event->xkey.time; | 293 | lasttime = event->xkey.time; |
294 | lastkeycode = event->xkey.keycode; | 294 | lastkeycode = event->xkey.keycode; |
295 | if(*repeat) | 295 | if(*repeat) |
296 | return 0; /* on repeats, return nothing on release */ | 296 | return 0; /* on repeats, return nothing on release */ |
297 | 297 | ||
298 | *release = TRUE; | 298 | *release = TRUE; |
299 | } | 299 | } |
300 | break; | 300 | break; |
301 | case Expose: | 301 | case Expose: |
302 | { | 302 | screen_redraw(); |
303 | screen_redraw(); | 303 | break; |
304 | } | 304 | case ClientMessage: |
305 | break; | 305 | if (event->xclient.message_type != XA_WM_PROTOCOLS) { |
306 | default: | 306 | char *s = XGetAtomName(dpy, event->xclient.message_type); |
307 | break; | 307 | if (!s) |
308 | case ClientMessage: | 308 | s = "(null)"; |
309 | { | 309 | fprintf (stderr, "%s: unknown ClientMessage %s received!\n", |
310 | if (event->xclient.message_type != XA_WM_PROTOCOLS) { | 310 | progname, s); |
311 | char *s = XGetAtomName(dpy, event->xclient.message_type); | 311 | } |
312 | if (!s) s = "(null)"; | 312 | else if (event->xclient.data.l[0] != (int)XA_WM_DELETE_WINDOW) { |
313 | fprintf (stderr, "%s: unknown ClientMessage %s received!\n", | 313 | char *s1 = XGetAtomName(dpy, event->xclient.message_type); |
314 | progname, s); | 314 | char *s2 = XGetAtomName(dpy, event->xclient.data.l[0]); |
315 | } | 315 | if (!s1) |
316 | else if (event->xclient.data.l[0] != (int)XA_WM_DELETE_WINDOW) { | 316 | s1 = "(null)"; |
317 | char *s1 = XGetAtomName(dpy, event->xclient.message_type); | 317 | if (!s2) |
318 | char *s2 = XGetAtomName(dpy, event->xclient.data.l[0]); | 318 | s2 = "(null)"; |
319 | if (!s1) s1 = "(null)"; | 319 | fprintf (stderr, "%s: unknown ClientMessage %s[%s] received!\n", |
320 | if (!s2) s2 = "(null)"; | 320 | progname, s1, s2); |
321 | fprintf (stderr, "%s: unknown ClientMessage %s[%s] received!\n", | 321 | } |
322 | progname, s1, s2); | 322 | else { |
323 | } | 323 | exit (0); |
324 | else { | 324 | } |
325 | exit (0); | 325 | break; |
326 | } | 326 | default: |
327 | } | 327 | break; |
328 | break; | ||
329 | } | 328 | } |
330 | return key; | 329 | return key; |
331 | } | 330 | } |
@@ -344,8 +343,7 @@ int screenhack_handle_events(bool *release, bool *repeat) | |||
344 | } | 343 | } |
345 | 344 | ||
346 | 345 | ||
347 | static Visual * | 346 | static Visual *pick_visual (Screen *screen) |
348 | pick_visual (Screen *screen) | ||
349 | { | 347 | { |
350 | #ifdef USE_GL | 348 | #ifdef USE_GL |
351 | /* If we're linking against GL (that is, this is the version of | 349 | /* If we're linking against GL (that is, this is the version of |
@@ -367,7 +365,7 @@ pick_visual (Screen *screen) | |||
367 | !strcmp (string, "best") || | 365 | !strcmp (string, "best") || |
368 | !strcmp (string, "color") || | 366 | !strcmp (string, "color") || |
369 | !strcmp (string, "default")) | 367 | !strcmp (string, "default")) |
370 | v = get_gl_visual (screen); /* from ../utils/visual-gl.c */ | 368 | v = get_gl_visual (screen); /* from ../utils/visual-gl.c */ |
371 | 369 | ||
372 | if (string) | 370 | if (string) |
373 | free (string); | 371 | free (string); |
@@ -393,64 +391,64 @@ int main (int argc, char **argv) | |||
393 | #ifdef HAVE_LCD_BITMAP | 391 | #ifdef HAVE_LCD_BITMAP |
394 | display_zoom=2; | 392 | display_zoom=2; |
395 | { | 393 | { |
396 | char *env=getenv("RECORDER_ZOOM"); | 394 | char *env=getenv("RECORDER_ZOOM"); |
397 | if (env) { | 395 | if (env) { |
398 | display_zoom=atoi(env); | 396 | display_zoom=atoi(env); |
399 | } | 397 | } |
400 | } | 398 | } |
401 | #else | 399 | #else |
402 | display_zoom=1; | 400 | display_zoom=1; |
403 | { | 401 | { |
404 | char *env=getenv("PLAYER_ZOOM"); | 402 | char *env=getenv("PLAYER_ZOOM"); |
405 | if (env) { | 403 | if (env) { |
406 | display_zoom=atoi(env); | 404 | display_zoom=atoi(env); |
407 | } | 405 | } |
408 | } | 406 | } |
409 | #endif | 407 | #endif |
410 | 408 | ||
411 | if (argc > 1) | 409 | if (argc > 1) |
412 | { | 410 | { |
413 | int x; | 411 | int x; |
414 | for (x=1; x<argc; x++) { | 412 | for (x=1; x<argc; x++) { |
415 | if (!strcmp("--old_lcd", argv[x])) { | 413 | if (!strcmp("--old_lcd", argv[x])) { |
416 | having_new_lcd=FALSE; | 414 | having_new_lcd=FALSE; |
417 | printf("Using old LCD layout.\n"); | 415 | printf("Using old LCD layout.\n"); |
418 | } else if (!strcmp("--recorder_zoom", argv[x])) { | 416 | } else if (!strcmp("--recorder_zoom", argv[x])) { |
419 | x++; | 417 | x++; |
420 | #ifdef HAVE_LCD_BITMAP | 418 | #ifdef HAVE_LCD_BITMAP |
421 | display_zoom=atoi(argv[x]); | 419 | display_zoom=atoi(argv[x]); |
422 | printf("Window zoom is %d\n", display_zoom); | 420 | printf("Window zoom is %d\n", display_zoom); |
423 | #endif | 421 | #endif |
424 | } else if (!strcmp("--player_zoom", argv[x])) { | 422 | } else if (!strcmp("--player_zoom", argv[x])) { |
425 | x++; | 423 | x++; |
426 | #ifndef HAVE_LCD_BITMAP | 424 | #ifndef HAVE_LCD_BITMAP |
427 | display_zoom=atoi(argv[x]); | 425 | display_zoom=atoi(argv[x]); |
428 | printf("Window zoom is %d\n", display_zoom); | 426 | printf("Window zoom is %d\n", display_zoom); |
429 | #endif | 427 | #endif |
430 | } else { | 428 | } else { |
431 | printf("rockboxui\n"); | 429 | printf("rockboxui\n"); |
432 | printf("Arguments:\n"); | 430 | printf("Arguments:\n"); |
433 | printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); | 431 | printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n"); |
434 | printf(" --player_zoom \t [Player] window zoom\n"); | 432 | printf(" --player_zoom \t [Player] window zoom\n"); |
435 | printf(" --recorder_zoom \t [Recorder] window zoom\n"); | 433 | printf(" --recorder_zoom \t [Recorder] window zoom\n"); |
436 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); | 434 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); |
437 | exit(0); | 435 | exit(0); |
438 | } | 436 | } |
439 | } | 437 | } |
440 | } | 438 | } |
441 | { | 439 | { |
442 | static char geometry[40]; | 440 | static char geometry[40]; |
443 | #ifdef HAVE_LCD_BITMAP | 441 | #ifdef HAVE_LCD_BITMAP |
444 | snprintf(geometry, 40, "*geometry: %dx%d", | 442 | snprintf(geometry, 40, "*geometry: %dx%d", |
445 | LCD_WIDTH*display_zoom+14, LCD_HEIGHT*display_zoom+8); | 443 | LCD_WIDTH*display_zoom+14, LCD_HEIGHT*display_zoom+8); |
446 | #else | 444 | #else |
447 | snprintf(geometry, 40, "*geometry: %dx%d", 280*display_zoom, 132*display_zoom); | 445 | snprintf(geometry, 40, "*geometry: %dx%d", 280*display_zoom, |
446 | 132*display_zoom); | ||
448 | #endif | 447 | #endif |
449 | default_defaults[GEOMETRY_POSITION]=geometry; | 448 | default_defaults[GEOMETRY_POSITION]=geometry; |
450 | } | 449 | } |
451 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); | 450 | printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC); |
452 | 451 | ||
453 | |||
454 | merge_options (); | 452 | merge_options (); |
455 | 453 | ||
456 | #ifdef __sgi | 454 | #ifdef __sgi |