xkb: ProcXkbBell should work on all attached SDs.
If called with XkbUseCoreKbd, run through all attached SDs and replicate the call. This way, we keep the SDs in sync with the MD as long as core clients control the MDs.
This commit is contained in:
		
							parent
							
								
									de4936d748
								
							
						
					
					
						commit
						31afd51dd4
					
				
							
								
								
									
										229
									
								
								xkb/xkb.c
								
								
								
								
							
							
						
						
									
										229
									
								
								xkb/xkb.c
								
								
								
								
							| 
						 | 
					@ -348,17 +348,119 @@ ProcXkbSelectEvents(ClientPtr client)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***====================================================================***/
 | 
					/***====================================================================***/
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Ring a bell on the given device for the given client.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int
 | 
				
			||||||
 | 
					_XkbBell(ClientPtr client, DeviceIntPtr dev, WindowPtr pWin,
 | 
				
			||||||
 | 
					         int bellClass, int bellID, int pitch, int duration,
 | 
				
			||||||
 | 
					         int percent, int forceSound, int eventOnly, Atom name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int         base;
 | 
				
			||||||
 | 
					    pointer     ctrl;
 | 
				
			||||||
 | 
					    int         oldPitch, oldDuration;
 | 
				
			||||||
 | 
					    int         newPercent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (bellClass == KbdFeedbackClass) {
 | 
				
			||||||
 | 
					        KbdFeedbackPtr	k;
 | 
				
			||||||
 | 
					        if (bellID==XkbDfltXIId)
 | 
				
			||||||
 | 
					            k= dev->kbdfeed;
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            for (k=dev->kbdfeed; k; k=k->next) {
 | 
				
			||||||
 | 
					                if (k->ctrl.id == bellID)
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!k) {
 | 
				
			||||||
 | 
					            client->errorValue = _XkbErrCode2(0x5,bellID);
 | 
				
			||||||
 | 
					            return BadValue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        base = k->ctrl.bell;
 | 
				
			||||||
 | 
					        ctrl = (pointer) &(k->ctrl);
 | 
				
			||||||
 | 
					        oldPitch= k->ctrl.bell_pitch;
 | 
				
			||||||
 | 
					        oldDuration= k->ctrl.bell_duration;
 | 
				
			||||||
 | 
					        if (pitch!=0) {
 | 
				
			||||||
 | 
					            if (pitch==-1)
 | 
				
			||||||
 | 
					                k->ctrl.bell_pitch= defaultKeyboardControl.bell_pitch;
 | 
				
			||||||
 | 
					            else k->ctrl.bell_pitch= pitch;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (duration!=0) {
 | 
				
			||||||
 | 
					            if (duration==-1)
 | 
				
			||||||
 | 
					                k->ctrl.bell_duration= defaultKeyboardControl.bell_duration;
 | 
				
			||||||
 | 
					            else k->ctrl.bell_duration= duration;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (bellClass == BellFeedbackClass) {
 | 
				
			||||||
 | 
					        BellFeedbackPtr	b;
 | 
				
			||||||
 | 
					        if (bellID==XkbDfltXIId)
 | 
				
			||||||
 | 
					            b= dev->bell;
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            for (b=dev->bell; b; b=b->next) {
 | 
				
			||||||
 | 
					                if (b->ctrl.id == bellID)
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!b) {
 | 
				
			||||||
 | 
					            client->errorValue = _XkbErrCode2(0x6,bellID);
 | 
				
			||||||
 | 
					            return BadValue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        base = b->ctrl.percent;
 | 
				
			||||||
 | 
					        ctrl = (pointer) &(b->ctrl);
 | 
				
			||||||
 | 
					        oldPitch= b->ctrl.pitch;
 | 
				
			||||||
 | 
					        oldDuration= b->ctrl.duration;
 | 
				
			||||||
 | 
					        if (pitch!=0) {
 | 
				
			||||||
 | 
					            if (pitch==-1)
 | 
				
			||||||
 | 
					                b->ctrl.pitch= defaultKeyboardControl.bell_pitch;
 | 
				
			||||||
 | 
					            else b->ctrl.pitch= pitch;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (duration!=0) {
 | 
				
			||||||
 | 
					            if (duration==-1)
 | 
				
			||||||
 | 
					                b->ctrl.duration= defaultKeyboardControl.bell_duration;
 | 
				
			||||||
 | 
					            else b->ctrl.duration= duration;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        client->errorValue = _XkbErrCode2(0x7, bellClass);;
 | 
				
			||||||
 | 
					        return BadValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    newPercent = (base * percent)/100;
 | 
				
			||||||
 | 
					    if (percent < 0)
 | 
				
			||||||
 | 
					         newPercent = base + newPercent;
 | 
				
			||||||
 | 
					    else newPercent = base - newPercent + percent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    XkbHandleBell(forceSound, eventOnly,
 | 
				
			||||||
 | 
					                  dev, newPercent, ctrl, bellClass,
 | 
				
			||||||
 | 
					                  name, pWin, client);
 | 
				
			||||||
 | 
					    if ((pitch!=0)||(duration!=0)) {
 | 
				
			||||||
 | 
					        if (bellClass == KbdFeedbackClass) {
 | 
				
			||||||
 | 
					            KbdFeedbackPtr      k;
 | 
				
			||||||
 | 
					            k= (KbdFeedbackPtr)ctrl;
 | 
				
			||||||
 | 
					            if (pitch!=0)
 | 
				
			||||||
 | 
					                k->ctrl.bell_pitch= oldPitch;
 | 
				
			||||||
 | 
					            if (duration!=0)
 | 
				
			||||||
 | 
					                k->ctrl.bell_duration= oldDuration;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            BellFeedbackPtr     b;
 | 
				
			||||||
 | 
					            b= (BellFeedbackPtr)ctrl;
 | 
				
			||||||
 | 
					            if (pitch!=0)
 | 
				
			||||||
 | 
					                b->ctrl.pitch= oldPitch;
 | 
				
			||||||
 | 
					            if (duration!=0)
 | 
				
			||||||
 | 
					                b->ctrl.duration= oldDuration;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return Success;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* FIXME: Needs to ding on all core-sending devices. */
 | 
					 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
ProcXkbBell(ClientPtr client)
 | 
					ProcXkbBell(ClientPtr client)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    REQUEST(xkbBellReq);
 | 
					    REQUEST(xkbBellReq);
 | 
				
			||||||
    DeviceIntPtr dev;
 | 
					    DeviceIntPtr dev;
 | 
				
			||||||
    WindowPtr	 pWin;
 | 
					    WindowPtr	 pWin;
 | 
				
			||||||
    int rc, base;
 | 
					    int rc;
 | 
				
			||||||
    int newPercent,oldPitch,oldDuration;
 | 
					 | 
				
			||||||
    pointer ctrl;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    REQUEST_SIZE_MATCH(xkbBellReq);
 | 
					    REQUEST_SIZE_MATCH(xkbBellReq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -368,6 +470,7 @@ ProcXkbBell(ClientPtr client)
 | 
				
			||||||
    CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess);
 | 
					    CHK_BELL_DEVICE(dev, stuff->deviceSpec, client, DixBellAccess);
 | 
				
			||||||
    CHK_ATOM_OR_NONE(stuff->name);
 | 
					    CHK_ATOM_OR_NONE(stuff->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* device-independent checks request for sane values */
 | 
				
			||||||
    if ((stuff->forceSound)&&(stuff->eventOnly)) {
 | 
					    if ((stuff->forceSound)&&(stuff->eventOnly)) {
 | 
				
			||||||
	client->errorValue=_XkbErrCode3(0x1,stuff->forceSound,stuff->eventOnly);
 | 
						client->errorValue=_XkbErrCode3(0x1,stuff->forceSound,stuff->eventOnly);
 | 
				
			||||||
	return BadMatch;
 | 
						return BadMatch;
 | 
				
			||||||
| 
						 | 
					@ -390,68 +493,7 @@ ProcXkbBell(ClientPtr client)
 | 
				
			||||||
	     stuff->bellClass= KbdFeedbackClass;
 | 
						     stuff->bellClass= KbdFeedbackClass;
 | 
				
			||||||
	else stuff->bellClass= BellFeedbackClass;
 | 
						else stuff->bellClass= BellFeedbackClass;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (stuff->bellClass == KbdFeedbackClass) {
 | 
					
 | 
				
			||||||
	KbdFeedbackPtr	k;
 | 
					 | 
				
			||||||
	if (stuff->bellID==XkbDfltXIId) 
 | 
					 | 
				
			||||||
	    k= dev->kbdfeed;
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
	    for (k=dev->kbdfeed; k; k=k->next) {
 | 
					 | 
				
			||||||
		if (k->ctrl.id == stuff->bellID)
 | 
					 | 
				
			||||||
		    break;
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!k) {
 | 
					 | 
				
			||||||
	    client->errorValue= _XkbErrCode2(0x5,stuff->bellID);
 | 
					 | 
				
			||||||
	    return BadValue;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	base = k->ctrl.bell;
 | 
					 | 
				
			||||||
	ctrl = (pointer) &(k->ctrl);
 | 
					 | 
				
			||||||
	oldPitch= k->ctrl.bell_pitch;
 | 
					 | 
				
			||||||
	oldDuration= k->ctrl.bell_duration;
 | 
					 | 
				
			||||||
	if (stuff->pitch!=0) {
 | 
					 | 
				
			||||||
	    if (stuff->pitch==-1)
 | 
					 | 
				
			||||||
		 k->ctrl.bell_pitch= defaultKeyboardControl.bell_pitch;
 | 
					 | 
				
			||||||
	    else k->ctrl.bell_pitch= stuff->pitch;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (stuff->duration!=0) {
 | 
					 | 
				
			||||||
	    if (stuff->duration==-1)
 | 
					 | 
				
			||||||
		 k->ctrl.bell_duration= defaultKeyboardControl.bell_duration;
 | 
					 | 
				
			||||||
	    else k->ctrl.bell_duration= stuff->duration;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else if (stuff->bellClass == BellFeedbackClass) {
 | 
					 | 
				
			||||||
	BellFeedbackPtr	b;
 | 
					 | 
				
			||||||
	if (stuff->bellID==XkbDfltXIId)
 | 
					 | 
				
			||||||
	    b= dev->bell;
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
	    for (b=dev->bell; b; b=b->next) {
 | 
					 | 
				
			||||||
		if (b->ctrl.id == stuff->bellID)
 | 
					 | 
				
			||||||
		    break;
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!b) {
 | 
					 | 
				
			||||||
	    client->errorValue = _XkbErrCode2(0x6,stuff->bellID);
 | 
					 | 
				
			||||||
	    return BadValue;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	base = b->ctrl.percent;
 | 
					 | 
				
			||||||
	ctrl = (pointer) &(b->ctrl);
 | 
					 | 
				
			||||||
	oldPitch= b->ctrl.pitch;
 | 
					 | 
				
			||||||
	oldDuration= b->ctrl.duration;
 | 
					 | 
				
			||||||
	if (stuff->pitch!=0) {
 | 
					 | 
				
			||||||
	    if (stuff->pitch==-1)
 | 
					 | 
				
			||||||
		 b->ctrl.pitch= defaultKeyboardControl.bell_pitch;
 | 
					 | 
				
			||||||
	    else b->ctrl.pitch= stuff->pitch;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (stuff->duration!=0) {
 | 
					 | 
				
			||||||
	    if (stuff->duration==-1)
 | 
					 | 
				
			||||||
		 b->ctrl.duration= defaultKeyboardControl.bell_duration;
 | 
					 | 
				
			||||||
	    else b->ctrl.duration= stuff->duration;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    else {
 | 
					 | 
				
			||||||
	client->errorValue = _XkbErrCode2(0x7,stuff->bellClass);;
 | 
					 | 
				
			||||||
	return BadValue;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (stuff->window!=None) {
 | 
					    if (stuff->window!=None) {
 | 
				
			||||||
	rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
 | 
						rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
 | 
				
			||||||
	if (rc != Success) {
 | 
						if (rc != Success) {
 | 
				
			||||||
| 
						 | 
					@ -461,32 +503,39 @@ ProcXkbBell(ClientPtr client)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else pWin= NULL;
 | 
					    else pWin= NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    newPercent= (base*stuff->percent)/100;
 | 
					    /* Client wants to ring a bell on the core keyboard?
 | 
				
			||||||
    if (stuff->percent < 0)
 | 
					       Ring the bell on the core keyboard (which does nothing, but if that
 | 
				
			||||||
         newPercent= base+newPercent;
 | 
					       fails the client is screwed anyway), and then on all extension devices.
 | 
				
			||||||
    else newPercent= base-newPercent+stuff->percent;
 | 
					       Fail if the core keyboard fails but not the extension devices.  this
 | 
				
			||||||
    XkbHandleBell(stuff->forceSound, stuff->eventOnly,
 | 
					       may cause some keyboards to ding and others to stay silent. Fix
 | 
				
			||||||
				dev, newPercent, ctrl, stuff->bellClass, 
 | 
					       your client to use explicit keyboards to avoid this.
 | 
				
			||||||
				stuff->name, pWin, client);
 | 
					
 | 
				
			||||||
    if ((stuff->pitch!=0)||(stuff->duration!=0)) {
 | 
					       dev is the device the client requested.
 | 
				
			||||||
	if (stuff->bellClass == KbdFeedbackClass) {
 | 
					     */
 | 
				
			||||||
	    KbdFeedbackPtr	k;
 | 
					    rc = _XkbBell(client, dev, pWin, stuff->bellClass, stuff->bellID,
 | 
				
			||||||
	    k= (KbdFeedbackPtr)ctrl;
 | 
					                  stuff->pitch, stuff->duration, stuff->percent,
 | 
				
			||||||
	    if (stuff->pitch!=0)
 | 
					                  stuff->forceSound, stuff->eventOnly, stuff->name);
 | 
				
			||||||
		k->ctrl.bell_pitch= oldPitch;
 | 
					
 | 
				
			||||||
	    if (stuff->duration!=0)
 | 
					    if ((rc == Success) && ((stuff->deviceSpec == XkbUseCoreKbd) ||
 | 
				
			||||||
		k->ctrl.bell_duration= oldDuration;
 | 
					                            (stuff->deviceSpec == XkbUseCorePtr)))
 | 
				
			||||||
	}
 | 
					    {
 | 
				
			||||||
	else {
 | 
					        DeviceIntPtr other;
 | 
				
			||||||
	    BellFeedbackPtr	b;
 | 
					        for (other = inputInfo.devices; other; other = other->next)
 | 
				
			||||||
	    b= (BellFeedbackPtr)ctrl;
 | 
					        {
 | 
				
			||||||
	    if (stuff->pitch!=0)
 | 
					            if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
 | 
				
			||||||
		b->ctrl.pitch= oldPitch;
 | 
					            {
 | 
				
			||||||
	    if (stuff->duration!=0)
 | 
					                rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixBellAccess);
 | 
				
			||||||
		b->ctrl.duration= oldDuration;
 | 
					                if (rc == Success)
 | 
				
			||||||
 | 
					                    _XkbBell(client, other, pWin, stuff->bellClass,
 | 
				
			||||||
 | 
					                             stuff->bellID, stuff->pitch, stuff->duration,
 | 
				
			||||||
 | 
					                             stuff->percent, stuff->forceSound,
 | 
				
			||||||
 | 
					                             stuff->eventOnly, stuff->name);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    return Success;
 | 
					        rc = Success; /* reset to success, that's what we got for the VCK */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/***====================================================================***/
 | 
					/***====================================================================***/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue