Fix for stupid Solaris (maybe other Sysv systems too).
[wmaker-crm.git] / src / wmsound.c
blobe8b35bccd55c1b4affb37ff702348ef080f744ad
1 #include "wconfig.h"
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <X11/X.h>
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 #include <X11/Xproto.h>
10 #include "WindowMaker.h"
11 #include "funcs.h"
12 #include "wmsound.h"
14 #ifdef WMSOUND
18 extern WPreferences wPreferences;
20 #if 0
21 void
22 wSoundServerGrab(Window wm_win)
24 Window *lstChildren;
25 Window retRoot;
26 Window retParent;
27 int indexCount;
28 u_int numChildren;
29 XClassHint *retHint;
31 if (XQueryTree(dpy, wm_win, &retRoot, &retParent, &lstChildren, &numChildren)) {
32 for (indexCount = 1; indexCount < numChildren; indexCount++) {
33 retHint = XAllocClassHint();
34 if (!retHint) {
35 XFree(lstChildren);
36 return;
39 XGetClassHint (dpy, lstChildren[indexCount], retHint);
41 if (retHint->res_class) {
42 if (strcmp("WMSoundServer", retHint->res_class)==0 ||
43 /*strcmp("WSoundServer", retHint->res_class)==0 ||*/
44 (retHint->res_name &&
45 strcmp("wsoundserver", retHint->res_name)==0 &&
46 strcmp("DockApp", retHint->res_class)==0)) {
48 soundServer = lstChildren[indexCount];
49 XFree(lstChildren);
50 if(retHint) {
51 XFree(retHint);
53 return;
56 XFree(retHint);
57 retHint = 0;
59 XFree(lstChildren);
61 return;
63 #endif
65 void
66 wSoundPlay(long event_sound)
68 static Atom atom = 0;
69 XEvent sound_event;
71 if (!atom) {
72 atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False);
75 if(!wPreferences.no_sound) {
76 Window win = wScreenWithNumber(0)->info_window;
78 sound_event.xclient.type = ClientMessage;
79 sound_event.xclient.message_type = atom;
80 sound_event.xclient.format = 32;
81 sound_event.xclient.display = dpy;
82 sound_event.xclient.window = win;
83 sound_event.xclient.data.l[0] = event_sound;
84 XSendEvent(dpy, win, False, StructureNotifyMask, &sound_event);
85 XFlush(dpy);
89 #endif /* WMSOUND */