11ab64890Smrg/************************************************************
21ab64890SmrgCopyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
31ab64890Smrg
41ab64890SmrgPermission to use, copy, modify, and distribute this
51ab64890Smrgsoftware and its documentation for any purpose and without
61ab64890Smrgfee is hereby granted, provided that the above copyright
71ab64890Smrgnotice appear in all copies and that both that copyright
81ab64890Smrgnotice and this permission notice appear in supporting
961b2299dSmrgdocumentation, and that the name of Silicon Graphics not be
1061b2299dSmrgused in advertising or publicity pertaining to distribution
111ab64890Smrgof the software without specific prior written permission.
1261b2299dSmrgSilicon Graphics makes no representation about the suitability
131ab64890Smrgof this software for any purpose. It is provided "as is"
141ab64890Smrgwithout any express or implied warranty.
151ab64890Smrg
1661b2299dSmrgSILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
1761b2299dSmrgSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
181ab64890SmrgAND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
1961b2299dSmrgGRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
2061b2299dSmrgDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
2161b2299dSmrgDATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
221ab64890SmrgOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
231ab64890SmrgTHE USE OR PERFORMANCE OF THIS SOFTWARE.
241ab64890Smrg
251ab64890Smrg********************************************************/
261ab64890Smrg
271ab64890Smrg#ifdef HAVE_CONFIG_H
281ab64890Smrg#include <config.h>
291ab64890Smrg#endif
301ab64890Smrg#include <stdio.h>
311ab64890Smrg#include "Xlibint.h"
321ab64890Smrg#include <X11/extensions/XKBproto.h>
331ab64890Smrg#include "XKBlibint.h"
341ab64890Smrg
351ab64890Smrg
361ab64890SmrgBool
37818534a1SmrgXkbDeviceBell(Display *dpy,
38818534a1Smrg              Window window,
39818534a1Smrg              int deviceID,
40818534a1Smrg              int bellClass,
41818534a1Smrg              int bellID,
42818534a1Smrg              int percent,
43818534a1Smrg              Atom name)
441ab64890Smrg{
451ab64890Smrg    register xkbBellReq *req;
461ab64890Smrg    XkbInfoPtr xkbi;
471ab64890Smrg
481ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
49818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
50818534a1Smrg        return False;
511ab64890Smrg    LockDisplay(dpy);
521ab64890Smrg    xkbi = dpy->xkb_info;
53818534a1Smrg    GetReq(kbBell, req);
541ab64890Smrg    req->reqType = xkbi->codes->major_opcode;
551ab64890Smrg    req->xkbReqType = X_kbBell;
561ab64890Smrg    req->deviceSpec = deviceID;
57818534a1Smrg    req->window = (CARD32) window;
58818534a1Smrg    req->bellClass = (CARD16) bellClass;
59818534a1Smrg    req->bellID = (CARD16) bellID;
601ab64890Smrg    req->percent = percent;
611ab64890Smrg    req->forceSound = False;
621ab64890Smrg    req->eventOnly = False;
631ab64890Smrg    req->pitch = 0;
641ab64890Smrg    req->duration = 0;
65818534a1Smrg    req->name = (CARD32) name;
66818534a1Smrg    req->pad1 = 0;
67818534a1Smrg    req->pad2 = 0;
681ab64890Smrg    UnlockDisplay(dpy);
691ab64890Smrg    SyncHandle();
701ab64890Smrg    return True;
711ab64890Smrg}
721ab64890Smrg
731ab64890SmrgBool
74818534a1SmrgXkbForceDeviceBell(Display *dpy,
75818534a1Smrg                   int deviceID,
76818534a1Smrg                   int bellClass,
77818534a1Smrg                   int bellID,
78818534a1Smrg                   int percent)
791ab64890Smrg{
801ab64890Smrg    register xkbBellReq *req;
811ab64890Smrg    XkbInfoPtr xkbi;
821ab64890Smrg
831ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
84818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
85818534a1Smrg        return False;
861ab64890Smrg    LockDisplay(dpy);
871ab64890Smrg    xkbi = dpy->xkb_info;
88818534a1Smrg    GetReq(kbBell, req);
891ab64890Smrg    req->reqType = xkbi->codes->major_opcode;
901ab64890Smrg    req->xkbReqType = X_kbBell;
911ab64890Smrg    req->deviceSpec = deviceID;
92818534a1Smrg    req->window = (CARD32) None;
93818534a1Smrg    req->bellClass = (CARD16) bellClass;
94818534a1Smrg    req->bellID = (CARD16) bellID;
951ab64890Smrg    req->percent = percent;
961ab64890Smrg    req->forceSound = True;
971ab64890Smrg    req->eventOnly = False;
981ab64890Smrg    req->pitch = 0;
991ab64890Smrg    req->duration = 0;
1001ab64890Smrg    req->name = None;
101818534a1Smrg    req->pad1 = 0;
102818534a1Smrg    req->pad2 = 0;
1031ab64890Smrg    UnlockDisplay(dpy);
1041ab64890Smrg    SyncHandle();
1051ab64890Smrg    return True;
1061ab64890Smrg}
1071ab64890Smrg
1081ab64890SmrgBool
109818534a1SmrgXkbDeviceBellEvent(Display *dpy,
110818534a1Smrg                   Window window,
111818534a1Smrg                   int deviceID,
112818534a1Smrg                   int bellClass,
113818534a1Smrg                   int bellID,
114818534a1Smrg                   int percent,
115818534a1Smrg                   Atom name)
1161ab64890Smrg{
1171ab64890Smrg    register xkbBellReq *req;
1181ab64890Smrg    XkbInfoPtr xkbi;
1191ab64890Smrg
1201ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
121818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL)))
122818534a1Smrg        return False;
1231ab64890Smrg    LockDisplay(dpy);
1241ab64890Smrg    xkbi = dpy->xkb_info;
125818534a1Smrg    GetReq(kbBell, req);
1261ab64890Smrg    req->reqType = xkbi->codes->major_opcode;
1271ab64890Smrg    req->xkbReqType = X_kbBell;
1281ab64890Smrg    req->deviceSpec = deviceID;
129818534a1Smrg    req->window = (CARD32) window;
130818534a1Smrg    req->bellClass = (CARD16) bellClass;
131818534a1Smrg    req->bellID = (CARD16) bellID;
1321ab64890Smrg    req->percent = percent;
1331ab64890Smrg    req->forceSound = False;
1341ab64890Smrg    req->eventOnly = True;
1351ab64890Smrg    req->pitch = 0;
1361ab64890Smrg    req->duration = 0;
137818534a1Smrg    req->name = (CARD32) name;
138818534a1Smrg    req->pad1 = 0;
139818534a1Smrg    req->pad2 = 0;
1401ab64890Smrg    UnlockDisplay(dpy);
1411ab64890Smrg    SyncHandle();
1421ab64890Smrg    return True;
1431ab64890Smrg}
1441ab64890Smrg
1451ab64890SmrgBool
146818534a1SmrgXkbBell(Display *dpy, Window window, int percent, Atom name)
1471ab64890Smrg{
1481ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
149818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
150818534a1Smrg        XBell(dpy, percent);
151818534a1Smrg        return False;
1521ab64890Smrg    }
153818534a1Smrg    return XkbDeviceBell(dpy, window, XkbUseCoreKbd,
154818534a1Smrg                         XkbDfltXIClass, XkbDfltXIId, percent, name);
1551ab64890Smrg}
1561ab64890Smrg
1571ab64890SmrgBool
158818534a1SmrgXkbForceBell(Display *dpy, int percent)
1591ab64890Smrg{
1601ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
161818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
162818534a1Smrg        XBell(dpy, percent);
163818534a1Smrg        return False;
1641ab64890Smrg    }
165818534a1Smrg    return XkbForceDeviceBell(dpy, XkbUseCoreKbd, XkbDfltXIClass, XkbDfltXIId,
166818534a1Smrg                              percent);
1671ab64890Smrg}
1681ab64890Smrg
1691ab64890SmrgBool
170818534a1SmrgXkbBellEvent(Display *dpy, Window window, int percent, Atom name)
1711ab64890Smrg{
1721ab64890Smrg    if ((dpy->flags & XlibDisplayNoXkb) ||
173818534a1Smrg        (!dpy->xkb_info && !XkbUseExtension(dpy, NULL, NULL))) {
174818534a1Smrg        return False;
1751ab64890Smrg    }
1761ab64890Smrg    /* class 0 = KbdFeedbackClass (X Input Extension) */
177818534a1Smrg    return XkbDeviceBellEvent(dpy, window, XkbUseCoreKbd,
178818534a1Smrg                              XkbDfltXIClass, XkbDfltXIId, percent, name);
1791ab64890Smrg}
180