xref: /OK3568_Linux_fs/external/xserver/xkb/ddxCtrls.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /************************************************************
2*4882a593Smuzhiyun Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun Permission to use, copy, modify, and distribute this
5*4882a593Smuzhiyun software and its documentation for any purpose and without
6*4882a593Smuzhiyun fee is hereby granted, provided that the above copyright
7*4882a593Smuzhiyun notice appear in all copies and that both that copyright
8*4882a593Smuzhiyun notice and this permission notice appear in supporting
9*4882a593Smuzhiyun documentation, and that the name of Silicon Graphics not be
10*4882a593Smuzhiyun used in advertising or publicity pertaining to distribution
11*4882a593Smuzhiyun of the software without specific prior written permission.
12*4882a593Smuzhiyun Silicon Graphics makes no representation about the suitability
13*4882a593Smuzhiyun of this software for any purpose. It is provided "as is"
14*4882a593Smuzhiyun without any express or implied warranty.
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17*4882a593Smuzhiyun SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18*4882a593Smuzhiyun AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19*4882a593Smuzhiyun GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20*4882a593Smuzhiyun DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21*4882a593Smuzhiyun DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22*4882a593Smuzhiyun OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23*4882a593Smuzhiyun THE USE OR PERFORMANCE OF THIS SOFTWARE.
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun ********************************************************/
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
28*4882a593Smuzhiyun #include <dix-config.h>
29*4882a593Smuzhiyun #endif
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #include <stdio.h>
32*4882a593Smuzhiyun #include <X11/X.h>
33*4882a593Smuzhiyun #include <X11/Xproto.h>
34*4882a593Smuzhiyun #include <X11/keysym.h>
35*4882a593Smuzhiyun #include "inputstr.h"
36*4882a593Smuzhiyun #include "scrnintstr.h"
37*4882a593Smuzhiyun #include "windowstr.h"
38*4882a593Smuzhiyun #include <xkbsrv.h>
39*4882a593Smuzhiyun #include <X11/extensions/XI.h>
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun void
XkbDDXKeybdCtrlProc(DeviceIntPtr dev,KeybdCtrl * ctrl)42*4882a593Smuzhiyun XkbDDXKeybdCtrlProc(DeviceIntPtr dev, KeybdCtrl * ctrl)
43*4882a593Smuzhiyun {
44*4882a593Smuzhiyun     int realRepeat;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun     realRepeat = ctrl->autoRepeat;
47*4882a593Smuzhiyun     if ((dev->kbdfeed) && (XkbDDXUsesSoftRepeat(dev)))
48*4882a593Smuzhiyun         ctrl->autoRepeat = 0;
49*4882a593Smuzhiyun     if (dev->key && dev->key->xkbInfo && dev->key->xkbInfo->kbdProc)
50*4882a593Smuzhiyun         (*dev->key->xkbInfo->kbdProc) (dev, ctrl);
51*4882a593Smuzhiyun     ctrl->autoRepeat = realRepeat;
52*4882a593Smuzhiyun     return;
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun int
XkbDDXUsesSoftRepeat(DeviceIntPtr pXDev)56*4882a593Smuzhiyun XkbDDXUsesSoftRepeat(DeviceIntPtr pXDev)
57*4882a593Smuzhiyun {
58*4882a593Smuzhiyun     return 1;
59*4882a593Smuzhiyun }
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun void
XkbDDXChangeControls(DeviceIntPtr dev,XkbControlsPtr old,XkbControlsPtr new)62*4882a593Smuzhiyun XkbDDXChangeControls(DeviceIntPtr dev, XkbControlsPtr old, XkbControlsPtr new)
63*4882a593Smuzhiyun {
64*4882a593Smuzhiyun     unsigned changed, i;
65*4882a593Smuzhiyun     unsigned char *rep_old, *rep_new, *rep_fb;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun     changed = new->enabled_ctrls ^ old->enabled_ctrls;
68*4882a593Smuzhiyun     for (rep_old = old->per_key_repeat,
69*4882a593Smuzhiyun          rep_new = new->per_key_repeat,
70*4882a593Smuzhiyun          rep_fb = dev->kbdfeed->ctrl.autoRepeats,
71*4882a593Smuzhiyun          i = 0; i < XkbPerKeyBitArraySize; i++) {
72*4882a593Smuzhiyun         if (rep_old[i] != rep_new[i]) {
73*4882a593Smuzhiyun             rep_fb[i] = rep_new[i];
74*4882a593Smuzhiyun             changed &= XkbPerKeyRepeatMask;
75*4882a593Smuzhiyun         }
76*4882a593Smuzhiyun     }
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun     if (changed & XkbPerKeyRepeatMask) {
79*4882a593Smuzhiyun         if (dev->kbdfeed->CtrlProc)
80*4882a593Smuzhiyun             (*dev->kbdfeed->CtrlProc) (dev, &dev->kbdfeed->ctrl);
81*4882a593Smuzhiyun     }
82*4882a593Smuzhiyun     return;
83*4882a593Smuzhiyun }
84