Debian Codegraph @

contrib/window_managers/twm

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 twm.
5
6 Sound events are stored the .twm-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 ----------------------twm patches -----------------------------------------
55
56 found the following files to diff
57 ./events.c.dist ./parse.h.dist ./sound.c.dist ./parse.c.dist ./menus.c.dist ./twm.c.dist ./Imakefile.dist
58 *** ./events.c.dist Tue Nov 9 22:36:17 1993
59 --- ./events.c Tue Nov 9 22:37:59 1993
60 ***************
61 *** 50,55 ****
62 --- 50,59 ----
63 #include "iconmgr.h"
64 #include "version.h"
65
66 + #ifdef SOUNDS
67 + extern play_sounds();
68 + #endif
69 +
70 extern int iconifybox_width, iconifybox_height;
71 extern unsigned int mods_used;
72 extern int menuFromFrameOrWindowOrTitlebar;
73 ***************
74 *** 277,282 ****
75 --- 281,290 ----
76
77 if (!Scr) return False;
78
79 + #ifdef SOUNDS
80 + play_sound(Event.type);
81 + #endif
82 +
83 if (menuFromFrameOrWindowOrTitlebar && Event.type == Expose)
84 HandleExpose();
85
86 ***************
87 *** 309,314 ****
88 --- 317,325 ----
89 if (!Scr) return False;
90
91 if (Event.type>= 0 && Event.type < MAX_X_EVENT) {
92 + #ifdef SOUNDS
93 + play_sound(Event.type);
94 + #endif
95 (*EventHandler[Event.type])();
96 }
97
98 *** ./parse.h.dist Tue Nov 9 22:38:04 1993
99 --- ./parse.h Tue Nov 9 22:38:49 1993
100 ***************
101 *** 90,95 ****
102 --- 90,100 ----
103 #define F_CUTFILE 43
104 #define F_SHOWLIST 44
105 #define F_HIDELIST 45
106 + #ifdef SOUNDS
107 + #define F_TOGGLESOUND 46
108 + #define F_REREADSOUNDS 47
109 + #endif
110 +
111
112 #define F_MENU 101 /* string */
113 #define F_WARPTO 102 /* string */
114 *** ./sound.c.dist Wed Nov 10 10:07:02 1993
115 --- ./sound.c Wed Nov 10 09:31:52 1993
116 ***************
117 *** 0 ****
118 --- 1,164 ----
119 + /*
120 + * These routines were extracted from the sound hack for olvwm3.3 by
121 + * Andrew "Ender" Scherpbier ([email protected])
122 + * and modified by J.E. Sacco (jsacco @ssl.com)
123 + */
124 +
125 + #include <rplay.h>
126 + #include <string.h>
127 + #include <stdio.h>
128 +
129 + char *eventNames[] =
130 + {
131 + "<EventZero>",
132 + "<EventOne>",
133 + "KeyPress",
134 + "KeyRelease",
135 + "ButtonPress",
136 + "ButtonRelease",
137 + "MotionNotify",
138 + "EnterNotify",
139 + "LeaveNotify",
140 + "FocusIn",
141 + "FocusOut",
142 + "KeymapNotify",
143 + "Expose",
144 + "GraphicsExpose",
145 + "NoExpose",
146 + "VisibilityNotify",
147 + "CreateNotify",
148 + "DestroyNotify",
149 + "UnmapNotify",
150 + "MapNotify",
151 + "MapRequest",
152 + "ReparentNotify",
153 + "ConfigureNotify",
154 + "ConfigureRequest",
155 + "GravityNotify",
156 + "ResizeRequest",
157 + "CirculateNotify",
158 + "CirculateRequest",
159 + "PropertyNotify",
160 + "SelectionClear",
161 + "SelectionRequest",
162 + "SelectionNotify",
163 + "ColormapNotify",
164 + "ClientMessage",
165 + "MappingNotify",
166 + "Startup",
167 + "Shutdown"
168 + };
169 +
170 + #define NEVENTS (sizeof(eventNames) / sizeof(char *))
171 +
172 + RPLAY *rp[NEVENTS];
173 +
174 + static int need_sound_init = 1;
175 + static int sound_fd = 0;
176 + static int sound_state = 1;
177 + static int startup_sound = NEVENTS -2;
178 + static int exit_sound = NEVENTS -1;
179 +
180 + /*
181 + * initialize
182 + */
183 + static
184 + sound_init ()
185 + {
186 + int i;
187 + FILE *fl;
188 + char buffer[100];
189 + char *token;
190 + char hostname[200];
191 +
192 + need_sound_init = 0;
193 + if (sound_fd == 0) {
194 + gethostname (hostname, 200);
195 +
196 + if ((sound_fd = rplay_open (hostname)) < 0)
197 + rplay_perror ("create");
198 + }
199 +
200 + /*
201 + * Destroy any old sounds
202 + */
203 + for (i = 0; i < NEVENTS; i++) {
204 + if (rp[i] != NULL)
205 + rplay_destroy (rp[i]);
206 + rp[i] = NULL;
207 + }
208 +
209 + /*
210 + * Now read the file which contains the sounds
211 + */
212 + fl = fopen (".twm-sounds", "r");
213 + if (fl == NULL)
214 + return;
215 + while (fgets (buffer, 100, fl) != NULL) {
216 + token = strtok (buffer, ": \t");
217 + if (token == NULL)
218 + continue;
219 + for (i = 0; i < NEVENTS; i++) {
220 + if (strcmp (token, eventNames[i]) == 0) {
221 + token = strtok (NULL, " \t\r\n");
222 + if (token == NULL || *token == '#' || isspace (*token))
223 + continue;
224 + rp[i] = rplay_create (RPLAY_PLAY);
225 + if (rp[i] == NULL) {
226 + rplay_perror ("create");
227 + continue;
228 + }
229 + if (rplay_set(rp[i], RPLAY_INSERT, 0, RPLAY_SOUND, token, NULL)
230 + < 0)
231 + rplay_perror ("rplay");
232 + }
233 + }
234 + }
235 + fclose (fl);
236 + }
237 +
238 +
239 + /*
240 + * Play sound
241 + */
242 + play_sound (snd)
243 + int snd;
244 + {
245 + if (sound_state == 0)
246 + return;
247 +
248 + if (need_sound_init)
249 + sound_init ();
250 +
251 + if (rp[snd] == NULL)
252 + return;
253 + if (rplay (sound_fd, rp[snd]) < 0)
254 + rplay_perror ("create");
255 + }
256 +
257 + play_startup_sound()
258 + {
259 + play_sound(startup_sound);
260 + }
261 +
262 + play_exit_sound()
263 + {
264 + play_sound(exit_sound);
265 + }
266 +
267 + /*
268 + * Toggle the sound on/off
269 + */
270 + toggle_sound ()
271 + {
272 + sound_state ^= 1;
273 + }
274 +
275 +
276 + /*
277 + * Re-read the sounds mapping file
278 + */
279 + reread_sounds ()
280 + {
281 + sound_init ();
282 + }
283 *** ./parse.c.dist Tue Nov 9 22:38:58 1993
284 --- ./parse.c Wed Nov 10 10:00:55 1993
285 ***************
286 *** 424,429 ****
287 --- 424,432 ----
288 { "f.raise", FKEYWORD, F_RAISE },
289 { "f.raiselower", FKEYWORD, F_RAISELOWER },
290 { "f.refresh", FKEYWORD, F_REFRESH },
291 + #ifdef SOUNDS
292 + { "f.rereadsounds", FKEYWORD, F_REREADSOUNDS },
293 + #endif
294 { "f.resize", FKEYWORD, F_RESIZE },
295 { "f.restart", FKEYWORD, F_RESTART },
296 { "f.righticonmgr", FKEYWORD, F_RIGHTICONMGR },
297 ***************
298 *** 433,438 ****
299 --- 436,444 ----
300 { "f.sorticonmgr", FKEYWORD, F_SORTICONMGR },
301 { "f.source", FSKEYWORD, F_BEEP }, /* XXX - don't work */
302 { "f.title", FKEYWORD, F_TITLE },
303 + #ifdef SOUNDS
304 + { "f.togglesound", FKEYWORD, F_TOGGLESOUND },
305 + #endif
306 { "f.topzoom", FKEYWORD, F_TOPZOOM },
307 { "f.twmrc", FKEYWORD, F_RESTART },
308 { "f.unfocus", FKEYWORD, F_UNFOCUS },
309 *** ./menus.c.dist Tue Nov 9 22:40:32 1993
310 --- ./menus.c Wed Nov 10 09:43:29 1993
311 ***************
312 *** 52,57 ****
313 --- 52,62 ----
314 #include <X11/bitmaps/menu12>
315 #include "version.h"
316
317 + #ifdef SOUNDS
318 + extern int toggle_sound();
319 + extern int reread_sounds();
320 + #endif
321 +
322 extern XEvent Event;
323
324 int RootFunction = NULL;
325 ***************
326 *** 1347,1352 ****
327 --- 1352,1365 ----
328
329 switch (func)
330 {
331 + #ifdef SOUNDS
332 + case F_TOGGLESOUND:
333 + toggle_sound();
334 + break;
335 + case F_REREADSOUNDS:
336 + reread_sounds();
337 + break;
338 + #endif
339 case F_UPICONMGR:
340 case F_LEFTICONMGR:
341 case F_RIGHTICONMGR:
342 *** ./twm.c.dist Tue Nov 9 22:42:59 1993
343 --- ./twm.c Tue Nov 9 22:46:34 1993
344 ***************
345 *** 110,115 ****
346 --- 110,120 ----
347
348 extern void assign_var_savecolor();
349
350 + #ifdef SOUNDS
351 + extern int play_startup_sound();
352 + extern int play_exit_sound();
353 + #endif
354 +
355 /***********************************************************************
356 *
357 * Procedure:
358 ***************
359 *** 511,516 ****
360 --- 516,524 ----
361
362 RestartPreviousState = False;
363 HandlingEvents = TRUE;
364 + #ifdef SOUNDS
365 + play_startup_sound();
366 + #endif
367 InitEvents();
368 HandleEvents();
369 }
370 ***************
371 *** 766,771 ****
372 --- 774,782 ----
373
374 SIGNAL_T Done()
375 {
376 + #ifdef SOUNDS
377 + play_exit_sound();
378 + #endif
379 Reborder (CurrentTime);
380 XCloseDisplay(dpy);
381 exit(0);
382 *** ./Imakefile.dist Tue Nov 9 22:46:46 1993
383 --- ./Imakefile Wed Nov 10 09:48:40 1993
384 ***************
385 *** 6,24 ****
386 XCOMM distribute this one.
387 XCOMM
388
389 YFLAGS = -d
390 DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
391 ! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(XLIB)
392 LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
393 ! DEFINES = $(SIGNAL_DEFINES)
394
395 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c twm.c \
396 parse.c menus.c events.c resize.c util.c version.c iconmgr.c \
397 ! cursor.c icons.c
398
399 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o twm.o \
400 parse.o menus.o events.o resize.o util.o version.o iconmgr.o \
401 ! cursor.o icons.o
402
403 AllTarget(twm)
404
405 --- 6,30 ----
406 XCOMM distribute this one.
407 XCOMM
408
409 + XCOMM Specify rplay library
410 + RPLAY = -lrplay
411 + RPLAY_INC = -I/usr/local/include
412 + EXTRA_INCLUDES = $(RPLAY_INC)
413 + LOCAL_DEFINES = -DSOUNDS
414 +
415 YFLAGS = -d
416 DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
417 ! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(XLIB) $(RPLAY)
418 LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
419 ! DEFINES = $(SIGNAL_DEFINES) $(LOCAL_DEFINES)
420
421 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c twm.c \
422 parse.c menus.c events.c resize.c util.c version.c iconmgr.c \
423 ! cursor.c icons.c sound.c
424
425 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o twm.o \
426 parse.o menus.o events.o resize.o util.o version.o iconmgr.o \
427 ! cursor.o icons.o sound.o
428
429 AllTarget(twm)
430
431