Debian Codegraph @

contrib/window_managers/ctwm

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]) and then slightly modified by
5 Mark Boyns ([email protected]) for ctwm-3.0.
6
7 Sound events are stored the .ctwm-sounds file located in your home
8 directory. Here a list of all the supported sound events:
9
10 <EventZero>
11 <EventOne>
12 KeyPress
13 KeyRelease
14 ButtonPress
15 ButtonRelease
16 MotionNotify
17 EnterNotify
18 LeaveNotify
19 FocusIn
20 FocusOut
21 KeymapNotify
22 Expose
23 GraphicsExpose
24 NoExpose
25 VisibilityNotify
26 CreateNotify
27 DestroyNotify
28 UnmapNotify
29 MapNotify
30 MapRequest
31 ReparentNotify
32 ConfigureNotify
33 ConfigureRequest
34 GravityNotify
35 ResizeRequest
36 CirculateNotify
37 CirculateRequest
38 PropertyNotify
39 SelectionClear
40 SelectionRequest
41 SelectionNotify
42 ColormapNotify
43 ClientMessage
44 MappingNotify
45
46 And here is a sample sounds file:
47
48 KeyPress: Cork.au
49 MapNotify: turbbeep.au
50 ResizeRequest: failure.au
51 Startup: 2lust.au
52 Shutdown: 1sadeness.au
53
54
55 *** Imakefile.orig Fri Nov 5 11:09:11 1993
56 --- Imakefile Wed Nov 10 09:03:05 1993
57 ***************
58 *** 9,14 ****
59 --- 9,15 ----
60 #define XPM
61 #undef IMCONV
62 #define USEM4
63 + #define USE_SOUND
64
65 YFLAGS = -d
66 DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
67 ***************
68 *** 51,67 ****
69 M4LIB =
70 #endif
71
72 ! LOCAL_LIBRARIES = $(M4LIB) $(IMCONVLIB) $(XPMLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
73 ! DEFINES = $(SIGNAL_DEFINES) $(M4DEFINES) $(IMCONVDEFINES) $(XPMDEFINES)
74 ! EXTRA_INCLUDES = $(M4INCDIR) $(IMCONVINCDIR) $(XPMINCDIR)
75
76 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c ctwm.c \
77 parse.c menus.c events.c resize.c util.c version.c iconmgr.c \
78 ! cursor.c icons.c workmgr.c
79
80 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o ctwm.o \
81 parse.o menus.o events.o resize.o util.o version.o iconmgr.o \
82 ! cursor.o icons.o workmgr.o
83
84 PIXMAPFILES = xpm/IslandD.xpm xpm/mail1.xpm xpm/xgopher.xpm \
85 xpm/IslandW.xpm xpm/nothing.xpm xpm/xgrab.xpm \
86 --- 52,78 ----
87 M4LIB =
88 #endif
89
90 ! #ifdef USE_SOUND
91 ! SOUND_LIBS = -lrplay
92 ! SOUND_INCLUDES = -I/usr/local/include
93 ! SOUND_DEFS = -DSOUNDS
94 ! #else
95 ! SOUND_LIBS =
96 ! SOUND_INCLUDES =
97 ! SOUND_DEFS =
98 ! #endif
99 !
100 ! LOCAL_LIBRARIES = $(M4LIB) $(IMCONVLIB) $(XPMLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(SOUND_LIBS)
101 ! DEFINES = $(SIGNAL_DEFINES) $(M4DEFINES) $(IMCONVDEFINES) $(XPMDEFINES) $(SOUND_DEFS)
102 ! EXTRA_INCLUDES = $(M4INCDIR) $(IMCONVINCDIR) $(XPMINCDIR) $(SOUND_INCLUDES)
103
104 SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c ctwm.c \
105 parse.c menus.c events.c resize.c util.c version.c iconmgr.c \
106 ! cursor.c icons.c workmgr.c sound.c
107
108 OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o ctwm.o \
109 parse.o menus.o events.o resize.o util.o version.o iconmgr.o \
110 ! cursor.o icons.o workmgr.o sound.o
111
112 PIXMAPFILES = xpm/IslandD.xpm xpm/mail1.xpm xpm/xgopher.xpm \
113 xpm/IslandW.xpm xpm/nothing.xpm xpm/xgrab.xpm \
114 *** ctwm.c.orig Tue Jul 20 03:29:19 1993
115 --- ctwm.c Tue Nov 9 22:14:21 1993
116 ***************
117 *** 574,579 ****
118 --- 574,583 ----
119 exit (1);
120 }
121
122 + #ifdef SOUNDS
123 + play_startup_sound();
124 + #endif
125 +
126 RestartPreviousState = True;
127 HandlingEvents = TRUE;
128 InitEvents();
129 ***************
130 *** 856,861 ****
131 --- 860,868 ----
132
133 SIGNAL_T Done()
134 {
135 + #ifdef SOUNDS
136 + play_exit_sound();
137 + #endif
138 Reborder (CurrentTime);
139 XDeleteProperty (dpy, Scr->Root, _XA_WM_WORKSPACESLIST);
140 XCloseDisplay(dpy);
141 *** events.c.orig Tue Jul 20 03:29:20 1993
142 --- events.c Tue Nov 9 22:15:17 1993
143 ***************
144 *** 61,66 ****
145 --- 61,70 ----
146 extern unsigned int mods_used;
147 extern int menuFromFrameOrWindowOrTitlebar;
148
149 + #ifdef SOUNDS
150 + extern play_sounds();
151 + #endif
152 +
153 #define MAX_X_EVENT 256
154 event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */
155 char *Action;
156 ***************
157 *** 272,278 ****
158 * Procedure:
159 * DispatchEvent2 -
160 * handle a single X event stored in global var Event
161 ! * this rouitine for is for a call during an f.move
162 *
163 ***********************************************************************
164 */
165 --- 276,282 ----
166 * Procedure:
167 * DispatchEvent2 -
168 * handle a single X event stored in global var Event
169 ! * this routine for is for a call during an f.move
170 *
171 ***********************************************************************
172 */
173 ***************
174 *** 290,295 ****
175 --- 294,303 ----
176
177 if (!Scr) return False;
178
179 + #ifdef SOUNDS
180 + play_sound(Event.type);
181 + #endif
182 +
183 if (menuFromFrameOrWindowOrTitlebar && Event.type == Expose)
184 HandleExpose();
185
186 ***************
187 *** 322,327 ****
188 --- 330,338 ----
189 if (!Scr) return False;
190
191 if (Event.type>= 0 && Event.type < MAX_X_EVENT) {
192 + #ifdef SOUNDS
193 + play_sound(Event.type);
194 + #endif
195 (*EventHandler[Event.type])();
196 }
197
198 *** menus.c.orig Tue Jul 20 03:29:20 1993
199 --- menus.c Wed Nov 10 10:16:48 1993
200 ***************
201 *** 58,63 ****
202 --- 58,68 ----
203 #include <X11/bitmaps/menu12>
204 #include "version.h"
205
206 + #ifdef SOUNDS
207 + extern int toggle_sound();
208 + extern int reread_sounds();
209 + #endif
210 +
211 extern XEvent Event;
212
213 int RootFunction = 0;
214 ***************
215 *** 1549,1554 ****
216 --- 1554,1567 ----
217
218 switch (func)
219 {
220 + #ifdef SOUNDS
221 + case F_TOGGLESOUND:
222 + toggle_sound();
223 + break;
224 + case F_REREADSOUNDS:
225 + reread_sounds();
226 + break;
227 + #endif
228 case F_NOP:
229 case F_TITLE:
230 break;
231 ***************
232 *** 3014,3019 ****
233 --- 3027,3035 ----
234 #endif
235 #ifdef USEM4
236 (void) strcat (Info[n], ", USEM4");
237 + #endif
238 + #ifdef SOUNDS
239 + (void) strcat (Info[n], ", SOUNDS");
240 #endif
241 n++;
242 Info[n++][0] = '\0';
243 *** parse.c.orig Tue Jul 20 03:29:20 1993
244 --- parse.c Wed Nov 10 09:56:35 1993
245 ***************
246 *** 95,100 ****
247 --- 95,103 ----
248
249 extern char *defTwmrc[]; /* default bindings */
250
251 + #ifdef SOUNDS
252 + extern int set_sound_host();
253 + #endif
254
255 /***********************************************************************
256 *
257 ***************
258 *** 472,477 ****
259 --- 475,484 ----
260 #define kws_IconDirectory 8
261 #define kws_MaxWindowSize 9
262 #define kws_PixmapDirectory 10
263 + #ifdef SOUNDS
264 + #define kws_SoundHost 11
265 + #endif
266 +
267
268 #define kwn_ConstrainedMoveTime 1
269 #define kwn_MoveDelta 2
270 ***************
271 *** 513,519 ****
272 #define kwc_MenuTitleBackground 6
273 #define kwc_MenuShadowColor 7
274
275 -
276 /*
277 * The following is sorted alphabetically according to name (which must be
278 * in lowercase and only contain the letters a-z). It is fed to a binary
279 --- 520,525 ----
280 ***************
281 *** 599,604 ****
282 --- 605,613 ----
283 { "f.raise", FKEYWORD, F_RAISE },
284 { "f.raiselower", FKEYWORD, F_RAISELOWER },
285 { "f.refresh", FKEYWORD, F_REFRESH },
286 + #ifdef SOUNDS
287 + { "f.rereadsounds", FKEYWORD, F_REREADSOUNDS },
288 + #endif
289 { "f.resize", FKEYWORD, F_RESIZE },
290 { "f.restart", FKEYWORD, F_RESTART },
291 { "f.righticonmgr", FKEYWORD, F_RIGHTICONMGR },
292 ***************
293 *** 612,617 ****
294 --- 621,629 ----
295 { "f.sorticonmgr", FKEYWORD, F_SORTICONMGR },
296 { "f.source", FSKEYWORD, F_BEEP }, /* XXX - don't work */
297 { "f.title", FKEYWORD, F_TITLE },
298 + #ifdef SOUNDS
299 + { "f.togglesound", FKEYWORD, F_TOGGLESOUND },
300 + #endif
301 { "f.togglestate", FKEYWORD, F_TOGGLESTATE },
302 { "f.topzoom", FKEYWORD, F_TOPZOOM },
303 { "f.twmrc", FKEYWORD, F_RESTART },
304 ***************
305 *** 722,727 ****
306 --- 734,742 ----
307 { "showiconmanager", KEYWORD, kw0_ShowIconManager },
308 { "showworkspacemanager", KEYWORD, kw0_ShowWorkspaceManager },
309 { "sorticonmanager", KEYWORD, kw0_SortIconManager },
310 + #ifdef SOUNDS
311 + { "soundhost", SKEYWORD, kws_SoundHost },
312 + #endif
313 { "south", DKEYWORD, D_SOUTH },
314 { "squeezetitle", SQUEEZE_TITLE, 0 },
315 { "starticonified", START_ICONIFIED, 0 },
316 ***************
317 *** 1007,1012 ****
318 --- 1022,1034 ----
319 Scr->MaxWindowWidth = JunkWidth;
320 Scr->MaxWindowHeight = JunkHeight;
321 return 1;
322 +
323 + #ifdef SOUNDS
324 + case kws_SoundHost:
325 + if (Scr->FirstTime) set_sound_host(s);
326 + return 1;
327 + #endif
328 +
329 }
330
331 return 0;
332 *** parse.h.orig Tue Jul 20 03:29:19 1993
333 --- parse.h Wed Nov 10 08:53:25 1993
334 ***************
335 *** 103,108 ****
336 --- 103,112 ----
337 #define F_NEXTWORKSPACE 56
338 #define F_PREVWORKSPACE 57
339 #define F_SEPARATOR 58
340 + #ifdef SOUNDS
341 + #define F_TOGGLESOUND 59
342 + #define F_REREADSOUNDS 60
343 + #endif
344
345 #define F_MENU 101 /* string */
346 #define F_WARPTO 102 /* string */
347 *** sound.c.orig Tue Nov 9 22:12:27 1993
348 --- sound.c Wed Nov 10 09:22:45 1993
349 ***************
350 *** 0 ****
351 --- 1,181 ----
352 + /*
353 + * These routines were extracted from the sound hack for olvwm3.3 by
354 + * Andrew "Ender" Scherpbier ([email protected])
355 + * and modified by J.E. Sacco (jsacco @ssl.com)
356 + */
357 +
358 + #include <rplay.h>
359 + #include <string.h>
360 + #include <stdio.h>
361 +
362 + char *eventNames[] =
363 + {
364 + "<EventZero>",
365 + "<EventOne>",
366 + "KeyPress",
367 + "KeyRelease",
368 + "ButtonPress",
369 + "ButtonRelease",
370 + "MotionNotify",
371 + "EnterNotify",
372 + "LeaveNotify",
373 + "FocusIn",
374 + "FocusOut",
375 + "KeymapNotify",
376 + "Expose",
377 + "GraphicsExpose",
378 + "NoExpose",
379 + "VisibilityNotify",
380 + "CreateNotify",
381 + "DestroyNotify",
382 + "UnmapNotify",
383 + "MapNotify",
384 + "MapRequest",
385 + "ReparentNotify",
386 + "ConfigureNotify",
387 + "ConfigureRequest",
388 + "GravityNotify",
389 + "ResizeRequest",
390 + "CirculateNotify",
391 + "CirculateRequest",
392 + "PropertyNotify",
393 + "SelectionClear",
394 + "SelectionRequest",
395 + "SelectionNotify",
396 + "ColormapNotify",
397 + "ClientMessage",
398 + "MappingNotify",
399 + "Startup",
400 + "Shutdown"
401 + };
402 +
403 + #define NEVENTS (sizeof(eventNames) / sizeof(char *))
404 +
405 + RPLAY *rp[NEVENTS];
406 +
407 + static int need_sound_init = 1;
408 + static int sound_fd = 0;
409 + static int sound_state = 1;
410 + static int startup_sound = NEVENTS -2;
411 + static int exit_sound = NEVENTS -1;
412 + static char hostname[200];
413 +
414 + /*
415 + * initialize
416 + */
417 + static
418 + sound_init ()
419 + {
420 + int i;
421 + FILE *fl;
422 + char buffer[100];
423 + char *token;
424 +
425 + need_sound_init = 0;
426 + if (sound_fd == 0) {
427 + if (hostname[0] == '\0') {
428 + strcpy(hostname, rplay_default_host());
429 + }
430 +
431 + if ((sound_fd = rplay_open (hostname)) < 0)
432 + rplay_perror ("create");
433 + }
434 +
435 + /*
436 + * Destroy any old sounds
437 + */
438 + for (i = 0; i < NEVENTS; i++) {
439 + if (rp[i] != NULL)
440 + rplay_destroy (rp[i]);
441 + rp[i] = NULL;
442 + }
443 +
444 + /*
445 + * Now read the file which contains the sounds
446 + */
447 + fl = fopen (".ctwm-sounds", "r");
448 + if (fl == NULL)
449 + return;
450 + while (fgets (buffer, 100, fl) != NULL) {
451 + token = strtok (buffer, ": \t");
452 + if (token == NULL)
453 + continue;
454 + for (i = 0; i < NEVENTS; i++) {
455 + if (strcmp (token, eventNames[i]) == 0) {
456 + token = strtok (NULL, " \t\r\n");
457 + if (token == NULL || *token == '#' || isspace (*token))
458 + continue;
459 + rp[i] = rplay_create (RPLAY_PLAY);
460 + if (rp[i] == NULL) {
461 + rplay_perror ("create");
462 + continue;
463 + }
464 + if (rplay_set(rp[i], RPLAY_INSERT, 0, RPLAY_SOUND, token, NULL)
465 + < 0)
466 + rplay_perror ("rplay");
467 + }
468 + }
469 + }
470 + fclose (fl);
471 + }
472 +
473 +
474 + /*
475 + * Play sound
476 + */
477 + play_sound (snd)
478 + int snd;
479 + {
480 + if (sound_state == 0)
481 + return;
482 +
483 + if (need_sound_init)
484 + sound_init ();
485 +
486 + if (rp[snd] == NULL)
487 + return;
488 + if (rplay (sound_fd, rp[snd]) < 0)
489 + rplay_perror ("create");
490 + }
491 +
492 + play_startup_sound()
493 + {
494 + play_sound(startup_sound);
495 + }
496 +
497 + play_exit_sound()
498 + {
499 + play_sound(exit_sound);
500 + }
501 +
502 + /*
503 + * Toggle the sound on/off
504 + */
505 + toggle_sound ()
506 + {
507 + sound_state ^= 1;
508 + }
509 +
510 +
511 + /*
512 + * Re-read the sounds mapping file
513 + */
514 + reread_sounds ()
515 + {
516 + sound_init ();
517 + }
518 +
519 + /*
520 + * Set the SoundHost and force the sound_fd to be re-opened.
521 + */
522 + set_sound_host(host)
523 + char *host;
524 + {
525 + strcpy(hostname, host);
526 + if (sound_fd != 0)
527 + {
528 + rplay_close(sound_fd);
529 + }
530 + sound_fd = 0;
531 + }
532 +