1 /************************************************************
2 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
3
4 Permission to use, copy, modify, and distribute this
5 software and its documentation for any purpose and without
6 fee is hereby granted, provided that the above copyright
7 notice appear in all copies and that both that copyright
8 notice and this permission notice appear in supporting
9 documentation, and that the name of Silicon Graphics not be
10 used in advertising or publicity pertaining to distribution
11 of the software without specific prior written permission.
12 Silicon Graphics makes no representation about the suitability
13 of this software for any purpose. It is provided "as is"
14 without any express or implied warranty.
15
16 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25 ********************************************************/
26
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30 #include <stdio.h>
31 #include "Xlibint.h"
32 #include <X11/extensions/XKBproto.h>
33 #include "XKBlibint.h"
34
35
36 Bool
XkbDeviceBell(Display * dpy,Window window,int deviceID,int bellClass,int bellID,int percent,Atom name)37 XkbDeviceBell(Display *dpy,
38 Window window,
39 int deviceID,
40 int bellClass,
41 int bellID,
42 int percent,
43 Atom name)
44 {
45 register xkbBellReq *req;
46 XkbInfoPtr xkbi;
47
48 if ((dpy->flags & XlibDisplayNoXkb) ||
49 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
50 return False;
51 LockDisplay(dpy);
52 xkbi = dpy->xkb_info;
53 GetReq(kbBell, req);
54 req->reqType = xkbi->codes->major_opcode;
55 req->xkbReqType = X_kbBell;
56 req->deviceSpec = deviceID;
57 req->window = (CARD32) window;
58 req->bellClass = (CARD16) bellClass;
59 req->bellID = (CARD16) bellID;
60 req->percent = percent;
61 req->forceSound = False;
62 req->eventOnly = False;
63 req->pitch = 0;
64 req->duration = 0;
65 req->name = (CARD32) name;
66 req->pad1 = 0;
67 req->pad2 = 0;
68 UnlockDisplay(dpy);
69 SyncHandle();
70 return True;
71 }
72
73 Bool
XkbForceDeviceBell(Display * dpy,int deviceID,int bellClass,int bellID,int percent)74 XkbForceDeviceBell(Display *dpy,
75 int deviceID,
76 int bellClass,
77 int bellID,
78 int percent)
79 {
80 register xkbBellReq *req;
81 XkbInfoPtr xkbi;
82
83 if ((dpy->flags & XlibDisplayNoXkb) ||
84 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
85 return False;
86 LockDisplay(dpy);
87 xkbi = dpy->xkb_info;
88 GetReq(kbBell, req);
89 req->reqType = xkbi->codes->major_opcode;
90 req->xkbReqType = X_kbBell;
91 req->deviceSpec = deviceID;
92 req->window = (CARD32) None;
93 req->bellClass = (CARD16) bellClass;
94 req->bellID = (CARD16) bellID;
95 req->percent = percent;
96 req->forceSound = True;
97 req->eventOnly = False;
98 req->pitch = 0;
99 req->duration = 0;
100 req->name = None;
101 req->pad1 = 0;
102 req->pad2 = 0;
103 UnlockDisplay(dpy);
104 SyncHandle();
105 return True;
106 }
107
108 Bool
XkbDeviceBellEvent(Display * dpy,Window window,int deviceID,int bellClass,int bellID,int percent,Atom name)109 XkbDeviceBellEvent(Display *dpy,
110 Window window,
111 int deviceID,
112 int bellClass,
113 int bellID,
114 int percent,
115 Atom name)
116 {
117 register xkbBellReq *req;
118 XkbInfoPtr xkbi;
119
120 if ((dpy->flags & XlibDisplayNoXkb) ||
121 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
122 return False;
123 LockDisplay(dpy);
124 xkbi = dpy->xkb_info;
125 GetReq(kbBell, req);
126 req->reqType = xkbi->codes->major_opcode;
127 req->xkbReqType = X_kbBell;
128 req->deviceSpec = deviceID;
129 req->window = (CARD32) window;
130 req->bellClass = (CARD16) bellClass;
131 req->bellID = (CARD16) bellID;
132 req->percent = percent;
133 req->forceSound = False;
134 req->eventOnly = True;
135 req->pitch = 0;
136 req->duration = 0;
137 req->name = (CARD32) name;
138 req->pad1 = 0;
139 req->pad2 = 0;
140 UnlockDisplay(dpy);
141 SyncHandle();
142 return True;
143 }
144
145 Bool
XkbBell(Display * dpy,Window window,int percent,Atom name)146 XkbBell(Display *dpy, Window window, int percent, Atom name)
147 {
148 if ((dpy->flags & XlibDisplayNoXkb) ||
149 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
150 XBell(dpy, percent);
151 return False;
152 }
153 return XkbDeviceBell(dpy, window, XkbUseCoreKbd,
154 XkbDfltXIClass, XkbDfltXIId, percent, name);
155 }
156
157 Bool
XkbForceBell(Display * dpy,int percent)158 XkbForceBell(Display *dpy, int percent)
159 {
160 if ((dpy->flags & XlibDisplayNoXkb) ||
161 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
162 XBell(dpy, percent);
163 return False;
164 }
165 return XkbForceDeviceBell(dpy, XkbUseCoreKbd, XkbDfltXIClass, XkbDfltXIId,
166 percent);
167 }
168
169 Bool
XkbBellEvent(Display * dpy,Window window,int percent,Atom name)170 XkbBellEvent(Display *dpy, Window window, int percent, Atom name)
171 {
172 if ((dpy->flags & XlibDisplayNoXkb) ||
173 (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
174 return False;
175 }
176 /* class 0 = KbdFeedbackClass (X Input Extension) */
177 return XkbDeviceBellEvent(dpy, window, XkbUseCoreKbd,
178 XkbDfltXIClass, XkbDfltXIId, percent, name);
179 }
180