summaryrefslogtreecommitdiff
path: root/uisimulator/x11
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/x11')
-rw-r--r--uisimulator/x11/Makefile60
-rw-r--r--uisimulator/x11/README6
-rw-r--r--uisimulator/x11/SOURCES14
-rw-r--r--uisimulator/x11/archos/rockbox112.bmpbin5222 -> 0 bytes
-rw-r--r--uisimulator/x11/atoi.h2
-rw-r--r--uisimulator/x11/button-x11.c321
-rw-r--r--uisimulator/x11/config-x11.h362
-rw-r--r--uisimulator/x11/kernel.c165
-rw-r--r--uisimulator/x11/lcd-x11.c262
-rw-r--r--uisimulator/x11/lcd-x11.h26
-rw-r--r--uisimulator/x11/oss_sound.c84
-rw-r--r--uisimulator/x11/resources.c113
-rw-r--r--uisimulator/x11/resources.h23
-rw-r--r--uisimulator/x11/screenhack.c579
-rw-r--r--uisimulator/x11/screenhack.h52
-rw-r--r--uisimulator/x11/sound.c140
-rw-r--r--uisimulator/x11/sound.h22
-rw-r--r--uisimulator/x11/sprintf.h12
-rw-r--r--uisimulator/x11/thread.c148
-rw-r--r--uisimulator/x11/timefuncs.h7
-rw-r--r--uisimulator/x11/uibasic.c277
-rw-r--r--uisimulator/x11/utils.h22
-rw-r--r--uisimulator/x11/version.h1
-rw-r--r--uisimulator/x11/visual.c544
-rw-r--r--uisimulator/x11/visual.h29
-rw-r--r--uisimulator/x11/vroot.h126
-rw-r--r--uisimulator/x11/xmu.h14
27 files changed, 0 insertions, 3411 deletions
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
deleted file mode 100644
index 989ac65223..0000000000
--- a/uisimulator/x11/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
1############################################################################
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10# Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11#
12# All files in this archive are subject to the GNU General Public License.
13# See the file COPYING in the source tree root for full license agreement.
14#
15# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16# KIND, either express or implied.
17#
18############################################################################
19
20SIMCOMMON = ../common
21
22DEPFILE = $(OBJDIR)/dep-sim
23
24RM = rm -f
25DEBUG = -g
26
27# Use this for simulator-only files
28INCLUDES = -I. -I$(SIMCOMMON) -I$(OBJDIR) -I$(FIRMDIR)/export -I$(APPSDIR) \
29 -I$(BUILDDIR)
30
31# This sets up 'SRC' based on the files mentioned in SOURCES
32include $(TOOLSDIR)/makesrc.inc
33
34OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
35
36DEFINES := -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
37$(TARGET) -DAPPSVERSION=\"$(VERSION)\" -DMEM=${MEMORYSIZE} $(EXTRA_DEFINES)
38
39SOURCES = $(SRC)
40
41DIRS = .
42
43CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) $(GCCOPTS)
44
45OUTFILE = $(BUILDDIR)/libsim.a
46
47all: $(OUTFILE)
48
49include $(TOOLSDIR)/make.inc
50
51clean:
52 @echo "cleaning sim"
53 @$(RM) $(OBJS) *~ core $(OUTFILE) $(DEPFILE)
54 @$(MAKE) -C $(SIMCOMMON) clean
55
56$(OUTFILE): $(OBJS)
57 @echo "AR $@"
58 @$(AR) ruv $@ $(OBJS) >/dev/null 2>&1
59
60-include $(DEPFILE)
diff --git a/uisimulator/x11/README b/uisimulator/x11/README
deleted file mode 100644
index 0a293f6ad2..0000000000
--- a/uisimulator/x11/README
+++ /dev/null
@@ -1,6 +0,0 @@
1To build:
2
3 $ ../tools/configure
4 [answer questions]
5 $ make
6 $ ./rockboxui
diff --git a/uisimulator/x11/SOURCES b/uisimulator/x11/SOURCES
deleted file mode 100644
index 0aabfb2c03..0000000000
--- a/uisimulator/x11/SOURCES
+++ /dev/null
@@ -1,14 +0,0 @@
1button-x11.c
2kernel.c
3lcd-x11.c
4#if 0 /* if sound is enabled */
5oss_sound.c
6#endif
7resources.c
8screenhack.c
9thread.c
10uibasic.c
11visual.c
12#if CONFIG_CODEC == SWCODEC
13sound.c
14#endif
diff --git a/uisimulator/x11/archos/rockbox112.bmp b/uisimulator/x11/archos/rockbox112.bmp
deleted file mode 100644
index 45392f9f7a..0000000000
--- a/uisimulator/x11/archos/rockbox112.bmp
+++ /dev/null
Binary files differ
diff --git a/uisimulator/x11/atoi.h b/uisimulator/x11/atoi.h
deleted file mode 100644
index 74474f110c..0000000000
--- a/uisimulator/x11/atoi.h
+++ /dev/null
@@ -1,2 +0,0 @@
1
2int atoi(const char *);
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c
deleted file mode 100644
index 673f71ea7b..0000000000
--- a/uisimulator/x11/button-x11.c
+++ /dev/null
@@ -1,321 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Björn Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <stdlib.h>
20#include "config.h"
21#include "button.h"
22#include "kernel.h"
23#include "debug.h"
24#include "backlight.h"
25#include "misc.h"
26
27#include "X11/keysym.h"
28
29extern int screenhack_handle_events(bool *release);
30
31struct event_queue button_queue;
32
33static int button_state = 0; /* keeps track of pressed keys */
34static long lastbtn; /* Last valid button status */
35
36/* how often we check to see if a button is pressed */
37#define POLL_FREQUENCY HZ/25
38
39/* how long until repeat kicks in */
40#define REPEAT_START 8
41
42/* the speed repeat starts at */
43#define REPEAT_INTERVAL_START 4
44
45/* speed repeat finishes at */
46#define REPEAT_INTERVAL_FINISH 2
47
48/* mostly copied from real button.c */
49void button_read (void);
50
51static void button_tick(void)
52{
53 static int tick = 0;
54 static int count = 0;
55 static int repeat_speed = REPEAT_INTERVAL_START;
56 static int repeat_count = 0;
57 static bool repeat = false;
58 static bool post = false;
59 int diff;
60 int btn;
61
62 /* only poll every X ticks */
63 if ( ++tick >= POLL_FREQUENCY )
64 {
65 button_read();
66 btn = button_state;
67
68 /* Find out if a key has been released */
69 diff = btn ^ lastbtn;
70 if(diff && (btn & diff) == 0)
71 {
72 queue_post(&button_queue, BUTTON_REL | diff, NULL);
73 }
74 else
75 {
76 if ( btn )
77 {
78 /* normal keypress */
79 if ( btn != lastbtn )
80 {
81 post = true;
82 repeat = false;
83 repeat_speed = REPEAT_INTERVAL_START;
84
85 }
86 else /* repeat? */
87 {
88 if ( repeat )
89 {
90 count--;
91 if (count == 0) {
92 post = true;
93 /* yes we have repeat */
94 repeat_speed--;
95 if (repeat_speed < REPEAT_INTERVAL_FINISH)
96 repeat_speed = REPEAT_INTERVAL_FINISH;
97 count = repeat_speed;
98
99 repeat_count++;
100
101 }
102 }
103 else
104 {
105 if (count++ > REPEAT_START)
106 {
107 post = true;
108 repeat = true;
109 repeat_count = 0;
110 /* initial repeat */
111 count = REPEAT_INTERVAL_START;
112 }
113 }
114 }
115 if ( post )
116 {
117 if (repeat)
118 {
119 if (queue_empty(&button_queue))
120 {
121 queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
122 post = false;
123 }
124 }
125 else
126 {
127 queue_post(&button_queue, btn, NULL);
128 post = false;
129 }
130#ifdef HAVE_REMOTE_LCD
131 if(btn & BUTTON_REMOTE)
132 remote_backlight_on();
133 else
134#endif
135 backlight_on();
136
137 }
138 }
139 else
140 {
141 repeat = false;
142 count = 0;
143 }
144 }
145 lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
146 tick = 0;
147 }
148}
149
150/*
151 * Read X keys and translate to rockbox buttons
152 */
153
154void button_read (void)
155{
156 int k;
157 bool release = false; /* is this a release event */
158 int ev = screenhack_handle_events(&release);
159
160 switch (ev)
161 {
162 case XK_KP_Left:
163 case XK_Left:
164 case XK_KP_4:
165 k = BUTTON_LEFT;
166 break;
167
168 case XK_KP_Right:
169 case XK_Right:
170 case XK_KP_6:
171 k = BUTTON_RIGHT;
172 break;
173
174 case XK_KP_Up:
175 case XK_Up:
176 case XK_KP_8:
177#ifdef BUTTON_UP
178 k = BUTTON_UP;
179#elif defined BUTTON_PLAY
180 k = BUTTON_PLAY;
181#endif
182 break;
183
184 case XK_KP_Down:
185 case XK_Down:
186 case XK_KP_2:
187#ifdef BUTTON_DOWN
188 k = BUTTON_DOWN;
189#elif defined BUTTON_STOP
190 k = BUTTON_STOP;
191#endif
192 break;
193
194#ifdef BUTTON_ON
195 case XK_KP_Add:
196 case XK_Q:
197 case XK_q:
198 k = BUTTON_ON;
199 break;
200#endif
201
202#ifdef BUTTON_OFF
203 case XK_KP_Enter:
204 case XK_A:
205 case XK_a:
206 k = BUTTON_OFF;
207 break;
208#endif
209
210#ifdef BUTTON_F1
211 case XK_KP_Divide:
212 case XK_1:
213 k = BUTTON_F1;
214 break;
215
216 case XK_KP_Multiply:
217 case XK_2:
218 k = BUTTON_F2;
219 break;
220
221 case XK_KP_Subtract:
222 case XK_3:
223 k = BUTTON_F3;
224 break;
225#elif defined(BUTTON_REC)
226 case XK_KP_Divide:
227 case XK_1:
228 k = BUTTON_REC;
229 break;
230#endif
231
232 case XK_KP_Space:
233 case XK_KP_5:
234 case XK_KP_Begin:
235 case XK_space:
236#ifdef BUTTON_PLAY
237 k = BUTTON_PLAY;
238#elif defined(BUTTON_SELECT)
239 k = BUTTON_SELECT;
240#endif
241 break;
242
243#ifdef HAVE_LCD_BITMAP
244 case XK_5:
245 if(!release)
246 screen_dump();
247 break;
248#endif
249
250 case XK_KP_Separator:
251 case XK_KP_Insert:
252 case XK_Insert:
253#ifdef BUTTON_MENU
254 k = BUTTON_MENU;
255#elif defined(BUTTON_MODE)
256 k = BUTTON_MODE;
257#endif
258 break;
259
260 default:
261 k = 0;
262 if(ev)
263 DEBUGF("received ev %d\n", ev);
264 break;
265 }
266
267 if (release)
268 button_state &= ~k;
269 else
270 button_state |= k;
271}
272
273/* Again copied from real button.c... */
274
275long button_get(bool block)
276{
277 struct event ev;
278
279 if ( block || !queue_empty(&button_queue) )
280 {
281 queue_wait(&button_queue, &ev);
282 return ev.id;
283 }
284 return BUTTON_NONE;
285}
286
287long button_get_w_tmo(int ticks)
288{
289 struct event ev;
290 queue_wait_w_tmo(&button_queue, &ev, ticks);
291 return (ev.id != SYS_TIMEOUT)? ev.id: BUTTON_NONE;
292}
293
294void button_init(void)
295{
296 tick_add_task(button_tick);
297}
298
299int button_status(void)
300{
301 return lastbtn;
302}
303
304void button_clear_queue(void)
305{
306 queue_clear(&button_queue);
307}
308
309#ifdef HAS_BUTTON_HOLD
310bool button_hold(void) {
311 /* temp fix for hold button on irivers */
312 return false;
313}
314#endif
315
316#ifdef HAS_REMOTE_BUTTON_HOLD
317bool remote_button_hold(void) {
318 /* temp fix for hold button on irivers */
319 return false;
320}
321#endif
diff --git a/uisimulator/x11/config-x11.h b/uisimulator/x11/config-x11.h
deleted file mode 100644
index 1c520cfbac..0000000000
--- a/uisimulator/x11/config-x11.h
+++ /dev/null
@@ -1,362 +0,0 @@
1/* config.h. Generated automatically by configure. */
2/* config.h.in --- xscreensaver, Copyright (c) 1998 Jamie Zawinski.
3 *
4 * The best way to set these parameters is by running the included `configure'
5 * script. That examines your system, and generates `config.h' from
6 * `config.h.in'.
7 *
8 * If something goes very wrong, you can edit `config.h' directly, but beware
9 * that your changes will be lost if you ever run `configure' again.
10 */
11
12
13/* *************************************************************************
14 CONFIGURING SERVER EXTENSIONS
15 ************************************************************************* */
16
17/* Define this if you have the XReadDisplay extension (I think this is an
18 SGI-only thing; it's in <X11/extensions/readdisplay.h>.) A few of the
19 screenhacks will take advantage of this if it's available.
20 */
21/* #undef HAVE_READ_DISPLAY_EXTENSION */
22
23/* Define this if you have the Iris Video Library (dmedia/vl.h on SGI.)
24 A few of the screenhacks will take advantage of this if it's available.
25 */
26/* #undef HAVE_SGI_VIDEO */
27
28/* Define this if you have the XHPDisableReset function (an HP only thing.)
29 */
30/* #undef HAVE_XHPDISABLERESET */
31
32/* First, some background: there are three distinct server extensions which
33 * are useful to a screen saver program: they are XIDLE, MIT-SCREEN-SAVER,
34 * and SCREEN_SAVER.
35 *
36 * The XIDLE extension resides in .../contrib/extensions/xidle/ on the X11R5
37 * contrib tape. This extension lets the client get accurate idle-time
38 * information from the X server in a potentially more reliable way than by
39 * simply watching for keyboard and mouse activity. However, the XIDLE
40 * extension has apparently not been ported to X11R6.
41 *
42 * The SCREEN_SAVER extension is found (as far as I know) only in the SGI
43 * X server, and it exists in all releases since (at least) Irix 5. The
44 * relevant header file is /usr/include/X11/extensions/XScreenSaver.h.
45 *
46 * The similarly-named MIT-SCREEN-SAVER extension came into existence long
47 * after the SGI SCREEN_SAVER extension was already in use, and resides in
48 * .../contrib/extensions/screensaver/ on the X11R6 contrib tape. It is
49 * also found in certain recent X servers built in to NCD X terminals.
50 *
51 * The MIT extension does basically the same thing that the XIDLE extension
52 * does, but there are two things wrong with it: first, because of the way
53 * the extension was designed, the `fade' option to XScreenSaver will be
54 * uglier: just before the screen fades out, there will be an unattractive
55 * flicker to black, because this extension blanks the screen *before*
56 * telling us that it is time to do so. Second, this extension is known to
57 * be buggy; on the systems I use, it works, but some people have reported
58 * X server crashes as a result of using it. XScreenSaver uses this
59 * extension rather conservatively, because when I tried to use any of its
60 * more complicated features, I could get it to crash the server at the
61 * drop of a hat.
62 *
63 * In short, the MIT-SCREEN-SAVER extension is a piece of junk. The older
64 * SGI SCREEN_SAVER extension works great, as does XIDLE. It would be nice
65 * If those two existed on more systems, that is, would be adopted by the
66 * X Consortium in favor of their inferior "not-invented-here" entry.
67 */
68
69/* Define this if you have the XIDLE extension installed. If you have the
70 * XIDLE extension, this is recommended. (You have this extension if the
71 * file /usr/include/X11/extensions/xidle.h exists.) Turning on this flag
72 * lets XScreenSaver work better with servers which support this extension;
73 * but it will still work with servers which do not suport it, so it's a good
74 * idea to compile in support for it if you can.
75 */
76/* #undef HAVE_XIDLE_EXTENSION */
77
78/* Define this if you have the MIT-SCREEN-SAVER extension installed. See the
79 * caveats about this extension, above. (It's available if the file
80 * /usr/include/X11/extensions/scrnsaver.h exists.)
81 */
82#define HAVE_MIT_SAVER_EXTENSION 1
83
84/* Define this if you have the SGI SCREEN_SAVER extension. This is standard
85 * on Irix systems, and not available elsewhere.
86 */
87/* #undef HAVE_SGI_SAVER_EXTENSION */
88
89/* Define this if you have the SGI-VIDEO-CONTROL extension. This is standard
90 * on Irix systems, and not available elsewhere.
91 */
92/* #undef HAVE_SGI_VC_EXTENSION */
93
94/* Define this if you have the XDPMS extension. This is standard on
95 * sufficiently-recent XFree86 systems, and possibly elsewhere. (It's
96 * available if the file /usr/include/X11/extensions/dpms.h exists.)
97 */
98/* #undef HAVE_DPMS_EXTENSION */
99
100/* Define this if you have the functions XF86VidModeGetModeLine() and
101 * XF86VidModeGetViewPort(), in support of virtual desktops where the
102 * X server's root window is bigger than the actual screen. This is
103 * an XFree86 thing, and probably doesn't exist elsewhere. (It's
104 * available if the file /usr/include/X11/extensions/xf86vmode.h exists.)
105 */
106/* #undef HAVE_XF86VMODE */
107
108/* Define this if you have a Linux-like /proc/interrupts file which can be
109 * examined to determine when keyboard activity has occurred.
110 */
111/* #undef HAVE_PROC_INTERRUPTS */
112
113
114
115/* *************************************************************************
116 CONFIGURING GRAPHICS TOOLKITS
117 ************************************************************************* */
118
119/* Define this if you have Motif.
120 */
121#define HAVE_MOTIF 1
122
123/* Define this if you have Gtk.
124 */
125/* #undef HAVE_GTK */
126
127/* Define this if you have Athena (-Xaw).
128 */
129#define HAVE_ATHENA 1
130
131/* Define this if you have Athena, and the version you have includes the
132 * XawViewportSetCoordinates function in Viewport.h (some old versions of
133 * the library didn't have this function.)
134 */
135#define HAVE_XawViewportSetCoordinates 1
136
137/* Define this if you have the XPM library installed. Some of the demos can
138 * make use of this if it is available.
139 */
140#define HAVE_XPM 1
141
142/* Define this if you have the Xmu library. This is standard part of X, and
143 * if your vendor doesn't ship it, you should report that as a bug.
144 */
145#define HAVE_XMU 1
146
147/* Define this if you have OpenGL. Some of the demos require it, so if you
148 * don't have it, then those particular demos won't be built. (This won't
149 * affect the screen saver as a whole.)
150 */
151/* #undef HAVE_GL */
152
153/* Define this if you have OpenGL, but it's the MesaGL variant. (The
154 libraries have different names.) (HAVE_GL should be defined too.)
155 */
156/* #undef HAVE_MESA_GL */
157
158/* Define this if your version of OpenGL has the glBindTexture() routine.
159 This is the case for OpenGL 1.1, but not for OpenGL 1.0.
160 */
161/* #undef HAVE_GLBINDTEXTURE */
162
163/* Define this if you have the -lgle and -lmatrix libraries (GL extrusion.)
164 */
165/* #undef HAVE_GLE */
166
167/* Define this if the `xscreensaver' process itself (the driver process)
168 should be linked against GL. Most systems won't want this (in particular,
169 if you're using Linux and/or Mesa, you don't want this) but SGI systems
170 do want this. It may also be useful on other systems that have serious
171 GL support -- you only need this if you have a lot of different visuals,
172 not all of which work with GL programs.
173 */
174/* #undef DAEMON_USE_GL */
175
176/* Define this if you have the X Shared Memory Extension.
177 */
178#define HAVE_XSHM_EXTENSION 1
179
180/* Define this if you have the X Double Buffer Extension.
181 */
182#define HAVE_DOUBLE_BUFFER_EXTENSION 1
183
184/* Some screenhacks like to run an external program to generate random pieces
185 of text; set this to the one you like ("yow" and "fortune" are the most
186 likely prospects.) Note that this is just the default; X resources can
187 be used to override it.
188 */
189#define ZIPPY_PROGRAM "/usr/local/libexec/emacs/20.4/sparc-sun-solaris2.6/yow"
190
191
192
193/* *************************************************************************
194 CONFIGURING PASSWORD AUTHENTICATION
195 ************************************************************************* */
196
197/* Define this to remove the option of locking the screen at all.
198 */
199/* #undef NO_LOCKING */
200
201/* Define this if you want to use Kerberos authentication to lock/unlock the
202 * screen instead of your local password. This currently uses Kerberos V4,
203 * but a V5 server with V4 compatibility will work. WARNING: DO NOT USE AFS
204 * string-to-key passwords with this option. This option currently *only*
205 * works with standard Kerberos des_string_to_key. If your password is an
206 * AFS password and not a kerberos password, it will not authenticate
207 * properly. See the comments in driver/kpasswd.c for more information if you
208 * need it.
209 */
210/* #undef HAVE_KERBEROS */
211
212/* Define this if you want to use PAM (Pluggable Authentication Modules)
213 * to lock/unlock the screen, instead of standard /etc/passwd authentication.
214 */
215/* #undef HAVE_PAM */
216
217/* If PAM is being used, this is the name of the PAM service that xscreensaver
218 * will authenticate as. The default is "xscreensaver", which means that the
219 * PAM library will look for an "xscreensaver" line in /etc/pam.conf, or (on
220 * recent Linux systems) will look for a file called /etc/pam.d/xscreensaver.
221 * Some systems might already have a PAM installation that is configured for
222 * xlock, so setting this to "xlock" would also work in that case.
223 */
224#define PAM_SERVICE_NAME "xscreensaver"
225
226/* Define if you have PAM and pam_strerror() requires two arguments. */
227/* #undef PAM_STRERROR_TWO_ARGS */
228
229/* Define this if your system uses `shadow' passwords, that is, the passwords
230 * live in /etc/shadow instead of /etc/passwd, and one reads them with
231 * getspnam() instead of getpwnam(). (Note that SCO systems do some random
232 * other thing; others might as well. See the ifdefs in driver/passwd-pwent.c
233 * if you're having trouble related to reading passwords.)
234 */
235#define HAVE_SHADOW_PASSWD 1
236
237/* Define this if your system is Digital or SCO Unix with so-called ``Enhanced
238 Security'', that is, the passwords live in /tcb/files/auth/<x>/<xyz>
239 instead of in /etc/passwd, and one reads them with getprpwnam() instead
240 of getpwnam().
241 */
242/* #undef HAVE_ENHANCED_PASSWD */
243
244/* Define this if your system is Solaris with ``adjunct'' passwords (this is
245 the version where one gets at the passwords with getpwanam() instead of
246 getpwnam().) I haven't tested this one, let me know if it works.
247 */
248/* #undef HAVE_ADJUNCT_PASSWD */
249
250/* Define this if you are running HPUX with so-called ``Secure Passwords''
251 (if you have /usr/include/hpsecurity.h, you probably have this.) I
252 haven't tested this one, let me know if it works.
253 */
254/* #undef HAVE_HPUX_PASSWD */
255
256/* Define this if you are on a system that supports the VT_LOCKSWITCH and
257 VT_UNLOCKSWITCH ioctls. If this is defined, then when the screen is
258 locked, switching to another virtual terminal will also be prevented.
259 That is, the whole console will be locked, rather than just the VT on
260 which X is running. (Well, that's the theory anyway -- in practice,
261 I haven't yet figured out how to make that work.)
262 */
263/* #undef HAVE_VT_LOCKSWITCH */
264
265
266/* Define this if you the openlog(), syslog(), and closelog() functions.
267 This is used for logging failed login attempts.
268 */
269#define HAVE_SYSLOG 1
270
271
272/* *************************************************************************
273 OTHER C ENVIRONMENT JUNK
274 ************************************************************************* */
275
276/* Define this to void* if you're using X11R4 or earlier. */
277/* #undef XPointer */
278
279/* Define if you have the nice function. */
280#define HAVE_NICE 1
281
282/* Define if you have the setpriority function. */
283#define HAVE_SETPRIORITY 1
284
285/* Define to empty if the keyword does not work. */
286/* #undef const */
287
288/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
289#define HAVE_SYS_WAIT_H 1
290
291/* Define as __inline if that's what the C compiler calls it. */
292/* #undef inline */
293
294/* Define to `int' if <sys/types.h> doesn't define. */
295/* #undef mode_t */
296
297/* Define to `int' if <sys/types.h> doesn't define. */
298/* #undef pid_t */
299
300/* Define as the return type of signal handlers (int or void). */
301#define RETSIGTYPE void
302
303/* Define to `unsigned' if <sys/types.h> doesn't define. */
304/* #undef size_t */
305
306/* Define if you have the ANSI C header files. */
307#define STDC_HEADERS 1
308
309/* Define if you can safely include both <sys/time.h> and <time.h>. */
310#define TIME_WITH_SYS_TIME 1
311
312/* Define if you have the gettimeofday function. */
313#define HAVE_GETTIMEOFDAY 1
314
315/* Define if gettimeofday requires two arguments. */
316#define GETTIMEOFDAY_TWO_ARGS 1
317
318/* Define if you have the putenv function. */
319#define HAVE_PUTENV 1
320
321/* Define if you have the select function. */
322#define HAVE_SELECT 1
323
324/* Define if you have the getcwd function. */
325#define HAVE_GETCWD 1
326
327/* Define if you have the getcwd function. */
328#define HAVE_GETWD 1
329
330/* Define if you have the realpath function. */
331#define HAVE_REALPATH 1
332
333/* Define if you have the uname function. */
334#define HAVE_UNAME 1
335
336/* Define if you have the fcntl function. */
337#define HAVE_FCNTL 1
338
339/* Define if you have the sigaction function. */
340#define HAVE_SIGACTION 1
341
342/* Define if you have the <unistd.h> header file. */
343#define HAVE_UNISTD_H 1
344
345/* Define if you have the <crypt.h> header file. */
346#define HAVE_CRYPT_H 1
347
348/* Define if you have <sys/select.h> that defines fd_set and FD_SET. */
349#define HAVE_SYS_SELECT_H 1
350
351/* Define to use sigaction() instead of signal() for SIGCHLD-related activity.
352 This is necessary at least on SCO OpenServer 5, due to a Unix kernel bug.
353 */
354/* #undef USE_SIGACTION */
355
356/* Define this if you do pings with a `struct icmp' and a `icmp_id' slot.
357 */
358#define HAVE_ICMP 1
359
360/* Define this if you do pings with a `struct icmphdr' and a `un.echo.id' slot.
361 */
362/* #undef HAVE_ICMPHDR */
diff --git a/uisimulator/x11/kernel.c b/uisimulator/x11/kernel.c
deleted file mode 100644
index 947d82a550..0000000000
--- a/uisimulator/x11/kernel.c
+++ /dev/null
@@ -1,165 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Jens Arnold
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stddef.h>
21#include "kernel.h"
22#include "thread.h"
23#include "debug.h"
24
25static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
26
27int set_irq_level (int level)
28{
29 static int _lv = 0;
30 return (_lv = level);
31}
32
33void queue_init(struct event_queue *q)
34{
35 q->read = 0;
36 q->write = 0;
37}
38
39void queue_delete(struct event_queue *q)
40{
41 (void)q;
42}
43
44void queue_wait(struct event_queue *q, struct event *ev)
45{
46 while(q->read == q->write)
47 {
48 switch_thread();
49 }
50
51 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
52}
53
54void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
55{
56 unsigned int timeout = current_tick + ticks;
57
58 while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
59 {
60 sleep(1);
61 }
62
63 if(q->read != q->write)
64 {
65 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
66 }
67 else
68 {
69 ev->id = SYS_TIMEOUT;
70 }
71}
72
73void queue_post(struct event_queue *q, long id, void *data)
74{
75 int wr;
76 int oldlevel;
77
78 oldlevel = set_irq_level(15<<4);
79 wr = (q->write++) & QUEUE_LENGTH_MASK;
80
81 q->events[wr].id = id;
82 q->events[wr].data = data;
83 set_irq_level(oldlevel);
84}
85
86bool queue_empty(const struct event_queue* q)
87{
88 return ( q->read == q->write );
89}
90
91void queue_clear(struct event_queue* q)
92{
93 /* fixme: This is potentially unsafe in case we do interrupt-like processing */
94 q->read = 0;
95 q->write = 0;
96}
97
98void switch_thread (void)
99{
100 yield ();
101}
102
103void sim_tick_tasks(void)
104{
105 int i;
106
107 /* Run through the list of tick tasks */
108 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
109 {
110 if(tick_funcs[i])
111 {
112 tick_funcs[i]();
113 }
114 }
115}
116
117int tick_add_task(void (*f)(void))
118{
119 int i;
120
121 /* Add a task if there is room */
122 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
123 {
124 if(tick_funcs[i] == NULL)
125 {
126 tick_funcs[i] = f;
127 return 0;
128 }
129 }
130 DEBUGF("Error! tick_add_task(): out of tasks");
131 return -1;
132}
133
134int tick_remove_task(void (*f)(void))
135{
136 int i;
137
138 /* Remove a task if it is there */
139 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
140 {
141 if(tick_funcs[i] == f)
142 {
143 tick_funcs[i] = NULL;
144 return 0;
145 }
146 }
147
148 return -1;
149}
150
151void mutex_init(struct mutex *m)
152{
153 (void)m;
154}
155
156void mutex_lock(struct mutex *m)
157{
158 (void)m;
159}
160
161void mutex_unlock(struct mutex *m)
162{
163 (void)m;
164}
165
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
deleted file mode 100644
index c85848c18b..0000000000
--- a/uisimulator/x11/lcd-x11.c
+++ /dev/null
@@ -1,262 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stdio.h>
21#include <string.h>
22#include <stdarg.h>
23#include <stdlib.h>
24#include <ctype.h>
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <fcntl.h>
28
29#include <errno.h>
30#include <ctype.h>
31#include <time.h>
32
33#include "screenhack.h"
34#include "config.h"
35#include "debug.h"
36
37/*
38 * Specific implementations for X11, using the generic LCD API and data.
39 */
40
41#include "lcd-x11.h"
42#include "lcd-playersim.h"
43
44#if LCD_DEPTH == 2
45#define YBLOCK 4
46#define ANDBIT 3 /* AND with this to get the color number */
47#else
48#define YBLOCK 8
49#define ANDBIT 1
50#endif
51
52extern void screen_resized(int width, int height);
53extern bool lcd_display_redraw;
54
55#ifdef HAVE_LCD_BITMAP
56#if LCD_DEPTH==16
57fb_data lcd_framebuffer_copy[LCD_HEIGHT][LCD_WIDTH*2];
58#else
59fb_data lcd_framebuffer_copy[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
60#endif
61
62void lcd_update (void)
63{
64 /* update a full screen rect */
65 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
66}
67
68void lcd_update_rect(int x_start, int y_start,
69 int width, int height)
70{
71 int x;
72 int yline=y_start;
73 int y;
74 int p=0;
75 int bit;
76 int xmax;
77 int ymax;
78 int colors[LCD_WIDTH * LCD_HEIGHT];
79 struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
80 unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
81
82#if 0
83 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
84 counter++, x_start, y_start, width, height);
85#endif
86 /* The Y coordinates have to work on even YBLOCK pixel rows */
87 ymax = (yline + height)/YBLOCK;
88 yline /= YBLOCK;
89
90 xmax = x_start + width;
91
92 if(xmax > LCD_WIDTH)
93 xmax = LCD_WIDTH;
94 if(ymax >= LCD_HEIGHT/YBLOCK)
95 ymax = LCD_HEIGHT/YBLOCK-1;
96
97 for(; yline <= ymax; yline++) {
98 y = yline * YBLOCK;
99 for(x = x_start; x < xmax; x++) {
100 unsigned char diff = (lcd_framebuffer[yline][x]
101 ^ lcd_framebuffer_copy[yline][x])
102 | force_mask;
103 if(diff) {
104 /* one or more bits/pixels are changed */
105 unsigned char mask = ANDBIT;
106 for(bit = 0; bit < YBLOCK; bit++) {
107 if(diff & mask) {
108 /* pixel has changed */
109 unsigned int col = lcd_framebuffer[yline][x] & mask;
110#if LCD_DEPTH == 2
111 colors[p] = col >> (bit * LCD_DEPTH);
112#else
113 colors[p] = col ? 3 : 0;
114#endif
115 points[p].x = x + MARGIN_X;
116 points[p].y = y + bit + MARGIN_Y;
117 p++; /* increase the point counter */
118 }
119 mask <<= LCD_DEPTH;
120 }
121
122 /* update the copy */
123 lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x];
124 }
125 }
126 }
127
128 dots(colors, &points[0], p);
129 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
130 XtAppLock(app);
131 XSync(dpy,False);
132 XtAppUnlock(app);
133 lcd_display_redraw=false;
134}
135
136#ifdef LCD_REMOTE_HEIGHT
137extern unsigned char lcd_remote_framebuffer[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
138unsigned char lcd_remote_framebuffer_copy[LCD_REMOTE_HEIGHT/8][LCD_REMOTE_WIDTH];
139
140#define REMOTE_START_Y (LCD_HEIGHT + 2*MARGIN_Y)
141
142void lcd_remote_update (void)
143{
144 lcd_remote_update_rect(0, 0, LCD_REMOTE_WIDTH, LCD_REMOTE_HEIGHT);
145}
146
147void lcd_remote_update_rect(int x_start, int y_start,
148 int width, int height)
149{
150 int x;
151 int yline=y_start;
152 int y;
153 int p=0;
154 int bit;
155 int xmax;
156 int ymax;
157 struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
158 int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
159 unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
160
161#if 0
162 fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
163 counter++, x_start, y_start, width, height);
164#endif
165 /* The Y coordinates have to work on even 8 pixel rows */
166 ymax = (yline + height)/8;
167 yline /= 8;
168
169 xmax = x_start + width;
170
171 if(xmax > LCD_REMOTE_WIDTH)
172 xmax = LCD_REMOTE_WIDTH;
173 if(ymax >= LCD_REMOTE_HEIGHT/8)
174 ymax = LCD_REMOTE_HEIGHT/8-1;
175
176 for(; yline <= ymax; yline++) {
177 y = yline * 8;
178 for(x = x_start; x < xmax; x++) {
179 unsigned char diff = (lcd_remote_framebuffer[yline][x]
180 ^ lcd_remote_framebuffer_copy[yline][x])
181 | force_mask;
182 if(diff) {
183 unsigned char mask = 1;
184 for(bit = 0; bit < 8; bit++) {
185 if(diff & mask) {
186 unsigned int col = lcd_remote_framebuffer[yline][x] & mask;
187 colors[p] = col ? 3 : 0;
188 points[p].x = x + MARGIN_X;
189 points[p].y = y + bit + (REMOTE_START_Y + MARGIN_Y);
190 p++; /* increase the point counter */
191 }
192 mask <<= 1;
193 }
194
195 /* update the copy */
196 lcd_remote_framebuffer_copy[yline][x] =
197 lcd_remote_framebuffer[yline][x];
198 }
199 }
200 }
201
202 dots(colors, &points[0], p);
203 /* printf("lcd_update_rect: Draws %d pixels, clears %d pixels\n", p, cp);*/
204 XtAppLock(app);
205 XSync(dpy,False);
206 XtAppUnlock(app);
207 lcd_display_redraw=false;
208}
209
210
211#endif
212
213#endif
214#ifdef HAVE_LCD_CHARCELLS
215
216/* Defined in lcd-playersim.c */
217extern void lcd_print_char(int x, int y);
218extern unsigned char lcd_buffer[2][11];
219extern void drawrect(int color, int x1, int y1, int x2, int y2);
220
221extern unsigned char hardware_buffer_lcd[11][2];
222static unsigned char lcd_buffer_copy[11][2];
223
224void lcd_update (void)
225{
226 bool changed=false;
227 int x, y;
228 for (y=0; y<2; y++) {
229 for (x=0; x<11; x++) {
230 if (lcd_display_redraw ||
231 lcd_buffer_copy[x][y] != hardware_buffer_lcd[x][y]) {
232 lcd_buffer_copy[x][y] = hardware_buffer_lcd[x][y];
233 lcd_print_char(x, y);
234 changed=true;
235 }
236 }
237 }
238 if (changed)
239 {
240 XtAppLock(app);
241 XSync(dpy,False);
242 XtAppUnlock(app);
243 }
244 lcd_display_redraw=false;
245}
246
247#endif
248
249#ifdef CONFIG_BACKLIGHT
250void sim_backlight(int value)
251{
252 DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off");
253}
254#endif
255
256#ifdef HAVE_REMOTE_LCD
257void sim_remote_backlight(int value)
258{
259 DEBUGF("remote backlight: %s\n", (value > 0) ? "on" : "off");
260}
261#endif
262
diff --git a/uisimulator/x11/lcd-x11.h b/uisimulator/x11/lcd-x11.h
deleted file mode 100644
index 07911b2530..0000000000
--- a/uisimulator/x11/lcd-x11.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#define MARGIN_X 3
21#define MARGIN_Y 3
22
23/* include the "real" lcd.h file here */
24#include <lcd.h>
25
26
diff --git a/uisimulator/x11/oss_sound.c b/uisimulator/x11/oss_sound.c
deleted file mode 100644
index 51d85470e7..0000000000
--- a/uisimulator/x11/oss_sound.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2002 Dave Chapman
10 *
11 * oss_sound - a sound driver for Linux (and others?) OSS audio
12 *
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include <stdio.h>
22#include <fcntl.h>
23
24#include <sys/soundcard.h>
25#include "../common/sound.h"
26
27/* We want to use the "real" open in this file */
28#undef open
29
30int init_sound(sound_t* sound) {
31 sound->fd=open("/dev/dsp", O_WRONLY);
32 sound->freq=-1;
33 sound->channels=-1;
34
35 if (sound->fd <= 0) {
36 fprintf(stderr,"Can not open /dev/dsp - simulating sound output\n");
37 sound->fd=0;
38 }
39}
40
41int config_sound(sound_t* sound, int sound_freq, int channels) {
42 int format=AFMT_S16_NE;
43 int setting=0x000C000D; // 12 fragments size 8kb ? WHAT IS THIS?
44
45 sound->freq=sound_freq;
46 sound->channels=channels;
47
48 if (sound->fd) {
49 if (ioctl(sound->fd,SNDCTL_DSP_SETFRAGMENT,&setting)==-1) {
50 perror("SNDCTL_DSP_SETFRAGMENT");
51 }
52
53 if (ioctl(sound->fd,SNDCTL_DSP_CHANNELS,&channels)==-1) {
54 perror("SNDCTL_DSP_STEREO");
55 }
56 if (channels==0) { fprintf(stderr,"Warning, only mono supported\n"); }
57
58 if (ioctl(sound->fd,SNDCTL_DSP_SETFMT,&format)==-1) {
59 perror("SNDCTL_DSP_SETFMT");
60 }
61
62 if (ioctl(sound->fd,SNDCTL_DSP_SPEED,&sound_freq)==-1) {
63 perror("SNDCTL_DSP_SPEED");
64 }
65 }
66}
67
68int output_sound(sound_t* sound,const void* buf, int count) {
69 unsigned long long t;
70
71 if (sound->fd) {
72 return(write(sound->fd,buf,count));
73 } else {
74 t=(unsigned int)(((unsigned int)(1000000/sound->channels)*count)/sound->freq);
75// fprintf(stderr,"writing %d bytes at %d frequency - sleeping for %u microseconds\n",count,sound->freq,t);
76 usleep(t);
77 return(count);
78 }
79}
80
81void close_sound(sound_t* sound) {
82 if (sound->fd) close(sound->fd);
83 sound->fd=-1;
84}
diff --git a/uisimulator/x11/resources.c b/uisimulator/x11/resources.c
deleted file mode 100644
index feaf3b8216..0000000000
--- a/uisimulator/x11/resources.c
+++ /dev/null
@@ -1,113 +0,0 @@
1/* xscreensaver, Copyright (c) 1992, 1997, 1998
2 * Jamie Zawinski <jwz@jwz.org>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
10 * implied warranty.
11 */
12
13#include "utils.h"
14#include "resources.h"
15#include <X11/Xresource.h>
16
17
18/* Resource functions. Assumes: */
19
20extern char *progname;
21extern char *progclass;
22extern XrmDatabase db;
23
24#ifndef isupper
25# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
26#endif
27#ifndef _tolower
28# define _tolower(c) ((c) - 'A' + 'a')
29#endif
30
31char *
32get_string_resource (char *res_name, char *res_class)
33{
34 XrmValue value;
35 char *type;
36 char full_name [1024], full_class [1024];
37 strcpy (full_name, progname);
38 strcat (full_name, ".");
39 strcat (full_name, res_name);
40 strcpy (full_class, progclass);
41 strcat (full_class, ".");
42 strcat (full_class, res_class);
43 if (XrmGetResource (db, full_name, full_class, &type, &value))
44 {
45 char *str = (char *) malloc (value.size + 1);
46 strncpy (str, (char *) value.addr, value.size);
47 str [value.size] = 0;
48 return str;
49 }
50 return 0;
51}
52
53Bool
54get_boolean_resource (char *res_name, char *res_class)
55{
56 char *tmp, buf [100];
57 char *s = get_string_resource (res_name, res_class);
58 char *os = s;
59 if (! s) return 0;
60 for (tmp = buf; *s; s++)
61 *tmp++ = isupper (*s) ? _tolower (*s) : *s;
62 *tmp = 0;
63 free (os);
64
65 while (*buf &&
66 (buf[strlen(buf)-1] == ' ' ||
67 buf[strlen(buf)-1] == '\t'))
68 buf[strlen(buf)-1] = 0;
69
70 if (!strcmp (buf, "on") || !strcmp (buf, "true") || !strcmp (buf, "yes"))
71 return 1;
72 if (!strcmp (buf,"off") || !strcmp (buf, "false") || !strcmp (buf,"no"))
73 return 0;
74 fprintf (stderr, "%s: %s must be boolean, not %s.\n",
75 progname, res_name, buf);
76 return 0;
77}
78
79unsigned int
80get_pixel_resource (char *res_name, char *res_class,
81 Display *dpy, Colormap cmap)
82{
83 XColor color;
84 char *s = get_string_resource (res_name, res_class);
85 char *s2;
86 if (!s) goto DEFAULT;
87
88 for (s2 = s + strlen(s) - 1; s2 > s; s2--)
89 if (*s2 == ' ' || *s2 == '\t')
90 *s2 = 0;
91 else
92 break;
93
94 if (! XParseColor (dpy, cmap, s, &color))
95 {
96 fprintf (stderr, "%s: can't parse color %s\n", progname, s);
97 goto DEFAULT;
98 }
99 if (! XAllocColor (dpy, cmap, &color))
100 {
101 fprintf (stderr, "%s: couldn't allocate color %s\n", progname, s);
102 goto DEFAULT;
103 }
104 free (s);
105 return color.pixel;
106 DEFAULT:
107 if (s) free (s);
108 return ((strlen(res_class) >= 10 &&
109 !strcmp ("Background", res_class + strlen(res_class) - 10))
110 ? BlackPixel (dpy, DefaultScreen (dpy))
111 : WhitePixel (dpy, DefaultScreen (dpy)));
112}
113
diff --git a/uisimulator/x11/resources.h b/uisimulator/x11/resources.h
deleted file mode 100644
index 1fbcfa7ce7..0000000000
--- a/uisimulator/x11/resources.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/* xscreensaver, Copyright (c) 1992, 1997 Jamie Zawinski <jwz@jwz.org>
2 *
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
9 * implied warranty.
10 */
11
12#ifndef __XSCREENSAVER_RESOURCES_H__
13#define __XSCREENSAVER_RESOURCES_H__
14extern char *get_string_resource (char*,char*);
15extern Bool get_boolean_resource (char*,char*);
16extern int get_integer_resource (char*,char*);
17extern double get_float_resource (char*,char*);
18extern unsigned int get_pixel_resource (char*,char*,Display*,Colormap);
19extern unsigned int get_minutes_resource (char*,char*);
20extern unsigned int get_seconds_resource (char*,char*);
21extern int parse_time (const char *string, Bool seconds_default_p,
22 Bool silent_p);
23#endif /* __XSCREENSAVER_RESOURCES_H__ */
diff --git a/uisimulator/x11/screenhack.c b/uisimulator/x11/screenhack.c
deleted file mode 100644
index c3aa2e4c63..0000000000
--- a/uisimulator/x11/screenhack.c
+++ /dev/null
@@ -1,579 +0,0 @@
1/* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998
2 * Jamie Zawinski <jwz@jwz.org>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
10 * implied warranty.
11 *
12 * And remember: X Windows is to graphics hacking as roman numerals are to
13 * the square root of pi.
14 */
15
16/* This file contains simple code to open a window or draw on the root.
17 The idea being that, when writing a graphics hack, you can just link
18 with this .o to get all of the uninteresting junk out of the way.
19
20 - create a procedure `screenhack(dpy, window)'
21
22 - create a variable `char *progclass' which names this program's
23 resource class.
24
25 - create a variable `char defaults []' for the default resources, and
26 null-terminate it.
27
28 - create a variable `XrmOptionDescRec options[]' for the command-line,
29 and null-terminate it.
30
31 And that's it...
32 */
33
34#include <stdio.h>
35#include <X11/Intrinsic.h>
36#include <X11/IntrinsicP.h>
37#include <X11/CoreP.h>
38#include <X11/Shell.h>
39#include <X11/StringDefs.h>
40#include <X11/Xutil.h>
41#include <X11/keysym.h>
42
43#ifdef __sgi
44# include <X11/SGIScheme.h> /* for SgiUseSchemes() */
45#endif /* __sgi */
46
47#ifdef HAVE_XMU
48# ifndef VMS
49# include <X11/Xmu/Error.h>
50# else /* VMS */
51# include <Xmu/Error.h>
52# endif
53#else
54# include "xmu.h"
55#endif
56#include "lcd-x11.h"
57#include "screenhack.h"
58#include "version.h"
59#include "vroot.h"
60
61#include "debug.h"
62#include "config.h"
63
64#ifndef isupper
65# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
66#endif
67#ifndef _tolower
68# define _tolower(c) ((c) - 'A' + 'a')
69#endif
70
71#define KEYBOARD_GENERIC \
72 "Keyboard Rockbox\n" \
73 "-------- ------------\n" \
74 "4, Left LEFT\n" \
75 "6, Right RIGHT\n"
76
77#if CONFIG_KEYPAD == PLAYER_PAD
78#define KEYBOARD_SPECIFIC \
79 "8, Up PLAY\n" \
80 "2, Down STOP\n" \
81 "+, Q ON\n" \
82 "., INS MENU\n"
83
84#elif CONFIG_KEYPAD == RECORDER_PAD
85#define KEYBOARD_SPECIFIC \
86 "8, Up UP\n" \
87 "2, Down DOWN\n" \
88 "5, Space PLAY\n" \
89 "+, Q ON\n" \
90 "Enter, A OFF\n" \
91 "/, (1) F1\n" \
92 "*, (2) F2\n" \
93 "-, (3) F3\n"
94
95#elif CONFIG_KEYPAD == ONDIO_PAD
96#define KEYBOARD_SPECIFIC \
97 "8, Up UP\n" \
98 "2, Down DOWN\n" \
99 "., INS MENU\n" \
100 "Enter, A OFF\n"
101
102#elif CONFIG_KEYPAD == IRIVER_H100_PAD
103#define KEYBOARD_SPECIFIC \
104 "8, Up UP\n" \
105 "2, Down DOWN\n" \
106 "5, Space SELECT\n" \
107 "+, Q ON\n" \
108 "Enter, A OFF\n" \
109 "., INS MODE\n" \
110 "/, (1) RECORD\n"
111
112#elif CONFIG_KEYPAD == IRIVER_H300_PAD
113#define KEYBOARD_SPECIFIC \
114 "[not written yet]"
115
116#elif CONFIG_KEYPAD == GMINI100_PAD
117#define KEYBOARD_SPECIFIC \
118 "8, Up UP\n" \
119 "2, Down DOWN\n" \
120 "5, Space PLAY\n" \
121 "+, Q ON\n" \
122 "Enter, A OFF\n" \
123 "., INS MENU\n"
124
125#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
126#define KEYBOARD_SPECIFIC \
127 "[not written yet]"
128
129#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
130#define KEYBOARD_SPECIFIC \
131 "[not written yet]"
132#else
133#error "Put your defines here"
134#endif
135
136
137char having_new_lcd=True;
138
139char *progname;
140XrmDatabase db;
141XtAppContext app;
142Display* dpy;
143Window window;
144Bool mono_p;
145
146static XrmOptionDescRec default_options [] = {
147 { "-root", ".root", XrmoptionNoArg, "True" },
148 { "-window", ".root", XrmoptionNoArg, "False" },
149 { "-mono", ".mono", XrmoptionNoArg, "True" },
150 { "-install", ".installColormap", XrmoptionNoArg, "True" },
151 { "-noinstall", ".installColormap", XrmoptionNoArg, "False" },
152 { "-visual", ".visualID", XrmoptionSepArg, 0 },
153 { "-window-id", ".windowID", XrmoptionSepArg, 0 },
154 { 0, 0, 0, 0 }
155};
156
157static char *default_defaults[] = {
158 ".root: false",
159#define GEOMETRY_POSITION 1
160 "*geometry: 120x68", /* to be replaced anyway */
161 "*mono: false",
162 "*installColormap: false",
163 "*visualID: default",
164 "*windowID: ",
165 0
166};
167
168extern int display_zoom;
169extern long current_tick;
170
171static XrmOptionDescRec *merged_options;
172static int merged_options_size;
173static char **merged_defaults;
174
175static void merge_options (void)
176{
177 int def_opts_size, opts_size;
178 int def_defaults_size, defaults_size;
179
180 for (def_opts_size = 0; default_options[def_opts_size].option;
181 def_opts_size++)
182 ;
183 for (opts_size = 0; options[opts_size].option; opts_size++)
184 ;
185
186 merged_options_size = def_opts_size + opts_size;
187 merged_options = (XrmOptionDescRec *)
188 malloc ((merged_options_size + 1) * sizeof(*default_options));
189 memcpy (merged_options, default_options,
190 (def_opts_size * sizeof(*default_options)));
191 memcpy (merged_options + def_opts_size, options,
192 ((opts_size + 1) * sizeof(*default_options)));
193
194 for (def_defaults_size = 0; default_defaults[def_defaults_size];
195 def_defaults_size++)
196 ;
197 for (defaults_size = 0; defaults[defaults_size]; defaults_size++)
198 ;
199
200 merged_defaults = (char **)
201 malloc ((def_defaults_size + defaults_size + 1) * sizeof (*defaults));
202
203 memcpy (merged_defaults, default_defaults,
204 def_defaults_size * sizeof(*defaults));
205 memcpy (merged_defaults + def_defaults_size, defaults,
206 (defaults_size + 1) * sizeof(*defaults));
207
208 /* This totally sucks. Xt should behave like this by default.
209 If the string in `defaults' looks like ".foo", change that
210 to "Progclass.foo".
211 */
212 {
213 char **s;
214 for (s = merged_defaults; *s; s++)
215 if (**s == '.')
216 {
217 const char *oldr = *s;
218 char *newr = (char *) malloc(strlen(oldr)
219 + strlen(progclass) + 3);
220 strcpy (newr, progclass);
221 strcat (newr, oldr);
222 *s = newr;
223 }
224 }
225}
226
227
228/* Make the X errors print out the name of this program, so we have some
229 clue which one has a bug when they die under the screensaver.
230 */
231
232static int screenhack_ehandler (Display *dpy, XErrorEvent *error)
233{
234 fprintf (stderr, "\nX error in %s:\n", progname);
235 if (XmuPrintDefaultErrorMessage (dpy, error, stderr))
236 exit (-1);
237 else
238 fprintf (stderr, " (nonfatal.)\n");
239 return 0;
240}
241
242static Bool MapNotify_event_p (Display *dpy, XEvent *event, XPointer window)
243{
244 (void)dpy;
245 return (event->xany.type == MapNotify &&
246 event->xvisibility.window == (Window) window);
247}
248
249static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
250
251
252static void kb_disable_auto_repeat(bool on)
253{
254 XKeyboardControl kb;
255
256 kb.auto_repeat_mode = on ? AutoRepeatModeOff : AutoRepeatModeDefault;
257 XChangeKeyboardControl(dpy, KBAutoRepeatMode, &kb);
258}
259
260static void kb_restore_auto_repeat(void) /* registered as an exit handler */
261{
262 kb_disable_auto_repeat(false);
263 XSync(dpy, false); /* force the X server to process that */
264}
265
266/* Dead-trivial event handling.
267 Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received.
268 */
269int screenhack_handle_event(XEvent *event, bool *release)
270{
271 int key=0;
272
273 *release = FALSE;
274
275 switch (event->xany.type) {
276 case KeyPress:
277 {
278 KeySym keysym;
279 unsigned char c = 0;
280 XLookupString (&event->xkey, (char *)&c, 1, &keysym, 0);
281 key = keysym;
282#if 0
283 DEBUGF("Got keypress: %c (%02x) %x, tick %ld\n", c, c,
284 event->xkey.keycode, current_tick);
285#endif
286 }
287 break;
288 case KeyRelease:
289 {
290 KeySym keysym;
291 unsigned char c = 0;
292 XLookupString (&event->xkey, (char *)&c, 1, &keysym, 0);
293 key = keysym;
294#if 0
295 DEBUGF("Got keyrelease: %c (%02x) %x, tick %ld\n", c, c,
296 event->xkey.keycode, current_tick);
297#endif
298 *release = TRUE;
299 }
300 break;
301 case Expose:
302 screen_redraw();
303 break;
304 case FocusIn:
305 kb_disable_auto_repeat(true);
306 break;
307 case FocusOut:
308 kb_disable_auto_repeat(false);
309 break;
310 case ClientMessage:
311 if (event->xclient.message_type != XA_WM_PROTOCOLS) {
312 char *s = XGetAtomName(dpy, event->xclient.message_type);
313 if (!s)
314 s = "(null)";
315 fprintf (stderr, "%s: unknown ClientMessage %s received!\n",
316 progname, s);
317 }
318 else if (event->xclient.data.l[0] != (int)XA_WM_DELETE_WINDOW) {
319 char *s1 = XGetAtomName(dpy, event->xclient.message_type);
320 char *s2 = XGetAtomName(dpy, event->xclient.data.l[0]);
321 if (!s1)
322 s1 = "(null)";
323 if (!s2)
324 s2 = "(null)";
325 fprintf (stderr, "%s: unknown ClientMessage %s[%s] received!\n",
326 progname, s1, s2);
327 }
328 else {
329 exit (0);
330 }
331 break;
332 default:
333 break;
334 }
335 return key;
336}
337
338
339int screenhack_handle_events(bool *release)
340{
341 int key=0;
342 XtAppLock(app);
343 if(XPending(dpy))
344 {
345 XEvent event;
346 XNextEvent(dpy, &event);
347 key=screenhack_handle_event(&event, release);
348 }
349 XtAppUnlock(app);
350 return key;
351}
352
353
354static Visual *pick_visual (Screen *screen)
355{
356#ifdef USE_GL
357 /* If we're linking against GL (that is, this is the version of
358 screenhack.o that the GL hacks will use, which is different from the
359 one that the non-GL hacks will use) then try to pick the "best" visual
360 by interrogating the GL library instead of by asking Xlib. GL knows
361 better.
362 */
363 Visual *v = 0;
364 char *string = get_string_resource ("visualID", "VisualID");
365 char *s;
366
367 if (string)
368 for (s = string; *s; s++)
369 if (isupper (*s)) *s = _tolower (*s);
370
371 if (!string || !*string ||
372 !strcmp (string, "gl") ||
373 !strcmp (string, "best") ||
374 !strcmp (string, "color") ||
375 !strcmp (string, "default"))
376 v = get_gl_visual (screen); /* from ../utils/visual-gl.c */
377
378 if (string)
379 free (string);
380 if (v)
381 return v;
382#endif /* USE_GL */
383
384 return get_visual_resource (screen, "visualID", "VisualID", False);
385}
386
387int main (int argc, char **argv)
388{
389 Widget toplevel;
390 Screen *screen;
391 Visual *visual;
392 Colormap cmap;
393 XEvent event;
394 char version[255];
395
396 sprintf(version,"rockboxui %s",ROCKBOXUI_VERSION);
397#ifdef HAVE_LCD_BITMAP
398 display_zoom=2;
399 {
400 char *env=getenv("RECORDER_ZOOM");
401 if (env) {
402 display_zoom=atoi(env);
403 }
404 }
405#else
406 display_zoom=1;
407 {
408 char *env=getenv("PLAYER_ZOOM");
409 if (env) {
410 display_zoom=atoi(env);
411 }
412 }
413#endif
414
415 if (argc > 1)
416 {
417 int x;
418 for (x=1; x<argc; x++) {
419 if (!strcmp("--old_lcd", argv[x])) {
420 having_new_lcd=FALSE;
421 printf("Using old LCD layout.\n");
422 } else if (!strcmp("--zoom", argv[x])) {
423 x++;
424 display_zoom=atoi(argv[x]);
425 printf("Window zoom is %d\n", display_zoom);
426 } else {
427 printf("rockboxui\n");
428 printf("Arguments:\n");
429 printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
430 printf(" --zoom \t window zoom\n");
431 printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC);
432 exit(0);
433 }
434 }
435 }
436 {
437 static char geometry[40];
438 unsigned int height = (LCD_HEIGHT+2*MARGIN_Y);
439#ifdef LCD_REMOTE_HEIGHT
440 height += (LCD_REMOTE_HEIGHT+2*MARGIN_Y);
441#endif
442 printf("height: %d\n", height);
443 snprintf(geometry, 40, "*geometry: %dx%d",
444 (LCD_WIDTH+2*MARGIN_X) * display_zoom, height * display_zoom);
445 default_defaults[GEOMETRY_POSITION]=geometry;
446 }
447 printf(KEYBOARD_GENERIC KEYBOARD_SPECIFIC);
448
449 merge_options ();
450
451#ifdef __sgi
452 /* We have to do this on SGI to prevent the background color from being
453 overridden by the current desktop color scheme (we'd like our
454 backgrounds to be black, thanks.) This should be the same as setting
455 the "*useSchemes: none" resource, but it's not -- if that resource is
456 present in the `default_defaults' above, it doesn't work, though it
457 does work when passed as an -xrm arg on the command line. So screw it,
458 turn them off from C instead.
459 */
460 SgiUseSchemes ("none");
461#endif /* __sgi */
462
463 XtToolkitThreadInitialize();
464
465 toplevel = XtAppInitialize (&app, progclass, merged_options,
466 merged_options_size, &argc, argv,
467 merged_defaults, 0, 0);
468 dpy = XtDisplay (toplevel);
469 screen = XtScreen (toplevel);
470 db = XtDatabase (dpy);
471
472 XtGetApplicationNameAndClass (dpy, &progname, &progclass);
473
474 /* half-assed way of avoiding buffer-overrun attacks. */
475 if (strlen (progname) >= 100) progname[100] = 0;
476
477 XSetErrorHandler (screenhack_ehandler);
478
479 XA_WM_PROTOCOLS = XInternAtom (dpy, "WM_PROTOCOLS", False);
480 XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
481
482
483 if (CellsOfScreen (DefaultScreenOfDisplay (dpy)) <= 2)
484 mono_p = True;
485
486 {
487 Boolean def_visual_p;
488 visual = pick_visual (screen);
489
490 if (toplevel->core.width <= 0)
491 toplevel->core.width = 600;
492 if (toplevel->core.height <= 0)
493 toplevel->core.height = 480;
494
495 def_visual_p = (visual == DefaultVisualOfScreen (screen));
496
497 if (!def_visual_p)
498 {
499 unsigned int bg, bd;
500 Widget new;
501
502 cmap = XCreateColormap (dpy, RootWindowOfScreen(screen),
503 visual, AllocNone);
504 bg = get_pixel_resource ("background", "Background", dpy, cmap);
505 bd = get_pixel_resource ("borderColor", "Foreground", dpy, cmap);
506
507 new = XtVaAppCreateShell (progname, progclass,
508 topLevelShellWidgetClass, dpy,
509 XtNmappedWhenManaged, False,
510 XtNvisual, visual,
511 XtNdepth, visual_depth (screen, visual),
512 XtNwidth, toplevel->core.width,
513 XtNheight, toplevel->core.height,
514 XtNcolormap, cmap,
515 XtNbackground, (Pixel) bg,
516 XtNborderColor, (Pixel) bd,
517 XtNinput, True, /* for WM_HINTS */
518 0);
519 XtDestroyWidget (toplevel);
520 toplevel = new;
521 XtRealizeWidget (toplevel);
522 window = XtWindow (toplevel);
523 }
524 else
525 {
526 XtVaSetValues (toplevel,
527 XtNmappedWhenManaged, False,
528 XtNinput, True, /* for WM_HINTS */
529 0);
530 XtRealizeWidget (toplevel);
531 window = XtWindow (toplevel);
532
533 if (get_boolean_resource ("installColormap", "InstallColormap"))
534 {
535 cmap = XCreateColormap (dpy, window,
536 DefaultVisualOfScreen (XtScreen
537 (toplevel)),
538 AllocNone);
539 XSetWindowColormap (dpy, window, cmap);
540 }
541 else
542 {
543 cmap = DefaultColormap (dpy, DefaultScreen (dpy));
544 }
545 }
546
547 XtPopup (toplevel, XtGrabNone);
548
549 XtVaSetValues(toplevel, XtNtitle, version, 0);
550
551 /* For screenhack_handle_events(): select KeyPress, and
552 announce that we accept WM_DELETE_WINDOW. */
553 {
554 XWindowAttributes xgwa;
555 XGetWindowAttributes (dpy, window, &xgwa);
556 XSelectInput (dpy, window,
557 xgwa.your_event_mask | KeyPressMask | KeyRelease |
558 ButtonPressMask | ExposureMask | FocusChangeMask );
559 XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32,
560 PropModeReplace,
561 (unsigned char *) &XA_WM_DELETE_WINDOW, 1);
562 }
563 }
564
565 XSetWindowBackground (dpy, window,
566 get_pixel_resource ("background", "Background",
567 dpy, cmap));
568 XClearWindow (dpy, window);
569
570 /* wait for it to be mapped */
571 XIfEvent (dpy, &event, MapNotify_event_p, (XPointer) window);
572
573 XSync (dpy, False);
574
575 atexit(kb_restore_auto_repeat);
576 kb_disable_auto_repeat(true);
577 screenhack(); /* doesn't return */
578 return 0;
579}
diff --git a/uisimulator/x11/screenhack.h b/uisimulator/x11/screenhack.h
deleted file mode 100644
index 5c2e5321ac..0000000000
--- a/uisimulator/x11/screenhack.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/* xscreensaver, Copyright (c) 1992-1997 Jamie Zawinski <jwz@jwz.org>
2 *
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
9 * implied warranty.
10 */
11
12#ifndef __SCREENHACK_H__
13#define __SCREENHACK_H__
14
15#include <stdlib.h>
16#include <stdbool.h>
17
18#include "config-x11.h"
19
20#ifdef __hpux
21 /* Which of the ten billion standards does values.h belong to?
22 What systems always have it? */
23# include <values.h>
24#endif
25
26#include <stdio.h>
27
28#include <X11/Xlib.h>
29#include <X11/Xresource.h>
30#include <X11/Xos.h>
31#include <X11/Intrinsic.h>
32
33#include "resources.h"
34#include "visual.h"
35
36extern Bool mono_p;
37extern char *progname;
38extern char *progclass;
39extern XrmDatabase db;
40extern XrmOptionDescRec options [];
41extern char *defaults [];
42extern XtAppContext app;
43extern Display* dpy;
44extern Window window;
45
46extern void screenhack();
47extern int screenhack_handle_event(XEvent*, bool *);
48extern int screenhack_handle_events(bool *);
49extern void screen_redraw();
50extern void screen_resized();
51
52#endif /* __SCREENHACK_H__ */
diff --git a/uisimulator/x11/sound.c b/uisimulator/x11/sound.c
deleted file mode 100644
index 06d9c014ff..0000000000
--- a/uisimulator/x11/sound.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "autoconf.h"
21
22#ifdef ROCKBOX_HAS_SIMSOUND /* play sound in sim enabled */
23
24#include <stdbool.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30#include <sys/ioctl.h>
31#include <sys/soundcard.h>
32
33#include "sound.h"
34
35static bool playing = false;
36
37int sim_sound_init(void)
38{
39 int fd;
40 int pcmbits;
41 int rc;
42 int channels;
43 int rate;
44
45 fd = open("/dev/dsp", O_WRONLY);
46 if(-1 == fd)
47 return 1;
48
49 pcmbits = 16;
50 rc = ioctl(fd, SOUND_PCM_WRITE_BITS, &pcmbits);
51 rc = ioctl(fd, SOUND_PCM_READ_BITS, &pcmbits);
52
53 channels = 2; /* Number of channels, 1=mono */
54 rc = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &channels);
55 rc = ioctl(fd, SOUND_PCM_READ_CHANNELS, &channels);
56
57 rate = 44100; /* Yeah. sampling rate */
58 rc = ioctl(fd, SOUND_PCM_WRITE_RATE, &rate);
59 rc = ioctl(fd, SOUND_PCM_READ_RATE, &rate);
60
61 return fd;
62}
63
64void sim_sound_play(int soundfd, char *buffer, long len)
65{
66 write(soundfd, buffer, len);
67}
68
69void sound_playback_thread(void)
70{
71 int soundfd = sim_sound_init();
72 unsigned char *buf;
73 long size;
74
75 while(-1 == soundfd)
76 sleep(100000); /* wait forever, can't play sound! */
77
78 do {
79
80 while(!sound_get_pcm)
81 /* TODO: fix a fine thread-synch mechanism here */
82 usleep(10000);
83
84 do {
85 sound_get_pcm(&buf, &size);
86 if(!size) {
87 sound_get_pcm = NULL;
88 break;
89 }
90 sim_sound_play(soundfd, (char *)buf, size);
91 usleep(10000);
92 } while(size);
93
94 } while(1);
95
96}
97
98/* Stubs for PCM audio playback. */
99bool pcm_is_playing(void)
100{
101 return playing;
102}
103
104void pcm_mute(bool state)
105{
106 (void)state;
107}
108
109void pcm_play_pause(bool state)
110{
111 (void)state;
112}
113
114bool pcm_is_paused(void)
115{
116 return false;
117}
118
119void pcm_play_stop(void)
120{
121 playing = false;
122}
123
124void pcm_init(void)
125{
126}
127
128void (*sound_get_pcm)(unsigned char** start, long* size);
129void pcm_play_data(void (*get_more)(unsigned char** start, long* size))
130{
131 sound_get_pcm = get_more;
132 playing = true;
133}
134
135long pcm_get_bytes_waiting(void)
136{
137 return 0;
138}
139
140#endif /* ROCKBOX_HAS_SIMSOUND */
diff --git a/uisimulator/x11/sound.h b/uisimulator/x11/sound.h
deleted file mode 100644
index 87499cac8e..0000000000
--- a/uisimulator/x11/sound.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20void sound_playback_thread(void);
21
22extern void (*sound_get_pcm)(unsigned char** start, long* size);
diff --git a/uisimulator/x11/sprintf.h b/uisimulator/x11/sprintf.h
deleted file mode 100644
index 64a22f3c6e..0000000000
--- a/uisimulator/x11/sprintf.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#include <stdarg.h>
2#include <stdio.h>
3
4int rockbox_snprintf (char *buf, size_t size, const char *fmt, ...);
5int rockbox_vsnprintf (char *buf, int size, const char *fmt, va_list ap);
6int rockbox_fprintf (int fd, const char *fmt, ...);
7
8#ifndef NO_REDEFINES_PLEASE
9#define snprintf rockbox_snprintf
10#define vsnprintf rockbox_vsnprintf
11#define fprintf rockbox_fprintf
12#endif
diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c
deleted file mode 100644
index 6d9139c35d..0000000000
--- a/uisimulator/x11/thread.c
+++ /dev/null
@@ -1,148 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "autoconf.h"
21
22#include <stdio.h>
23#include <pthread.h>
24
25#include "kernel.h"
26#include <sys/time.h>
27
28#ifdef ROCKBOX_HAS_SIMSOUND
29#include "sound.h"
30#endif
31
32long current_tick = 0;
33extern void sim_tick_tasks(void);
34
35static void msleep(int msec)
36{
37 struct timeval delay;
38
39 delay.tv_sec = msec / 1000;
40 delay.tv_usec = (msec % 1000) * 1000;
41 select(0, NULL, NULL, NULL, &delay); /* portable sub-second sleep */
42}
43
44/*
45 * This is not a target thread, so it does not fall under the 1 thread at a
46 * time thing.
47 */
48static void update_tick_thread()
49{
50 struct timeval start, now;
51 long new_tick;
52
53 gettimeofday(&start, NULL);
54 while (1)
55 {
56 msleep(5); /* check twice per simulated target tick */
57 gettimeofday(&now, NULL);
58 new_tick = (now.tv_sec - start.tv_sec) * HZ
59 + (now.tv_usec - start.tv_usec) / (1000000/HZ);
60 if (new_tick > current_tick)
61 {
62 sim_tick_tasks();
63 current_tick = new_tick;
64 }
65 }
66}
67
68/*
69 * We emulate the target threads by using pthreads. We have a mutex that only
70 * allows one thread at a time to execute. It forces each thread to yield()
71 * for the other(s) to run.
72 */
73
74pthread_mutex_t mp;
75
76void init_threads(void)
77{
78 pthread_t tick_tid;
79
80 pthread_mutex_init(&mp, NULL);
81 /* get mutex to only allow one thread running at a time */
82 pthread_mutex_lock(&mp);
83
84 /* start a tick thread */
85 pthread_create(&tick_tid, NULL, (void *(*)(void *)) update_tick_thread,
86 NULL);
87
88#ifdef ROCKBOX_HAS_SIMSOUND /* start thread that plays PCM data */
89 {
90 pthread_t sound_tid;
91 pthread_create(&sound_tid, NULL,
92 (void *(*)(void *)) sound_playback_thread,
93 NULL);
94 }
95#endif
96
97}
98/*
99 int pthread_create(pthread_t *new_thread_ID,
100 const pthread_attr_t *attr,
101 void * (*start_func)(void *), void *arg);
102*/
103
104void yield(void)
105{
106 pthread_mutex_unlock(&mp); /* return */
107 msleep(1); /* prevent busy loop */
108 pthread_mutex_lock(&mp); /* get it again */
109}
110
111void newfunc(void (*func)(void))
112{
113 pthread_mutex_lock(&mp);
114 func();
115 pthread_mutex_unlock(&mp);
116}
117
118
119int create_thread(void (*fp)(void), void* sp, int stk_size)
120{
121 pthread_t tid;
122 int i;
123 int error;
124
125 /* we really don't care about these arguments */
126 (void)sp;
127 (void)stk_size;
128 error = pthread_create(&tid,
129 NULL, /* default attributes please */
130 (void *(*)(void *)) newfunc, /* function to start */
131 fp /* start argument */);
132 if(0 != error)
133 fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error);
134 else
135 fprintf(stderr, "Thread %ld is running\n", (long)tid);
136
137 yield();
138
139 return error;
140}
141
142void sim_sleep(int ticks)
143{
144 pthread_mutex_unlock(&mp); /* return */
145 msleep((1000/HZ) * ticks);
146 pthread_mutex_lock(&mp); /* get it again */
147}
148
diff --git a/uisimulator/x11/timefuncs.h b/uisimulator/x11/timefuncs.h
deleted file mode 100644
index de17fcdc73..0000000000
--- a/uisimulator/x11/timefuncs.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#include <time.h>
2#include <stdbool.h>
3
4/* struct tm defined */
5struct tm *get_time(void);
6int set_time(const struct tm *tm);
7bool valid_time(const struct tm *tm);
diff --git a/uisimulator/x11/uibasic.c b/uisimulator/x11/uibasic.c
deleted file mode 100644
index 57870c39d3..0000000000
--- a/uisimulator/x11/uibasic.c
+++ /dev/null
@@ -1,277 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <stdio.h>
20#include <string.h>
21#include <stdarg.h>
22#include <stdlib.h>
23#include <ctype.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <fcntl.h>
27
28#include <errno.h>
29#include <ctype.h>
30#include <time.h>
31
32#include "config.h"
33#include "screenhack.h"
34
35#include "version.h"
36
37#include "lcd-x11.h"
38#include "lcd-playersim.h"
39
40#define MAX(x,y) ((x)>(y)?(x):(y))
41#define MIN(x,y) ((x)<(y)?(x):(y))
42
43#define PROGNAME "rockboxui"
44
45/* -- -- */
46
47GC draw_gc;
48static Colormap cmap;
49
50int display_zoom=1;
51bool lcd_display_redraw=true;
52
53XrmOptionDescRec options [] = {
54 /* { "-subtractive", ".additive", XrmoptionNoArg, "false" }, */
55 { "-server", ".server", XrmoptionSepArg, 0 },
56 { "-help", ".help", XrmoptionNoArg, "false" },
57 { 0, 0, 0, 0 }
58};
59char *progclass = "rockboxui";
60
61#ifdef IRIVER_H100_SERIES
62#define BGCOLOR "lightblue"
63#elif defined ARCHOS_GMINI120
64#define BGCOLOR "royalblue"
65#else
66#define BGCOLOR "lightgreen"
67#endif
68
69
70char *defaults [] = {
71 ".background: " BGCOLOR,
72 ".foreground: black",
73 "*help: false",
74 0
75};
76
77static XColor getcolor[4];
78
79/* set a range of bitmap indices to a gradient from startcolour to endcolour
80 inherited from the win32 sim code by Jens Arnold */
81static void lcdcolors(int index, int count, XColor *start, XColor *end)
82{
83 int i;
84 count--;
85 for (i = 0; i <= count; i++)
86 {
87 getcolor[i+index].red = start->red
88 + (end->red - start->red) * i / count;
89 getcolor[i+index].green = start->green
90 + (end->green - start->green) * i / count;
91 getcolor[i+index].blue = start->blue
92 + (end->blue - start->blue) * i / count;
93 XAllocColor (dpy, cmap, &getcolor[i+index]);
94 }
95}
96
97
98void init_window ()
99{
100 XGCValues gcv;
101 XWindowAttributes xgwa;
102
103 XGetWindowAttributes (dpy, window, &xgwa);
104 XColor bg;
105 XColor fg;
106
107 cmap = xgwa.colormap;
108
109 XParseColor (dpy, cmap, BGCOLOR, &bg);
110 XParseColor (dpy, cmap, "black", &fg);
111 getcolor[0] = bg;
112 getcolor[1] = bg;
113 getcolor[2] = bg;
114 getcolor[3] = bg;
115
116 lcdcolors(0, 4, &bg, &fg);
117
118#if 0
119 for(i=0; i<4; i++) {
120 printf("color %d: %d %d %d\n",
121 i,
122 getcolor[i].red,
123 getcolor[i].green,
124 getcolor[i].blue);
125 }
126#endif
127
128 gcv.function = GXxor;
129 gcv.foreground = getcolor[3].pixel;
130 draw_gc = XCreateGC (dpy, window, GCForeground, &gcv);
131
132 screen_resized(LCD_WIDTH, LCD_HEIGHT);
133}
134
135void screen_resized(int width, int height)
136{
137 int maxx, maxy;
138 maxx = width;
139 maxy = height;
140
141 XtAppLock(app);
142 XSetForeground(dpy, draw_gc, getcolor[0].pixel);
143
144 XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom,
145 height*display_zoom);
146 XtAppUnlock(app);
147 screen_redraw();
148}
149
150void drawrect(int color, int x1, int y1, int x2, int y2)
151{
152 XtAppLock(app);
153 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
154 XFillRectangle(dpy, window, draw_gc, x1*display_zoom, y1*display_zoom,
155 x2*display_zoom, y2*display_zoom);
156 XtAppUnlock(app);
157}
158
159static void help(void)
160{
161 printf(PROGNAME " " ROCKBOXUI_VERSION " " __DATE__ "\n"
162 "usage: " PROGNAME "\n");
163}
164
165static void drawline(int color, int x1, int y1, int x2, int y2)
166{
167 XtAppLock(app);
168 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
169
170 XDrawLine(dpy, window, draw_gc,
171 (int)(x1*display_zoom),
172 (int)(y1*display_zoom),
173 (int)(x2*display_zoom),
174 (int)(y2*display_zoom));
175 XtAppUnlock(app);
176}
177
178void dots(int *colors, struct coordinate *points, int count)
179{
180 int color;
181 XtAppLock(app);
182
183 while (count--) {
184 color = colors[count];
185 XSetForeground(dpy, draw_gc, getcolor[color].pixel);
186 XFillRectangle(dpy, window, draw_gc,
187 points[count].x*display_zoom,
188 points[count].y*display_zoom,
189 display_zoom,
190 display_zoom);
191 }
192 XtAppUnlock(app);
193}
194
195/* this is where the applicaton starts */
196extern void app_main(void);
197
198void screenhack()
199{
200 Bool helpme;
201
202 /* This doesn't work, but I don't know why (Daniel 1999-12-01) */
203 helpme = get_boolean_resource ("help", "Boolean");
204 if(helpme)
205 help();
206
207 printf(PROGNAME " " ROCKBOXUI_VERSION " (" __DATE__ ")\n");
208
209 init_window();
210
211 screen_redraw();
212
213 app_main();
214}
215
216/* used for the player sim */
217void drawdots(int color, struct coordinate *points, int count)
218{
219 XtAppLock(app);
220 XSetForeground(dpy, draw_gc, getcolor[color==0?0:3].pixel);
221
222 while (count--) {
223 XFillRectangle(dpy, window, draw_gc,
224 points[count].x*display_zoom,
225 points[count].y*display_zoom,
226 display_zoom,
227 display_zoom);
228 }
229 XtAppUnlock(app);
230}
231
232/* used for the player sim */
233void drawrectangles(int color, struct rectangle *points, int count)
234{
235 XtAppLock(app);
236
237 XSetForeground(dpy, draw_gc, getcolor[color==0?0:3].pixel);
238 while (count--) {
239 XFillRectangle(dpy, window, draw_gc,
240 points[count].x*display_zoom,
241 points[count].y*display_zoom,
242 points[count].width*display_zoom,
243 points[count].height*display_zoom);
244 }
245 XtAppUnlock(app);
246}
247
248
249void screen_redraw()
250{
251 /* draw a border around the screen */
252#define X1 0
253#define Y1 0
254#define X2 (LCD_WIDTH + 2*MARGIN_X - 1)
255#define Y2 (LCD_HEIGHT + 2*MARGIN_Y - 1)
256
257 drawline(1, X1, Y1, X2, Y1);
258 drawline(1, X2, Y1, X2, Y2);
259 drawline(1, X1, Y2, X2, Y2);
260 drawline(1, X1, Y1, X1, Y2);
261 lcd_display_redraw = true;
262 lcd_update();
263#ifdef LCD_REMOTE_HEIGHT
264 /* draw a border around the remote LCD screen */
265#define RX1 0
266#define RY1 (Y2 + 1)
267#define RX2 (LCD_REMOTE_WIDTH + 2*MARGIN_X - 1)
268#define RY2 (RY1 + LCD_REMOTE_HEIGHT + 2*MARGIN_Y - 1)
269
270 drawline(1, RX1, RY1, RX2, RY1);
271 drawline(1, RX2, RY1, RX2, RY2);
272 drawline(1, RX1, RY2, RX2, RY2);
273 drawline(1, RX1, RY1, RX1, RY2);
274 lcd_display_redraw = true;
275 lcd_remote_update();
276#endif
277}
diff --git a/uisimulator/x11/utils.h b/uisimulator/x11/utils.h
deleted file mode 100644
index 5045d4aa6d..0000000000
--- a/uisimulator/x11/utils.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* xscreensaver, Copyright (c) 1997 Jamie Zawinski <jwz@jwz.org>
2 *
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
9 * implied warranty.
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config-x11.h"
14#endif
15
16#include <stdlib.h>
17#include <stdio.h>
18#include <string.h>
19#include <math.h>
20
21#include <X11/Xlib.h>
22#include <X11/Xos.h>
diff --git a/uisimulator/x11/version.h b/uisimulator/x11/version.h
deleted file mode 100644
index 1d40c08781..0000000000
--- a/uisimulator/x11/version.h
+++ /dev/null
@@ -1 +0,0 @@
1#define ROCKBOXUI_VERSION "0.2"
diff --git a/uisimulator/x11/visual.c b/uisimulator/x11/visual.c
deleted file mode 100644
index 57b73151c5..0000000000
--- a/uisimulator/x11/visual.c
+++ /dev/null
@@ -1,544 +0,0 @@
1/* xscreensaver, Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999
2 * by Jamie Zawinski <jwz@jwz.org>
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation. No representations are made about the suitability of this
9 * software for any purpose. It is provided "as is" without express or
10 * implied warranty.
11 */
12
13/* This file contains some code for intelligently picking the best visual
14 (where "best" is biased in the direction of either: high color counts;
15 or: having writable color cells...)
16 */
17
18#include "utils.h"
19#include "resources.h" /* for get_string_resource() */
20#include "visual.h"
21
22#include <X11/Xutil.h>
23
24extern char *progname;
25
26
27#ifndef isupper
28# define isupper(c) ((c) >= 'A' && (c) <= 'Z')
29#endif
30#ifndef _tolower
31# define _tolower(c) ((c) - 'A' + 'a')
32#endif
33
34
35static Visual *pick_best_visual (Screen *, Bool, Bool);
36static Visual *pick_mono_visual (Screen *);
37static Visual *pick_best_visual_of_class (Screen *, int);
38static Visual *pick_best_gl_visual (Screen *);
39static Visual *id_to_visual (Screen *, int);
40static Visual *id_to_visual (Screen *screen, int id);
41
42
43#define DEFAULT_VISUAL -1
44#define BEST_VISUAL -2
45#define MONO_VISUAL -3
46#define GRAY_VISUAL -4
47#define COLOR_VISUAL -5
48#define GL_VISUAL -6
49#define SPECIFIC_VISUAL -7
50
51Visual *
52get_visual (Screen *screen, const char *string, Bool prefer_writable_cells,
53 Bool verbose_p)
54{
55 char *v = (string ? strdup(string) : 0);
56 char c, *tmp;
57 int vclass;
58 unsigned long id;
59 Visual *result = 0;
60
61 if (v)
62 for (tmp = v; *tmp; tmp++)
63 if (isupper (*tmp)) *tmp = _tolower (*tmp);
64
65 if (!v || !*v) vclass = BEST_VISUAL;
66 else if (!strcmp (v, "default")) vclass = DEFAULT_VISUAL;
67 else if (!strcmp (v, "best")) vclass = BEST_VISUAL;
68 else if (!strcmp (v, "mono")) vclass = MONO_VISUAL;
69 else if (!strcmp (v, "monochrome")) vclass = MONO_VISUAL;
70 else if (!strcmp (v, "gray")) vclass = GRAY_VISUAL;
71 else if (!strcmp (v, "grey")) vclass = GRAY_VISUAL;
72 else if (!strcmp (v, "color")) vclass = COLOR_VISUAL;
73 else if (!strcmp (v, "gl")) vclass = GL_VISUAL;
74 else if (!strcmp (v, "staticgray")) vclass = StaticGray;
75 else if (!strcmp (v, "staticcolor")) vclass = StaticColor;
76 else if (!strcmp (v, "truecolor")) vclass = TrueColor;
77 else if (!strcmp (v, "grayscale")) vclass = GrayScale;
78 else if (!strcmp (v, "greyscale")) vclass = GrayScale;
79 else if (!strcmp (v, "pseudocolor")) vclass = PseudoColor;
80 else if (!strcmp (v, "directcolor")) vclass = DirectColor;
81 else if (1 == sscanf (v, " %ld %c", &id, &c)) vclass = SPECIFIC_VISUAL;
82 else if (1 == sscanf (v, " 0x%lx %c", &id, &c)) vclass = SPECIFIC_VISUAL;
83 else
84 {
85 fprintf (stderr, "%s: unrecognized visual \"%s\".\n", progname, v);
86 vclass = DEFAULT_VISUAL;
87 }
88
89 if (vclass == DEFAULT_VISUAL)
90 result = DefaultVisualOfScreen (screen);
91 else if (vclass == BEST_VISUAL)
92 result = pick_best_visual (screen, prefer_writable_cells, False);
93 else if (vclass == MONO_VISUAL)
94 {
95 result = pick_mono_visual (screen);
96 if (!result && verbose_p)
97 fprintf (stderr, "%s: no monochrome visuals.\n", progname);
98 }
99 else if (vclass == GRAY_VISUAL)
100 {
101 if (prefer_writable_cells)
102 result = pick_best_visual_of_class (screen, GrayScale);
103 if (!result)
104 result = pick_best_visual_of_class (screen, StaticGray);
105 if (!result)
106 result = pick_best_visual_of_class (screen, GrayScale);
107 if (!result && verbose_p)
108 fprintf (stderr, "%s: no GrayScale or StaticGray visuals.\n",
109 progname);
110 }
111 else if (vclass == COLOR_VISUAL)
112 {
113 int class;
114 /* First see if the default visual will do. */
115 result = DefaultVisualOfScreen (screen);
116 class = visual_class(screen, result);
117 if (class != TrueColor &&
118 class != PseudoColor &&
119 class != DirectColor &&
120 class != StaticColor)
121 result = 0;
122 if (result && visual_depth(screen, result) <= 1)
123 result = 0;
124
125 /* Else, find the best non-default color visual */
126 if (!result)
127 result = pick_best_visual (screen, prefer_writable_cells, True);
128
129 if (!result && verbose_p)
130 fprintf (stderr, "%s: no color visuals.\n", progname);
131 }
132 else if (vclass == GL_VISUAL)
133 {
134 Visual *visual = pick_best_gl_visual (screen);
135 if (visual)
136 result = visual;
137 else if (verbose_p)
138 fprintf (stderr, "%s: no visual suitable for GL.\n", progname);
139 }
140 else if (vclass == SPECIFIC_VISUAL)
141 {
142 result = id_to_visual (screen, id);
143 if (!result && verbose_p)
144 fprintf (stderr, "%s: no visual with id 0x%x.\n", progname,
145 (unsigned int) id);
146 }
147 else
148 {
149 Visual *visual = pick_best_visual_of_class (screen, vclass);
150 if (visual)
151 result = visual;
152 else if (verbose_p)
153 fprintf (stderr, "%s: no visual of class %s.\n", progname, v);
154 }
155
156 if (v) free (v);
157 return result;
158}
159
160Visual *
161get_visual_resource (Screen *screen, char *name, char *class,
162 Bool prefer_writable_cells)
163{
164 char *string = get_string_resource (name, class);
165 Visual *v = get_visual (screen, string, prefer_writable_cells, True);
166 if (string)
167 free(string);
168 if (v)
169 return v;
170 else
171 return DefaultVisualOfScreen (screen);
172}
173
174
175static Visual *
176pick_best_visual (Screen *screen, Bool prefer_writable_cells, Bool color_only)
177{
178 Visual *visual;
179
180 if (!prefer_writable_cells)
181 {
182 /* If we don't prefer writable cells, then the "best" visual is the one
183 on which we can allocate the largest range and number of colors.
184
185 Therefore, a TrueColor visual which is at least 16 bits deep is best.
186 (The assumption here being that a TrueColor of less than 16 bits is
187 really just a PseudoColor visual with a pre-allocated color cube.)
188
189 The next best thing is a PseudoColor visual of any type. After that
190 come the non-colormappable visuals, and non-color visuals.
191 */
192 if ((visual = pick_best_visual_of_class (screen, TrueColor)) &&
193 visual_depth (screen, visual) >= 16)
194 return visual;
195 }
196
197#define TRY_CLASS(CLASS) \
198 if ((visual = pick_best_visual_of_class (screen, CLASS)) && \
199 (!color_only || visual_depth(screen, visual) > 1)) \
200 return visual
201 TRY_CLASS(PseudoColor);
202 TRY_CLASS(TrueColor);
203 TRY_CLASS(DirectColor);
204 TRY_CLASS(StaticColor);
205 if (!color_only)
206 {
207 TRY_CLASS(GrayScale);
208 TRY_CLASS(StaticGray);
209 }
210#undef TRY_CLASS
211
212 visual = DefaultVisualOfScreen (screen);
213 if (!color_only || visual_depth(screen, visual) > 1)
214 return visual;
215 else
216 return 0;
217}
218
219static Visual *
220pick_mono_visual (Screen *screen)
221{
222 Display *dpy = DisplayOfScreen (screen);
223 XVisualInfo vi_in, *vi_out;
224 int out_count;
225
226 vi_in.depth = 1;
227 vi_in.screen = screen_number (screen);
228 vi_out = XGetVisualInfo (dpy, (VisualDepthMask | VisualScreenMask),
229 &vi_in, &out_count);
230 if (vi_out)
231 {
232 Visual *v = (out_count > 0 ? vi_out [0].visual : 0);
233 if (v && vi_out[0].depth != 1)
234 v = 0;
235 XFree ((char *) vi_out);
236 return v;
237 }
238 else
239 return 0;
240}
241
242
243static Visual *
244pick_best_visual_of_class (Screen *screen, int visual_class)
245{
246 /* The best visual of a class is the one which on which we can allocate
247 the largest range and number of colors, which means the one with the
248 greatest depth and number of cells.
249
250 (But actually, for XDaliClock, all visuals of the same class are
251 probably equivalent - either we have writable cells or we don't.)
252 */
253 Display *dpy = DisplayOfScreen (screen);
254 XVisualInfo vi_in, *vi_out;
255 int out_count;
256
257 vi_in.class = visual_class;
258 vi_in.screen = screen_number (screen);
259 vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask),
260 &vi_in, &out_count);
261 if (vi_out)
262 {
263 /* choose the 'best' one, if multiple */
264 int i, best;
265 Visual *visual;
266/* for (i = 0, best = 0; i < out_count; i++) */
267 for (i = out_count-1, best = i; i >= 0; i--) /* go backwards */
268 /* It's better if it's deeper, or if it's the same depth with
269 more cells (does that ever happen? Well, it could...) */
270 if ((vi_out [i].depth > vi_out [best].depth) ||
271 ((vi_out [i].depth == vi_out [best].depth) &&
272 (vi_out [i].colormap_size > vi_out [best].colormap_size)))
273 best = i;
274 visual = (best < out_count ? vi_out [best].visual : 0);
275 XFree ((char *) vi_out);
276 return visual;
277 }
278 else
279 return 0;
280}
281
282static Visual *
283pick_best_gl_visual (Screen *screen)
284{
285 /* The best visual for GL is a TrueColor visual that is half as deep as
286 the screen. If such a thing doesn't exist, then TrueColor is best.
287 Failing that, the deepest available color visual is best.
288
289 Compare this function to get_gl_visual() in visual-gl.c.
290 This function tries to find the best GL visual using Xlib calls,
291 whereas that function does the same thing using GLX calls.
292 */
293 Display *dpy = DisplayOfScreen (screen);
294 XVisualInfo vi_in, *vi_out;
295 int out_count;
296 Visual *result = 0;
297
298 int ndepths = 0;
299 int *depths = XListDepths (dpy, screen_number (screen), &ndepths);
300 int screen_depth = depths[ndepths];
301 XFree (depths);
302
303 vi_in.class = TrueColor;
304 vi_in.screen = screen_number (screen);
305 vi_in.depth = screen_depth / 2;
306 vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask |
307 VisualDepthMask),
308 &vi_in, &out_count);
309 if (out_count > 0)
310 result = vi_out[0].visual;
311
312 if (vi_out)
313 XFree ((char *) vi_out);
314
315 if (!result && screen_depth > 24)
316 {
317 /* If it's a 32-deep screen and we didn't find a depth-16 visual,
318 see if there's a depth-12 visual. */
319 vi_in.class = TrueColor;
320 vi_in.screen = screen_number (screen);
321 vi_in.depth = 12;
322 vi_out = XGetVisualInfo (dpy, (VisualClassMask | VisualScreenMask |
323 VisualDepthMask),
324 &vi_in, &out_count);
325 if (out_count > 0)
326 result = vi_out[0].visual;
327 }
328
329 if (!result)
330 /* No half-depth TrueColor? Ok, try for any TrueColor (the deepest.) */
331 result = pick_best_visual_of_class (screen, TrueColor);
332
333 if (!result)
334 /* No TrueColor? Ok, try for anything. */
335 result = pick_best_visual (screen, False, False);
336
337 return result;
338}
339
340
341static Visual *
342id_to_visual (Screen *screen, int id)
343{
344 Display *dpy = DisplayOfScreen (screen);
345 XVisualInfo vi_in, *vi_out;
346 int out_count;
347 vi_in.screen = screen_number (screen);
348 vi_in.visualid = id;
349 vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),
350 &vi_in, &out_count);
351 if (vi_out)
352 {
353 Visual *v = vi_out[0].visual;
354 XFree ((char *) vi_out);
355 return v;
356 }
357 return 0;
358}
359
360int
361visual_depth (Screen *screen, Visual *visual)
362{
363 Display *dpy = DisplayOfScreen (screen);
364 XVisualInfo vi_in, *vi_out;
365 int out_count, d;
366 vi_in.screen = screen_number (screen);
367 vi_in.visualid = XVisualIDFromVisual (visual);
368 vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
369 &vi_in, &out_count);
370 if (! vi_out) abort ();
371 d = vi_out [0].depth;
372 XFree ((char *) vi_out);
373 return d;
374}
375
376
377#if 0
378/* You very probably don't want to be using this.
379 Pixmap depth doesn't refer to the depths of pixmaps, but rather, to
380 the depth of protocol-level on-the-wire pixmap data, that is, XImages.
381 To get this info, you should be looking at XImage->bits_per_pixel
382 instead. (And allocating the data for your XImage structures by
383 multiplying ximage->bytes_per_line by ximage->height.)
384 */
385int
386visual_pixmap_depth (Screen *screen, Visual *visual)
387{
388 Display *dpy = DisplayOfScreen (screen);
389 int vdepth = visual_depth (screen, visual);
390 int pdepth = vdepth;
391 int i, pfvc = 0;
392 XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc);
393
394 /* Return the first matching depth in the pixmap formats. If there are no
395 matching pixmap formats (which shouldn't be able to happen at all) then
396 return the visual depth instead. */
397 for (i = 0; i < pfvc; i++)
398 if (pfv[i].depth == vdepth)
399 {
400 pdepth = pfv[i].bits_per_pixel;
401 break;
402 }
403 if (pfv)
404 XFree (pfv);
405 return pdepth;
406}
407#endif /* 0 */
408
409
410int
411visual_class (Screen *screen, Visual *visual)
412{
413 Display *dpy = DisplayOfScreen (screen);
414 XVisualInfo vi_in, *vi_out;
415 int out_count, c;
416 vi_in.screen = screen_number (screen);
417 vi_in.visualid = XVisualIDFromVisual (visual);
418 vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
419 &vi_in, &out_count);
420 if (! vi_out) abort ();
421 c = vi_out [0].class;
422 XFree ((char *) vi_out);
423 return c;
424}
425
426Bool
427has_writable_cells (Screen *screen, Visual *visual)
428{
429 switch (visual_class (screen, visual))
430 {
431 case GrayScale: /* Mappable grays. */
432 case PseudoColor: /* Mappable colors. */
433 return True;
434 case StaticGray: /* Fixed grays. */
435 case TrueColor: /* Fixed colors. */
436 case StaticColor: /* (What's the difference again?) */
437 case DirectColor: /* DirectColor visuals are like TrueColor, but have
438 three colormaps - one for each component of RGB.
439 Screw it. */
440 return False;
441 default:
442 abort();
443 return False;
444 }
445}
446
447void
448describe_visual (FILE *f, Screen *screen, Visual *visual, Bool private_cmap_p)
449{
450 char n[10];
451 Display *dpy = DisplayOfScreen (screen);
452 XVisualInfo vi_in, *vi_out;
453 int out_count;
454 vi_in.screen = screen_number (screen);
455 vi_in.visualid = XVisualIDFromVisual (visual);
456 vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualIDMask),
457 &vi_in, &out_count);
458 if (! vi_out) abort ();
459 if (private_cmap_p)
460 sprintf(n, "%3d", vi_out->colormap_size);
461 else
462 strcpy(n, "default");
463
464 fprintf (f, "0x%02x (%s depth: %2d, cmap: %s)\n",
465 (unsigned int) vi_out->visualid,
466 (vi_out->class == StaticGray ? "StaticGray, " :
467 vi_out->class == StaticColor ? "StaticColor," :
468 vi_out->class == TrueColor ? "TrueColor, " :
469 vi_out->class == GrayScale ? "GrayScale, " :
470 vi_out->class == PseudoColor ? "PseudoColor," :
471 vi_out->class == DirectColor ? "DirectColor," :
472 "UNKNOWN: "),
473 vi_out->depth, n);
474 XFree ((char *) vi_out);
475}
476
477int
478screen_number (Screen *screen)
479{
480 Display *dpy = DisplayOfScreen (screen);
481 int i;
482 for (i = 0; i < ScreenCount (dpy); i++)
483 if (ScreenOfDisplay (dpy, i) == screen)
484 return i;
485 abort ();
486 return 0;
487}
488
489int
490visual_cells (Screen *screen, Visual *visual)
491{
492 Display *dpy = DisplayOfScreen (screen);
493 XVisualInfo vi_in, *vi_out;
494 int out_count, c;
495 vi_in.screen = screen_number (screen);
496 vi_in.visualid = XVisualIDFromVisual (visual);
497 vi_out = XGetVisualInfo (dpy, VisualScreenMask|VisualIDMask,
498 &vi_in, &out_count);
499 if (! vi_out) abort ();
500 c = vi_out [0].colormap_size;
501 XFree ((char *) vi_out);
502 return c;
503}
504
505Visual *
506find_similar_visual(Screen *screen, Visual *old_visual)
507{
508 Display *dpy = DisplayOfScreen (screen);
509 XVisualInfo vi_in, *vi_out;
510 Visual *result = 0;
511 int out_count;
512
513 vi_in.screen = screen_number (screen);
514 vi_in.class = visual_class (screen, old_visual);
515 vi_in.depth = visual_depth (screen, old_visual);
516
517 /* Look for a visual of the same class and depth.
518 */
519 vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask |
520 VisualDepthMask),
521 &vi_in, &out_count);
522 if (vi_out && out_count > 0)
523 result = vi_out[0].visual;
524 if (vi_out) XFree (vi_out);
525 vi_out = 0;
526
527 /* Failing that, look for a visual of the same class.
528 */
529 if (!result)
530 {
531 vi_out = XGetVisualInfo (dpy, (VisualScreenMask | VisualClassMask),
532 &vi_in, &out_count);
533 if (vi_out && out_count > 0)
534 result = vi_out[0].visual;
535 if (vi_out) XFree (vi_out);
536 vi_out = 0;
537 }
538
539 /* Failing that, return the default visual. */
540 if (!result)
541 result = DefaultVisualOfScreen (screen);
542
543 return result;
544}
diff --git a/uisimulator/x11/visual.h b/uisimulator/x11/visual.h
deleted file mode 100644
index dd45708ea0..0000000000
--- a/uisimulator/x11/visual.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/* xscreensaver, Copyright (c) 1993-1999 by Jamie Zawinski <jwz@jwz.org>
2 *
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
9 * implied warranty.
10 */
11
12#ifndef __VISUAL_H__
13#define __VISUAL_H__
14
15extern Visual *get_visual (Screen *, const char *name, Bool, Bool);
16extern Visual *get_visual_resource (Screen *, char *, char *, Bool);
17extern int visual_depth (Screen *, Visual *);
18/* extern int visual_pixmap_depth (Screen *, Visual *); */
19extern int visual_class (Screen *, Visual *);
20extern int visual_cells (Screen *, Visual *);
21extern int screen_number (Screen *);
22extern Visual *find_similar_visual (Screen *, Visual *old);
23extern void describe_visual (FILE *f, Screen *, Visual *, Bool private_cmap_p);
24extern Visual *get_overlay_visual (Screen *, unsigned long *pixel_return);
25extern Bool has_writable_cells (Screen *screen, Visual *visual);
26
27Visual *get_gl_visual (Screen *screen);
28
29#endif /* __VISUAL_H__ */
diff --git a/uisimulator/x11/vroot.h b/uisimulator/x11/vroot.h
deleted file mode 100644
index 83c7ba9acc..0000000000
--- a/uisimulator/x11/vroot.h
+++ /dev/null
@@ -1,126 +0,0 @@
1/*****************************************************************************/
2/** Copyright 1991 by Andreas Stolcke **/
3/** Copyright 1990 by Solbourne Computer Inc. **/
4/** Longmont, Colorado **/
5/** **/
6/** All Rights Reserved **/
7/** **/
8/** Permission to use, copy, modify, and distribute this software and **/
9/** its documentation for any purpose and without fee is hereby **/
10/** granted, provided that the above copyright notice appear in all **/
11/** copies and that both that copyright notice and this permis- **/
12/** sion notice appear in supporting documentation, and that the **/
13/** name of Solbourne not be used in advertising **/
14/** in publicity pertaining to distribution of the software without **/
15/** specific, written prior permission. **/
16/** **/
17/** ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/
18/** WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF **/
19/** MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ANDREAS STOLCKE **/
20/** OR SOLBOURNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL **/
21/** DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
22/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
23/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
24/** OR PERFORMANCE OF THIS SOFTWARE. **/
25/*****************************************************************************/
26/*
27 * vroot.h -- Virtual Root Window handling header file
28 *
29 * This header file redefines the X11 macros RootWindow and DefaultRootWindow,
30 * making them look for a virtual root window as provided by certain `virtual'
31 * window managers like swm and tvtwm. If none is found, the ordinary root
32 * window is returned, thus retaining backward compatibility with standard
33 * window managers.
34 * The function implementing the virtual root lookup remembers the result of
35 * its last invocation to avoid overhead in the case of repeated calls
36 * on the same display and screen arguments.
37 * The lookup code itself is taken from Tom LaStrange's ssetroot program.
38 *
39 * Most simple root window changing X programs can be converted to using
40 * virtual roots by just including
41 *
42 * #include <X11/vroot.h>
43 *
44 * after all the X11 header files. It has been tested on such popular
45 * X clients as xphoon, xfroot, xloadimage, and xaqua.
46 * It also works with the core clients xprop, xwininfo, xwd, and editres
47 * (and is necessary to get those clients working under tvtwm).
48 * It does NOT work with xsetroot; get the xsetroot replacement included in
49 * the tvtwm distribution instead.
50 *
51 * Andreas Stolcke <stolcke@ICSI.Berkeley.EDU>, 9/7/90
52 * - replaced all NULL's with properly cast 0's, 5/6/91
53 * - free children list (suggested by Mark Martin <mmm@cetia.fr>), 5/16/91
54 * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91
55 */
56
57#ifndef _VROOT_H_
58#define _VROOT_H_
59
60#if !defined(lint) && !defined(SABER)
61static const char vroot_rcsid[] = "#Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke #";
62#endif
63
64#include <X11/X.h>
65#include <X11/Xatom.h>
66#include <X11/Xlib.h>
67
68static Window
69#ifdef __STDC__ /* ANSIfication added by jwz, to avoid superfluous warnings. */
70VirtualRootWindowOfScreen(Screen *screen)
71#else /* !__STDC__ */
72VirtualRootWindowOfScreen(screen) Screen *screen;
73#endif /* !__STDC__ */
74{
75 static Screen *save_screen = (Screen *)0;
76 static Window root = (Window)0;
77
78 if (screen != save_screen) {
79 Display *dpy = DisplayOfScreen(screen);
80 Atom __SWM_VROOT = None;
81 unsigned int i;
82 Window rootReturn, parentReturn, *children;
83 unsigned int numChildren;
84
85 root = RootWindowOfScreen(screen);
86
87 /* go look for a virtual root */
88 __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
89 if (XQueryTree(dpy, root, &rootReturn, &parentReturn,
90 &children, &numChildren)) {
91 for (i = 0; i < numChildren; i++) {
92 Atom actual_type;
93 int actual_format;
94 unsigned long nitems, bytesafter;
95 Window *newRoot = (Window *)0;
96
97 if (XGetWindowProperty(dpy, children[i],
98 __SWM_VROOT, 0, 1, False, XA_WINDOW,
99 &actual_type, &actual_format,
100 &nitems, &bytesafter,
101 (unsigned char **) &newRoot) == Success
102 && newRoot) {
103 root = *newRoot;
104 break;
105 }
106 }
107 if (children)
108 XFree((char *)children);
109 }
110
111 save_screen = screen;
112 }
113
114 return root;
115}
116
117#undef RootWindowOfScreen
118#define RootWindowOfScreen(s) VirtualRootWindowOfScreen(s)
119
120#undef RootWindow
121#define RootWindow(dpy,screen) VirtualRootWindowOfScreen(ScreenOfDisplay(dpy,screen))
122
123#undef DefaultRootWindow
124#define DefaultRootWindow(dpy) VirtualRootWindowOfScreen(DefaultScreenOfDisplay(dpy))
125
126#endif /* _VROOT_H_ */
diff --git a/uisimulator/x11/xmu.h b/uisimulator/x11/xmu.h
deleted file mode 100644
index 48084f747e..0000000000
--- a/uisimulator/x11/xmu.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/* This file contains compatibility routines for systems without Xmu.
2 * You would be better served by installing Xmu on your machine or
3 * yelling at your vendor to ship it.
4 */
5
6#ifndef __XMU_H__
7#define __XMU_H__
8
9#include <X11/Xlib.h>
10#include <stdio.h>
11
12int XmuPrintDefaultErrorMessage (Display *dpy, XErrorEvent *event, FILE *fp);
13
14#endif /* __XMU_H__ */