summaryrefslogtreecommitdiff
path: root/xkb/xkbLEDs.c
diff options
context:
space:
mode:
authorAdam Jackson <ajax@benzedrine.nwnk.net>2007-03-18 16:31:19 -0400
committerAdam Jackson <ajax@benzedrine.nwnk.net>2007-03-20 18:37:02 -0400
commit021fc5cb2cb4a7972b4a6fcb570c1da92787d68d (patch)
tree58063be57aef43d15f51822264d4a7a789ee7c77 /xkb/xkbLEDs.c
parent9398d62f27ee1b287e4458fd8b011c10f7b59efd (diff)
Static markup and dead code cull over xkb/.
The former <X11/extensions/XKBsrv.h> has been pulled into the server now as include/xkbsrv.h, and the world updated to look for it in the new place, since it made no sense to define server API in an extension header. Any further work along this line will need to do similar things with XKBgeom.h and friends.
Diffstat (limited to 'xkb/xkbLEDs.c')
-rw-r--r--xkb/xkbLEDs.c453
1 files changed, 161 insertions, 292 deletions
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index e94e0bff4..d607d9066 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -38,7 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "inputstr.h"
#include <X11/extensions/XI.h>
-#include <X11/extensions/XKBsrv.h>
+#include <xkbsrv.h>
#include "xkb.h"
/***====================================================================***/
@@ -82,7 +82,7 @@ XkbSrvLedInfoPtr sli;
/*
* Bool
- * XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
+ *XkbApplyLEDChangeToKeyboard(xkbi,map,on,change)
*
* Some indicators "drive" the keyboard when their state is explicitly
* changed, as described in section 9.2.1 of the XKB protocol spec.
@@ -91,7 +91,7 @@ XkbSrvLedInfoPtr sli;
* when the indicator described by 'map' is turned on or off. The
* extent of the changes is reported in change, which must be defined.
*/
-Bool
+static Bool
XkbApplyLEDChangeToKeyboard( XkbSrvInfoPtr xkbi,
XkbIndicatorMapPtr map,
Bool on,
@@ -166,6 +166,164 @@ XkbStatePtr state;
}
return (stateChange || ctrlChange);
}
+
+ /*
+ * Bool
+ * ComputeAutoState(map,state,ctrls)
+ *
+ * This function reports the effect of applying the specified
+ * indicator map given the specified state and controls, as
+ * described in section 9.2 of the XKB protocol specification.
+ */
+
+static Bool
+ComputeAutoState( XkbIndicatorMapPtr map,
+ XkbStatePtr state,
+ XkbControlsPtr ctrls)
+{
+Bool on;
+CARD8 mods,group;
+
+ on= False;
+ mods= group= 0;
+ if (map->which_mods&XkbIM_UseAnyMods) {
+ if (map->which_mods&XkbIM_UseBase)
+ mods|= state->base_mods;
+ if (map->which_mods&XkbIM_UseLatched)
+ mods|= state->latched_mods;
+ if (map->which_mods&XkbIM_UseLocked)
+ mods|= state->locked_mods;
+ if (map->which_mods&XkbIM_UseEffective)
+ mods|= state->mods;
+ if (map->which_mods&XkbIM_UseCompat)
+ mods|= state->compat_state;
+ on = ((map->mods.mask&mods)!=0);
+ on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
+ }
+ if (map->which_groups&XkbIM_UseAnyGroup) {
+ if (map->which_groups&XkbIM_UseBase)
+ group|= (1L << state->base_group);
+ if (map->which_groups&XkbIM_UseLatched)
+ group|= (1L << state->latched_group);
+ if (map->which_groups&XkbIM_UseLocked)
+ group|= (1L << state->locked_group);
+ if (map->which_groups&XkbIM_UseEffective)
+ group|= (1L << state->group);
+ on = on||(((map->groups&group)!=0)||(map->groups==0));
+ }
+ if (map->ctrls)
+ on = on||(ctrls->enabled_ctrls&map->ctrls);
+ return on;
+}
+
+
+static void
+XkbUpdateLedAutoState( DeviceIntPtr dev,
+ XkbSrvLedInfoPtr sli,
+ unsigned maps_to_check,
+ xkbExtensionDeviceNotify * ed,
+ XkbChangesPtr changes,
+ XkbEventCausePtr cause)
+{
+DeviceIntPtr kbd;
+XkbStatePtr state;
+XkbControlsPtr ctrls;
+XkbChangesRec my_changes;
+xkbExtensionDeviceNotify my_ed;
+register unsigned i,bit,affected;
+register XkbIndicatorMapPtr map;
+unsigned oldState;
+
+ if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
+ return;
+
+ if (dev->key && dev->key->xkbInfo)
+ kbd= dev;
+ else kbd= (DeviceIntPtr)LookupKeyboardDevice();
+
+ state= &kbd->key->xkbInfo->state;
+ ctrls= kbd->key->xkbInfo->desc->ctrls;
+ affected= maps_to_check;
+ oldState= sli->effectiveState;
+ sli->autoState&= ~affected;
+ for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
+ if ((affected&bit)==0)
+ continue;
+ affected&= ~bit;
+ map= &sli->maps[i];
+ if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
+ sli->autoState|= bit;
+ }
+ sli->effectiveState= (sli->autoState|sli->explicitState);
+ affected= sli->effectiveState^oldState;
+ if (affected==0)
+ return;
+
+ if (ed==NULL) {
+ ed= &my_ed;
+ bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ }
+ else if ((ed->reason&XkbXI_IndicatorsMask)&&
+ ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ }
+
+ if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
+ if (changes==NULL) {
+ changes= &my_changes;
+ bzero((char *)changes,sizeof(XkbChangesRec));
+ }
+ changes->indicators.state_changes|= affected;
+ }
+
+ ed->reason|= XkbXI_IndicatorStateMask;
+ ed->ledClass= sli->class;
+ ed->ledID= sli->id;
+ ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
+ ed->ledState= sli->effectiveState;
+ ed->unsupported|= XkbXI_IndicatorStateMask;
+ ed->supported= XkbXI_AllFeaturesMask;
+
+ if (changes!=&my_changes) changes= NULL;
+ if (ed!=&my_ed) ed= NULL;
+ if (changes || ed)
+ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
+ return;
+}
+
+static void
+XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
+{
+DeviceIntPtr edev;
+XkbSrvLedInfoPtr sli;
+
+ for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
+ if (edev->kbdfeed) {
+ KbdFeedbackPtr kf;
+ for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
+ if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
+ continue;
+ sli= kf->xkb_sli;
+ XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+ changes,cause);
+
+ }
+ }
+ if (edev->leds) {
+ LedFeedbackPtr lf;
+ for (lf=edev->leds;lf!=NULL;lf=lf->next) {
+ if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
+ continue;
+ sli= lf->xkb_sli;
+ XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
+ changes,cause);
+
+ }
+ }
+ }
+ return;
+}
+
/***====================================================================***/
@@ -228,55 +386,6 @@ unsigned side_affected;
/***====================================================================***/
- /*
- * Bool
- * ComputeAutoState(map,state,ctrls)
- *
- * This function reports the effect of applying the specified
- * indicator map given the specified state and controls, as
- * described in section 9.2 of the XKB protocol specification.
- */
-
-static Bool
-ComputeAutoState( XkbIndicatorMapPtr map,
- XkbStatePtr state,
- XkbControlsPtr ctrls)
-{
-Bool on;
-CARD8 mods,group;
-
- on= False;
- mods= group= 0;
- if (map->which_mods&XkbIM_UseAnyMods) {
- if (map->which_mods&XkbIM_UseBase)
- mods|= state->base_mods;
- if (map->which_mods&XkbIM_UseLatched)
- mods|= state->latched_mods;
- if (map->which_mods&XkbIM_UseLocked)
- mods|= state->locked_mods;
- if (map->which_mods&XkbIM_UseEffective)
- mods|= state->mods;
- if (map->which_mods&XkbIM_UseCompat)
- mods|= state->compat_state;
- on = ((map->mods.mask&mods)!=0);
- on = on||((mods==0)&&(map->mods.mask==0)&&(map->mods.vmods==0));
- }
- if (map->which_groups&XkbIM_UseAnyGroup) {
- if (map->which_groups&XkbIM_UseBase)
- group|= (1L << state->base_group);
- if (map->which_groups&XkbIM_UseLatched)
- group|= (1L << state->latched_group);
- if (map->which_groups&XkbIM_UseLocked)
- group|= (1L << state->locked_group);
- if (map->which_groups&XkbIM_UseEffective)
- group|= (1L << state->group);
- on = on||(((map->groups&group)!=0)||(map->groups==0));
- }
- if (map->ctrls)
- on = on||(ctrls->enabled_ctrls&map->ctrls);
- return on;
-}
-
/***====================================================================***/
/*
@@ -314,39 +423,6 @@ XkbSrvLedInfoPtr sli;
/***====================================================================***/
-void
-XkbUpdateAllDeviceIndicators(XkbChangesPtr changes,XkbEventCausePtr cause)
-{
-DeviceIntPtr edev;
-XkbSrvLedInfoPtr sli;
-
- for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
- if (edev->kbdfeed) {
- KbdFeedbackPtr kf;
- for (kf=edev->kbdfeed;kf!=NULL;kf=kf->next) {
- if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
- continue;
- sli= kf->xkb_sli;
- XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
- changes,cause);
-
- }
- }
- if (edev->leds) {
- LedFeedbackPtr lf;
- for (lf=edev->leds;lf!=NULL;lf=lf->next) {
- if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
- continue;
- sli= lf->xkb_sli;
- XkbUpdateLedAutoState(edev,sli,sli->mapsPresent,NULL,
- changes,cause);
-
- }
- }
- }
- return;
-}
-
/***====================================================================***/
/*
@@ -856,210 +932,3 @@ Bool kb_changed;
XkbUpdateAllDeviceIndicators(NULL,cause);
return;
}
-
-/***====================================================================***/
-
-void
-XkbUpdateLedAutoState( DeviceIntPtr dev,
- XkbSrvLedInfoPtr sli,
- unsigned maps_to_check,
- xkbExtensionDeviceNotify * ed,
- XkbChangesPtr changes,
- XkbEventCausePtr cause)
-{
-DeviceIntPtr kbd;
-XkbStatePtr state;
-XkbControlsPtr ctrls;
-XkbChangesRec my_changes;
-xkbExtensionDeviceNotify my_ed;
-register unsigned i,bit,affected;
-register XkbIndicatorMapPtr map;
-unsigned oldState;
-
- if ((maps_to_check==0)||(sli->maps==NULL)||(sli->mapsPresent==0))
- return;
-
- if (dev->key && dev->key->xkbInfo)
- kbd= dev;
- else kbd= (DeviceIntPtr)LookupKeyboardDevice();
-
- state= &kbd->key->xkbInfo->state;
- ctrls= kbd->key->xkbInfo->desc->ctrls;
- affected= maps_to_check;
- oldState= sli->effectiveState;
- sli->autoState&= ~affected;
- for (i=0,bit=1;(i<XkbNumIndicators)&&(affected);i++,bit<<=1) {
- if ((affected&bit)==0)
- continue;
- affected&= ~bit;
- map= &sli->maps[i];
- if((!(map->flags&XkbIM_NoAutomatic))&&ComputeAutoState(map,state,ctrls))
- sli->autoState|= bit;
- }
- sli->effectiveState= (sli->autoState|sli->explicitState);
- affected= sli->effectiveState^oldState;
- if (affected==0)
- return;
-
- if (ed==NULL) {
- ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
- }
- else if ((ed->reason&XkbXI_IndicatorsMask)&&
- ((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
- XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
- }
-
- if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
- if (changes==NULL) {
- changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
- }
- changes->indicators.state_changes|= affected;
- }
-
- ed->reason|= XkbXI_IndicatorStateMask;
- ed->ledClass= sli->class;
- ed->ledID= sli->id;
- ed->ledsDefined= sli->namesPresent|sli->mapsPresent;
- ed->ledState= sli->effectiveState;
- ed->unsupported|= XkbXI_IndicatorStateMask;
- ed->supported= XkbXI_AllFeaturesMask;
-
- if (changes!=&my_changes) changes= NULL;
- if (ed!=&my_ed) ed= NULL;
- if (changes || ed)
- XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause);
- return;
-}
-
-/***====================================================================***/
-
-static void
-_UpdateButtonVMods( XkbDescPtr xkb,
- unsigned num_btns,
- XkbAction * acts,
- unsigned changed,
- xkbExtensionDeviceNotify * ed_inout)
-{
-register int i;
-
- for (i=0;i<num_btns;i++,acts++) {
- if ((acts->any.type!=XkbSA_NoAction)&&
- XkbUpdateActionVirtualMods(xkb,acts,changed)) {
- if ((ed_inout->reason&XkbXI_ButtonActionsMask)==0) {
- ed_inout->reason|= XkbXI_ButtonActionsMask;
- ed_inout->firstBtn= i;
- ed_inout->nBtns= 1;
- }
- else {
- ed_inout->nBtns= (i-ed_inout->firstBtn)+1;
- }
- }
- }
- return;
-}
-
-static void
-_UpdateMapVMods( XkbDescPtr xkb,
- register XkbIndicatorMapPtr map,
- unsigned changed_vmods,
- unsigned * changed_maps_rtrn)
-{
-register int i;
-
- *changed_maps_rtrn= 0;
- for (i=0;i<XkbNumIndicators;i++,map++) {
- if (map->mods.vmods&changed_vmods) {
- map->mods.mask= map->mods.real_mods;
- map->mods.mask|= XkbMaskForVMask(xkb,map->mods.vmods);
- *changed_maps_rtrn|= (1L<<i);
- }
- }
- return;
-}
-
-static void
-_UpdateDeviceVMods( DeviceIntPtr dev,
- XkbDescPtr xkb,
- unsigned changed,
- XkbEventCausePtr cause)
-{
-xkbExtensionDeviceNotify ed;
-XkbSrvLedInfoPtr sli;
-unsigned changed_maps;
-
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
- ed.deviceID= dev->id;
- if ((dev->button)&&(dev->button->xkb_acts)) {
- _UpdateButtonVMods(xkb,dev->button->numButtons,
- dev->button->xkb_acts,changed,&ed);
- }
- if (dev->kbdfeed) {
- KbdFeedbackPtr kf;
- for (kf=dev->kbdfeed;kf!=NULL;kf=kf->next) {
- if ((kf->xkb_sli==NULL)||(kf->xkb_sli->maps==NULL))
- continue;
- sli= kf->xkb_sli;
- _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
- if (changed_maps) {
- if (ed.reason&XkbXI_IndicatorsMask) {
- XkbSendExtensionDeviceNotify(dev,NULL,&ed);
- ed.reason= 0;
- ed.firstBtn= ed.nBtns;
- }
- ed.ledClass= sli->class;
- ed.ledID= sli->id;
- ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
- ed.reason|= XkbXI_IndicatorMapsMask;
- XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
- }
- }
- }
- if (dev->leds) {
- LedFeedbackPtr lf;
- for (lf=dev->leds;lf!=NULL;lf=lf->next) {
- if ((lf->xkb_sli==NULL)||(lf->xkb_sli->maps==NULL))
- continue;
- sli= lf->xkb_sli;
- _UpdateMapVMods(xkb,sli->maps,changed,&changed_maps);
- if (changed_maps) {
- if (ed.reason&XkbXI_IndicatorsMask) {
- XkbSendExtensionDeviceNotify(dev,NULL,&ed);
- ed.reason= 0;
- ed.firstBtn= ed.nBtns;
- }
- ed.ledClass= sli->class;
- ed.ledID= sli->id;
- ed.ledsDefined= sli->namesPresent|sli->mapsPresent;
- ed.reason|= XkbXI_IndicatorMapsMask;
- XkbUpdateLedAutoState(dev,sli,changed_maps,&ed,NULL,cause);
- }
- }
- }
- if (ed.reason!=0)
- XkbSendExtensionDeviceNotify(dev,NULL,&ed);
- return;
-}
-
-void
-XkbApplyVModChangesToAllDevices( DeviceIntPtr dev,
- XkbDescPtr xkb,
- unsigned changed,
- XkbEventCausePtr cause)
-{
-DeviceIntPtr edev;
- if (dev!=(DeviceIntPtr)LookupKeyboardDevice())
- return;
- for (edev=inputInfo.devices;edev!=NULL;edev=edev->next) {
- if (edev->key)
- continue;
- _UpdateDeviceVMods(edev,xkb,changed,cause);
- }
- for (edev=inputInfo.off_devices;edev!=NULL;edev=edev->next) {
- if (edev->key)
- continue;
- _UpdateDeviceVMods(edev,xkb,changed,cause);
- }
- return;
-}