From 9f6733fcc802d3b0a3f64ff5f2745c83534d68ad Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 25 Mar 2002 14:21:30 +0000 Subject: [PATCH] Initial revision git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4 a1c6a512-1295-4272-9138-f99709370657 --- uisimulator/.depends | 11 + uisimulator/FILES | 8 + uisimulator/Makefile | 40 +++ uisimulator/alpha.c | 215 +++++++++++++++ uisimulator/alpha.h | 22 ++ uisimulator/colors.h | 140 ++++++++++ uisimulator/config.h | 362 ++++++++++++++++++++++++ uisimulator/grabscreen.h | 27 ++ uisimulator/guiclient.h | 6 + uisimulator/hsv.c | 81 ++++++ uisimulator/hsv.h | 27 ++ uisimulator/list.h | 38 +++ uisimulator/resources.c | 231 ++++++++++++++++ uisimulator/resources.h | 23 ++ uisimulator/rockboxui | Bin 0 -> 44204 bytes uisimulator/screenhack.c | 581 +++++++++++++++++++++++++++++++++++++++ uisimulator/screenhack.h | 102 +++++++ uisimulator/sourceheader | 18 ++ uisimulator/uibasic.c | 220 +++++++++++++++ uisimulator/usleep.c | 58 ++++ uisimulator/usleep.h | 20 ++ uisimulator/utils.h | 22 ++ uisimulator/version.h | 1 + uisimulator/visual.c | 544 ++++++++++++++++++++++++++++++++++++ uisimulator/visual.h | 29 ++ uisimulator/vroot.h | 126 +++++++++ uisimulator/xgui.log | 22 ++ uisimulator/xmu.h | 14 + uisimulator/yarandom.c | 115 ++++++++ uisimulator/yarandom.h | 64 +++++ 30 files changed, 3167 insertions(+) create mode 100644 uisimulator/.depends create mode 100644 uisimulator/FILES create mode 100644 uisimulator/Makefile create mode 100644 uisimulator/alpha.c create mode 100644 uisimulator/alpha.h create mode 100644 uisimulator/colors.h create mode 100644 uisimulator/config.h create mode 100644 uisimulator/grabscreen.h create mode 100644 uisimulator/guiclient.h create mode 100644 uisimulator/hsv.c create mode 100644 uisimulator/hsv.h create mode 100644 uisimulator/list.h create mode 100644 uisimulator/resources.c create mode 100644 uisimulator/resources.h create mode 100755 uisimulator/rockboxui create mode 100644 uisimulator/screenhack.c create mode 100644 uisimulator/screenhack.h create mode 100644 uisimulator/sourceheader create mode 100644 uisimulator/uibasic.c create mode 100644 uisimulator/usleep.c create mode 100644 uisimulator/usleep.h create mode 100644 uisimulator/utils.h create mode 100644 uisimulator/version.h create mode 100644 uisimulator/visual.c create mode 100644 uisimulator/visual.h create mode 100644 uisimulator/vroot.h create mode 100644 uisimulator/xgui.log create mode 100644 uisimulator/xmu.h create mode 100644 uisimulator/yarandom.c create mode 100644 uisimulator/yarandom.h diff --git a/uisimulator/.depends b/uisimulator/.depends new file mode 100644 index 0000000000..412d5508d2 --- /dev/null +++ b/uisimulator/.depends @@ -0,0 +1,11 @@ +alpha.o: alpha.c utils.h alpha.h visual.h hsv.h yarandom.h resources.h +hsv.o: hsv.c utils.h hsv.h +screenhack.o: screenhack.c xmu.h screenhack.h config.h yarandom.h \ + usleep.h resources.h hsv.h colors.h grabscreen.h visual.h version.h \ + vroot.h +yarandom.o: yarandom.c yarandom.h +uibasic.o: uibasic.c screenhack.h config.h yarandom.h usleep.h \ + resources.h hsv.h colors.h grabscreen.h visual.h alpha.h version.h +resources.o: resources.c utils.h resources.h +visual.o: visual.c utils.h resources.h visual.h +usleep.o: usleep.c diff --git a/uisimulator/FILES b/uisimulator/FILES new file mode 100644 index 0000000000..6baec58f84 --- /dev/null +++ b/uisimulator/FILES @@ -0,0 +1,8 @@ +*.c +*.cpp +*.h +Makefile +README +FILES +maketgz +CHANGES diff --git a/uisimulator/Makefile b/uisimulator/Makefile new file mode 100644 index 0000000000..eb478a6d6b --- /dev/null +++ b/uisimulator/Makefile @@ -0,0 +1,40 @@ +############################################################################## +# Rockbox UI simulator +############################################################################# + +TARGET = rockboxui + +CC = gcc +RM = rm + +CFLAGS = -g -O2 +CPPFLAGS = -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS +LDFLAGS = -lX11 -lm -lXt -lXmu -lsocket -lnsl + +DEPEND = .depends + +OBJS= alpha.o hsv.o screenhack.o yarandom.o uibasic.o resources.o visual.o\ + usleep.o + +SRCS = $(OBJS:%.o=%.c) +HDRS = $(OBJS:%.o=%.h) + +all: $(DEPEND) $(TARGET) + +clean: + $(RM) -f $(OBJS) *~ core $(TARGET) $(CLIENTS) $(DEPEND) + +distclean: clean + $(RM) config.cache + +.c.o: + $(CC) $(CPPFLAGS) $(CCFLAGS) -c $< + +$(DEPEND): + $(CC) -MM $(CFLAGS) $(SRCS) > $(DEPEND) + +$(TARGET): $(OBJS) + $(CC) -o $(TARGET) $(LDFLAGS) $(OBJS) + +# Dependencies +include $(DEPEND) diff --git a/uisimulator/alpha.c b/uisimulator/alpha.c new file mode 100644 index 0000000000..22504fcd93 --- /dev/null +++ b/uisimulator/alpha.c @@ -0,0 +1,215 @@ +/* xscreensaver, Copyright (c) 1992, 1995, 1996, 1997 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +/* Beauty is only skin deep, unless you've got an alpha channel. */ + + +#include "utils.h" +#include "alpha.h" +#include "visual.h" +#include "hsv.h" +#include "yarandom.h" +#include "resources.h" + +#include + +#ifndef countof +# define countof(x) (sizeof(*(x))/sizeof((x))) +#endif + + +/* I don't believe this fucking language doesn't have builtin exponentiation. + I further can't believe that the fucking ^ character means fucking XOR!! */ +static int +i_exp (int i, int j) +{ + int k = 1; + while (j--) k *= i; + return k; +} + + +static void +merge_colors (int argc, XColor **argv, XColor *into_color, int mask, + Bool additive_p) +{ + int j; + *into_color = *argv [0]; + into_color->pixel |= mask; + + for (j = 1; j < argc; j++) + { +# define SHORT_INC(x,y) (x = ((((x)+(y)) > 0xFFFF) ? 0xFFFF : ((x)+(y)))) +# define SHORT_DEC(x,y) (x = ((((x)-(y)) < 0) ? 0 : ((x)-(y)))) + if (additive_p) + { + SHORT_INC (into_color->red, argv[j]->red); + SHORT_INC (into_color->green, argv[j]->green); + SHORT_INC (into_color->blue, argv[j]->blue); + } + else + { + SHORT_DEC (into_color->red, argv[j]->red); + SHORT_DEC (into_color->green, argv[j]->green); + SHORT_DEC (into_color->blue, argv[j]->blue); + } +# undef SHORT_INC +# undef SHORT_DEC + } +} + +static void +permute_colors (XColor *pcolors, XColor *colors, + int count, + unsigned long *plane_masks, + Bool additive_p) +{ + int out = 0; + int max = i_exp (2, count); + if (count > 31) abort (); + for (out = 1; out < max; out++) + { + XColor *argv [32]; + int this_mask = 0; + int argc = 0; + int bit; + for (bit = 0; bit < 32; bit++) + if (out & (1< 1 && + !XAllocColorCells (dpy, cmap, False, plane_masks, nplanes, + base_pixel_ret, 1)) + nplanes--; + + return nplanes; +} + + +static void +initialize_transparency_colormap (Display *dpy, Colormap cmap, + int nplanes, + unsigned long base_pixel, + unsigned long *plane_masks, + XColor *colors, + Bool additive_p) +{ + int i; + int total_colors = i_exp (2, nplanes); + XColor *all_colors = (XColor *) calloc (total_colors, sizeof (XColor)); + + for (i = 0; i < nplanes; i++) + colors[i].pixel = base_pixel | plane_masks [i]; + permute_colors (colors, all_colors, nplanes, plane_masks, additive_p); + + /* clone the default background of the window into our "base" pixel */ + all_colors [total_colors - 1].pixel = + get_pixel_resource ("background", "Background", dpy, cmap); + XQueryColor (dpy, cmap, &all_colors [total_colors - 1]); + all_colors [total_colors - 1].pixel = base_pixel; + + for (i = 0; i < total_colors; i++) + all_colors[i].flags = DoRed|DoGreen|DoBlue; + XStoreColors (dpy, cmap, all_colors, total_colors); + XFree ((XPointer) all_colors); +} + + +Bool +allocate_alpha_colors (Screen *screen, Visual *visual, Colormap cmap, + int *nplanesP, Bool additive_p, + unsigned long **plane_masks, + unsigned long *base_pixelP) +{ + Display *dpy = DisplayOfScreen (screen); + XColor *colors; + int nplanes = *nplanesP; + int i; + + if (!has_writable_cells (screen, visual)) + cmap = 0; + + if (!cmap) /* A TrueColor visual, or similar. */ + { + int depth = visual_depth (screen, visual); + unsigned long masks; + XVisualInfo vi_in, *vi_out; + + /* Find out which bits the R, G, and B components actually occupy + on this visual. */ + vi_in.screen = screen_number (screen); + vi_in.visualid = XVisualIDFromVisual (visual); + vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, + &vi_in, &i); + if (! vi_out) abort (); + masks = vi_out[0].red_mask | vi_out[0].green_mask | vi_out[0].blue_mask; + XFree ((char *) vi_out); + + if (nplanes > depth) + nplanes = depth; + *nplanesP = nplanes; + *base_pixelP = 0; + *plane_masks = (unsigned long *) calloc(sizeof(unsigned long), nplanes); + + /* Pick the planar values randomly, but constrain them to fall within + the bit positions of the R, G, and B fields. */ + for (i = 0; i < nplanes; i++) + (*plane_masks)[i] = random() & masks; + + } + else /* A PseudoColor visual, or similar. */ + { + if (nplanes > 31) nplanes = 31; + *plane_masks = (unsigned long *) malloc(sizeof(unsigned long) * nplanes); + + nplanes = allocate_color_planes (dpy, cmap, nplanes, *plane_masks, + base_pixelP); + *nplanesP = nplanes; + + if (nplanes <= 1) + { + free(*plane_masks); + *plane_masks = 0; + return False; + } + + colors = (XColor *) calloc (nplanes, sizeof (XColor)); + for (i = 0; i < nplanes; i++) + { + /* pick the base colors. If we are in subtractive mode, pick higher + intensities. */ + hsv_to_rgb (random () % 360, + frand (1.0), + frand (0.5) + (additive_p ? 0.2 : 0.5), + &colors[i].red, + &colors[i].green, + &colors[i].blue); + } + initialize_transparency_colormap (dpy, cmap, nplanes, + *base_pixelP, *plane_masks, colors, + additive_p); + XFree ((XPointer) colors); + } + return True; +} diff --git a/uisimulator/alpha.h b/uisimulator/alpha.h new file mode 100644 index 0000000000..4ff99037b3 --- /dev/null +++ b/uisimulator/alpha.h @@ -0,0 +1,22 @@ +/* xscreensaver, Copyright (c) 1992, 1995, 1996, 1997 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __XSCREENSAVER_ALPHA_H__ +#define __XSCREENSAVER_ALPHA_H__ + +extern Bool allocate_alpha_colors (Screen *screen, Visual *visual, + Colormap cmap, + int *nplanesP, Bool additive_p, + unsigned long **plane_masks, + unsigned long *base_pixelP); + +#endif /* __XSCREENSAVER_ALPHA_H__ */ diff --git a/uisimulator/colors.h b/uisimulator/colors.h new file mode 100644 index 0000000000..61421cf5c3 --- /dev/null +++ b/uisimulator/colors.h @@ -0,0 +1,140 @@ +/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __COLORS_H__ +#define __COLORS_H__ + +/* Like XFreeColors, but works on `XColor *' instead of `unsigned long *' + */ +extern void free_colors (Display *, Colormap, XColor *, int ncolors); + + +/* Allocates writable, non-contiguous color cells. The number requested is + passed in *ncolorsP, and the number actually allocated is returned there. + (Unlike XAllocColorCells(), this will allocate as many as it can, instead + of failing if they can't all be allocated.) + */ +extern void allocate_writable_colors (Display *dpy, Colormap cmap, + unsigned long *pixels, int *ncolorsP); + + +/* Generates a sequence of colors evenly spaced between the given pair + of HSV coordinates. + + If closed_p is true, the colors will go from the first point to the + second then back to the first. + + If allocate_p is true, the colors will be allocated from the map; + if enough colors can't be allocated, we will try for less, and the + result will be returned to ncolorsP. + + If writable_p is true, writable color cells will be allocated; + otherwise, read-only cells will be allocated. + */ +extern void make_color_ramp (Display *dpy, Colormap cmap, + int h1, double s1, double v1, + int h2, double s2, double v2, + XColor *colors, int *ncolorsP, + Bool closed_p, + Bool allocate_p, + Bool writable_p); + +/* Generates a sequence of colors evenly spaced around the triangle + indicated by the thee HSV coordinates. + + If allocate_p is true, the colors will be allocated from the map; + if enough colors can't be allocated, we will try for less, and the + result will be returned to ncolorsP. + + If writable_p is true, writable color cells will be allocated; + otherwise, read-only cells will be allocated. + */ +extern void make_color_loop (Display *, Colormap, + int h1, double s1, double v1, + int h2, double s2, double v2, + int h3, double s3, double v3, + XColor *colors, int *ncolorsP, + Bool allocate_p, + Bool writable_p); + + +/* Allocates a hopefully-interesting colormap, which will be a closed loop + without any sudden transitions. + + If allocate_p is true, the colors will be allocated from the map; + if enough colors can't be allocated, we will try for less, and the + result will be returned to ncolorsP. An error message will be + printed on stderr (if verbose_p). + + If *writable_pP is true, writable color cells will be allocated; + otherwise, read-only cells will be allocated. If no writable cells + cannot be allocated, we will try to allocate unwritable cells + instead, and print a message on stderr to that effect (if verbose_p). + */ +extern void make_smooth_colormap (Display *dpy, Visual *visual, + Colormap cmap, + XColor *colors, int *ncolorsP, + Bool allocate_p, + Bool *writable_pP, + Bool verbose_p); + +/* Allocates a uniform colormap which touches each hue of the spectrum, + evenly spaced. The saturation and intensity are chosen randomly, but + will be high enough to be visible. + + If allocate_p is true, the colors will be allocated from the map; + if enough colors can't be allocated, we will try for less, and the + result will be returned to ncolorsP. An error message will be + printed on stderr (if verbose_p). + + If *writable_pP is true, writable color cells will be allocated; + otherwise, read-only cells will be allocated. If no writable cells + cannot be allocated, we will try to allocate unwritable cells + instead, and print a message on stderr to that effect (if verbose_p). + */ +extern void make_uniform_colormap (Display *dpy, Visual *visual, + Colormap cmap, + XColor *colors, int *ncolorsP, + Bool allocate_p, + Bool *writable_pP, + Bool verbose_p); + +/* Allocates a random colormap (the colors are unrelated to one another.) + If `bright_p' is false, the colors will be completely random; if it is + true, all of the colors will be bright enough to see on a black background. + + If allocate_p is true, the colors will be allocated from the map; + if enough colors can't be allocated, we will try for less, and the + result will be returned to ncolorsP. An error message will be + printed on stderr (if verbose_p). + + If *writable_pP is true, writable color cells will be allocated; + otherwise, read-only cells will be allocated. If no writable cells + cannot be allocated, we will try to allocate unwritable cells + instead, and print a message on stderr to that effect (if verbose_p). + */ +extern void make_random_colormap (Display *dpy, Visual *visual, + Colormap cmap, + XColor *colors, int *ncolorsP, + Bool bright_p, + Bool allocate_p, + Bool *writable_pP, + Bool verbose_p); + + +/* Assuming that the array of colors indicates the current state of a set + of writable color cells, this rotates the contents of the array by + `distance' steps, moving the colors of cell N to cell (N - distance). + */ +extern void rotate_colors (Display *, Colormap, + XColor *, int ncolors, int distance); + +#endif /* __COLORS_H__ */ diff --git a/uisimulator/config.h b/uisimulator/config.h new file mode 100644 index 0000000000..1c520cfbac --- /dev/null +++ b/uisimulator/config.h @@ -0,0 +1,362 @@ +/* config.h. Generated automatically by configure. */ +/* config.h.in --- xscreensaver, Copyright (c) 1998 Jamie Zawinski. + * + * The best way to set these parameters is by running the included `configure' + * script. That examines your system, and generates `config.h' from + * `config.h.in'. + * + * If something goes very wrong, you can edit `config.h' directly, but beware + * that your changes will be lost if you ever run `configure' again. + */ + + +/* ************************************************************************* + CONFIGURING SERVER EXTENSIONS + ************************************************************************* */ + +/* Define this if you have the XReadDisplay extension (I think this is an + SGI-only thing; it's in .) A few of the + screenhacks will take advantage of this if it's available. + */ +/* #undef HAVE_READ_DISPLAY_EXTENSION */ + +/* Define this if you have the Iris Video Library (dmedia/vl.h on SGI.) + A few of the screenhacks will take advantage of this if it's available. + */ +/* #undef HAVE_SGI_VIDEO */ + +/* Define this if you have the XHPDisableReset function (an HP only thing.) + */ +/* #undef HAVE_XHPDISABLERESET */ + +/* First, some background: there are three distinct server extensions which + * are useful to a screen saver program: they are XIDLE, MIT-SCREEN-SAVER, + * and SCREEN_SAVER. + * + * The XIDLE extension resides in .../contrib/extensions/xidle/ on the X11R5 + * contrib tape. This extension lets the client get accurate idle-time + * information from the X server in a potentially more reliable way than by + * simply watching for keyboard and mouse activity. However, the XIDLE + * extension has apparently not been ported to X11R6. + * + * The SCREEN_SAVER extension is found (as far as I know) only in the SGI + * X server, and it exists in all releases since (at least) Irix 5. The + * relevant header file is /usr/include/X11/extensions/XScreenSaver.h. + * + * The similarly-named MIT-SCREEN-SAVER extension came into existence long + * after the SGI SCREEN_SAVER extension was already in use, and resides in + * .../contrib/extensions/screensaver/ on the X11R6 contrib tape. It is + * also found in certain recent X servers built in to NCD X terminals. + * + * The MIT extension does basically the same thing that the XIDLE extension + * does, but there are two things wrong with it: first, because of the way + * the extension was designed, the `fade' option to XScreenSaver will be + * uglier: just before the screen fades out, there will be an unattractive + * flicker to black, because this extension blanks the screen *before* + * telling us that it is time to do so. Second, this extension is known to + * be buggy; on the systems I use, it works, but some people have reported + * X server crashes as a result of using it. XScreenSaver uses this + * extension rather conservatively, because when I tried to use any of its + * more complicated features, I could get it to crash the server at the + * drop of a hat. + * + * In short, the MIT-SCREEN-SAVER extension is a piece of junk. The older + * SGI SCREEN_SAVER extension works great, as does XIDLE. It would be nice + * If those two existed on more systems, that is, would be adopted by the + * X Consortium in favor of their inferior "not-invented-here" entry. + */ + +/* Define this if you have the XIDLE extension installed. If you have the + * XIDLE extension, this is recommended. (You have this extension if the + * file /usr/include/X11/extensions/xidle.h exists.) Turning on this flag + * lets XScreenSaver work better with servers which support this extension; + * but it will still work with servers which do not suport it, so it's a good + * idea to compile in support for it if you can. + */ +/* #undef HAVE_XIDLE_EXTENSION */ + +/* Define this if you have the MIT-SCREEN-SAVER extension installed. See the + * caveats about this extension, above. (It's available if the file + * /usr/include/X11/extensions/scrnsaver.h exists.) + */ +#define HAVE_MIT_SAVER_EXTENSION 1 + +/* Define this if you have the SGI SCREEN_SAVER extension. This is standard + * on Irix systems, and not available elsewhere. + */ +/* #undef HAVE_SGI_SAVER_EXTENSION */ + +/* Define this if you have the SGI-VIDEO-CONTROL extension. This is standard + * on Irix systems, and not available elsewhere. + */ +/* #undef HAVE_SGI_VC_EXTENSION */ + +/* Define this if you have the XDPMS extension. This is standard on + * sufficiently-recent XFree86 systems, and possibly elsewhere. (It's + * available if the file /usr/include/X11/extensions/dpms.h exists.) + */ +/* #undef HAVE_DPMS_EXTENSION */ + +/* Define this if you have the functions XF86VidModeGetModeLine() and + * XF86VidModeGetViewPort(), in support of virtual desktops where the + * X server's root window is bigger than the actual screen. This is + * an XFree86 thing, and probably doesn't exist elsewhere. (It's + * available if the file /usr/include/X11/extensions/xf86vmode.h exists.) + */ +/* #undef HAVE_XF86VMODE */ + +/* Define this if you have a Linux-like /proc/interrupts file which can be + * examined to determine when keyboard activity has occurred. + */ +/* #undef HAVE_PROC_INTERRUPTS */ + + + +/* ************************************************************************* + CONFIGURING GRAPHICS TOOLKITS + ************************************************************************* */ + +/* Define this if you have Motif. + */ +#define HAVE_MOTIF 1 + +/* Define this if you have Gtk. + */ +/* #undef HAVE_GTK */ + +/* Define this if you have Athena (-Xaw). + */ +#define HAVE_ATHENA 1 + +/* Define this if you have Athena, and the version you have includes the + * XawViewportSetCoordinates function in Viewport.h (some old versions of + * the library didn't have this function.) + */ +#define HAVE_XawViewportSetCoordinates 1 + +/* Define this if you have the XPM library installed. Some of the demos can + * make use of this if it is available. + */ +#define HAVE_XPM 1 + +/* Define this if you have the Xmu library. This is standard part of X, and + * if your vendor doesn't ship it, you should report that as a bug. + */ +#define HAVE_XMU 1 + +/* Define this if you have OpenGL. Some of the demos require it, so if you + * don't have it, then those particular demos won't be built. (This won't + * affect the screen saver as a whole.) + */ +/* #undef HAVE_GL */ + +/* Define this if you have OpenGL, but it's the MesaGL variant. (The + libraries have different names.) (HAVE_GL should be defined too.) + */ +/* #undef HAVE_MESA_GL */ + +/* Define this if your version of OpenGL has the glBindTexture() routine. + This is the case for OpenGL 1.1, but not for OpenGL 1.0. + */ +/* #undef HAVE_GLBINDTEXTURE */ + +/* Define this if you have the -lgle and -lmatrix libraries (GL extrusion.) + */ +/* #undef HAVE_GLE */ + +/* Define this if the `xscreensaver' process itself (the driver process) + should be linked against GL. Most systems won't want this (in particular, + if you're using Linux and/or Mesa, you don't want this) but SGI systems + do want this. It may also be useful on other systems that have serious + GL support -- you only need this if you have a lot of different visuals, + not all of which work with GL programs. + */ +/* #undef DAEMON_USE_GL */ + +/* Define this if you have the X Shared Memory Extension. + */ +#define HAVE_XSHM_EXTENSION 1 + +/* Define this if you have the X Double Buffer Extension. + */ +#define HAVE_DOUBLE_BUFFER_EXTENSION 1 + +/* Some screenhacks like to run an external program to generate random pieces + of text; set this to the one you like ("yow" and "fortune" are the most + likely prospects.) Note that this is just the default; X resources can + be used to override it. + */ +#define ZIPPY_PROGRAM "/usr/local/libexec/emacs/20.4/sparc-sun-solaris2.6/yow" + + + +/* ************************************************************************* + CONFIGURING PASSWORD AUTHENTICATION + ************************************************************************* */ + +/* Define this to remove the option of locking the screen at all. + */ +/* #undef NO_LOCKING */ + +/* Define this if you want to use Kerberos authentication to lock/unlock the + * screen instead of your local password. This currently uses Kerberos V4, + * but a V5 server with V4 compatibility will work. WARNING: DO NOT USE AFS + * string-to-key passwords with this option. This option currently *only* + * works with standard Kerberos des_string_to_key. If your password is an + * AFS password and not a kerberos password, it will not authenticate + * properly. See the comments in driver/kpasswd.c for more information if you + * need it. + */ +/* #undef HAVE_KERBEROS */ + +/* Define this if you want to use PAM (Pluggable Authentication Modules) + * to lock/unlock the screen, instead of standard /etc/passwd authentication. + */ +/* #undef HAVE_PAM */ + +/* If PAM is being used, this is the name of the PAM service that xscreensaver + * will authenticate as. The default is "xscreensaver", which means that the + * PAM library will look for an "xscreensaver" line in /etc/pam.conf, or (on + * recent Linux systems) will look for a file called /etc/pam.d/xscreensaver. + * Some systems might already have a PAM installation that is configured for + * xlock, so setting this to "xlock" would also work in that case. + */ +#define PAM_SERVICE_NAME "xscreensaver" + +/* Define if you have PAM and pam_strerror() requires two arguments. */ +/* #undef PAM_STRERROR_TWO_ARGS */ + +/* Define this if your system uses `shadow' passwords, that is, the passwords + * live in /etc/shadow instead of /etc/passwd, and one reads them with + * getspnam() instead of getpwnam(). (Note that SCO systems do some random + * other thing; others might as well. See the ifdefs in driver/passwd-pwent.c + * if you're having trouble related to reading passwords.) + */ +#define HAVE_SHADOW_PASSWD 1 + +/* Define this if your system is Digital or SCO Unix with so-called ``Enhanced + Security'', that is, the passwords live in /tcb/files/auth// + instead of in /etc/passwd, and one reads them with getprpwnam() instead + of getpwnam(). + */ +/* #undef HAVE_ENHANCED_PASSWD */ + +/* Define this if your system is Solaris with ``adjunct'' passwords (this is + the version where one gets at the passwords with getpwanam() instead of + getpwnam().) I haven't tested this one, let me know if it works. + */ +/* #undef HAVE_ADJUNCT_PASSWD */ + +/* Define this if you are running HPUX with so-called ``Secure Passwords'' + (if you have /usr/include/hpsecurity.h, you probably have this.) I + haven't tested this one, let me know if it works. + */ +/* #undef HAVE_HPUX_PASSWD */ + +/* Define this if you are on a system that supports the VT_LOCKSWITCH and + VT_UNLOCKSWITCH ioctls. If this is defined, then when the screen is + locked, switching to another virtual terminal will also be prevented. + That is, the whole console will be locked, rather than just the VT on + which X is running. (Well, that's the theory anyway -- in practice, + I haven't yet figured out how to make that work.) + */ +/* #undef HAVE_VT_LOCKSWITCH */ + + +/* Define this if you the openlog(), syslog(), and closelog() functions. + This is used for logging failed login attempts. + */ +#define HAVE_SYSLOG 1 + + +/* ************************************************************************* + OTHER C ENVIRONMENT JUNK + ************************************************************************* */ + +/* Define this to void* if you're using X11R4 or earlier. */ +/* #undef XPointer */ + +/* Define if you have the nice function. */ +#define HAVE_NICE 1 + +/* Define if you have the setpriority function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define to `int' if doesn't define. */ +/* #undef mode_t */ + +/* Define to `int' if doesn't define. */ +/* #undef pid_t */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define if you have the gettimeofday function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define if gettimeofday requires two arguments. */ +#define GETTIMEOFDAY_TWO_ARGS 1 + +/* Define if you have the putenv function. */ +#define HAVE_PUTENV 1 + +/* Define if you have the select function. */ +#define HAVE_SELECT 1 + +/* Define if you have the getcwd function. */ +#define HAVE_GETCWD 1 + +/* Define if you have the getcwd function. */ +#define HAVE_GETWD 1 + +/* Define if you have the realpath function. */ +#define HAVE_REALPATH 1 + +/* Define if you have the uname function. */ +#define HAVE_UNAME 1 + +/* Define if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if you have the header file. */ +#define HAVE_CRYPT_H 1 + +/* Define if you have that defines fd_set and FD_SET. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to use sigaction() instead of signal() for SIGCHLD-related activity. + This is necessary at least on SCO OpenServer 5, due to a Unix kernel bug. + */ +/* #undef USE_SIGACTION */ + +/* Define this if you do pings with a `struct icmp' and a `icmp_id' slot. + */ +#define HAVE_ICMP 1 + +/* Define this if you do pings with a `struct icmphdr' and a `un.echo.id' slot. + */ +/* #undef HAVE_ICMPHDR */ diff --git a/uisimulator/grabscreen.h b/uisimulator/grabscreen.h new file mode 100644 index 0000000000..6d2503a1fc --- /dev/null +++ b/uisimulator/grabscreen.h @@ -0,0 +1,27 @@ +/* xscreensaver, Copyright (c) 1992, 1993, 1994, 1997 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __GRABSCREEN_H__ +#define __GRABSCREEN_H__ + +/* This will write a snapshot of the screen image into the given window. + Beware that the colormap of the window may also be changed (to match + the bits that were drawn.) + */ +extern void grab_screen_image (Screen *, Window); + +/* Whether one should use GCSubwindowMode when drawing on this window + (assuming a screen image has been grabbed onto it.) Yes, this is a + total kludge. */ +extern Bool use_subwindow_mode_p(Screen *screen, Window window); + +#endif /* __GRABSCREEN_H__ */ diff --git a/uisimulator/guiclient.h b/uisimulator/guiclient.h new file mode 100644 index 0000000000..472e7fa3be --- /dev/null +++ b/uisimulator/guiclient.h @@ -0,0 +1,6 @@ +#ifndef GUICLIENT_H +#define GUICLIENT_H + +extern void drawline(int color, int x1, int y1, int x2, int y2); + +#endif diff --git a/uisimulator/hsv.c b/uisimulator/hsv.c new file mode 100644 index 0000000000..cf1cc8d18e --- /dev/null +++ b/uisimulator/hsv.c @@ -0,0 +1,81 @@ +/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +/* This file contains some utility routines for randomly picking the colors + to hack the screen with. + */ + +#include "utils.h" +#include "hsv.h" + +void +hsv_to_rgb (int h, double s, double v, + unsigned short *r, unsigned short *g, unsigned short *b) +{ + double H, S, V, R, G, B; + double p1, p2, p3; + double f; + int i; + + if (s < 0) s = 0; + if (v < 0) v = 0; + if (s > 1) s = 1; + if (v > 1) v = 1; + + S = s; V = v; + H = (h % 360) / 60.0; + i = H; + f = H - i; + p1 = V * (1 - S); + p2 = V * (1 - (S * f)); + p3 = V * (1 - (S * (1 - f))); + if (i == 0) { R = V; G = p3; B = p1; } + else if (i == 1) { R = p2; G = V; B = p1; } + else if (i == 2) { R = p1; G = V; B = p3; } + else if (i == 3) { R = p1; G = p2; B = V; } + else if (i == 4) { R = p3; G = p1; B = V; } + else { R = V; G = p1; B = p2; } + *r = R * 65535; + *g = G * 65535; + *b = B * 65535; +} + +void +rgb_to_hsv (unsigned short r, unsigned short g, unsigned short b, + int *h, double *s, double *v) +{ + double R, G, B, H, S, V; + double cmax, cmin; + double cmm; + int imax; + R = ((double) r) / 65535.0; + G = ((double) g) / 65535.0; + B = ((double) b) / 65535.0; + cmax = R; cmin = G; imax = 1; + if ( cmax < G ) { cmax = G; cmin = R; imax = 2; } + if ( cmax < B ) { cmax = B; imax = 3; } + if ( cmin > B ) { cmin = B; } + cmm = cmax - cmin; + V = cmax; + if (cmm == 0) + S = H = 0; + else + { + S = cmm / cmax; + if (imax == 1) H = (G - B) / cmm; + else if (imax == 2) H = 2.0 + (B - R) / cmm; + else /*if (imax == 3)*/ H = 4.0 + (R - G) / cmm; + if (H < 0) H += 6.0; + } + *h = (H * 60.0); + *s = S; + *v = V; +} diff --git a/uisimulator/hsv.h b/uisimulator/hsv.h new file mode 100644 index 0000000000..e0fdfb0fe6 --- /dev/null +++ b/uisimulator/hsv.h @@ -0,0 +1,27 @@ +/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __HSV_H__ +#define __HSV_H__ + +/* Converts between RGB and HSV color spaces. + R, G, and B are in the range 0 - 65535; + H is in the range 0 - 360; + S and V are in the range 0.0 - 1.0. + */ +extern void hsv_to_rgb (int h, double s, double v, + unsigned short *r, + unsigned short *g, + unsigned short *b); +extern void rgb_to_hsv (unsigned short r, unsigned short g, unsigned short b, + int *h, double *s, double *v); + +#endif /* __HSV_H__ */ diff --git a/uisimulator/list.h b/uisimulator/list.h new file mode 100644 index 0000000000..91a85869bc --- /dev/null +++ b/uisimulator/list.h @@ -0,0 +1,38 @@ +#ifndef LIST_H +#define LIST_H + + +class ListWalk { + public: + ListWalk(class List *list); + void restart(); + + void* getNext(); + + private: + int index; + class List *list; +}; + +class List { + friend ListWalk; + public: + List(); + + void* getNext(void *); // next after this + + int getSize(); + + bool add(void *); + void *remove(void *); + + private: + void **data; + int datasize; + + int size; + +}; + + +#endif // LIST_H diff --git a/uisimulator/resources.c b/uisimulator/resources.c new file mode 100644 index 0000000000..e0925d0fc7 --- /dev/null +++ b/uisimulator/resources.c @@ -0,0 +1,231 @@ +/* xscreensaver, Copyright (c) 1992, 1997, 1998 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#include "utils.h" +#include "resources.h" +#include + + +/* Resource functions. Assumes: */ + +extern char *progname; +extern char *progclass; +extern XrmDatabase db; + +static unsigned int get_time_resource (char *res_name, char *res_class, + Bool sec_p); + +#ifndef isupper +# define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#endif +#ifndef _tolower +# define _tolower(c) ((c) - 'A' + 'a') +#endif + +char * +get_string_resource (char *res_name, char *res_class) +{ + XrmValue value; + char *type; + char full_name [1024], full_class [1024]; + strcpy (full_name, progname); + strcat (full_name, "."); + strcat (full_name, res_name); + strcpy (full_class, progclass); + strcat (full_class, "."); + strcat (full_class, res_class); + if (XrmGetResource (db, full_name, full_class, &type, &value)) + { + char *str = (char *) malloc (value.size + 1); + strncpy (str, (char *) value.addr, value.size); + str [value.size] = 0; + return str; + } + return 0; +} + +Bool +get_boolean_resource (char *res_name, char *res_class) +{ + char *tmp, buf [100]; + char *s = get_string_resource (res_name, res_class); + char *os = s; + if (! s) return 0; + for (tmp = buf; *s; s++) + *tmp++ = isupper (*s) ? _tolower (*s) : *s; + *tmp = 0; + free (os); + + while (*buf && + (buf[strlen(buf)-1] == ' ' || + buf[strlen(buf)-1] == '\t')) + buf[strlen(buf)-1] = 0; + + if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes")) + return 1; + if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no")) + return 0; + fprintf (stderr, "%s: %s must be boolean, not %s.\n", + progname, res_name, buf); + return 0; +} + +int +get_integer_resource (char *res_name, char *res_class) +{ + int val; + char c, *s = get_string_resource (res_name, res_class); + char *ss = s; + if (!s) return 0; + + while (*ss && *ss <= ' ') ss++; /* skip whitespace */ + + if (ss[0] == '0' && (ss[1] == 'x' || ss[1] == 'X')) /* 0x: parse as hex */ + { + if (1 == sscanf (ss+2, "%x %c", &val, &c)) + { + free (s); + return val; + } + } + else /* else parse as dec */ + { + if (1 == sscanf (ss, "%d %c", &val, &c)) + { + free (s); + return val; + } + } + + fprintf (stderr, "%s: %s must be an integer, not %s.\n", + progname, res_name, s); + free (s); + return 0; +} + +double +get_float_resource (char *res_name, char *res_class) +{ + double val; + char c, *s = get_string_resource (res_name, res_class); + if (! s) return 0.0; + if (1 == sscanf (s, " %lf %c", &val, &c)) + { + free (s); + return val; + } + fprintf (stderr, "%s: %s must be a float, not %s.\n", + progname, res_name, s); + free (s); + return 0.0; +} + + +unsigned int +get_pixel_resource (char *res_name, char *res_class, + Display *dpy, Colormap cmap) +{ + XColor color; + char *s = get_string_resource (res_name, res_class); + char *s2; + if (!s) goto DEFAULT; + + for (s2 = s + strlen(s) - 1; s2 > s; s2--) + if (*s2 == ' ' || *s2 == '\t') + *s2 = 0; + else + break; + + if (! XParseColor (dpy, cmap, s, &color)) + { + fprintf (stderr, "%s: can't parse color %s\n", progname, s); + goto DEFAULT; + } + if (! XAllocColor (dpy, cmap, &color)) + { + fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s); + goto DEFAULT; + } + free (s); + return color.pixel; + DEFAULT: + if (s) free (s); + return ((strlen(res_class) >= 10 && + !strcmp ("Background", res_class + strlen(res_class) - 10)) + ? BlackPixel (dpy, DefaultScreen (dpy)) + : WhitePixel (dpy, DefaultScreen (dpy))); +} + + +int +parse_time (const char *string, Bool seconds_default_p, Bool silent_p) +{ + unsigned int h, m, s; + char c; + if (3 == sscanf (string, " %u : %2u : %2u %c", &h, &m, &s, &c)) + ; + else if (2 == sscanf (string, " : %2u : %2u %c", &m, &s, &c) || + 2 == sscanf (string, " %u : %2u %c", &m, &s, &c)) + h = 0; + else if (1 == sscanf (string, " : %2u %c", &s, &c)) + h = m = 0; + else if (1 == sscanf (string, " %u %c", + (seconds_default_p ? &s : &m), &c)) + { + h = 0; + if (seconds_default_p) m = 0; + else s = 0; + } + else + { + if (! silent_p) + fprintf (stderr, "%s: invalid time interval specification \"%s\".\n", + progname, string); + return -1; + } + if (s >= 60 && (h != 0 || m != 0)) + { + if (! silent_p) + fprintf (stderr, "%s: seconds > 59 in \"%s\".\n", progname, string); + return -1; + } + if (m >= 60 && h > 0) + { + if (! silent_p) + fprintf (stderr, "%s: minutes > 59 in \"%s\".\n", progname, string); + return -1; + } + return ((h * 60 * 60) + (m * 60) + s); +} + +static unsigned int +get_time_resource (char *res_name, char *res_class, Bool sec_p) +{ + int val; + char *s = get_string_resource (res_name, res_class); + if (!s) return 0; + val = parse_time (s, sec_p, False); + free (s); + return (val < 0 ? 0 : val); +} + +unsigned int +get_seconds_resource (char *res_name, char *res_class) +{ + return get_time_resource (res_name, res_class, True); +} + +unsigned int +get_minutes_resource (char *res_name, char *res_class) +{ + return get_time_resource (res_name, res_class, False); +} diff --git a/uisimulator/resources.h b/uisimulator/resources.h new file mode 100644 index 0000000000..1fbcfa7ce7 --- /dev/null +++ b/uisimulator/resources.h @@ -0,0 +1,23 @@ +/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __XSCREENSAVER_RESOURCES_H__ +#define __XSCREENSAVER_RESOURCES_H__ +extern char *get_string_resource (char*,char*); +extern Bool get_boolean_resource (char*,char*); +extern int get_integer_resource (char*,char*); +extern double get_float_resource (char*,char*); +extern unsigned int get_pixel_resource (char*,char*,Display*,Colormap); +extern unsigned int get_minutes_resource (char*,char*); +extern unsigned int get_seconds_resource (char*,char*); +extern int parse_time (const char *string, Bool seconds_default_p, + Bool silent_p); +#endif /* __XSCREENSAVER_RESOURCES_H__ */ diff --git a/uisimulator/rockboxui b/uisimulator/rockboxui new file mode 100755 index 0000000000000000000000000000000000000000..d0f71b64d62d3abd5b4ec1e3de3680e44b6bb770 GIT binary patch literal 44204 zcmeHwe|(fzmG_;=kObsoQ_8l~qJ0QZXoV0cZ7FSKAPIyvgg{c5R_tUlGfBoyW~MU} z2#Pkf(1KDoMOtaabxNz^E3ZZux2#fhfnZ39^J+J@XP?mpZxp;#xWktwL!D8MqLy|{11{Sn;H;9iS+EAB1x)=n|>dVoV`dtCU6f@vI||ibfVsi^Z@RMa4(U(6_UxBF8 zqk!+iy$W|4_dMKm)!=><_ZHksalaq;HMl>B`!l%B)dZj$_vcIo(vZMAk#-7vGtxNj zXL0Y5yu#!Y1sN&9t0moy^l98r;(iMEhj8D6o34aT`1ely-Y@uOq$_b>i#v(ikNYv) zAI41=`NfoL!I3>4O@bv<>Aq`sj0fB3+yeJuo;S43f@eh})g4#`phf?Lb%Ao}K1WJK>DFI$eDRAl+ z!pkTHPVtKHa!O@hA$+37x3p3Ue3IbX1b>&{6kn-)GUGBQ0bKrhKb%KiNs;LjQ5dXL|_!pJEQ?{u2C2$UjK*fzi??+dLO_($b)r%=h6sc_T<#$J#|MDy ziT1j?lxQt0<6*PUrJVu_T07Uher@@JImgY&>=NXidEzx`JEx6s}Z z4Aa9>K8W@>R{4*CpSAFxDOdMg$lE0JzeRbIRsIKz_g0j9ba}}n<=VU*w#^+cMJW^D5v&I`$|3l{%BtgZ$>%nlEd48_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Q2=b~|R{|lW{1Oxy8 literal 0 HcmV?d00001 diff --git a/uisimulator/screenhack.c b/uisimulator/screenhack.c new file mode 100644 index 0000000000..538400944e --- /dev/null +++ b/uisimulator/screenhack.c @@ -0,0 +1,581 @@ +/* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * And remember: X Windows is to graphics hacking as roman numerals are to + * the square root of pi. + */ + +/* This file contains simple code to open a window or draw on the root. + The idea being that, when writing a graphics hack, you can just link + with this .o to get all of the uninteresting junk out of the way. + + - create a procedure `screenhack(dpy, window)' + + - create a variable `char *progclass' which names this program's + resource class. + + - create a variable `char defaults []' for the default resources, and + null-terminate it. + + - create a variable `XrmOptionDescRec options[]' for the command-line, + and null-terminate it. + + And that's it... + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __sgi +# include /* for SgiUseSchemes() */ +#endif /* __sgi */ + +#ifdef HAVE_XMU +# ifndef VMS +# include +# else /* VMS */ +# include +# endif +#else +# include "xmu.h" +#endif +#include "screenhack.h" +#include "version.h" +#include "vroot.h" + +#ifndef isupper +# define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#endif +#ifndef _tolower +# define _tolower(c) ((c) - 'A' + 'a') +#endif + + +char *progname; +XrmDatabase db; +XtAppContext app; +Bool mono_p; + +static XrmOptionDescRec default_options [] = { + { "-root", ".root", XrmoptionNoArg, "True" }, + { "-window", ".root", XrmoptionNoArg, "False" }, + { "-mono", ".mono", XrmoptionNoArg, "True" }, + { "-install", ".installColormap", XrmoptionNoArg, "True" }, + { "-noinstall",".installColormap", XrmoptionNoArg, "False" }, + { "-visual", ".visualID", XrmoptionSepArg, 0 }, + { "-window-id", ".windowID", XrmoptionSepArg, 0 }, + { 0, 0, 0, 0 } +}; + +static char *default_defaults[] = { + ".root: false", + "*geometry: 100x200", /* this should be .geometry, but nooooo... */ + "*mono: false", + "*installColormap: false", + "*visualID: default", + "*windowID: ", + 0 +}; + +static XrmOptionDescRec *merged_options; +static int merged_options_size; +static char **merged_defaults; + +static void +merge_options (void) +{ + int def_opts_size, opts_size; + int def_defaults_size, defaults_size; + + for (def_opts_size = 0; default_options[def_opts_size].option; + def_opts_size++) + ; + for (opts_size = 0; options[opts_size].option; opts_size++) + ; + + merged_options_size = def_opts_size + opts_size; + merged_options = (XrmOptionDescRec *) + malloc ((merged_options_size + 1) * sizeof(*default_options)); + memcpy (merged_options, default_options, + (def_opts_size * sizeof(*default_options))); + memcpy (merged_options + def_opts_size, options, + ((opts_size + 1) * sizeof(*default_options))); + + for (def_defaults_size = 0; default_defaults[def_defaults_size]; + def_defaults_size++) + ; + for (defaults_size = 0; defaults[defaults_size]; defaults_size++) + ; + merged_defaults = (char **) + malloc ((def_defaults_size + defaults_size + 1) * sizeof (*defaults));; + memcpy (merged_defaults, default_defaults, + def_defaults_size * sizeof(*defaults)); + memcpy (merged_defaults + def_defaults_size, defaults, + (defaults_size + 1) * sizeof(*defaults)); + + /* This totally sucks. Xt should behave like this by default. + If the string in `defaults' looks like ".foo", change that + to "Progclass.foo". + */ + { + char **s; + for (s = merged_defaults; *s; s++) + if (**s == '.') + { + const char *oldr = *s; + char *newr = (char *) malloc(strlen(oldr) + strlen(progclass) + 3); + strcpy (newr, progclass); + strcat (newr, oldr); + *s = newr; + } + } +} + + +/* Make the X errors print out the name of this program, so we have some + clue which one has a bug when they die under the screensaver. + */ + +static int +screenhack_ehandler (Display *dpy, XErrorEvent *error) +{ + fprintf (stderr, "\nX error in %s:\n", progname); + if (XmuPrintDefaultErrorMessage (dpy, error, stderr)) + exit (-1); + else + fprintf (stderr, " (nonfatal.)\n"); + return 0; +} + +static Bool +MapNotify_event_p (Display *dpy, XEvent *event, XPointer window) +{ + return (event->xany.type == MapNotify && + event->xvisibility.window == (Window) window); +} + + +#ifdef XLOCKMORE +extern void pre_merge_options (void); +#endif + + +static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW; + +/* Dead-trivial event handling: exits if "q" or "ESC" are typed. + Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received. + */ +void +screenhack_handle_event (Display *dpy, XEvent *event) +{ + switch (event->xany.type) + { + case KeyPress: + { + KeySym keysym; + unsigned char c = 0; + XLookupString (&event->xkey, &c, 1, &keysym, 0); + if (c == 'q' || + c == 'Q' || + c == 3 || /* ^C */ + c == 27) /* ESC */ + exit (0); + else if (! (keysym >= XK_Shift_L && keysym <= XK_Hyper_R)) + XBell (dpy, 0); /* beep for non-chord keys */ + + fprintf(stderr, "KEY PRESSED: %c (%02x)\n", c, c); + } + break; + case ResizeRequest: + screen_resized(event->xresizerequest.width, event->xresizerequest.height); + screen_redraw(); + fprintf(stderr, "WINDOW RESIZED to width %d height %d\n", + event->xresizerequest.width, event->xresizerequest.height); + break; + default: + fprintf(stderr, "EVENT: %d (see /usr/include/X11/X.h)\n", + event->xany.type); + break; + case Expose: + screen_redraw(); + fprintf(stderr, "EXPOSE: x: %d y: %d width: %d height: %d\n", + event->xexpose.x, event->xexpose.y, + event->xexpose.width, event->xexpose.height); + break; + case ButtonPress: + fprintf(stderr, "BUTTON PRESSED\n"); + break; + case ClientMessage: + { + if (event->xclient.message_type != XA_WM_PROTOCOLS) + { + char *s = XGetAtomName(dpy, event->xclient.message_type); + if (!s) s = "(null)"; + fprintf (stderr, "%s: unknown ClientMessage %s received!\n", + progname, s); + } + else if (event->xclient.data.l[0] != XA_WM_DELETE_WINDOW) + { + char *s1 = XGetAtomName(dpy, event->xclient.message_type); + char *s2 = XGetAtomName(dpy, event->xclient.data.l[0]); + if (!s1) s1 = "(null)"; + if (!s2) s2 = "(null)"; + fprintf (stderr, "%s: unknown ClientMessage %s[%s] received!\n", + progname, s1, s2); + } + else + { + exit (0); + } + } + break; + } +} + + +void +screenhack_handle_events (Display *dpy) +{ + while (XPending (dpy)) + { + XEvent event; + XNextEvent (dpy, &event); + screenhack_handle_event (dpy, &event); + } +} + + +static Visual * +pick_visual (Screen *screen) +{ +#ifdef USE_GL + /* If we're linking against GL (that is, this is the version of screenhack.o + that the GL hacks will use, which is different from the one that the + non-GL hacks will use) then try to pick the "best" visual by interrogating + the GL library instead of by asking Xlib. GL knows better. + */ + Visual *v = 0; + char *string = get_string_resource ("visualID", "VisualID"); + char *s; + + if (string) + for (s = string; *s; s++) + if (isupper (*s)) *s = _tolower (*s); + + if (!string || !*string || + !strcmp (string, "gl") || + !strcmp (string, "best") || + !strcmp (string, "color") || + !strcmp (string, "default")) + v = get_gl_visual (screen); /* from ../utils/visual-gl.c */ + + if (string) + free (string); + if (v) + return v; +#endif /* USE_GL */ + + return get_visual_resource (screen, "visualID", "VisualID", False); +} + + +/* Notice when the user has requested a different visual or colormap + on a pre-existing window (e.g., "-root -visual truecolor" or + "-window-id 0x2c00001 -install") and complain, since when drawing + on an existing window, we have no choice about these things. + */ +static void +visual_warning (Screen *screen, Window window, Visual *visual, Colormap cmap, + Bool window_p) +{ + char *visual_string = get_string_resource ("visualID", "VisualID"); + Visual *desired_visual = pick_visual (screen); + char win[100]; + char why[100]; + + if (window == RootWindowOfScreen (screen)) + strcpy (win, "root window"); + else + sprintf (win, "window 0x%x", (unsigned long) window); + + if (window_p) + sprintf (why, "-window-id 0x%x", (unsigned long) window); + else + strcpy (why, "-root"); + + if (visual_string && *visual_string) + { + char *s; + for (s = visual_string; *s; s++) + if (isupper (*s)) *s = _tolower (*s); + + if (!strcmp (visual_string, "default") || + !strcmp (visual_string, "default") || + !strcmp (visual_string, "best")) + /* don't warn about these, just silently DWIM. */ + ; + else if (visual != desired_visual) + { + fprintf (stderr, "%s: ignoring `-visual %s' because of `%s'.\n", + progname, visual_string, why); + fprintf (stderr, "%s: using %s's visual 0x%x.\n", + progname, win, XVisualIDFromVisual (visual)); + } + free (visual_string); + } + + if (visual == DefaultVisualOfScreen (screen) && + has_writable_cells (screen, visual) && + get_boolean_resource ("installColormap", "InstallColormap")) + { + fprintf (stderr, "%s: ignoring `-install' because of `%s'.\n", + progname, why); + fprintf (stderr, "%s: using %s's colormap 0x%x.\n", + progname, win, (unsigned long) cmap); + } +} + + +int +main (int argc, char **argv) +{ + Widget toplevel; + Display *dpy; + Window window; + Screen *screen; + Visual *visual; + Colormap cmap; + Bool root_p; + Window on_window = 0; + XEvent event; + Boolean dont_clear /*, dont_map */; + char version[255]; + +#ifdef XLOCKMORE + pre_merge_options (); +#endif + merge_options (); + +#ifdef __sgi + /* We have to do this on SGI to prevent the background color from being + overridden by the current desktop color scheme (we'd like our backgrounds + to be black, thanks.) This should be the same as setting the + "*useSchemes: none" resource, but it's not -- if that resource is + present in the `default_defaults' above, it doesn't work, though it + does work when passed as an -xrm arg on the command line. So screw it, + turn them off from C instead. + */ + SgiUseSchemes ("none"); +#endif /* __sgi */ + + toplevel = XtAppInitialize (&app, progclass, merged_options, + merged_options_size, &argc, argv, + merged_defaults, 0, 0); + dpy = XtDisplay (toplevel); + screen = XtScreen (toplevel); + db = XtDatabase (dpy); + + XtGetApplicationNameAndClass (dpy, &progname, &progclass); + + /* half-assed way of avoiding buffer-overrun attacks. */ + if (strlen (progname) >= 100) progname[100] = 0; + + XSetErrorHandler (screenhack_ehandler); + + XA_WM_PROTOCOLS = XInternAtom (dpy, "WM_PROTOCOLS", False); + XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False); + + + if (argc > 1) + { + const char *s; + int i; + int x = 18; + int end = 78; + Bool help_p = !strcmp(argv[1], "-help"); + fprintf (stderr, "%s\n", version); + for (s = progclass; *s; s++) fprintf(stderr, " "); + fprintf (stderr, " eXcellent GUI\n\n"); + + if (!help_p) + fprintf(stderr, "Unrecognised option: %s\n", argv[1]); + fprintf (stderr, "Options include: "); + for (i = 0; i < merged_options_size; i++) + { + char *sw = merged_options [i].option; + Bool argp = (merged_options [i].argKind == XrmoptionSepArg); + int size = strlen (sw) + (argp ? 6 : 0) + 2; + if (x + size >= end) + { + fprintf (stderr, "\n\t\t "); + x = 18; + } + x += size; + fprintf (stderr, "%s", sw); + if (argp) fprintf (stderr, " "); + if (i != merged_options_size - 1) fprintf (stderr, ", "); + } + fprintf (stderr, ".\n"); + exit (help_p ? 0 : 1); + } + + dont_clear = get_boolean_resource ("dontClearRoot", "Boolean"); +/*dont_map = get_boolean_resource ("dontMapWindow", "Boolean"); */ + mono_p = get_boolean_resource ("mono", "Boolean"); + if (CellsOfScreen (DefaultScreenOfDisplay (dpy)) <= 2) + mono_p = True; + + root_p = get_boolean_resource ("root", "Boolean"); + + { + char *s = get_string_resource ("windowID", "WindowID"); + if (s && *s) + on_window = get_integer_resource ("windowID", "WindowID"); + if (s) free (s); + } + + if (on_window) + { + XWindowAttributes xgwa; + window = (Window) on_window; + XtDestroyWidget (toplevel); + XGetWindowAttributes (dpy, window, &xgwa); + cmap = xgwa.colormap; + visual = xgwa.visual; + visual_warning (screen, window, visual, cmap, True); + } + else if (root_p) + { + XWindowAttributes xgwa; + window = RootWindowOfScreen (XtScreen (toplevel)); + XtDestroyWidget (toplevel); + XGetWindowAttributes (dpy, window, &xgwa); + cmap = xgwa.colormap; + visual = xgwa.visual; + visual_warning (screen, window, visual, cmap, False); + } + else + { + Boolean def_visual_p; + visual = pick_visual (screen); + + if (toplevel->core.width <= 0) + toplevel->core.width = 600; + if (toplevel->core.height <= 0) + toplevel->core.height = 480; + + def_visual_p = (visual == DefaultVisualOfScreen (screen)); + + if (!def_visual_p) + { + unsigned int bg, bd; + Widget new; + + cmap = XCreateColormap (dpy, RootWindowOfScreen(screen), + visual, AllocNone); + bg = get_pixel_resource ("background", "Background", dpy, cmap); + bd = get_pixel_resource ("borderColor", "Foreground", dpy, cmap); + + new = XtVaAppCreateShell (progname, progclass, + topLevelShellWidgetClass, dpy, + XtNmappedWhenManaged, False, + XtNvisual, visual, + XtNdepth, visual_depth (screen, visual), + XtNwidth, toplevel->core.width, + XtNheight, toplevel->core.height, + XtNcolormap, cmap, + XtNbackground, (Pixel) bg, + XtNborderColor, (Pixel) bd, + XtNinput, True, /* for WM_HINTS */ + 0); + XtDestroyWidget (toplevel); + toplevel = new; + XtRealizeWidget (toplevel); + window = XtWindow (toplevel); + } + else + { + XtVaSetValues (toplevel, + XtNmappedWhenManaged, False, + XtNinput, True, /* for WM_HINTS */ + 0); + XtRealizeWidget (toplevel); + window = XtWindow (toplevel); + + if (get_boolean_resource ("installColormap", "InstallColormap")) + { + cmap = XCreateColormap (dpy, window, + DefaultVisualOfScreen (XtScreen (toplevel)), + AllocNone); + XSetWindowColormap (dpy, window, cmap); + } + else + { + cmap = DefaultColormap (dpy, DefaultScreen (dpy)); + } + } + +/* + if (dont_map) + { + XtVaSetValues (toplevel, XtNmappedWhenManaged, False, 0); + XtRealizeWidget (toplevel); + } + else +*/ + { + XtPopup (toplevel, XtGrabNone); + } + + XtVaSetValues(toplevel, XtNtitle, version, 0); + + /* For screenhack_handle_events(): select KeyPress, and + announce that we accept WM_DELETE_WINDOW. */ + { + XWindowAttributes xgwa; + XGetWindowAttributes (dpy, window, &xgwa); + XSelectInput (dpy, window, + xgwa.your_event_mask | KeyPressMask | ButtonPressMask | ResizeRedirectMask | ExposureMask); + XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32, + PropModeReplace, + (unsigned char *) &XA_WM_DELETE_WINDOW, 1); + } + } + + if (!dont_clear) + { + XSetWindowBackground (dpy, window, + get_pixel_resource ("background", "Background", + dpy, cmap)); + XClearWindow (dpy, window); + } + + if (!root_p && !on_window) + /* wait for it to be mapped */ + XIfEvent (dpy, &event, MapNotify_event_p, (XPointer) window); + + XSync (dpy, False); + + /* This is the one and only place that the random-number generator is + seeded in any screenhack. You do not need to seed the RNG again, + it is done for you before your code is invoked. */ +# undef ya_rand_init + ya_rand_init ((int) time ((time_t *) 0)); + + screenhack (dpy, window); /* doesn't return */ + return 0; +} diff --git a/uisimulator/screenhack.h b/uisimulator/screenhack.h new file mode 100644 index 0000000000..761b244bec --- /dev/null +++ b/uisimulator/screenhack.h @@ -0,0 +1,102 @@ +/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +/* Found in Don Hopkins' .plan file: + * + * The color situation is a total flying circus. The X approach to + * device independence is to treat everything like a MicroVax framebuffer + * on acid. A truely portable X application is required to act like the + * persistent customer in the Monty Python ``Cheese Shop'' sketch. Even + * the simplest applications must answer many difficult questions, like: + * + * WHAT IS YOUR DISPLAY? + * display = XOpenDisplay("unix:0"); + * WHAT IS YOUR ROOT? + * root = RootWindow(display, DefaultScreen(display)); + * AND WHAT IS YOUR WINDOW? + * win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1, + * BlackPixel(display, DefaultScreen(display)), + * WhitePixel(display, DefaultScreen(display))) + * OH ALL RIGHT, YOU CAN GO ON. + * + * WHAT IS YOUR DISPLAY? + * display = XOpenDisplay("unix:0"); + * WHAT IS YOUR COLORMAP? + * cmap = DefaultColormap(display, DefaultScreen(display)); + * AND WHAT IS YOUR FAVORITE COLOR? + * favorite_color = 0; / * Black. * / + * / * Whoops! No, I mean: * / + * favorite_color = BlackPixel(display, DefaultScreen(display)); + * / * AAAYYYYEEEEE!! (client dumps core & falls into the chasm) * / + * + * WHAT IS YOUR DISPLAY? + * display = XOpenDisplay("unix:0"); + * WHAT IS YOUR VISUAL? + * struct XVisualInfo vinfo; + * if (XMatchVisualInfo(display, DefaultScreen(display), + * 8, PseudoColor, &vinfo) != 0) + * visual = vinfo.visual; + * AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST? + * / * Is that a SubStructureRedirectMask or a ResizeRedirectMask? * / + * WHAT?! HOW AM I SUPPOSED TO KNOW THAT? + * AAAAUUUGGGHHH!!!! (server dumps core & falls into the chasm) + */ + +#ifndef __SCREENHACK_H__ +#define __SCREENHACK_H__ + +#include + +#include "config.h" + +#ifdef __hpux + /* Which of the ten billion standards does values.h belong to? + What systems always have it? */ +# include +#endif + +#include + +#include +#include +#include + +/* M_PI ought to have been defined in math.h, but... */ +#ifndef M_PI +# define M_PI 3.1415926535 +#endif + +#ifndef M_PI_2 +# define M_PI_2 1.5707963267 +#endif + +#include "yarandom.h" +#include "usleep.h" +#include "resources.h" +#include "hsv.h" +#include "colors.h" +#include "grabscreen.h" +#include "visual.h" + +extern Bool mono_p; +extern char *progname; +extern char *progclass; +extern XrmDatabase db; +extern XrmOptionDescRec options []; +extern char *defaults []; + +extern void screenhack (Display*,Window); +extern void screenhack_handle_event (Display*, XEvent*); +extern void screenhack_handle_events (Display*); +extern void screen_redraw(); +extern void screen_resized(); + +#endif /* __SCREENHACK_H__ */ diff --git a/uisimulator/sourceheader b/uisimulator/sourceheader new file mode 100644 index 0000000000..df255c5ec8 --- /dev/null +++ b/uisimulator/sourceheader @@ -0,0 +1,18 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $id:$ + * + * Copyright (C) 2002 by Daniel Stenberg + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ diff --git a/uisimulator/uibasic.c b/uisimulator/uibasic.c new file mode 100644 index 0000000000..df35fac79c --- /dev/null +++ b/uisimulator/uibasic.c @@ -0,0 +1,220 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $id:$ + * + * Copyright (C) 2002 by Daniel Stenberg + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "screenhack.h" +#include "alpha.h" + +#include "version.h" + +#define MAX(x,y) ((x)>(y)?(x):(y)) +#define MIN(x,y) ((x)<(y)?(x):(y)) + +#define PROGNAME "rockboxui" + +/* -- -- */ + +static GC draw_gc, erase_gc; +static Colormap cmap; +static XColor color_track, color_car; + +static long maxx, maxy; +static double track_zoom=1; + +Display *dpy; +Window window; + +XrmOptionDescRec options [] = { + /* { "-subtractive", ".additive", XrmoptionNoArg, "false" }, */ + { "-server", ".server", XrmoptionSepArg, 0 }, + { "-help", ".help", XrmoptionNoArg, "false" }, + { 0, 0, 0, 0 } +}; +char *progclass = "rockboxui"; + +char *defaults [] = { + ".background: black", + ".foreground: white", + "*help: false", + 0 +}; + +#define LOGFILE "xgui.log" +void Logf(char *fmt, ...) +{ + va_list args; + FILE *log; + struct tm *t; + time_t now=time(NULL); + + va_start(args, fmt); + + t = localtime(&now); + log = fopen(LOGFILE, "a"); + if(log) { + fprintf(log, "%02d.%02d.%02d ", + t->tm_hour, t->tm_min, t->tm_sec); + vfprintf(log, fmt, args); + fprintf(log, "\n"); + + fclose(log); + } + + fprintf(stderr, "%02d.%02d.%02d ", + t->tm_hour, t->tm_min, t->tm_sec); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); +} + +void init_window () +{ + XGCValues gcv; + XWindowAttributes xgwa; + char *test_p; + + XGetWindowAttributes (dpy, window, &xgwa); + + color_track.red=65535; + color_track.green=65535; + color_track.blue=65535; + + color_car.red=65535; + color_car.green=65535; + color_car.blue=0; + + cmap = xgwa.colormap; + + gcv.function = GXxor; + gcv.foreground = + get_pixel_resource ("foreground", "Foreground", dpy, cmap); + draw_gc = erase_gc = XCreateGC (dpy, window, GCForeground, &gcv); + XAllocColor (dpy, cmap, &color_track); + XAllocColor (dpy, cmap, &color_car); + + screen_resized(200, 100); +} + +void screen_resized(int width, int height) +{ +#if 0 + XWindowAttributes xgwa; + XGetWindowAttributes (dpy, window, &xgwa); + maxx = ((long)(xgwa.width)); + maxy = ((long)(xgwa.height)); +#else + maxx = width-1; + maxy = height-1; +#endif + XSetForeground (dpy, draw_gc, get_pixel_resource ("background", "Background", + dpy, cmap)); + XFillRectangle(dpy, window, draw_gc, 0, 0, width, height); + +} + +static void help(void) +{ + printf(PROGNAME " " ROCKBOXUI_VERSION " " __DATE__ "\n" + "usage: " PROGNAME "\n" + ); +} + +void drawline(int color, int x1, int y1, int x2, int y2) +{ + if (color==0) { + XSetForeground(dpy, draw_gc, + get_pixel_resource("background", "Background", dpy, cmap)); + } + else + XSetForeground(dpy, draw_gc, + get_pixel_resource("foreground", "Foreground", dpy, cmap)); + + XDrawLine(dpy, window, draw_gc, + (int)(x1*track_zoom), + (int)(y1*track_zoom), + (int)(x2*track_zoom), + (int)(y2*track_zoom)); +} + +void drawtext(int color, int x, int y, char *text) +{ + if (color==0) { + XSetForeground(dpy, draw_gc, + get_pixel_resource("background", "Background", dpy, cmap)); + } + else + XSetForeground(dpy, draw_gc, + get_pixel_resource("foreground", "Foreground", dpy, cmap)); + + XDrawString(dpy, window, draw_gc, x, y, text, strlen(text)); +} + + +void +screenhack (Display *the_dpy, Window the_window) +{ + unsigned short porttouse=0; + char *proxy = NULL; + char *url = NULL; + int i; + char *guiname="Rock-the-box"; + Bool helpme; + + /* This doesn't work, but I don't know why (Daniel 1999-12-01) */ + helpme = get_boolean_resource ("help", "Boolean"); + if(helpme) { + help(); + } + printf(PROGNAME " " ROCKBOXUI_VERSION " (" __DATE__ ")\n"); + + dpy=the_dpy; + window=the_window; + + init_window(); + + drawtext(1, 20, 20, PROGNAME); + drawline(1, 0, 0, 40, 50); + + Logf("Rockbox will kill ya!"); + + while (1) { + /* deal with input here */ + + XSync (dpy, False); + screenhack_handle_events (dpy); + } +} + +void screen_redraw() +{ + /* does nothing yet */ + drawtext(1, 20, 20, PROGNAME); + drawline(1, 0, 0, 40, 50); +} diff --git a/uisimulator/usleep.c b/uisimulator/usleep.c new file mode 100644 index 0000000000..706675910e --- /dev/null +++ b/uisimulator/usleep.c @@ -0,0 +1,58 @@ +/* xscreensaver, Copyright (c) 1992, 1996, 1997 + * Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#else /* !HAVE_CONFIG_H */ +# ifndef NO_SELECT +# define HAVE_SELECT +# endif +#endif /* !HAVE_CONFIG_H */ + +#ifdef __STDC__ +# include +#endif + +#if defined(VMS) +# include +# include +# include +#elif defined(HAVE_SELECT) +# include /* for struct timeval */ +#endif + + +#ifdef __SCREENHACK_USLEEP_H__ +ERROR, do not include that here +#endif + +void +screenhack_usleep (unsigned long usecs) +{ +# if defined(VMS) + float seconds = ((float) usecs)/1000000.0; + unsigned long int statvms = lib$wait(&seconds); + +#elif defined(HAVE_SELECT) + /* usleep() doesn't exist everywhere, and select() is faster anyway. */ + struct timeval tv; + tv.tv_sec = usecs / 1000000L; + tv.tv_usec = usecs % 1000000L; + (void) select (0, 0, 0, 0, &tv); + +#else /* !VMS && !HAVE_SELECT */ + /* If you don't have select() or usleep(), I guess you lose... + Maybe you have napms() instead? Let me know. */ + usleep (usecs); + +#endif /* !VMS && !HAVE_SELECT */ +} diff --git a/uisimulator/usleep.h b/uisimulator/usleep.h new file mode 100644 index 0000000000..c40363ef4a --- /dev/null +++ b/uisimulator/usleep.h @@ -0,0 +1,20 @@ +/* xscreensaver, Copyright (c) 1992, 1996 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __SCREENHACK_USLEEP_H__ +#define __SCREENHACK_USLEEP_H__ + +extern void screenhack_usleep (unsigned long usecs); + +#undef usleep +#define usleep(usecs) screenhack_usleep(usecs) + +#endif /* __SCREENHACK_USLEEP_H__ */ diff --git a/uisimulator/utils.h b/uisimulator/utils.h new file mode 100644 index 0000000000..284bb86dcd --- /dev/null +++ b/uisimulator/utils.h @@ -0,0 +1,22 @@ +/* xscreensaver, Copyright (c) 1997 Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include diff --git a/uisimulator/version.h b/uisimulator/version.h new file mode 100644 index 0000000000..e9e70b675b --- /dev/null +++ b/uisimulator/version.h @@ -0,0 +1 @@ +#define ROCKBOXUI_VERSION "0.1" diff --git a/uisimulator/visual.c b/uisimulator/visual.c new file mode 100644 index 0000000000..57b73151c5 --- /dev/null +++ b/uisimulator/visual.c @@ -0,0 +1,544 @@ +/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999 + * by Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +/* This file contains some code for intelligently picking the best visual + (where "best" is biased in the direction of either: high color counts; + or: having writable color cells...) + */ + +#include "utils.h" +#include "resources.h" /* for get_string_resource() */ +#include "visual.h" + +#include + +extern char *progname; + + +#ifndef isupper +# define isupper(c) ((c) >= 'A' && (c) <= 'Z') +#endif +#ifndef _tolower +# define _tolower(c) ((c) - 'A' + 'a') +#endif + + +static Visual *pick_best_visual (Screen *, Bool, Bool); +static Visual *pick_mono_visual (Screen *); +static Visual *pick_best_visual_of_class (Screen *, int); +static Visual *pick_best_gl_visual (Screen *); +static Visual *id_to_visual (Screen *, int); +static Visual *id_to_visual (Screen *screen, int id); + + +#define DEFAULT_VISUAL -1 +#define BEST_VISUAL -2 +#define MONO_VISUAL -3 +#define GRAY_VISUAL -4 +#define COLOR_VISUAL -5 +#define GL_VISUAL -6 +#define SPECIFIC_VISUAL -7 + +Visual * +get_visual (Screen *screen, const char *string, Bool prefer_writable_cells, + Bool verbose_p) +{ + char *v = (string ? strdup(string) : 0); + char c, *tmp; + int vclass; + unsigned long id; + Visual *result = 0; + + if (v) + for (tmp = v; *tmp; tmp++) + if (isupper (*tmp)) *tmp = _tolower (*tmp); + + if (!v || !*v) vclass = BEST_VISUAL; + else if (!strcmp (v, "default")) vclass = DEFAULT_VISUAL; + else if (!strcmp (v, "best")) vclass = BEST_VISUAL; + else if (!strcmp (v, "mono")) vclass = MONO_VISUAL; + else if (!strcmp (v, "monochrome")) vclass = MONO_VISUAL; + else if (!strcmp (v, "gray")) vclass = GRAY_VISUAL; + else if (!strcmp (v, "grey")) vclass = GRAY_VISUAL; + else if (!strcmp (v, "color")) vclass = COLOR_VISUAL; + else if (!strcmp (v, "gl")) vclass = GL_VISUAL; + else if (!strcmp (v, "staticgray")) vclass = StaticGray; + else if (!strcmp (v, "staticcolor")) vclass = StaticColor; + else if (!strcmp (v, "truecolor")) vclass = TrueColor; + else if (!strcmp (v, "grayscale")) vclass = GrayScale; + else if (!strcmp (v, "greyscale")) vclass = GrayScale; + else if (!strcmp (v, "pseudocolor")) vclass = PseudoColor; + else if (!strcmp (v, "directcolor")) vclass = DirectColor; + else if (1 == sscanf (v, " %ld %c", &id, &c)) vclass = SPECIFIC_VISUAL; + else if (1 == sscanf (v, " 0x%lx %c", &id, &c)) vclass = SPECIFIC_VISUAL; + else + { + fprintf (stderr, "%s: unrecognized visual \"%s\".\n", progname, v); + vclass = DEFAULT_VISUAL; + } + + if (vclass == DEFAULT_VISUAL) + result = DefaultVisualOfScreen (screen); + else if (vclass == BEST_VISUAL) + result = pick_best_visual (screen, prefer_writable_cells, False); + else if (vclass == MONO_VISUAL) + { + result = pick_mono_visual (screen); + if (!result && verbose_p) + fprintf (stderr, "%s: no monochrome visuals.\n", progname); + } + else if (vclass == GRAY_VISUAL) + { + if (prefer_writable_cells) + result = pick_best_visual_of_class (screen, GrayScale); + if (!result) + result = pick_best_visual_of_class (screen, StaticGray); + if (!result) + result = pick_best_visual_of_class (screen, GrayScale); + if (!result && verbose_p) + fprintf (stderr, "%s: no GrayScale or StaticGray visuals.\n", + progname); + } + else if (vclass == COLOR_VISUAL) + { + int class; + /* First see if the default visual will do. */ + result = DefaultVisualOfScreen (screen); + class = visual_class(screen, result); + if (class != TrueColor && + class != PseudoColor && + class != DirectColor && + class != StaticColor) + result = 0; + if (result && visual_depth(screen, result) <= 1) + result = 0; + + /* Else, find the best non-default color visual */ + if (!result) + result = pick_best_visual (screen, prefer_writable_cells, True); + + if (!result && verbose_p) + fprintf (stderr, "%s: no color visuals.\n", progname); + } + else if (vclass == GL_VISUAL) + { + Visual *visual = pick_best_gl_visual (screen); + if (visual) + result = visual; + else if (verbose_p) + fprintf (stderr, "%s: no visual suitable for GL.\n", progname); + } + else if (vclass == SPECIFIC_VISUAL) + { + result = id_to_visual (screen, id); + if (!result && verbose_p) + fprintf (stderr, "%s: no visual with id 0x%x.\n", progname, + (unsigned int) id); + } + else + { + Visual *visual = pick_best_visual_of_class (screen, vclass); + if (visual) + result = visual; + else if (verbose_p) + fprintf (stderr, "%s: no visual of class %s.\n", progname, v); + } + + if (v) free (v); + return result; +} + +Visual * +get_visual_resource (Screen *screen, char *name, char *class, + Bool prefer_writable_cells) +{ + char *string = get_string_resource (name, class); + Visual *v = get_visual (screen, string, prefer_writable_cells, True); + if (string) + free(string); + if (v) + return v; + else + return DefaultVisualOfScreen (screen); +} + + +static Visual * +pick_best_visual (Screen *screen, Bool prefer_writable_cells, Bool color_only) +{ + Visual *visual; + + if (!prefer_writable_cells) + { + /* If we don't prefer writable cells, then the "best" visual is the one + on which we can allocate the largest range and number of colors. + + Therefore, a TrueColor visual which is at least 16 bits deep is best. + (The assumption here being that a TrueColor of less than 16 bits is + really just a PseudoColor visual with a pre-allocated color cube.) + + The next best thing is a PseudoColor visual of any type. After that + come the non-colormappable visuals, and non-color visuals. + */ + if ((visual = pick_best_visual_of_class (screen, TrueColor)) && + visual_depth (screen, visual) >= 16) + return visual; + } + +#define TRY_CLASS(CLASS) \ + if ((visual = pick_best_visual_of_class (screen, CLASS)) && \ + (!color_only || visual_depth(screen, visual) > 1)) \ + return visual + TRY_CLASS(PseudoColor); + TRY_CLASS(TrueColor); + TRY_CLASS(DirectColor); + TRY_CLASS(StaticColor); + if (!color_only) + { + TRY_CLASS(GrayScale); + TRY_CLASS(StaticGray); + } +#undef TRY_CLASS + + visual = DefaultVisualOfScreen (screen); + if (!color_only || visual_depth(screen, visual) > 1) + return visual; + else + return 0; +} + +static Visual * +pick_mono_visual (Screen *screen) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count; + + vi_in.depth = 1; + vi_in.screen = screen_number (screen); + vi_out = XGetVisualInfo (dpy, (VisualDepthMask | VisualScreenMask), + &vi_in, &out_count); + if (vi_out) + { + Visual *v = (out_count > 0 ? vi_out [0].visual : 0); + if (v && vi_out[0].depth != 1) + v = 0; + XFree ((char *) vi_out); + return v; + } + else + return 0; +} + + +static Visual * +pick_best_visual_of_class (Screen *screen, int visual_class) +{ + /* The best visual of a class is the one which on which we can allocate + the largest range and number of colors, which means the one with the + greatest depth and number of cells. + + (But actually, for XDaliClock, all visuals of the same class are + probably equivalent - either we have writable cells or we don't.) + */ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count; + + vi_in.class = visual_class; + vi_in.screen = screen_number (screen); + vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask), + &vi_in, &out_count); + if (vi_out) + { + /* choose the 'best' one, if multiple */ + int i, best; + Visual *visual; +/* for (i = 0, best = 0; i < out_count; i++) */ + for (i = out_count-1, best = i; i >= 0; i--) /* go backwards */ + /* It's better if it's deeper, or if it's the same depth with + more cells (does that ever happen? Well, it could...) */ + if ((vi_out [i].depth > vi_out [best].depth) || + ((vi_out [i].depth == vi_out [best].depth) && + (vi_out [i].colormap_size > vi_out [best].colormap_size))) + best = i; + visual = (best < out_count ? vi_out [best].visual : 0); + XFree ((char *) vi_out); + return visual; + } + else + return 0; +} + +static Visual * +pick_best_gl_visual (Screen *screen) +{ + /* The best visual for GL is a TrueColor visual that is half as deep as + the screen. If such a thing doesn't exist, then TrueColor is best. + Failing that, the deepest available color visual is best. + + Compare this function to get_gl_visual() in visual-gl.c. + This function tries to find the best GL visual using Xlib calls, + whereas that function does the same thing using GLX calls. + */ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count; + Visual *result = 0; + + int ndepths = 0; + int *depths = XListDepths (dpy, screen_number (screen), &ndepths); + int screen_depth = depths[ndepths]; + XFree (depths); + + vi_in.class = TrueColor; + vi_in.screen = screen_number (screen); + vi_in.depth = screen_depth / 2; + vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask | + VisualDepthMask), + &vi_in, &out_count); + if (out_count > 0) + result = vi_out[0].visual; + + if (vi_out) + XFree ((char *) vi_out); + + if (!result && screen_depth > 24) + { + /* If it's a 32-deep screen and we didn't find a depth-16 visual, + see if there's a depth-12 visual. */ + vi_in.class = TrueColor; + vi_in.screen = screen_number (screen); + vi_in.depth = 12; + vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask | + VisualDepthMask), + &vi_in, &out_count); + if (out_count > 0) + result = vi_out[0].visual; + } + + if (!result) + /* No half-depth TrueColor? Ok, try for any TrueColor (the deepest.) */ + result = pick_best_visual_of_class (screen, TrueColor); + + if (!result) + /* No TrueColor? Ok, try for anything. */ + result = pick_best_visual (screen, False, False); + + return result; +} + + +static Visual * +id_to_visual (Screen *screen, int id) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count; + vi_in.screen = screen_number (screen); + vi_in.visualid = id; + vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask), + &vi_in, &out_count); + if (vi_out) + { + Visual *v = vi_out[0].visual; + XFree ((char *) vi_out); + return v; + } + return 0; +} + +int +visual_depth (Screen *screen, Visual *visual) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count, d; + vi_in.screen = screen_number (screen); + vi_in.visualid = XVisualIDFromVisual (visual); + vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, + &vi_in, &out_count); + if (! vi_out) abort (); + d = vi_out [0].depth; + XFree ((char *) vi_out); + return d; +} + + +#if 0 +/* You very probably don't want to be using this. + Pixmap depth doesn't refer to the depths of pixmaps, but rather, to + the depth of protocol-level on-the-wire pixmap data, that is, XImages. + To get this info, you should be looking at XImage->bits_per_pixel + instead. (And allocating the data for your XImage structures by + multiplying ximage->bytes_per_line by ximage->height.) + */ +int +visual_pixmap_depth (Screen *screen, Visual *visual) +{ + Display *dpy = DisplayOfScreen (screen); + int vdepth = visual_depth (screen, visual); + int pdepth = vdepth; + int i, pfvc = 0; + XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc); + + /* Return the first matching depth in the pixmap formats. If there are no + matching pixmap formats (which shouldn't be able to happen at all) then + return the visual depth instead. */ + for (i = 0; i < pfvc; i++) + if (pfv[i].depth == vdepth) + { + pdepth = pfv[i].bits_per_pixel; + break; + } + if (pfv) + XFree (pfv); + return pdepth; +} +#endif /* 0 */ + + +int +visual_class (Screen *screen, Visual *visual) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count, c; + vi_in.screen = screen_number (screen); + vi_in.visualid = XVisualIDFromVisual (visual); + vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, + &vi_in, &out_count); + if (! vi_out) abort (); + c = vi_out [0].class; + XFree ((char *) vi_out); + return c; +} + +Bool +has_writable_cells (Screen *screen, Visual *visual) +{ + switch (visual_class (screen, visual)) + { + case GrayScale: /* Mappable grays. */ + case PseudoColor: /* Mappable colors. */ + return True; + case StaticGray: /* Fixed grays. */ + case TrueColor: /* Fixed colors. */ + case StaticColor: /* (What's the difference again?) */ + case DirectColor: /* DirectColor visuals are like TrueColor, but have + three colormaps - one for each component of RGB. + Screw it. */ + return False; + default: + abort(); + return False; + } +} + +void +describe_visual (FILE *f, Screen *screen, Visual *visual, Bool private_cmap_p) +{ + char n[10]; + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count; + vi_in.screen = screen_number (screen); + vi_in.visualid = XVisualIDFromVisual (visual); + vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask), + &vi_in, &out_count); + if (! vi_out) abort (); + if (private_cmap_p) + sprintf(n, "%3d", vi_out->colormap_size); + else + strcpy(n, "default"); + + fprintf (f, "0x%02x (%s depth: %2d, cmap: %s)\n", + (unsigned int) vi_out->visualid, + (vi_out->class == StaticGray ? "StaticGray, " : + vi_out->class == StaticColor ? "StaticColor," : + vi_out->class == TrueColor ? "TrueColor, " : + vi_out->class == GrayScale ? "GrayScale, " : + vi_out->class == PseudoColor ? "PseudoColor," : + vi_out->class == DirectColor ? "DirectColor," : + "UNKNOWN: "), + vi_out->depth, n); + XFree ((char *) vi_out); +} + +int +screen_number (Screen *screen) +{ + Display *dpy = DisplayOfScreen (screen); + int i; + for (i = 0; i < ScreenCount (dpy); i++) + if (ScreenOfDisplay (dpy, i) == screen) + return i; + abort (); + return 0; +} + +int +visual_cells (Screen *screen, Visual *visual) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + int out_count, c; + vi_in.screen = screen_number (screen); + vi_in.visualid = XVisualIDFromVisual (visual); + vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask, + &vi_in, &out_count); + if (! vi_out) abort (); + c = vi_out [0].colormap_size; + XFree ((char *) vi_out); + return c; +} + +Visual * +find_similar_visual(Screen *screen, Visual *old_visual) +{ + Display *dpy = DisplayOfScreen (screen); + XVisualInfo vi_in, *vi_out; + Visual *result = 0; + int out_count; + + vi_in.screen = screen_number (screen); + vi_in.class = visual_class (screen, old_visual); + vi_in.depth = visual_depth (screen, old_visual); + + /* Look for a visual of the same class and depth. + */ + vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask | + VisualDepthMask), + &vi_in, &out_count); + if (vi_out && out_count > 0) + result = vi_out[0].visual; + if (vi_out) XFree (vi_out); + vi_out = 0; + + /* Failing that, look for a visual of the same class. + */ + if (!result) + { + vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask), + &vi_in, &out_count); + if (vi_out && out_count > 0) + result = vi_out[0].visual; + if (vi_out) XFree (vi_out); + vi_out = 0; + } + + /* Failing that, return the default visual. */ + if (!result) + result = DefaultVisualOfScreen (screen); + + return result; +} diff --git a/uisimulator/visual.h b/uisimulator/visual.h new file mode 100644 index 0000000000..dd45708ea0 --- /dev/null +++ b/uisimulator/visual.h @@ -0,0 +1,29 @@ +/* xscreensaver, Copyright (c) 1993-1999 by Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __VISUAL_H__ +#define __VISUAL_H__ + +extern Visual *get_visual (Screen *, const char *name, Bool, Bool); +extern Visual *get_visual_resource (Screen *, char *, char *, Bool); +extern int visual_depth (Screen *, Visual *); +/* extern int visual_pixmap_depth (Screen *, Visual *); */ +extern int visual_class (Screen *, Visual *); +extern int visual_cells (Screen *, Visual *); +extern int screen_number (Screen *); +extern Visual *find_similar_visual (Screen *, Visual *old); +extern void describe_visual (FILE *f, Screen *, Visual *, Bool private_cmap_p); +extern Visual *get_overlay_visual (Screen *, unsigned long *pixel_return); +extern Bool has_writable_cells (Screen *screen, Visual *visual); + +Visual *get_gl_visual (Screen *screen); + +#endif /* __VISUAL_H__ */ diff --git a/uisimulator/vroot.h b/uisimulator/vroot.h new file mode 100644 index 0000000000..ba3e5d29fa --- /dev/null +++ b/uisimulator/vroot.h @@ -0,0 +1,126 @@ +/*****************************************************************************/ +/** Copyright 1991 by Andreas Stolcke **/ +/** Copyright 1990 by Solbourne Computer Inc. **/ +/** Longmont, Colorado **/ +/** **/ +/** All Rights Reserved **/ +/** **/ +/** Permission to use, copy, modify, and distribute this software and **/ +/** its documentation for any purpose and without fee is hereby **/ +/** granted, provided that the above copyright notice appear in all **/ +/** copies and that both that copyright notice and this permis- **/ +/** sion notice appear in supporting documentation, and that the **/ +/** name of Solbourne not be used in advertising **/ +/** in publicity pertaining to distribution of the software without **/ +/** specific, written prior permission. **/ +/** **/ +/** ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/ +/** WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF **/ +/** MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ANDREAS STOLCKE **/ +/** OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL **/ +/** DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ +/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ +/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ +/** OR PERFORMANCE OF THIS SOFTWARE. **/ +/*****************************************************************************/ +/* + * vroot.h -- Virtual Root Window handling header file + * + * This header file redefines the X11 macros RootWindow and DefaultRootWindow, + * making them look for a virtual root window as provided by certain `virtual' + * window managers like swm and tvtwm. If none is found, the ordinary root + * window is returned, thus retaining backward compatibility with standard + * window managers. + * The function implementing the virtual root lookup remembers the result of + * its last invocation to avoid overhead in the case of repeated calls + * on the same display and screen arguments. + * The lookup code itself is taken from Tom LaStrange's ssetroot program. + * + * Most simple root window changing X programs can be converted to using + * virtual roots by just including + * + * #include + * + * after all the X11 header files. It has been tested on such popular + * X clients as xphoon, xfroot, xloadimage, and xaqua. + * It also works with the core clients xprop, xwininfo, xwd, and editres + * (and is necessary to get those clients working under tvtwm). + * It does NOT work with xsetroot; get the xsetroot replacement included in + * the tvtwm distribution instead. + * + * Andreas Stolcke , 9/7/90 + * - replaced all NULL's with properly cast 0's, 5/6/91 + * - free children list (suggested by Mark Martin ), 5/16/91 + * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91 + */ + +#ifndef _VROOT_H_ +#define _VROOT_H_ + +#if !defined(lint) && !defined(SABER) +static const char vroot_rcsid[] = "#Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke #"; +#endif + +#include +#include +#include + +static Window +#ifdef __STDC__ /* ANSIfication added by jwz, to avoid superfluous warnings. */ +VirtualRootWindowOfScreen(Screen *screen) +#else /* !__STDC__ */ +VirtualRootWindowOfScreen(screen) Screen *screen; +#endif /* !__STDC__ */ +{ + static Screen *save_screen = (Screen *)0; + static Window root = (Window)0; + + if (screen != save_screen) { + Display *dpy = DisplayOfScreen(screen); + Atom __SWM_VROOT = None; + int i; + Window rootReturn, parentReturn, *children; + unsigned int numChildren; + + root = RootWindowOfScreen(screen); + + /* go look for a virtual root */ + __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False); + if (XQueryTree(dpy, root, &rootReturn, &parentReturn, + &children, &numChildren)) { + for (i = 0; i < numChildren; i++) { + Atom actual_type; + int actual_format; + unsigned long nitems, bytesafter; + Window *newRoot = (Window *)0; + + if (XGetWindowProperty(dpy, children[i], + __SWM_VROOT, 0, 1, False, XA_WINDOW, + &actual_type, &actual_format, + &nitems, &bytesafter, + (unsigned char **) &newRoot) == Success + && newRoot) { + root = *newRoot; + break; + } + } + if (children) + XFree((char *)children); + } + + save_screen = screen; + } + + return root; +} + +#undef RootWindowOfScreen +#define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s) + +#undef RootWindow +#define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen)) + +#undef DefaultRootWindow +#define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy)) + +#endif /* _VROOT_H_ */ diff --git a/uisimulator/xgui.log b/uisimulator/xgui.log new file mode 100644 index 0000000000..aac53fb382 --- /dev/null +++ b/uisimulator/xgui.log @@ -0,0 +1,22 @@ +13.07.21 Rockbox will kill ya! +13.08.13 Rockbox will kill ya! +13.09.12 Rockbox will kill ya! +13.09.42 Rockbox will kill ya! +13.12.26 Rockbox will kill ya! +13.14.27 Rockbox will kill ya! +13.15.48 Rockbox will kill ya! +13.16.32 Rockbox will kill ya! +13.22.54 Rockbox will kill ya! +13.25.02 Rockbox will kill ya! +13.37.39 Rockbox will kill ya! +13.38.14 Rockbox will kill ya! +13.38.31 Rockbox will kill ya! +13.38.49 Rockbox will kill ya! +13.39.39 Rockbox will kill ya! +13.40.07 Rockbox will kill ya! +13.50.51 Rockbox will kill ya! +13.52.27 Rockbox will kill ya! +13.53.16 Rockbox will kill ya! +13.53.31 Rockbox will kill ya! +13.53.46 Rockbox will kill ya! +13.55.39 Rockbox will kill ya! diff --git a/uisimulator/xmu.h b/uisimulator/xmu.h new file mode 100644 index 0000000000..48084f747e --- /dev/null +++ b/uisimulator/xmu.h @@ -0,0 +1,14 @@ +/* This file contains compatibility routines for systems without Xmu. + * You would be better served by installing Xmu on your machine or + * yelling at your vendor to ship it. + */ + +#ifndef __XMU_H__ +#define __XMU_H__ + +#include +#include + +int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp); + +#endif /* __XMU_H__ */ diff --git a/uisimulator/yarandom.c b/uisimulator/yarandom.c new file mode 100644 index 0000000000..3d24943e0e --- /dev/null +++ b/uisimulator/yarandom.c @@ -0,0 +1,115 @@ +/* yarandom.c -- Yet Another Random Number Generator. + + The unportable mess that is rand(), random(), drand48() and friends led me + to ask Phil Karlton what the Right Thing to Do was. + He responded with this. It is non-cryptographically secure, reasonably + random (more so than anything that is in any C library), and very fast. + + I don't understand how it works at all, but he says "look at Knuth, + Vol. 2 (original edition), page 26, Algorithm A. In this case n=55, + k=20 and m=2^32." + + So there you have it. + + --------------------------- + Note: xlockmore 4.03a10 uses this very simple RNG: + + if ((seed = seed % 44488 * 48271 - seed / 44488 * 3399) < 0) + seed += 2147483647; + return seed-1; + + of which it says + + ``Dr. Park's algorithm published in the Oct. '88 ACM "Random Number + Generators: Good Ones Are Hard To Find" His version available at + ftp://cs.wm.edu/pub/rngs.tar Present form by many authors.'' + + Karlton says: ``the usual problem with that kind of RNG turns out to + be unexepected short cycles for some word lengths.'' + + Karlton's RNG is faster, since it does three adds and two stores, while the + xlockmore RNG does two multiplies, two divides, three adds, and one store. + + Compiler optimizations make a big difference here: + gcc -O: difference is 1.2x. + gcc -O2: difference is 1.4x. + gcc -O3: difference is 1.5x. + SGI cc -O: difference is 2.4x. + SGI cc -O2: difference is 2.4x. + SGI cc -O3: difference is 5.1x. + Irix 6.2; Indy r5k; SGI cc version 6; gcc version 2.7.2.1. + */ + + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_UNISTD_H +# include /* for getpid() */ +#endif +#include /* for gettimeofday() */ + +#include "yarandom.h" +# undef ya_rand_init + + +/* The following 'random' numbers are taken from CRC, 18th Edition, page 622. + Each array element was taken from the corresponding line in the table, + except that a[0] was from line 100. 8s and 9s in the table were simply + skipped. The high order digit was taken mod 4. + */ +#define VectorSize 55 +static unsigned int a[VectorSize] = { + 035340171546, 010401501101, 022364657325, 024130436022, 002167303062, /* 5 */ + 037570375137, 037210607110, 016272055420, 023011770546, 017143426366, /* 10 */ + 014753657433, 021657231332, 023553406142, 004236526362, 010365611275, /* 14 */ + 007117336710, 011051276551, 002362132524, 001011540233, 012162531646, /* 20 */ + 007056762337, 006631245521, 014164542224, 032633236305, 023342700176, /* 25 */ + 002433062234, 015257225043, 026762051606, 000742573230, 005366042132, /* 30 */ + 012126416411, 000520471171, 000725646277, 020116577576, 025765742604, /* 35 */ + 007633473735, 015674255275, 017555634041, 006503154145, 021576344247, /* 40 */ + 014577627653, 002707523333, 034146376720, 030060227734, 013765414060, /* 45 */ + 036072251540, 007255221037, 024364674123, 006200353166, 010126373326, /* 50 */ + 015664104320, 016401041535, 016215305520, 033115351014, 017411670323 /* 55 */ +}; + +static int i1, i2; + +unsigned int +ya_random (void) +{ + register int ret = a[i1] + a[i2]; + a[i1] = ret; + if (++i1 >= VectorSize) i1 = 0; + if (++i2 >= VectorSize) i2 = 0; + return ret; +} + +void +ya_rand_init(unsigned int seed) +{ + int i; + if (seed == 0) + { + struct timeval tp; +#ifdef GETTIMEOFDAY_TWO_ARGS + struct timezone tzp; + gettimeofday(&tp, &tzp); +#else + gettimeofday(&tp); +#endif + /* ignore overflow */ + seed = (999*tp.tv_sec) + (1001*tp.tv_usec) + (1003 * getpid()); + } + + a[0] += seed; + for (i = 1; i < VectorSize; i++) + { + seed = a[i-1]*1001 + seed*999; + a[i] += seed; + } + + i1 = a[0] % VectorSize; + i2 = (i1 + 024) % VectorSize; +} diff --git a/uisimulator/yarandom.h b/uisimulator/yarandom.h new file mode 100644 index 0000000000..0e1dfcfb76 --- /dev/null +++ b/uisimulator/yarandom.h @@ -0,0 +1,64 @@ +/* xscreensaver, Copyright (c) 1997, 1998 by Jamie Zawinski + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + */ + +#ifndef __YARANDOM_H__ +#define __YARANDOM_H__ + +#undef random +#undef rand +#undef drand48 +#undef srandom +#undef srand +#undef srand48 +#undef frand +#undef RAND_MAX + +#ifdef VMS +# include "vms-gtod.h" +#endif + +extern unsigned int ya_random (void); +extern void ya_rand_init (unsigned int); + +#define random() ya_random() +#define RAND_MAX 0x7FFFFFFF + +/*#define srandom(i) ya_rand_init(0)*/ + +/* Define these away to keep people from using the wrong APIs in xscreensaver. + */ +#define rand __ERROR_use_random_not_rand_in_xscreensaver__ +#define drand48 __ERROR_use_random_not_drand48_in_xscreensaver__ +#define srandom __ERROR_do_not_call_srandom_in_xscreensaver__ +#define srand __ERROR_do_not_call_srand_in_xscreensaver__ +#define srand48 __ERROR_do_not_call_srand48_in_xscreensaver__ +#define ya_rand_init __ERROR_do_not_call_ya_rand_init_in_xscreensaver__ + + +#if defined (__GNUC__) && (__GNUC__ >= 2) + /* Implement frand using GCC's statement-expression extension. */ + +# define frand(f) \ + ({ double tmp = (((double) random()) / \ + (((double) ((unsigned int)~0)) / ((double) (f)))); \ + tmp < 0 ? (-tmp) : tmp; }) + +#else /* not GCC2 - implement frand using a global variable.*/ + +static double _frand_tmp_; +# define frand(f) \ + (_frand_tmp_ = (((double) random()) / \ + (((double) ((unsigned int)~0)) / ((double) (f)))), \ + _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_) + +#endif /* not GCC2 */ + +#endif /* __YARANDOM_H__ */