XKBBell.c revision b4ee4795
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#define NEED_REPLIES 32#define NEED_EVENTS 33#include "Xlibint.h" 34#include <X11/extensions/XKBproto.h> 35#include "XKBlibint.h" 36 37 38Bool 39XkbDeviceBell( Display * dpy, 40 Window window, 41 int deviceID, 42 int bellClass, 43 int bellID, 44 int percent, 45 Atom name) 46{ 47 register xkbBellReq *req; 48 XkbInfoPtr xkbi; 49 50 if ((dpy->flags & XlibDisplayNoXkb) || 51 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) 52 return False; 53 LockDisplay(dpy); 54 xkbi = dpy->xkb_info; 55 GetReq(kbBell,req); 56 req->reqType = xkbi->codes->major_opcode; 57 req->xkbReqType = X_kbBell; 58 req->deviceSpec = deviceID; 59 req->window = (CARD32)window; 60 req->bellClass = (CARD16)bellClass; 61 req->bellID = (CARD16)bellID; 62 req->percent = percent; 63 req->forceSound = False; 64 req->eventOnly = False; 65 req->pitch = 0; 66 req->duration = 0; 67 req->name = (CARD32)name; 68 req->pad1= 0; req->pad2= 0; 69 UnlockDisplay(dpy); 70 SyncHandle(); 71 return True; 72} 73 74Bool 75XkbForceDeviceBell( Display * dpy, 76 int deviceID, 77 int bellClass, 78 int bellID, 79 int percent) 80{ 81 register xkbBellReq *req; 82 XkbInfoPtr xkbi; 83 84 if ((dpy->flags & XlibDisplayNoXkb) || 85 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) 86 return False; 87 LockDisplay(dpy); 88 xkbi = dpy->xkb_info; 89 GetReq(kbBell,req); 90 req->reqType = xkbi->codes->major_opcode; 91 req->xkbReqType = X_kbBell; 92 req->deviceSpec = deviceID; 93 req->window = (CARD32)None; 94 req->bellClass = (CARD16)bellClass; 95 req->bellID = (CARD16)bellID; 96 req->percent = percent; 97 req->forceSound = True; 98 req->eventOnly = False; 99 req->pitch = 0; 100 req->duration = 0; 101 req->name = None; 102 req->pad1= 0; req->pad2= 0; 103 UnlockDisplay(dpy); 104 SyncHandle(); 105 return True; 106} 107 108Bool 109XkbDeviceBellEvent( 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; req->pad2= 0; 139 UnlockDisplay(dpy); 140 SyncHandle(); 141 return True; 142} 143 144Bool 145XkbBell(Display *dpy,Window window,int percent,Atom name) 146{ 147 if ((dpy->flags & XlibDisplayNoXkb) || 148 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) { 149 XBell(dpy,percent); 150 return False; 151 } 152 return XkbDeviceBell(dpy,window,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId, 153 percent,name); 154} 155 156Bool 157XkbForceBell(Display *dpy,int percent) 158{ 159 if ((dpy->flags & XlibDisplayNoXkb) || 160 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) { 161 XBell(dpy,percent); 162 return False; 163 } 164 return XkbForceDeviceBell(dpy,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId, 165 percent); 166} 167 168Bool 169XkbBellEvent(Display *dpy,Window window,int percent,Atom name) 170{ 171 if ((dpy->flags & XlibDisplayNoXkb) || 172 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) { 173 return False; 174 } 175 /* class 0 = KbdFeedbackClass (X Input Extension) */ 176 return XkbDeviceBellEvent(dpy,window,XkbUseCoreKbd, 177 XkbDfltXIClass,XkbDfltXIId, 178 percent,name); 179} 180 181