Debian Codegraph @

contrib/window_managers/tvtwm

raw
1
2 These routines were extracted from the sound hack for olvwm3.3 by
3 Andrew "Ender" Scherpbier ([email protected]) and modified
4 by J.E. Sacco ([email protected]) for tvtwm.
5
6 Sound events are stored the .tvtwm-sounds file located in your home
7 directory. Here a list of all the supported sound events:
8
9 <EventZero>
10 <EventOne>
11 KeyPress
12 KeyRelease
13 ButtonPress
14 ButtonRelease
15 MotionNotify
16 EnterNotify
17 LeaveNotify
18 FocusIn
19 FocusOut
20 KeymapNotify
21 Expose
22 GraphicsExpose
23 NoExpose
24 VisibilityNotify
25 CreateNotify
26 DestroyNotify
27 UnmapNotify
28 MapNotify
29 MapRequest
30 ReparentNotify
31 ConfigureNotify
32 ConfigureRequest
33 GravityNotify
34 ResizeRequest
35 CirculateNotify
36 CirculateRequest
37 PropertyNotify
38 SelectionClear
39 SelectionRequest
40 SelectionNotify
41 ColormapNotify
42 ClientMessage
43 MappingNotify
44
45 And here is a sample sounds file:
46
47 KeyPress: Cork.au
48 MapNotify: turbbeep.au
49 ResizeRequest: failure.au
50 Startup: 2lust.au
51 Shutdown: 1sadeness.au
52
53
54 found the following files to diff
55 ./sound.c.dist ./events.c.dist ./parse.c.dist ./parse.h.dist ./menus.c.dist ./twm.c.dist ./Imakefile.dist
56 *** ./sound.c.dist Tue Nov 9 21:41:54 1993
57 --- ./sound.c Tue Nov 9 20:37:17 1993
58 ***************
59 *** 0 ****
60 --- 1,164 ----
61 + /*
62 + * These routines were extracted from the sound hack for olvwm3.3 by
63 + * Andrew "Ender" Scherpbier ([email protected])
64 + * and modified by J.E. Sacco (jsacco @ssl.com)
65 + */
66 +
67 + #include <rplay.h>
68 + #include <string.h>
69 + #include <stdio.h>
70 +
71 + char *eventNames[] =
72 + {
73 + "<EventZero>",
74 + "<EventOne>",
75 + "KeyPress",
76 + "KeyRelease",
77 + "ButtonPress",
78 + "ButtonRelease",
79 + "MotionNotify",
80 + "EnterNotify",
81 + "LeaveNotify",
82 + "FocusIn",
83 + "FocusOut",
84 + "KeymapNotify",
85 + "Expose",
86 + "GraphicsExpose",
87 + "NoExpose",
88 + "VisibilityNotify",
89 + "CreateNotify",
90 + "DestroyNotify",
91 + "UnmapNotify",
92 + "MapNotify",
93 + "MapRequest",
94 + "ReparentNotify",
95 + "ConfigureNotify",
96 + "ConfigureRequest",
97 + "GravityNotify",
98 + "ResizeRequest",
99 + "CirculateNotify",
100 + "CirculateRequest",
101 + "PropertyNotify",
102 + "SelectionClear",
103 + "SelectionRequest",
104 + "SelectionNotify",
105 + "ColormapNotify",
106 + "ClientMessage",
107 + "MappingNotify",
108 + "Startup",
109 + "Shutdown"
110 + };
111 +
112 + #define NEVENTS (sizeof(eventNames) / sizeof(char *))
113 +
114 + RPLAY *rp[NEVENTS];
115 +
116 + static int need_sound_init = 1;
117 + static int sound_fd = 0;
118 + static int sound_state = 1;
119 + static int startup_sound = NEVENTS -2;
120 + static int exit_sound = NEVENTS -1;
121 +
122 + /*
123 + * initialize
124 + */
125 + static
126 + sound_init ()
127 + {
128 + int i;
129 + FILE *fl;
130 + char buffer[100];
131 + char *token;
132 + char hostname[200];
133 +
134 + need_sound_init = 0;
135 + if (sound_fd == 0) {
136 + gethostname (hostname, 200);
137 +
138 + if ((sound_fd = rplay_open (hostname)) < 0)
139 + rplay_perror ("create");
140 + }
141 +
142 + /*
143 + * Destroy any old sounds
144 + */
145 + for (i = 0; i < NEVENTS; i++) {
146 + if (rp[i] != NULL)
147 + rplay_destroy (rp[i]);
148 + rp[i] = NULL;
149 + }
150 +
151 + /*
152 + * Now read the file which contains the sounds
153 + */
154 + fl = fopen (".tvtwm-sounds", "r");
155 + if (fl == NULL)
156 + return;
157 + while (fgets (buffer, 100, fl) != NULL) {
158 + token = strtok (buffer, ": \t");
159 + if (token == NULL)
160 + continue;
161 + for (i = 0; i < NEVENTS; i++) {
162 + if (strcmp (token, eventNames[i]) == 0) {
163 + token = strtok (NULL, " \t\r\n");
164 + if (token == NULL || *token == '#' || isspace (*token))
165 + continue;
166 + rp[i] = rplay_create (RPLAY_PLAY);
167 + if (rp[i] == NULL) {
168 + rplay_perror ("create");
169 + continue;
170 + }
171 + if (rplay_set(rp[i], RPLAY_INSERT, 0, RPLAY_SOUND, token, NULL)
172 + < 0)
173 + rplay_perror ("rplay");
174 + }
175 + }
176 + }
177 + fclose (fl);
178 + }
179 +
180 +
181 + /*
182 + * Play sound
183 + */
184 + play_sound (snd)
185 + int snd;
186 + {
187 + if (sound_state == 0)
188 + return;
189 +
190 + if (need_sound_init)
191 + sound_init ();
192 +
193 + if (rp[snd] == NULL)
194 + return;
195 + if (rplay (sound_fd, rp[snd]) < 0)
196 + rplay_perror ("create");
197 + }
198 +
199 + play_startup_sound()
200 + {
201 + play_sound(startup_sound);
202 + }
203 +
204 + play_exit_sound()
205 + {
206 + play_sound(exit_sound);
207 + }
208 +
209 + /*
210 + * Toggle the sound on/off
211 + */
212 + toggle_sound ()
213 + {
214 + sound_state ^= 1;
215 + }
216 +
217 +
218 + /*
219 + * Re-read the sounds mapping file
220 + */
221 + reread_sounds ()
222 + {
223 + sound_init ();
224 + }
225 *** ./events.c.dist Fri Nov 5 11:11:04 1993
226 --- ./events.c Tue Nov 9 18:18:00 1993
227 ***************
228 *** 134,139 ****
229 --- 134,143 ----
230 #include "version.h"
231 #include "vdt.h"
232
233 + #ifdef SOUNDS
234 + extern play_sounds();
235 + #endif
236 +
237 extern unsigned int mods_used;
238 extern int menuFromFrameOrWindowOrTitlebar;
239
240 ***************
241 *** 351,357 ****
242 * Procedure:
243 * DispatchEvent2 -
244 * handle a single X event stored in global var Event
245 ! * this rouitine for is for a call during an f.move
246 *
247 ***********************************************************************
248 */
249 --- 355,361 ----
250 * Procedure:
251 * DispatchEvent2 -
252 * handle a single X event stored in global var Event
253 ! * this routine for is for a call during an f.move
254 *
255 ***********************************************************************
256 */
257 ***************
258 *** 373,378 ****
259 --- 377,386 ----
260
261 if (!Scr) return False;
262
263 + #ifdef SOUNDS
264 + play_sound(Event.type);
265 + #endif
266 +
267 if (menuFromFrameOrWindowOrTitlebar && Event.type == Expose)
268 HandleExpose();
269
270 ***************
271 *** 407,412 ****
272 --- 415,423 ----
273 if (!Scr) return False;
274
275 if (Event.type>= 0 && Event.type < MAX_X_EVENT) {
276 + #ifdef SOUNDS
277 + play_sound(Event.type);
278 + #endif
279 (*EventHandler[Event.type])();
280 }
281
282 *** ./parse.c.dist Tue Nov 9 18:27:11 1993
283 --- ./parse.c Tue Nov 9 19:23:46 1993
284 ***************
285 *** 56,62 ****
286 #include <netdb.h>
287
288 #ifndef SYSTEM_INIT_FILE
289 ! #define SYSTEM_INIT_FILE "/usr/local/X11R4/lib/twm/system.twmrc"
290 #endif
291 #define BUF_LEN 300
292
293 --- 56,62 ----
294 #include <netdb.h>
295
296 #ifndef SYSTEM_INIT_FILE
297 ! #define SYSTEM_INIT_FILE "/usr/local/X11R5/lib/twm/system.twmrc"
298 #endif
299 #define BUF_LEN 300
300
301 ***************
302 *** 652,657 ****
303 --- 652,660 ----
304 { "f.raiselower", FKEYWORD, F_RAISELOWER },
305 { "f.refresh", FKEYWORD, F_REFRESH },
306 { "f.relativeresize", FKEYWORD, F_RELATIVERESIZE },
307 + #ifdef SOUNDS
308 + { "f.rereadsounds", FKEYWORD, F_REREADSOUNDS },
309 + #endif
310 { "f.resize", FKEYWORD, F_RESIZE },
311 { "f.restart", FKEYWORD, F_RESTART },
312 { "f.righticonmgr", FKEYWORD, F_RIGHTICONMGR },
313 ***************
314 *** 670,675 ****
315 --- 673,681 ----
316 { "f.stick", FKEYWORD, F_STICK },
317 { "f.test", FKEYWORD, F_TESTEXEC },
318 { "f.title", FKEYWORD, F_TITLE },
319 + #ifdef SOUNDS
320 + { "f.togglesound", FKEYWORD, F_TOGGLESOUND },
321 + #endif
322 { "f.topzoom", FKEYWORD, F_TOPZOOM },
323 { "f.twmrc", FKEYWORD, F_RESTART },
324 { "f.unfocus", FKEYWORD, F_UNFOCUS },
325 *** ./parse.h.dist Tue Nov 9 18:35:53 1993
326 --- ./parse.h Tue Nov 9 18:37:02 1993
327 ***************
328 *** 102,107 ****
329 --- 102,112 ----
330 #define F_CONSTRAINEDMOVE 55
331 #define F_OPAQUEMOVE 56
332 #define F_DELETEORDESTROY 57
333 + #ifdef SOUNDS
334 + #define F_TOGGLESOUND 58
335 + #define F_REREADSOUNDS 59
336 + #endif
337 +
338
339 #define F_MENU 101 /* string */
340 #define F_WARPTO 102 /* string */
341 *** ./menus.c.dist Tue Nov 9 18:42:53 1993
342 --- ./menus.c Tue Nov 9 18:49:00 1993
343 ***************
344 *** 172,177 ****
345 --- 172,182 ----
346 #include "add_window.h"
347 #include "patchlevel.h"
348
349 + #ifdef SOUNDS
350 + extern int toggle_sound();
351 + extern int reread_sounds();
352 + #endif
353 +
354 extern XEvent Event;
355
356 int RootFunction = 0;
357 ***************
358 *** 1959,1964 ****
359 --- 1964,1977 ----
360
361 switch (func)
362 {
363 + #ifdef SOUNDS
364 + case F_TOGGLESOUND:
365 + toggle_sound();
366 + break;
367 + case F_REREADSOUNDS:
368 + reread_sounds();
369 + break;
370 + #endif
371 case F_NOP:
372 case F_TITLE:
373 break;
374 *** ./twm.c.dist Tue Nov 9 18:50:08 1993
375 --- ./twm.c Tue Nov 9 21:35:26 1993
376 ***************
377 *** 717,722 ****
378 --- 717,726 ----
379 }
380 }
381
382 + #ifdef SOUNDS
383 + play_startup_sound();
384 + #endif
385 +
386 HandleEvents();
387 }
388
389 ***************
390 *** 1161,1166 ****
391 --- 1165,1173 ----
392
393 SIGNAL_T Done()
394 {
395 + #ifdef SOUNDS
396 + play_exit_sound();
397 + #endif
398 Reborder (CurrentTime);
399 RemoveProperties();
400 XCloseDisplay(dpy);
401 *** ./Imakefile.dist Tue Nov 9 18:58:26 1993
402 --- ./Imakefile Tue Nov 9 20:24:29 1993
403 ***************
404 *** 46,58 ****
405 XPM_DEF = -DXPM
406 XLOADIM_DEF = -DXLOADIMAGE=\"$(BINDIR)/xloadimage\"
407
408 XCOMM Ultrix doesn't have a mkstemp in libc...
409 XCOMM SysV R4 doesn't seem to either...
410
411 #if SystemV || defined(UltrixArchitecture)
412 ! LOCAL_DEFINES = $(XPM_DEF) -DNOSTEMP
413 #else
414 ! LOCAL_DEFINES = $(XPM_DEF)
415 #endif
416
417 XCOMM Various defines to pass into twm.c
418 --- 46,63 ----
419 XPM_DEF = -DXPM
420 XLOADIM_DEF = -DXLOADIMAGE=\"$(BINDIR)/xloadimage\"
421
422 + XCOMM Specify rplay library
423 + RPLAY = -lrplay
424 + RPLAY_INC = -I/usr/local/include
425 + EXTRA_INCLUDES = $(RPLAY_INC)
426 +
427 XCOMM Ultrix doesn't have a mkstemp in libc...
428 XCOMM SysV R4 doesn't seem to either...
429
430 #if SystemV || defined(UltrixArchitecture)
431 ! LOCAL_DEFINES = $(XPM_DEF) -DNOSTEMP -SOUNDS
432 #else
433 ! LOCAL_DEFINES = $(XPM_DEF) -DSOUNDS
434 #endif
435
436 XCOMM Various defines to pass into twm.c
437 ***************
438 *** 65,83 ****
439 #endif
440 TWM_DEFS = $(XLOADIM_DEF) $(M4_DEF) $(WAITPID_DEF)
441
442 ! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(XPMLIB) $(XLIB)
443 LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
444 DEFINES = -DSHAPE $(RELEASE_DEFINES) $(LOCAL_DEFINES) $(SIGNAL_DEFINES)
445
446 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c twm.c \
447 parse.c menus.c events.c resize.c util.c version.c \
448 iconmgr.c cursor.c icons.c vdt.c move.c LocPixmap.c \
449 ! regexp.c
450
451 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o twm.o \
452 parse.o menus.o events.o resize.o util.o version.o \
453 iconmgr.o cursor.o icons.o vdt.o move.o LocPixmap.o \
454 ! regexp.o
455
456 AllTarget(tvtwm ssetroot)
457
458 --- 70,88 ----
459 #endif
460 TWM_DEFS = $(XLOADIM_DEF) $(M4_DEF) $(WAITPID_DEF)
461
462 ! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(XPMLIB) $(XLIB) $(RPLAY)
463 LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
464 DEFINES = -DSHAPE $(RELEASE_DEFINES) $(LOCAL_DEFINES) $(SIGNAL_DEFINES)
465
466 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c twm.c \
467 parse.c menus.c events.c resize.c util.c version.c \
468 iconmgr.c cursor.c icons.c vdt.c move.c LocPixmap.c \
469 ! regexp.c sound.c
470
471 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o twm.o \
472 parse.o menus.o events.o resize.o util.o version.o \
473 iconmgr.o cursor.o icons.o vdt.o move.o LocPixmap.o \
474 ! regexp.o sound.o
475
476 AllTarget(tvtwm ssetroot)
477
478