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