103
RegisterOtherDevice (device)
99
RegisterOtherDevice(DeviceIntPtr device)
106
101
device->public.processInputProc = ProcessOtherEvent;
107
102
device->public.realInputProc = ProcessOtherEvent;
108
103
(device)->ActivateGrab = ActivateKeyboardGrab;
109
104
(device)->DeactivateGrab = DeactivateKeyboardGrab;
114
ProcessOtherEvent (xE, other, count)
116
register DeviceIntPtr other;
121
register CARD16 modifiers;
122
register CARD16 mask;
123
GrabPtr grab = other->grab;
124
Bool deactivateDeviceGrab = FALSE;
125
int key = 0, bit = 0, rootX, rootY;
126
ButtonClassPtr b = other->button;
127
KeyClassPtr k = other->key;
128
ValuatorClassPtr v = other->valuator;
129
deviceValuator *xV = (deviceValuator *) xE;
108
ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
112
register CARD16 modifiers;
113
register CARD16 mask;
114
GrabPtr grab = other->grab;
115
Bool deactivateDeviceGrab = FALSE;
116
int key = 0, bit = 0, rootX, rootY;
117
ButtonClassPtr b = other->button;
118
KeyClassPtr k = other->key;
119
ValuatorClassPtr v = other->valuator;
120
deviceValuator *xV = (deviceValuator *) xE;
131
122
if (xE->u.u.type != DeviceValuator) {
132
GetSpritePosition(&rootX, &rootY);
133
xE->u.keyButtonPointer.rootX = rootX;
134
xE->u.keyButtonPointer.rootY = rootY;
135
key = xE->u.u.detail;
137
xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state |
138
inputInfo.pointer->button->state;
139
bit = 1 << (key & 7);
123
GetSpritePosition(&rootX, &rootY);
124
xE->u.keyButtonPointer.rootX = rootX;
125
xE->u.keyButtonPointer.rootY = rootY;
126
key = xE->u.u.detail;
128
xE->u.keyButtonPointer.state = inputInfo.keyboard->key->state |
129
inputInfo.pointer->button->state;
130
bit = 1 << (key & 7);
141
if (DeviceEventCallback)
132
if (DeviceEventCallback) {
143
133
DeviceEventInfoRec eventinfo;
144
135
eventinfo.events = (xEventPtr) xE;
145
136
eventinfo.count = count;
146
CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
137
CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
148
for (i=1; i<count; i++)
149
if ((++xV)->type == DeviceValuator)
139
for (i = 1; i < count; i++)
140
if ((++xV)->type == DeviceValuator) {
151
141
int first = xV->first_valuator;
154
if (xV->num_valuators && (!v || (xV->num_valuators && (first + xV->num_valuators > v->numAxes))))
155
FatalError("Bad valuators reported for device %s\n",other->name);
144
if (xV->num_valuators
146
|| (xV->num_valuators
147
&& (first + xV->num_valuators > v->numAxes))))
148
FatalError("Bad valuators reported for device %s\n",
156
150
xV->device_state = 0;
158
152
xV->device_state |= k->state;
160
xV->device_state |= b->state;
163
axisvals = v->axisVal;
164
switch (xV->num_valuators) {
166
*(axisvals+first+5) = xV->valuator5;
168
*(axisvals+first+4) = xV->valuator4;
170
*(axisvals+first+3) = xV->valuator3;
172
*(axisvals+first+2) = xV->valuator2;
174
*(axisvals+first+1) = xV->valuator1;
176
*(axisvals+first) = xV->valuator0;
154
xV->device_state |= b->state;
155
if (v && v->axisVal) {
156
axisvals = v->axisVal;
157
switch (xV->num_valuators) {
159
*(axisvals + first + 5) = xV->valuator5;
161
*(axisvals + first + 4) = xV->valuator4;
163
*(axisvals + first + 3) = xV->valuator3;
165
*(axisvals + first + 2) = xV->valuator2;
167
*(axisvals + first + 1) = xV->valuator1;
169
*(axisvals + first) = xV->valuator0;
184
if (xE->u.u.type == DeviceKeyPress)
177
if (xE->u.u.type == DeviceKeyPress) {
186
178
modifiers = k->modifierMap[key];
187
kptr = &k->down[key >> 3];
188
if (*kptr & bit) /* allow ddx to generate multiple downs */
179
kptr = &k->down[key >> 3];
180
if (*kptr & bit) { /* allow ddx to generate multiple downs */
192
182
xE->u.u.type = DeviceKeyRelease;
193
183
ProcessOtherEvent(xE, other, count);
194
184
xE->u.u.type = DeviceKeyPress;
195
185
/* release can have side effects, don't fall through */
196
186
ProcessOtherEvent(xE, other, count);
200
190
if (other->valuator)
201
191
other->valuator->motionHintWindow = NullWindow;
203
193
k->prev_state = k->state;
204
for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
206
if (mask & modifiers)
194
for (i = 0, mask = 1; modifiers; i++, mask <<= 1) {
195
if (mask & modifiers) {
208
196
/* This key affects modifier "i" */
209
197
k->modifierKeyCount[i]++;
210
198
k->state |= mask;
211
199
modifiers &= ~mask;
214
if (!grab && CheckDeviceGrabs(other, xE, 0, count))
202
if (!grab && CheckDeviceGrabs(other, xE, 0, count)) {
216
203
other->activatingKey = key;
220
else if (xE->u.u.type == DeviceKeyRelease)
222
kptr = &k->down[key >> 3];
223
if (!(*kptr & bit)) /* guard against duplicates */
206
} else if (xE->u.u.type == DeviceKeyRelease) {
207
kptr = &k->down[key >> 3];
208
if (!(*kptr & bit)) /* guard against duplicates */
225
210
modifiers = k->modifierMap[key];
226
211
if (other->valuator)
227
212
other->valuator->motionHintWindow = NullWindow;
229
214
k->prev_state = k->state;
230
for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
232
if (mask & modifiers)
215
for (i = 0, mask = 1; modifiers; i++, mask <<= 1) {
216
if (mask & modifiers) {
234
217
/* This key affects modifier "i" */
235
if (--k->modifierKeyCount[i] <= 0)
218
if (--k->modifierKeyCount[i] <= 0) {
237
219
k->modifierKeyCount[i] = 0;
238
220
k->state &= ~mask;
240
222
modifiers &= ~mask;
244
226
if (other->fromPassiveGrab && (key == other->activatingKey))
245
227
deactivateDeviceGrab = TRUE;
247
else if (xE->u.u.type == DeviceButtonPress)
249
kptr = &b->down[key >> 3];
228
} else if (xE->u.u.type == DeviceButtonPress) {
229
kptr = &b->down[key >> 3];
251
231
if (other->valuator)
252
232
other->valuator->motionHintWindow = NullWindow;
463
424
sev = ev = (deviceStateNotify *) xalloc(evcount * sizeof(xEvent));
464
FixDeviceStateNotify (dev, ev, NULL, NULL, NULL, first);
425
FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
467
FixDeviceStateNotify (dev, ev++, NULL, b, v, first);
428
FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
470
431
if (nbuttons > 32) {
471
(ev-1)->deviceid |= MORE_EVENTS;
472
bev = (deviceButtonStateNotify *) ev++;
432
(ev - 1)->deviceid |= MORE_EVENTS;
433
bev = (deviceButtonStateNotify *) ev++;
473
434
bev->type = DeviceButtonStateNotify;
474
435
bev->deviceid = dev->id;
475
memmove((char *) &bev->buttons[0], (char *) &b->down[4], 28);
436
memmove((char *)&bev->buttons[0], (char *)&b->down[4], 28);
478
(ev-1)->deviceid |= MORE_EVENTS;
479
FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
439
(ev - 1)->deviceid |= MORE_EVENTS;
440
FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
486
FixDeviceStateNotify (dev, ev++, k, NULL, v, first);
447
FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
489
450
if (nkeys > 32) {
490
(ev-1)->deviceid |= MORE_EVENTS;
491
kev = (deviceKeyStateNotify *) ev++;
451
(ev - 1)->deviceid |= MORE_EVENTS;
452
kev = (deviceKeyStateNotify *) ev++;
492
453
kev->type = DeviceKeyStateNotify;
493
454
kev->deviceid = dev->id;
494
memmove((char *) &kev->keys[0], (char *) &k->down[4], 28);
455
memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
497
(ev-1)->deviceid |= MORE_EVENTS;
498
FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
458
(ev - 1)->deviceid |= MORE_EVENTS;
459
FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
504
465
while (nval > 0) {
505
FixDeviceStateNotify (dev, ev++, NULL, NULL, v, first);
466
FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
509
(ev-1)->deviceid |= MORE_EVENTS;
510
FixDeviceValuator (dev, (deviceValuator *) ev++, v, first);
470
(ev - 1)->deviceid |= MORE_EVENTS;
471
FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
516
(void) DeliverEventsToWindow(pWin, (xEvent *)sev, evcount,
517
DeviceStateNotifyMask, NullGrab, dev->id);
477
(void)DeliverEventsToWindow(pWin, (xEvent *) sev, evcount,
478
DeviceStateNotifyMask, NullGrab, dev->id);
526
BYTE this_device_mode,
527
BYTE other_devices_mode,
529
DeviceIntPtr modifier_device,
484
GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
485
BYTE other_devices_mode, CARD16 modifiers,
486
DeviceIntPtr modifier_device, CARD8 button, Window grabWindow,
487
BOOL ownerEvents, Cursor rcursor, Window rconfineTo, Mask eventMask)
537
489
WindowPtr pWin, confineTo;
538
490
CursorPtr cursor;
541
493
if ((this_device_mode != GrabModeSync) &&
542
(this_device_mode != GrabModeAsync))
494
(this_device_mode != GrabModeAsync)) {
544
495
client->errorValue = this_device_mode;
547
498
if ((other_devices_mode != GrabModeSync) &&
548
(other_devices_mode != GrabModeAsync))
499
(other_devices_mode != GrabModeAsync)) {
550
500
client->errorValue = other_devices_mode;
553
if ((modifiers != AnyModifier) &&
554
(modifiers & ~AllModifiersMask))
503
if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) {
556
504
client->errorValue = modifiers;
559
if ((ownerEvents != xFalse) && (ownerEvents != xTrue))
507
if ((ownerEvents != xFalse) && (ownerEvents != xTrue)) {
561
508
client->errorValue = ownerEvents;
566
513
return BadWindow;
567
514
if (rconfineTo == None)
568
515
confineTo = NullWindow;
571
517
confineTo = LookupWindow(rconfineTo, client);
573
519
return BadWindow;
575
521
if (rcursor == None)
576
522
cursor = NullCursor;
579
cursor = (CursorPtr)LookupIDByType(rcursor, RT_CURSOR);
524
cursor = (CursorPtr) LookupIDByType(rcursor, RT_CURSOR);
582
526
client->errorValue = rcursor;
583
527
return BadCursor;
587
531
grab = CreateGrab(client->index, dev, pWin, eventMask,
588
(Bool)ownerEvents, (Bool) this_device_mode, (Bool)other_devices_mode,
589
modifier_device, modifiers, DeviceButtonPress, button, confineTo,
532
(Bool) ownerEvents, (Bool) this_device_mode,
533
(Bool) other_devices_mode, modifier_device, modifiers,
534
DeviceButtonPress, button, confineTo, cursor);
593
537
return AddPassiveGrabToList(grab);
600
BYTE this_device_mode,
601
BYTE other_devices_mode,
603
DeviceIntPtr modifier_device,
541
GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
542
BYTE other_devices_mode, CARD16 modifiers,
543
DeviceIntPtr modifier_device, CARD8 key, Window grabWindow,
544
BOOL ownerEvents, Mask mask)
611
548
KeyClassPtr k = dev->key;
615
552
if ((other_devices_mode != GrabModeSync) &&
616
(other_devices_mode != GrabModeAsync))
553
(other_devices_mode != GrabModeAsync)) {
618
554
client->errorValue = other_devices_mode;
621
557
if ((this_device_mode != GrabModeSync) &&
622
(this_device_mode != GrabModeAsync))
558
(this_device_mode != GrabModeAsync)) {
624
559
client->errorValue = this_device_mode;
627
if (((key > k->curKeySyms.maxKeyCode) ||
628
(key < k->curKeySyms.minKeyCode))
562
if (((key > k->curKeySyms.maxKeyCode) || (key < k->curKeySyms.minKeyCode))
563
&& (key != AnyKey)) {
631
564
client->errorValue = key;
634
if ((modifiers != AnyModifier) &&
635
(modifiers & ~AllModifiersMask))
567
if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) {
637
568
client->errorValue = modifiers;
640
if ((ownerEvents != xTrue) && (ownerEvents != xFalse))
571
if ((ownerEvents != xTrue) && (ownerEvents != xFalse)) {
642
572
client->errorValue = ownerEvents;
645
575
pWin = LookupWindow(grabWindow, client);
647
577
return BadWindow;
649
grab = CreateGrab(client->index, dev, pWin,
650
mask, ownerEvents, this_device_mode, other_devices_mode,
651
modifier_device, modifiers, DeviceKeyPress, key, NullWindow,
579
grab = CreateGrab(client->index, dev, pWin,
580
mask, ownerEvents, this_device_mode, other_devices_mode,
581
modifier_device, modifiers, DeviceKeyPress, key,
582
NullWindow, NullCursor);
655
585
return AddPassiveGrabToList(grab);
659
SelectForWindow(dev, pWin, client, mask, exclusivemasks, validmasks)
589
SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
590
Mask mask, Mask exclusivemasks, Mask validmasks)
667
592
int mskidx = dev->id;
670
595
InputClientsPtr others;
672
if (mask & ~validmasks)
597
if (mask & ~validmasks) {
674
598
client->errorValue = mask;
677
601
check = (mask & exclusivemasks);
678
if (wOtherInputMasks(pWin))
680
if (check & wOtherInputMasks(pWin)->inputEvents[mskidx])
681
{ /* It is illegal for two different
682
clients to select on any of the
683
events for maskcheck. However,
684
it is OK, for some client to
685
continue selecting on one of those
687
for (others = wOtherInputMasks(pWin)->inputClients; others;
688
others = others->next)
690
if (!SameClient(others, client) && (check &
691
others->mask[mskidx]))
602
if (wOtherInputMasks(pWin)) {
603
if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different
604
* clients to select on any of the
605
* events for maskcheck. However,
606
* it is OK, for some client to
607
* continue selecting on one of those
609
for (others = wOtherInputMasks(pWin)->inputClients; others;
610
others = others->next) {
611
if (!SameClient(others, client) && (check &
612
others->mask[mskidx]))
692
613
return BadAccess;
695
for (others = wOtherInputMasks(pWin)->inputClients; others;
696
others = others->next)
698
if (SameClient(others, client))
616
for (others = wOtherInputMasks(pWin)->inputClients; others;
617
others = others->next) {
618
if (SameClient(others, client)) {
700
619
check = others->mask[mskidx];
701
620
others->mask[mskidx] = mask;
704
for (i=0; i<EMASKSIZE; i++)
622
for (i = 0; i < EMASKSIZE; i++)
705
623
if (i != mskidx && others->mask[i] != 0)
625
if (i == EMASKSIZE) {
709
626
RecalculateDeviceDeliverableEvents(pWin);
710
627
if (ShouldFreeInputMasks(pWin, FALSE))
711
628
FreeResource(others->resource, RT_NONE);
720
if ((ret = AddExtensionClient (pWin, client, mask, mskidx)) != Success)
637
if ((ret = AddExtensionClient(pWin, client, mask, mskidx)) != Success)
723
640
if (dev->valuator)
724
641
if ((dev->valuator->motionHintWindow == pWin) &&
725
642
(mask & DevicePointerMotionHintMask) &&
726
!(check & DevicePointerMotionHintMask) &&
643
!(check & DevicePointerMotionHintMask) && !dev->grab)
728
644
dev->valuator->motionHintWindow = NullWindow;
729
645
RecalculateDeviceDeliverableEvents(pWin);
734
AddExtensionClient (pWin, client, mask, mskidx)
650
AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
740
652
InputClientsPtr others;
742
if (!pWin->optional && !MakeWindowOptional (pWin))
654
if (!pWin->optional && !MakeWindowOptional(pWin))
744
656
others = (InputClients *) xalloc(sizeof(InputClients));
747
if (!pWin->optional->inputMasks && !MakeInputMasks (pWin))
659
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
749
bzero((char *) &others->mask[0], sizeof(Mask)*EMASKSIZE);
661
bzero((char *)&others->mask[0], sizeof(Mask) * EMASKSIZE);
750
662
others->mask[mskidx] = mask;
751
663
others->resource = FakeClientID(client->index);
752
664
others->next = pWin->optional->inputMasks->inputClients;
753
665
pWin->optional->inputMasks->inputClients = others;
754
if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer)pWin))
666
if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer) pWin))
760
MakeInputMasks (pWin)
672
MakeInputMasks(WindowPtr pWin)
763
674
struct _OtherInputMasks *imasks;
765
imasks = (struct _OtherInputMasks *)
766
xalloc (sizeof (struct _OtherInputMasks));
676
imasks = (struct _OtherInputMasks *)
677
xalloc(sizeof(struct _OtherInputMasks));
769
bzero((char *) imasks, sizeof (struct _OtherInputMasks));
680
bzero((char *)imasks, sizeof(struct _OtherInputMasks));
770
681
pWin->optional->inputMasks = imasks;
775
RecalculateDeviceDeliverableEvents(pWin)
686
RecalculateDeviceDeliverableEvents(WindowPtr pWin)
778
688
register InputClientsPtr others;
779
struct _OtherInputMasks *inputMasks; /* default: NULL */
689
struct _OtherInputMasks *inputMasks; /* default: NULL */
780
690
register WindowPtr pChild, tmp;
786
if ((inputMasks = wOtherInputMasks(pChild)) != 0)
788
for (others = inputMasks->inputClients; others;
789
others = others->next)
791
for (i=0; i<EMASKSIZE; i++)
695
if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
696
for (others = inputMasks->inputClients; others;
697
others = others->next) {
698
for (i = 0; i < EMASKSIZE; i++)
792
699
inputMasks->inputEvents[i] |= others->mask[i];
794
for (i=0; i<EMASKSIZE; i++)
701
for (i = 0; i < EMASKSIZE; i++)
795
702
inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
796
for (tmp = pChild->parent; tmp; tmp=tmp->parent)
703
for (tmp = pChild->parent; tmp; tmp = tmp->parent)
797
704
if (wOtherInputMasks(tmp))
798
for (i=0; i<EMASKSIZE; i++)
705
for (i = 0; i < EMASKSIZE; i++)
799
706
inputMasks->deliverableEvents[i] |=
800
(wOtherInputMasks(tmp)->deliverableEvents[i]
801
& ~inputMasks->dontPropagateMask[i] & PropagateMask[i]);
803
if (pChild->firstChild)
707
(wOtherInputMasks(tmp)->deliverableEvents[i]
709
dontPropagateMask[i] & PropagateMask[i]);
711
if (pChild->firstChild) {
805
712
pChild = pChild->firstChild;
808
715
while (!pChild->nextSib && (pChild != pWin))
809
716
pChild = pChild->parent;
810
717
if (pChild == pWin)
812
719
pChild = pChild->nextSib;
817
InputClientGone(pWin, id)
818
register WindowPtr pWin;
724
InputClientGone(register WindowPtr pWin, XID id)
821
726
register InputClientsPtr other, prev;
822
728
if (!wOtherInputMasks(pWin))
825
for (other = wOtherInputMasks(pWin)->inputClients; other;
828
if (other->resource == id)
731
for (other = wOtherInputMasks(pWin)->inputClients; other;
732
other = other->next) {
733
if (other->resource == id) {
832
735
prev->next = other->next;
835
else if (!(other->next))
837
if (ShouldFreeInputMasks(pWin, TRUE))
737
} else if (!(other->next)) {
738
if (ShouldFreeInputMasks(pWin, TRUE)) {
839
739
wOtherInputMasks(pWin)->inputClients = other->next;
840
740
xfree(wOtherInputMasks(pWin));
841
741
pWin->optional->inputMasks = (OtherInputMasks *) NULL;
842
CheckWindowOptionalNeed (pWin);
742
CheckWindowOptionalNeed(pWin);
847
745
other->resource = FakeClientID(0);
848
if (!AddResource(other->resource, RT_INPUTCLIENT,
746
if (!AddResource(other->resource, RT_INPUTCLIENT,
855
751
wOtherInputMasks(pWin)->inputClients = other->next;
858
754
RecalculateDeviceDeliverableEvents(pWin);
863
759
FatalError("client not on device event list");
868
SendEvent (client, d, dest, propagate, ev, mask, count)
763
SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate,
764
xEvent * ev, Mask mask, int count)
878
WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
879
WindowPtr spriteWin=GetSpriteWindow();
767
WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */
768
WindowPtr spriteWin = GetSpriteWindow();
881
770
if (dest == PointerWindow)
882
771
pWin = spriteWin;
883
else if (dest == InputFocus)
772
else if (dest == InputFocus) {
885
773
WindowPtr inputFocus;
888
776
inputFocus = spriteWin;
936
(void)(DeliverEventsToWindow( pWin, ev, count, mask, NullGrab, d->id));
817
(void)(DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, d->id));
941
SetButtonMapping (client, dev, nElts, map)
822
SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map)
948
825
ButtonClassPtr b = dev->button;
953
if (nElts != b->numButtons)
830
if (nElts != b->numButtons) {
955
831
client->errorValue = nElts;
958
834
if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue))
960
for (i=0; i < nElts; i++)
961
if ((b->map[i + 1] != map[i]) &&
962
BitIsOn(b->down, i + 1))
836
for (i = 0; i < nElts; i++)
837
if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1))
964
839
for (i = 0; i < nElts; i++)
965
840
b->map[i + 1] = map[i];
970
SetModifierMapping(client, dev, len, rlen, numKeyPerModifier, inputMap, k)
975
int numKeyPerModifier;
845
SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen,
846
int numKeyPerModifier, KeyCode * inputMap, KeyClassPtr * k)
979
848
KeyCode *map = NULL;
986
if (len != ((numKeyPerModifier<<1) + rlen))
855
if (len != ((numKeyPerModifier << 1) + rlen))
987
856
return BadLength;
989
inputMapLen = 8*numKeyPerModifier;
858
inputMapLen = 8 * numKeyPerModifier;
992
* Now enforce the restriction that "all of the non-zero keycodes must be
993
* in the range specified by min-keycode and max-keycode in the
994
* connection setup (else a Value error)"
861
* Now enforce the restriction that "all of the non-zero keycodes must be
862
* in the range specified by min-keycode and max-keycode in the
863
* connection setup (else a Value error)"
999
868
&& (inputMap[i] < (*k)->curKeySyms.minKeyCode
1000
869
|| inputMap[i] > (*k)->curKeySyms.maxKeyCode)) {
1001
client->errorValue = inputMap[i];
1002
return -1; /* BadValue collides with MappingFailed */
870
client->errorValue = inputMap[i];
871
return -1; /* BadValue collides with MappingFailed */
1007
* Now enforce the restriction that none of the old or new
1008
* modifier keys may be down while we change the mapping, and
1009
* that the DDX layer likes the choice.
876
* Now enforce the restriction that none of the old or new
877
* modifier keys may be down while we change the mapping, and
878
* that the DDX layer likes the choice.
1011
if (!AllModifierKeysAreUp (dev, (*k)->modifierKeyMap,
1012
(int)(*k)->maxKeysPerModifier, inputMap, (int)numKeyPerModifier)
1014
!AllModifierKeysAreUp(dev, inputMap, (int)numKeyPerModifier,
1015
(*k)->modifierKeyMap, (int)(*k)->maxKeysPerModifier)) {
880
if (!AllModifierKeysAreUp(dev, (*k)->modifierKeyMap,
881
(int)(*k)->maxKeysPerModifier, inputMap,
882
(int)numKeyPerModifier)
883
|| !AllModifierKeysAreUp(dev, inputMap, (int)numKeyPerModifier,
884
(*k)->modifierKeyMap,
885
(int)(*k)->maxKeysPerModifier)) {
1016
886
return MappingBusy;
1018
888
for (i = 0; i < inputMapLen; i++) {
1019
if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)dev)) {
889
if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr) dev)) {
1020
890
return MappingFailed;
1026
* Now build the keyboard's modifier bitmap from the
896
* Now build the keyboard's modifier bitmap from the
1029
899
if (inputMapLen) {
1030
map = (KeyCode *)xalloc(inputMapLen);
900
map = (KeyCode *) xalloc(inputMapLen);
1034
904
if ((*k)->modifierKeyMap)
1035
xfree((*k)->modifierKeyMap);
905
xfree((*k)->modifierKeyMap);
1036
906
if (inputMapLen) {
1037
(*k)->modifierKeyMap = map;
1038
memmove((char *)(*k)->modifierKeyMap, (char *)inputMap, inputMapLen);
907
(*k)->modifierKeyMap = map;
908
memmove((char *)(*k)->modifierKeyMap, (char *)inputMap, inputMapLen);
1040
910
(*k)->modifierKeyMap = NULL;
1042
912
(*k)->maxKeysPerModifier = numKeyPerModifier;
1043
913
for (i = 0; i < MAP_LENGTH; i++)
1044
(*k)->modifierMap[i] = 0;
1045
for (i = 0; i < inputMapLen; i++) if (inputMap[i]) {
1046
(*k)->modifierMap[inputMap[i]]
1047
|= (1<<(i/ (*k)->maxKeysPerModifier));
914
(*k)->modifierMap[i] = 0;
915
for (i = 0; i < inputMapLen; i++)
917
(*k)->modifierMap[inputMap[i]]
918
|= (1 << (i / (*k)->maxKeysPerModifier));
1050
return(MappingSuccess);
921
return (MappingSuccess);
1054
SendDeviceMappingNotify(
1056
KeyCode firstKeyCode,
925
SendDeviceMappingNotify(CARD8 request,
926
KeyCode firstKeyCode, CARD8 count, DeviceIntPtr dev)
1061
deviceMappingNotify *ev = (deviceMappingNotify *) &event;
929
deviceMappingNotify *ev = (deviceMappingNotify *) & event;
1063
931
ev->type = DeviceMappingNotify;
1064
932
ev->request = request;
1065
933
ev->deviceid = dev->id;
1066
934
ev->time = currentTime.milliseconds;
1067
if (request == MappingKeyboard)
935
if (request == MappingKeyboard) {
1069
936
ev->firstKeyCode = firstKeyCode;
1070
937
ev->count = count;
1073
SendEventToAllWindows (dev, DeviceMappingNotifyMask, (xEvent *)ev, 1);
940
SendEventToAllWindows(dev, DeviceMappingNotifyMask, (xEvent *) ev, 1);
1082
KeyCode firstKeyCode,
1084
CARD8 keySymsPerKeyCode,
944
ChangeKeyMapping(ClientPtr client,
948
KeyCode firstKeyCode,
949
CARD8 keyCodes, CARD8 keySymsPerKeyCode, KeySym * map)
1087
951
KeySymsRec keysyms;
1088
952
KeyClassPtr k = dev->key;
1110
972
keysyms.map = map;
1111
973
if (!SetKeySymsMap(&k->curKeySyms, &keysyms))
1112
974
return BadAlloc;
1113
SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes,
975
SendDeviceMappingNotify(MappingKeyboard, firstKeyCode, keyCodes, dev);
1115
976
return client->noClientException;
1119
DeleteWindowFromAnyExtEvents(pWin, freeResources)
980
DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources)
1126
985
struct _OtherInputMasks *inputMasks;
1128
for (dev=inputInfo.devices; dev; dev=dev->next)
1130
if (dev == inputInfo.pointer ||
1131
dev == inputInfo.keyboard)
987
for (dev = inputInfo.devices; dev; dev = dev->next) {
988
if (dev == inputInfo.pointer || dev == inputInfo.keyboard)
1133
990
DeleteDeviceFromAnyExtEvents(pWin, dev);
1136
for (dev=inputInfo.off_devices; dev; dev=dev->next)
993
for (dev = inputInfo.off_devices; dev; dev = dev->next)
1137
994
DeleteDeviceFromAnyExtEvents(pWin, dev);
1139
996
if (freeResources)
1140
while ((inputMasks = wOtherInputMasks(pWin)) != 0)
997
while ((inputMasks = wOtherInputMasks(pWin)) != 0) {
1142
998
ic = inputMasks->inputClients;
1143
for (i=0; i<EMASKSIZE; i++)
999
for (i = 0; i < EMASKSIZE; i++)
1144
1000
inputMasks->dontPropagateMask[i] = 0;
1145
1001
FreeResource(ic->resource, RT_NONE);
1150
DeleteDeviceFromAnyExtEvents(pWin, dev)
1006
DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev)
1156
1010
/* Deactivate any grabs performed on this window, before making
1157
any input focus changes.
1158
Deactivating a device grab should cause focus events. */
1011
* any input focus changes.
1012
* Deactivating a device grab should cause focus events. */
1160
1014
if (dev->grab && (dev->grab->window == pWin))
1161
(*dev->DeactivateGrab)(dev);
1015
(*dev->DeactivateGrab) (dev);
1163
1017
/* If the focus window is a root window (ie. has no parent)
1164
then don't delete the focus from it. */
1166
if (dev->focus && (pWin==dev->focus->win) && (pWin->parent != NullWindow))
1018
* then don't delete the focus from it. */
1020
if (dev->focus && (pWin == dev->focus->win) && (pWin->parent != NullWindow)) {
1168
1021
int focusEventMode = NotifyNormal;
1170
/* If a grab is in progress, then alter the mode of focus events. */
1023
/* If a grab is in progress, then alter the mode of focus events. */
1173
1026
focusEventMode = NotifyWhileGrabbed;
1175
switch (dev->focus->revert)
1028
switch (dev->focus->revert) {
1030
DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
1031
dev->focus->win = NoneWin;
1032
dev->focus->traceGood = 0;
1034
case RevertToParent:
1037
parent = parent->parent;
1038
dev->focus->traceGood--;
1040
while (!parent->realized);
1041
DoFocusEvents(dev, pWin, parent, focusEventMode);
1042
dev->focus->win = parent;
1043
dev->focus->revert = RevertToNone;
1045
case RevertToPointerRoot:
1046
DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode);
1047
dev->focus->win = PointerRootWin;
1048
dev->focus->traceGood = 0;
1050
case RevertToFollowKeyboard:
1051
if (inputInfo.keyboard->focus->win) {
1052
DoFocusEvents(dev, pWin, inputInfo.keyboard->focus->win,
1054
dev->focus->win = FollowKeyboardWin;
1055
dev->focus->traceGood = 0;
1178
1057
DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
1179
1058
dev->focus->win = NoneWin;
1180
1059
dev->focus->traceGood = 0;
1182
case RevertToParent:
1186
parent = parent->parent;
1187
dev->focus->traceGood--;
1188
} while (!parent->realized);
1189
DoFocusEvents(dev, pWin, parent, focusEventMode);
1190
dev->focus->win = parent;
1191
dev->focus->revert = RevertToNone;
1193
case RevertToPointerRoot:
1194
DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode);
1195
dev->focus->win = PointerRootWin;
1196
dev->focus->traceGood = 0;
1198
case RevertToFollowKeyboard:
1199
if (inputInfo.keyboard->focus->win) {
1200
DoFocusEvents(dev, pWin, inputInfo.keyboard->focus->win,
1202
dev->focus->win = FollowKeyboardWin;
1203
dev->focus->traceGood = 0;
1205
DoFocusEvents(dev, pWin, NoneWin, focusEventMode);
1206
dev->focus->win = NoneWin;
1207
dev->focus->traceGood = 0;
1213
1065
if (dev->valuator)
1214
1066
if (dev->valuator->motionHintWindow == pWin)
1215
1067
dev->valuator->motionHintWindow = NullWindow;
1219
MaybeSendDeviceMotionNotifyHint (pEvents, mask)
1220
deviceKeyButtonPointer *pEvents;
1071
MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask)
1223
1073
DeviceIntPtr dev;
1225
dev = LookupDeviceIntRec (pEvents->deviceid & DEVICE_BITS);
1226
if (pEvents->type == DeviceMotionNotify)
1228
if (mask & DevicePointerMotionHintMask)
1230
if (WID(dev->valuator->motionHintWindow) == pEvents->event)
1232
return 1; /* don't send, but pretend we did */
1075
dev = LookupDeviceIntRec(pEvents->deviceid & DEVICE_BITS);
1076
if (pEvents->type == DeviceMotionNotify) {
1077
if (mask & DevicePointerMotionHintMask) {
1078
if (WID(dev->valuator->motionHintWindow) == pEvents->event) {
1079
return 1; /* don't send, but pretend we did */
1234
1081
pEvents->detail = NotifyHint;
1238
1083
pEvents->detail = NotifyNormal;
1245
CheckDeviceGrabAndHintWindow (pWin, type, xE, grab, client, deliveryMask)
1248
deviceKeyButtonPointer *xE;
1090
CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
1091
deviceKeyButtonPointer * xE, GrabPtr grab,
1092
ClientPtr client, Mask deliveryMask)
1253
1094
DeviceIntPtr dev;
1255
dev = LookupDeviceIntRec (xE->deviceid & DEVICE_BITS);
1096
dev = LookupDeviceIntRec(xE->deviceid & DEVICE_BITS);
1256
1097
if (type == DeviceMotionNotify)
1257
1098
dev->valuator->motionHintWindow = pWin;
1258
else if ((type == DeviceButtonPress) && (!grab) &&
1259
(deliveryMask & DeviceButtonGrabMask))
1099
else if ((type == DeviceButtonPress) && (!grab) &&
1100
(deliveryMask & DeviceButtonGrabMask)) {
1261
1101
GrabRec tempGrab;
1263
1103
tempGrab.device = dev;
1264
1104
tempGrab.resource = client->clientAsMask;
1265
1105
tempGrab.window = pWin;
1266
tempGrab.ownerEvents = (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
1106
tempGrab.ownerEvents =
1107
(deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
1267
1108
tempGrab.eventMask = deliveryMask;
1268
1109
tempGrab.keyboardMode = GrabModeAsync;
1269
1110
tempGrab.pointerMode = GrabModeAsync;
1270
1111
tempGrab.confineTo = NullWindow;
1271
1112
tempGrab.cursor = NullCursor;
1272
(*dev->ActivateGrab)(dev, &tempGrab, currentTime, TRUE);
1113
(*dev->ActivateGrab) (dev, &tempGrab, currentTime, TRUE);
1277
DeviceEventMaskForClient(dev, pWin, client)
1118
DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client)
1282
1120
register InputClientsPtr other;
1284
1122
if (!wOtherInputMasks(pWin))
1286
for (other = wOtherInputMasks(pWin)->inputClients; other;
1287
other = other->next)
1124
for (other = wOtherInputMasks(pWin)->inputClients; other;
1125
other = other->next) {
1289
1126
if (SameClient(other, client))
1290
1127
return other->mask[dev->id];
1296
MaybeStopDeviceHint(dev, client)
1297
register DeviceIntPtr dev;
1133
MaybeStopDeviceHint(register DeviceIntPtr dev, ClientPtr client)
1300
1135
WindowPtr pWin;
1301
1136
GrabPtr grab = dev->grab;
1302
1138
pWin = dev->valuator->motionHintWindow;
1304
1140
if ((grab && SameClient(grab, client) &&