2006-11-26 11:13:41 -07:00
|
|
|
/************************************************************
|
|
|
|
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this
|
|
|
|
software and its documentation for any purpose and without
|
|
|
|
fee is hereby granted, provided that the above copyright
|
|
|
|
notice appear in all copies and that both that copyright
|
|
|
|
notice and this permission notice appear in supporting
|
|
|
|
documentation, and that the name of Silicon Graphics not be
|
|
|
|
used in advertising or publicity pertaining to distribution
|
|
|
|
of the software without specific prior written permission.
|
|
|
|
Silicon Graphics makes no representation about the suitability
|
|
|
|
of this software for any purpose. It is provided "as is"
|
|
|
|
without any express or implied warranty.
|
|
|
|
|
|
|
|
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
|
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
|
|
|
|
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
|
|
|
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
|
|
THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
#include <X11/extensions/XI.h>
|
2007-12-13 14:06:02 -07:00
|
|
|
#include <X11/extensions/XIproto.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "inputstr.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "exevents.h"
|
|
|
|
#include "exglobals.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "windowstr.h"
|
2007-11-24 10:55:21 -07:00
|
|
|
#include <xkbsrv.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
#include "xkb.h"
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/*
|
|
|
|
* This function sends out two kinds of notification:
|
|
|
|
* - Core mapping notify events sent to clients for whom kbd is the
|
|
|
|
* current core ('picked') keyboard _and_ have not explicitly
|
|
|
|
* selected for XKB mapping notify events;
|
|
|
|
* - Xi mapping events, sent unconditionally to all clients who have
|
|
|
|
* explicitly selected for them (including those who have explicitly
|
|
|
|
* selected for XKB mapping notify events!).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
|
|
|
|
int first_key, int num_keys)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int keymap_changed = 0;
|
|
|
|
int modmap_changed = 0;
|
|
|
|
CARD32 time = GetTimeInMillis();
|
|
|
|
|
|
|
|
if (xkb_event == XkbNewKeyboardNotify) {
|
|
|
|
if (changed & XkbNKN_KeycodesMask) {
|
|
|
|
keymap_changed = 1;
|
|
|
|
modmap_changed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (xkb_event == XkbMapNotify) {
|
|
|
|
if (changed & XkbKeySymsMask)
|
|
|
|
keymap_changed = 1;
|
|
|
|
if (changed & XkbModifierMapMask)
|
|
|
|
modmap_changed = 1;
|
|
|
|
}
|
|
|
|
if (!keymap_changed && !modmap_changed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* 0 is serverClient. */
|
|
|
|
for (i = 1; i < currentMaxClients; i++) {
|
|
|
|
if (!clients[i] || clients[i]->clientState != ClientStateRunning)
|
|
|
|
continue;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/* XKB allows clients to restrict the MappingNotify events sent to
|
|
|
|
* them. This was broken for three years. Sorry. */
|
|
|
|
if (xkb_event == XkbMapNotify &&
|
|
|
|
(clients[i]->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
!(clients[i]->mapNotifyMask & changed))
|
2010-07-27 13:02:24 -06:00
|
|
|
continue;
|
2011-11-05 07:32:40 -06:00
|
|
|
/* Emulate previous server behaviour: any client which has activated
|
|
|
|
* XKB will not receive core events emulated from a NewKeyboardNotify
|
|
|
|
* at all. */
|
2010-07-27 13:02:24 -06:00
|
|
|
if (xkb_event == XkbNewKeyboardNotify &&
|
|
|
|
(clients[i]->xkbClientFlags & _XkbClientInitialized))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Don't send core events to clients who don't know about us. */
|
|
|
|
if (!XIShouldNotify(clients[i], kbd))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (keymap_changed) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent core_mn = { .u.u.type = MappingNotify };
|
2010-07-27 13:02:24 -06:00
|
|
|
core_mn.u.mappingNotify.request = MappingKeyboard;
|
|
|
|
|
|
|
|
/* Clip the keycode range to what the client knows about, so it
|
|
|
|
* doesn't freak out. */
|
|
|
|
if (first_key >= clients[i]->minKC)
|
|
|
|
core_mn.u.mappingNotify.firstKeyCode = first_key;
|
|
|
|
else
|
|
|
|
core_mn.u.mappingNotify.firstKeyCode = clients[i]->minKC;
|
|
|
|
if (first_key + num_keys - 1 <= clients[i]->maxKC)
|
|
|
|
core_mn.u.mappingNotify.count = num_keys;
|
|
|
|
else
|
|
|
|
core_mn.u.mappingNotify.count = clients[i]->maxKC -
|
2012-06-10 07:21:05 -06:00
|
|
|
clients[i]->minKC + 1;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
WriteEventsToClient(clients[i], 1, &core_mn);
|
|
|
|
}
|
|
|
|
if (modmap_changed) {
|
2013-06-07 11:28:45 -06:00
|
|
|
xEvent core_mn = {
|
|
|
|
.u.mappingNotify.request = MappingModifier,
|
|
|
|
.u.mappingNotify.firstKeyCode = 0,
|
|
|
|
.u.mappingNotify.count = 0
|
|
|
|
};
|
|
|
|
core_mn.u.u.type = MappingNotify;
|
2010-07-27 13:02:24 -06:00
|
|
|
WriteEventsToClient(clients[i], 1, &core_mn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hmm, maybe we can accidentally generate Xi events for core devices
|
|
|
|
* here? Clients might be upset, but that seems better than the
|
|
|
|
* alternative of stale keymaps. -ds */
|
|
|
|
if (keymap_changed) {
|
2013-06-07 11:28:45 -06:00
|
|
|
deviceMappingNotify xi_mn = {
|
|
|
|
.type = DeviceMappingNotify,
|
|
|
|
.deviceid = kbd->id,
|
|
|
|
.request = MappingKeyboard,
|
|
|
|
.firstKeyCode = first_key,
|
|
|
|
.count = num_keys,
|
|
|
|
.time = time
|
|
|
|
};
|
2010-07-27 13:02:24 -06:00
|
|
|
SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
if (modmap_changed) {
|
2013-06-07 11:28:45 -06:00
|
|
|
deviceMappingNotify xi_mn = {
|
|
|
|
.type = DeviceMappingNotify,
|
|
|
|
.deviceid = kbd->id,
|
|
|
|
.request = MappingModifier,
|
|
|
|
.firstKeyCode = 0,
|
|
|
|
.count = 0,
|
|
|
|
.time = time
|
|
|
|
};
|
2010-07-27 13:02:24 -06:00
|
|
|
SendEventToAllWindows(kbd, DeviceMappingNotifyMask, (xEvent *) &xi_mn,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendNewKeyboardNotify(DeviceIntPtr kbd, xkbNewKeyboardNotify * pNKN)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
Time time = GetTimeInMillis();
|
|
|
|
CARD16 changed = pNKN->changed;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pNKN->type = XkbEventCode + XkbEventBase;
|
|
|
|
pNKN->xkbType = XkbNewKeyboardNotify;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 1; i < currentMaxClients; i++) {
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!clients[i] || clients[i]->clientState != ClientStateRunning)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(clients[i]->newKeyboardNotifyMask & changed))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pNKN->sequenceNumber = clients[i]->sequence;
|
|
|
|
pNKN->time = time;
|
|
|
|
pNKN->changed = changed;
|
|
|
|
if (clients[i]->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&pNKN->sequenceNumber);
|
|
|
|
swapl(&pNKN->time);
|
|
|
|
swaps(&pNKN->changed);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
WriteToClient(clients[i], sizeof(xEvent), pNKN);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (changed & XkbNKN_KeycodesMask) {
|
|
|
|
clients[i]->minKC = pNKN->minKeyCode;
|
|
|
|
clients[i]->maxKC = pNKN->maxKeyCode;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
XkbSendLegacyMapNotify(kbd, XkbNewKeyboardNotify, changed, pNKN->minKeyCode,
|
|
|
|
pNKN->maxKeyCode - pNKN->minKeyCode + 1);
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendStateNotify(DeviceIntPtr kbd, xkbStateNotify * pSN)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
XkbStatePtr state;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time;
|
|
|
|
register CARD16 changed, bState;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
2009-01-12 13:17:47 -07:00
|
|
|
if (!interest || !kbd->key || !kbd->key->xkbInfo)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
xkbi = kbd->key->xkbInfo;
|
2012-06-10 07:21:05 -06:00
|
|
|
state = &xkbi->state;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pSN->type = XkbEventCode + XkbEventBase;
|
|
|
|
pSN->xkbType = XkbStateNotify;
|
|
|
|
pSN->deviceID = kbd->id;
|
|
|
|
pSN->time = time = GetTimeInMillis();
|
|
|
|
pSN->mods = state->mods;
|
|
|
|
pSN->baseMods = state->base_mods;
|
|
|
|
pSN->latchedMods = state->latched_mods;
|
|
|
|
pSN->lockedMods = state->locked_mods;
|
|
|
|
pSN->group = state->group;
|
|
|
|
pSN->baseGroup = state->base_group;
|
|
|
|
pSN->latchedGroup = state->latched_group;
|
|
|
|
pSN->lockedGroup = state->locked_group;
|
|
|
|
pSN->compatState = state->compat_state;
|
|
|
|
pSN->grabMods = state->grab_mods;
|
|
|
|
pSN->compatGrabMods = state->compat_grab_mods;
|
|
|
|
pSN->lookupMods = state->lookup_mods;
|
|
|
|
pSN->compatLookupMods = state->compat_lookup_mods;
|
|
|
|
pSN->ptrBtnState = state->ptr_buttons;
|
|
|
|
changed = pSN->changed;
|
2012-06-10 07:21:05 -06:00
|
|
|
bState = pSN->ptrBtnState;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->stateNotifyMask & changed)) {
|
|
|
|
pSN->sequenceNumber = interest->client->sequence;
|
|
|
|
pSN->time = time;
|
|
|
|
pSN->changed = changed;
|
|
|
|
pSN->ptrBtnState = bState;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pSN->sequenceNumber);
|
|
|
|
swapl(&pSN->time);
|
|
|
|
swaps(&pSN->changed);
|
|
|
|
swaps(&pSN->ptrBtnState);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pSN);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/*
|
|
|
|
* This function sends out XKB mapping notify events to clients which
|
|
|
|
* have explicitly selected for them. Core and Xi events are handled by
|
|
|
|
* XkbSendLegacyMapNotify. */
|
2006-11-26 11:13:41 -07:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify * pMN)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
int i;
|
|
|
|
CARD32 time = GetTimeInMillis();
|
|
|
|
CARD16 changed = pMN->changed;
|
|
|
|
XkbSrvInfoPtr xkbi = kbd->key->xkbInfo;
|
|
|
|
|
|
|
|
pMN->minKeyCode = xkbi->desc->min_key_code;
|
|
|
|
pMN->maxKeyCode = xkbi->desc->max_key_code;
|
|
|
|
pMN->type = XkbEventCode + XkbEventBase;
|
|
|
|
pMN->xkbType = XkbMapNotify;
|
|
|
|
pMN->deviceID = kbd->id;
|
|
|
|
|
|
|
|
/* 0 is serverClient. */
|
|
|
|
for (i = 1; i < currentMaxClients; i++) {
|
|
|
|
if (!clients[i] || clients[i]->clientState != ClientStateRunning)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(clients[i]->mapNotifyMask & changed))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pMN->time = time;
|
|
|
|
pMN->sequenceNumber = clients[i]->sequence;
|
|
|
|
pMN->changed = changed;
|
|
|
|
|
|
|
|
if (clients[i]->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&pMN->sequenceNumber);
|
|
|
|
swapl(&pMN->time);
|
|
|
|
swaps(&pMN->changed);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
WriteToClient(clients[i], sizeof(xEvent), pMN);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
XkbSendLegacyMapNotify(kbd, XkbMapNotify, changed, pMN->firstKeySym,
|
|
|
|
pMN->nKeySyms);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbComputeControlsNotify(DeviceIntPtr kbd,
|
|
|
|
XkbControlsPtr old,
|
|
|
|
XkbControlsPtr new,
|
|
|
|
xkbControlsNotify * pCN, Bool forceCtrlProc)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int i;
|
|
|
|
CARD32 changedControls;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
changedControls = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!kbd || !kbd->kbdfeed)
|
|
|
|
return 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
|
|
|
if (old->enabled_ctrls != new->enabled_ctrls)
|
|
|
|
changedControls |= XkbControlsEnabledMask;
|
|
|
|
if ((old->repeat_delay != new->repeat_delay) ||
|
|
|
|
(old->repeat_interval != new->repeat_interval))
|
|
|
|
changedControls |= XkbRepeatKeysMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
for (i = 0; i < XkbPerKeyBitArraySize; i++)
|
2012-06-10 07:21:05 -06:00
|
|
|
if (old->per_key_repeat[i] != new->per_key_repeat[i])
|
|
|
|
changedControls |= XkbPerKeyRepeatMask;
|
|
|
|
if (old->slow_keys_delay != new->slow_keys_delay)
|
|
|
|
changedControls |= XkbSlowKeysMask;
|
|
|
|
if (old->debounce_delay != new->debounce_delay)
|
|
|
|
changedControls |= XkbBounceKeysMask;
|
|
|
|
if ((old->mk_delay != new->mk_delay) ||
|
|
|
|
(old->mk_interval != new->mk_interval) ||
|
|
|
|
(old->mk_dflt_btn != new->mk_dflt_btn))
|
|
|
|
changedControls |= XkbMouseKeysMask;
|
|
|
|
if ((old->mk_time_to_max != new->mk_time_to_max) ||
|
|
|
|
(old->mk_curve != new->mk_curve) ||
|
|
|
|
(old->mk_max_speed != new->mk_max_speed))
|
|
|
|
changedControls |= XkbMouseKeysAccelMask;
|
|
|
|
if (old->ax_options != new->ax_options)
|
|
|
|
changedControls |= XkbAccessXKeysMask;
|
|
|
|
if ((old->ax_options ^ new->ax_options) & XkbAX_SKOptionsMask)
|
|
|
|
changedControls |= XkbStickyKeysMask;
|
|
|
|
if ((old->ax_options ^ new->ax_options) & XkbAX_FBOptionsMask)
|
|
|
|
changedControls |= XkbAccessXFeedbackMask;
|
|
|
|
if ((old->ax_timeout != new->ax_timeout) ||
|
|
|
|
(old->axt_ctrls_mask != new->axt_ctrls_mask) ||
|
|
|
|
(old->axt_ctrls_values != new->axt_ctrls_values) ||
|
|
|
|
(old->axt_opts_mask != new->axt_opts_mask) ||
|
|
|
|
(old->axt_opts_values != new->axt_opts_values)) {
|
|
|
|
changedControls |= XkbAccessXTimeoutMask;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((old->internal.mask != new->internal.mask) ||
|
|
|
|
(old->internal.real_mods != new->internal.real_mods) ||
|
|
|
|
(old->internal.vmods != new->internal.vmods))
|
|
|
|
changedControls |= XkbInternalModsMask;
|
|
|
|
if ((old->ignore_lock.mask != new->ignore_lock.mask) ||
|
|
|
|
(old->ignore_lock.real_mods != new->ignore_lock.real_mods) ||
|
|
|
|
(old->ignore_lock.vmods != new->ignore_lock.vmods))
|
|
|
|
changedControls |= XkbIgnoreLockModsMask;
|
|
|
|
|
|
|
|
if (new->enabled_ctrls & XkbRepeatKeysMask)
|
|
|
|
kbd->kbdfeed->ctrl.autoRepeat = TRUE;
|
|
|
|
else
|
|
|
|
kbd->kbdfeed->ctrl.autoRepeat = FALSE;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (kbd->kbdfeed && kbd->kbdfeed->CtrlProc &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(changedControls || forceCtrlProc))
|
|
|
|
(*kbd->kbdfeed->CtrlProc) (kbd, &kbd->kbdfeed->ctrl);
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!changedControls) && (old->num_groups == new->num_groups))
|
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
if (!kbd->xkb_interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
pCN->changedControls = changedControls;
|
|
|
|
pCN->enabledControls = new->enabled_ctrls;
|
2012-06-10 07:21:05 -06:00
|
|
|
pCN->enabledControlChanges = (new->enabled_ctrls ^ old->enabled_ctrls);
|
2006-11-26 11:13:41 -07:00
|
|
|
pCN->numGroups = new->num_groups;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendControlsNotify(DeviceIntPtr kbd, xkbControlsNotify * pCN)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
CARD32 changedControls, enabledControls, enabledChanges = 0;
|
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
2009-01-12 13:17:47 -07:00
|
|
|
if (!interest || !kbd->key || !kbd->key->xkbInfo)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
2006-11-26 11:13:41 -07:00
|
|
|
xkbi = kbd->key->xkbInfo;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
|
|
|
enabledControls = xkbi->desc->ctrls->enabled_ctrls;
|
|
|
|
changedControls = pCN->changedControls;
|
2012-06-10 07:21:05 -06:00
|
|
|
pCN->numGroups = xkbi->desc->ctrls->num_groups;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->ctrlsNotifyMask & changedControls)) {
|
|
|
|
if (!initialized) {
|
|
|
|
pCN->type = XkbEventCode + XkbEventBase;
|
|
|
|
pCN->xkbType = XkbControlsNotify;
|
|
|
|
pCN->deviceID = kbd->id;
|
|
|
|
pCN->time = time = GetTimeInMillis();
|
|
|
|
enabledChanges = pCN->enabledControlChanges;
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pCN->changedControls = changedControls;
|
|
|
|
pCN->enabledControls = enabledControls;
|
|
|
|
pCN->enabledControlChanges = enabledChanges;
|
|
|
|
pCN->sequenceNumber = interest->client->sequence;
|
|
|
|
pCN->time = time;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pCN->sequenceNumber);
|
|
|
|
swapl(&pCN->changedControls);
|
|
|
|
swapl(&pCN->enabledControls);
|
|
|
|
swapl(&pCN->enabledControlChanges);
|
|
|
|
swapl(&pCN->time);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pCN);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-24 10:55:21 -07:00
|
|
|
static void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendIndicatorNotify(DeviceIntPtr kbd, int xkbType, xkbIndicatorNotify * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
|
|
|
CARD32 state, changed;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
|
|
|
if (!interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
|
|
|
state = pEv->state;
|
|
|
|
changed = pEv->changed;
|
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(((xkbType == XkbIndicatorStateNotify) &&
|
|
|
|
(interest->iStateNotifyMask & changed)) ||
|
|
|
|
((xkbType == XkbIndicatorMapNotify) &&
|
|
|
|
(interest->iMapNotifyMask & changed)))) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = xkbType;
|
|
|
|
pEv->deviceID = kbd->id;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
pEv->changed = changed;
|
|
|
|
pEv->state = state;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
swapl(&pEv->changed);
|
|
|
|
swapl(&pEv->state);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbHandleBell(BOOL force,
|
|
|
|
BOOL eventOnly,
|
|
|
|
DeviceIntPtr kbd,
|
|
|
|
CARD8 percent,
|
|
|
|
pointer pCtrl,
|
|
|
|
CARD8 class, Atom name, WindowPtr pWin, ClientPtr pClient)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbBellNotify bn;
|
|
|
|
int initialized;
|
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
CARD8 id;
|
|
|
|
CARD16 pitch, duration;
|
|
|
|
Time time = 0;
|
|
|
|
XID winID = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-01-12 13:17:47 -07:00
|
|
|
if (!kbd->key || !kbd->key->xkbInfo)
|
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
xkbi = kbd->key->xkbInfo;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((force || (xkbi->desc->ctrls->enabled_ctrls & XkbAudibleBellMask)) &&
|
|
|
|
(!eventOnly)) {
|
2007-12-13 14:06:02 -07:00
|
|
|
if (kbd->kbdfeed->BellProc)
|
2012-06-10 07:21:05 -06:00
|
|
|
(*kbd->kbdfeed->BellProc) (percent, kbd, (pointer) pCtrl, class);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
interest = kbd->xkb_interest;
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest) || (force))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((class == 0) || (class == KbdFeedbackClass)) {
|
|
|
|
KeybdCtrl *pKeyCtrl = (KeybdCtrl *) pCtrl;
|
|
|
|
|
|
|
|
id = pKeyCtrl->id;
|
|
|
|
pitch = pKeyCtrl->bell_pitch;
|
|
|
|
duration = pKeyCtrl->bell_duration;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else if (class == BellFeedbackClass) {
|
|
|
|
BellCtrl *pBellCtrl = (BellCtrl *) pCtrl;
|
|
|
|
|
|
|
|
id = pBellCtrl->id;
|
|
|
|
pitch = pBellCtrl->pitch;
|
|
|
|
duration = pBellCtrl->duration;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->bellNotifyMask)) {
|
|
|
|
if (!initialized) {
|
|
|
|
time = GetTimeInMillis();
|
|
|
|
bn.type = XkbEventCode + XkbEventBase;
|
|
|
|
bn.xkbType = XkbBellNotify;
|
|
|
|
bn.deviceID = kbd->id;
|
|
|
|
bn.bellClass = class;
|
|
|
|
bn.bellID = id;
|
|
|
|
bn.percent = percent;
|
|
|
|
bn.eventOnly = (eventOnly != 0);
|
|
|
|
winID = (pWin ? pWin->drawable.id : None);
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
bn.sequenceNumber = interest->client->sequence;
|
|
|
|
bn.time = time;
|
|
|
|
bn.pitch = pitch;
|
|
|
|
bn.duration = duration;
|
|
|
|
bn.name = name;
|
|
|
|
bn.window = winID;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&bn.sequenceNumber);
|
|
|
|
swapl(&bn.time);
|
|
|
|
swaps(&bn.pitch);
|
|
|
|
swaps(&bn.duration);
|
|
|
|
swapl(&bn.name);
|
|
|
|
swapl(&bn.window);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), &bn);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendAccessXNotify(DeviceIntPtr kbd, xkbAccessXNotify * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
|
|
|
CARD16 sk_delay, db_delay;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
|
|
|
if (!interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
sk_delay = pEv->slowKeysDelay;
|
|
|
|
db_delay = pEv->debounceDelay;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->accessXNotifyMask & (1 << pEv->detail))) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = XkbAccessXNotify;
|
|
|
|
pEv->deviceID = kbd->id;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
pEv->slowKeysDelay = sk_delay;
|
|
|
|
pEv->debounceDelay = db_delay;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
swaps(&pEv->slowKeysDelay);
|
|
|
|
swaps(&pEv->debounceDelay);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendNamesNotify(DeviceIntPtr kbd, xkbNamesNotify * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
|
|
|
CARD16 changed, changedVirtualMods;
|
|
|
|
CARD32 changedIndicators;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
|
|
|
if (!interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
changed = pEv->changed;
|
|
|
|
changedIndicators = pEv->changedIndicators;
|
|
|
|
changedVirtualMods = pEv->changedVirtualMods;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->namesNotifyMask & pEv->changed)) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = XkbNamesNotify;
|
|
|
|
pEv->deviceID = kbd->id;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
pEv->changed = changed;
|
|
|
|
pEv->changedIndicators = changedIndicators;
|
|
|
|
pEv->changedVirtualMods = changedVirtualMods;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
swaps(&pEv->changed);
|
|
|
|
swapl(&pEv->changedIndicators);
|
|
|
|
swaps(&pEv->changedVirtualMods);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendCompatMapNotify(DeviceIntPtr kbd, xkbCompatMapNotify * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
|
|
|
CARD16 firstSI = 0, nSI = 0, nTotalSI = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
|
|
|
if (!interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->compatNotifyMask)) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = XkbCompatMapNotify;
|
|
|
|
pEv->deviceID = kbd->id;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
firstSI = pEv->firstSI;
|
|
|
|
nSI = pEv->nSI;
|
|
|
|
nTotalSI = pEv->nTotalSI;
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
pEv->firstSI = firstSI;
|
|
|
|
pEv->nSI = nSI;
|
|
|
|
pEv->nTotalSI = nTotalSI;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
swaps(&pEv->firstSI);
|
|
|
|
swaps(&pEv->nSI);
|
|
|
|
swaps(&pEv->nTotalSI);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendActionMessage(DeviceIntPtr kbd, xkbActionMessage * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = kbd->xkb_interest;
|
2009-01-12 13:17:47 -07:00
|
|
|
if (!interest || !kbd->key || !kbd->key->xkbInfo)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2009-01-12 13:17:47 -07:00
|
|
|
xkbi = kbd->key->xkbInfo;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
pEv->mods = xkbi->state.mods;
|
|
|
|
pEv->group = xkbi->state.group;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->actionMessageMask)) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = XkbActionMessage;
|
|
|
|
pEv->deviceID = kbd->id;
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendExtensionDeviceNotify(DeviceIntPtr dev,
|
|
|
|
ClientPtr client, xkbExtensionDeviceNotify * pEv)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
int initialized;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Time time = 0;
|
|
|
|
CARD32 defined, state;
|
|
|
|
CARD16 reason;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = dev->xkb_interest;
|
|
|
|
if (!interest)
|
2012-06-10 07:21:05 -06:00
|
|
|
return;
|
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
initialized = 0;
|
2012-06-10 07:21:05 -06:00
|
|
|
reason = pEv->reason;
|
|
|
|
defined = pEv->ledsDefined;
|
|
|
|
state = pEv->ledState;
|
2006-11-26 11:13:41 -07:00
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((!interest->client->clientGone) &&
|
|
|
|
(interest->client->requestVector != InitialVector) &&
|
|
|
|
(interest->client->xkbClientFlags & _XkbClientInitialized) &&
|
|
|
|
(interest->extDevNotifyMask & reason)) {
|
|
|
|
if (!initialized) {
|
|
|
|
pEv->type = XkbEventCode + XkbEventBase;
|
|
|
|
pEv->xkbType = XkbExtensionDeviceNotify;
|
|
|
|
pEv->deviceID = dev->id;
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time = GetTimeInMillis();
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pEv->sequenceNumber = interest->client->sequence;
|
|
|
|
pEv->time = time;
|
|
|
|
pEv->ledsDefined = defined;
|
|
|
|
pEv->ledState = state;
|
|
|
|
pEv->reason = reason;
|
|
|
|
pEv->supported = XkbXI_AllFeaturesMask;
|
|
|
|
}
|
|
|
|
if (interest->client->swapped) {
|
|
|
|
swaps(&pEv->sequenceNumber);
|
|
|
|
swapl(&pEv->time);
|
|
|
|
swapl(&pEv->ledsDefined);
|
|
|
|
swapl(&pEv->ledState);
|
|
|
|
swaps(&pEv->reason);
|
|
|
|
swaps(&pEv->supported);
|
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(interest->client, sizeof(xEvent), pEv);
|
2012-06-10 07:21:05 -06:00
|
|
|
}
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSendNotification(DeviceIntPtr kbd,
|
|
|
|
XkbChangesPtr pChanges, XkbEventCausePtr cause)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSrvLedInfoPtr sli;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
sli = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
if (pChanges->state_changes) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbStateNotify sn;
|
|
|
|
|
|
|
|
sn.changed = pChanges->state_changes;
|
|
|
|
sn.keycode = cause->kc;
|
|
|
|
sn.eventType = cause->event;
|
|
|
|
sn.requestMajor = cause->mjr;
|
|
|
|
sn.requestMinor = cause->mnr;
|
|
|
|
XkbSendStateNotify(kbd, &sn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pChanges->map.changed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbMapNotify mn;
|
|
|
|
|
|
|
|
memset(&mn, 0, sizeof(xkbMapNotify));
|
|
|
|
mn.changed = pChanges->map.changed;
|
|
|
|
mn.firstType = pChanges->map.first_type;
|
|
|
|
mn.nTypes = pChanges->map.num_types;
|
|
|
|
mn.firstKeySym = pChanges->map.first_key_sym;
|
|
|
|
mn.nKeySyms = pChanges->map.num_key_syms;
|
|
|
|
mn.firstKeyAct = pChanges->map.first_key_act;
|
|
|
|
mn.nKeyActs = pChanges->map.num_key_acts;
|
|
|
|
mn.firstKeyBehavior = pChanges->map.first_key_behavior;
|
|
|
|
mn.nKeyBehaviors = pChanges->map.num_key_behaviors;
|
|
|
|
mn.virtualMods = pChanges->map.vmods;
|
|
|
|
mn.firstKeyExplicit = pChanges->map.first_key_explicit;
|
|
|
|
mn.nKeyExplicit = pChanges->map.num_key_explicit;
|
|
|
|
mn.firstModMapKey = pChanges->map.first_modmap_key;
|
|
|
|
mn.nModMapKeys = pChanges->map.num_modmap_keys;
|
|
|
|
mn.firstVModMapKey = pChanges->map.first_vmodmap_key;
|
|
|
|
mn.nVModMapKeys = pChanges->map.num_vmodmap_keys;
|
|
|
|
XkbSendMapNotify(kbd, &mn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pChanges->ctrls.changed_ctrls) ||
|
|
|
|
(pChanges->ctrls.enabled_ctrls_changes)) {
|
|
|
|
xkbControlsNotify cn;
|
|
|
|
|
|
|
|
memset(&cn, 0, sizeof(xkbControlsNotify));
|
|
|
|
cn.changedControls = pChanges->ctrls.changed_ctrls;
|
|
|
|
cn.enabledControlChanges = pChanges->ctrls.enabled_ctrls_changes;
|
|
|
|
cn.keycode = cause->kc;
|
|
|
|
cn.eventType = cause->event;
|
|
|
|
cn.requestMajor = cause->mjr;
|
|
|
|
cn.requestMinor = cause->mnr;
|
|
|
|
XkbSendControlsNotify(kbd, &cn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pChanges->indicators.map_changes) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbIndicatorNotify in;
|
|
|
|
|
|
|
|
if (sli == NULL)
|
|
|
|
sli = XkbFindSrvLedInfo(kbd, XkbDfltXIClass, XkbDfltXIId, 0);
|
|
|
|
memset(&in, 0, sizeof(xkbIndicatorNotify));
|
|
|
|
in.state = sli->effectiveState;
|
|
|
|
in.changed = pChanges->indicators.map_changes;
|
|
|
|
XkbSendIndicatorNotify(kbd, XkbIndicatorMapNotify, &in);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pChanges->indicators.state_changes) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbIndicatorNotify in;
|
|
|
|
|
|
|
|
if (sli == NULL)
|
|
|
|
sli = XkbFindSrvLedInfo(kbd, XkbDfltXIClass, XkbDfltXIId, 0);
|
|
|
|
memset(&in, 0, sizeof(xkbIndicatorNotify));
|
|
|
|
in.state = sli->effectiveState;
|
|
|
|
in.changed = pChanges->indicators.state_changes;
|
|
|
|
XkbSendIndicatorNotify(kbd, XkbIndicatorStateNotify, &in);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
if (pChanges->names.changed) {
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbNamesNotify nn;
|
|
|
|
|
|
|
|
memset(&nn, 0, sizeof(xkbNamesNotify));
|
|
|
|
nn.changed = pChanges->names.changed;
|
|
|
|
nn.firstType = pChanges->names.first_type;
|
|
|
|
nn.nTypes = pChanges->names.num_types;
|
|
|
|
nn.firstLevelName = pChanges->names.first_lvl;
|
|
|
|
nn.nLevelNames = pChanges->names.num_lvls;
|
|
|
|
nn.nRadioGroups = pChanges->names.num_rg;
|
|
|
|
nn.changedVirtualMods = pChanges->names.changed_vmods;
|
|
|
|
nn.changedIndicators = pChanges->names.changed_indicators;
|
|
|
|
XkbSendNamesNotify(kbd, &nn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((pChanges->compat.changed_groups) || (pChanges->compat.num_si > 0)) {
|
|
|
|
xkbCompatMapNotify cmn;
|
|
|
|
|
|
|
|
memset(&cmn, 0, sizeof(xkbCompatMapNotify));
|
|
|
|
cmn.changedGroups = pChanges->compat.changed_groups;
|
|
|
|
cmn.firstSI = pChanges->compat.first_si;
|
|
|
|
cmn.nSI = pChanges->compat.num_si;
|
|
|
|
cmn.nTotalSI = kbd->key->xkbInfo->desc->compat->num_si;
|
|
|
|
XkbSendCompatMapNotify(kbd, &cmn);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
void
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbFilterEvents(ClientPtr client, int nEvents, xEvent *xE)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2010-07-27 13:02:24 -06:00
|
|
|
DeviceIntPtr dev = NULL;
|
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
CARD8 type = xE[0].u.u.type;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2009-09-06 13:44:18 -06:00
|
|
|
if (xE->u.u.type & EXTENSION_EVENT_BASE)
|
2010-07-27 13:02:24 -06:00
|
|
|
dev = XIGetDevice(xE);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!dev)
|
|
|
|
dev = PickKeyboard(client);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (!dev->key)
|
|
|
|
return;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
xkbi = dev->key->xkbInfo;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
if (client->xkbClientFlags & _XkbClientInitialized) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if ((xkbDebugFlags & 0x10) &&
|
2010-07-27 13:02:24 -06:00
|
|
|
(type == KeyPress || type == KeyRelease ||
|
|
|
|
type == DeviceKeyPress || type == DeviceKeyRelease))
|
2012-06-10 07:21:05 -06:00
|
|
|
DebugF("[xkb] XkbFilterWriteEvents (XKB client): state 0x%04x\n",
|
2010-07-27 13:02:24 -06:00
|
|
|
xE[0].u.keyButtonPointer.state);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
if (dev->deviceGrab.grab != NullGrab && dev->deviceGrab.fromPassiveGrab
|
|
|
|
&& (type == KeyPress || type == KeyRelease || type == DeviceKeyPress
|
|
|
|
|| type == DeviceKeyRelease)) {
|
|
|
|
unsigned int state, flags;
|
|
|
|
|
|
|
|
flags = client->xkbClientFlags;
|
|
|
|
state = xkbi->state.compat_grab_mods;
|
|
|
|
if (flags & XkbPCF_GrabsUseXKBStateMask) {
|
|
|
|
int group;
|
|
|
|
|
|
|
|
if (flags & XkbPCF_LookupStateWhenGrabbed) {
|
|
|
|
group = xkbi->state.group;
|
|
|
|
state = xkbi->state.lookup_mods;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
state = xkbi->state.grab_mods;
|
|
|
|
group = xkbi->state.base_group + xkbi->state.latched_group;
|
|
|
|
if (group < 0 || group >= xkbi->desc->ctrls->num_groups)
|
|
|
|
group = XkbAdjustGroup(group, xkbi->desc->ctrls);
|
|
|
|
}
|
|
|
|
state = XkbBuildCoreState(state, group);
|
|
|
|
}
|
|
|
|
else if (flags & XkbPCF_LookupStateWhenGrabbed) {
|
|
|
|
state = xkbi->state.compat_lookup_mods;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
xE[0].u.keyButtonPointer.state = state;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
else {
|
2010-07-27 13:02:24 -06:00
|
|
|
if ((xkbDebugFlags & 0x4) &&
|
2012-06-10 07:21:05 -06:00
|
|
|
(xE[0].u.u.type == KeyPress || xE[0].u.u.type == KeyRelease ||
|
2010-07-27 13:02:24 -06:00
|
|
|
xE[0].u.u.type == DeviceKeyPress ||
|
|
|
|
xE[0].u.u.type == DeviceKeyRelease)) {
|
2012-06-10 07:21:05 -06:00
|
|
|
DebugF("[xkb] XKbFilterWriteEvents (non-XKB):\n");
|
|
|
|
DebugF("[xkb] event= 0x%04x\n", xE[0].u.keyButtonPointer.state);
|
|
|
|
DebugF("[xkb] lookup= 0x%02x, grab= 0x%02x\n",
|
2010-07-27 13:02:24 -06:00
|
|
|
xkbi->state.lookup_mods, xkbi->state.grab_mods);
|
2012-06-10 07:21:05 -06:00
|
|
|
DebugF("[xkb] compat lookup= 0x%02x, grab= 0x%02x\n",
|
|
|
|
xkbi->state.compat_lookup_mods,
|
|
|
|
xkbi->state.compat_grab_mods);
|
|
|
|
}
|
|
|
|
if (type >= KeyPress && type <= MotionNotify) {
|
|
|
|
CARD16 old, new;
|
|
|
|
|
|
|
|
old = xE[0].u.keyButtonPointer.state & ~0x1f00;
|
|
|
|
new = xE[0].u.keyButtonPointer.state & 0x1F00;
|
|
|
|
|
|
|
|
if (old == XkbStateFieldFromRec(&xkbi->state))
|
|
|
|
new |= xkbi->state.compat_lookup_mods;
|
|
|
|
else
|
2010-07-27 13:02:24 -06:00
|
|
|
new |= xkbi->state.compat_grab_mods;
|
2012-06-10 07:21:05 -06:00
|
|
|
xE[0].u.keyButtonPointer.state = new;
|
|
|
|
}
|
|
|
|
else if (type == EnterNotify || type == LeaveNotify) {
|
|
|
|
xE[0].u.enterLeave.state &= 0x1F00;
|
|
|
|
xE[0].u.enterLeave.state |= xkbi->state.compat_grab_mods;
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (type >= DeviceKeyPress && type <= DeviceMotionNotify) {
|
|
|
|
CARD16 old, new;
|
2012-06-10 07:21:05 -06:00
|
|
|
deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) &xE[0];
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
old = kbp->state & ~0x1F00;
|
|
|
|
new = kbp->state & 0x1F00;
|
2012-06-10 07:21:05 -06:00
|
|
|
if (old == XkbStateFieldFromRec(&xkbi->state))
|
|
|
|
new |= xkbi->state.compat_lookup_mods;
|
|
|
|
else
|
2010-07-27 13:02:24 -06:00
|
|
|
new |= xkbi->state.compat_grab_mods;
|
|
|
|
kbp->state = new;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***====================================================================***/
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbInterestPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbFindClientResource(DevicePtr inDev, ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev = (DeviceIntPtr) inDev;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
|
|
|
|
if (dev->xkb_interest) {
|
|
|
|
interest = dev->xkb_interest;
|
|
|
|
while (interest) {
|
|
|
|
if (interest->client == client) {
|
|
|
|
return interest;
|
|
|
|
}
|
|
|
|
interest = interest->next;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
XkbInterestPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbAddClientResource(DevicePtr inDev, ClientPtr client, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
DeviceIntPtr dev = (DeviceIntPtr) inDev;
|
|
|
|
XkbInterestPtr interest;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
interest = dev->xkb_interest;
|
|
|
|
while (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
if (interest->client == client)
|
|
|
|
return ((interest->resource == id) ? interest : NULL);
|
|
|
|
interest = interest->next;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
interest = calloc(1, sizeof(XkbInterestRec));
|
2006-11-26 11:13:41 -07:00
|
|
|
if (interest) {
|
2012-06-10 07:21:05 -06:00
|
|
|
interest->dev = dev;
|
|
|
|
interest->client = client;
|
|
|
|
interest->resource = id;
|
|
|
|
interest->next = dev->xkb_interest;
|
|
|
|
dev->xkb_interest = interest;
|
|
|
|
return interest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbRemoveResourceClient(DevicePtr inDev, XID id)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2012-06-10 07:21:05 -06:00
|
|
|
XkbSrvInfoPtr xkbi;
|
|
|
|
DeviceIntPtr dev = (DeviceIntPtr) inDev;
|
|
|
|
XkbInterestPtr interest;
|
|
|
|
Bool found;
|
|
|
|
unsigned long autoCtrls, autoValues;
|
|
|
|
ClientPtr client = NULL;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
found = FALSE;
|
2009-01-12 13:17:47 -07:00
|
|
|
|
|
|
|
if (!dev->key || !dev->key->xkbInfo)
|
|
|
|
return found;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
autoCtrls = autoValues = 0;
|
|
|
|
if (dev->xkb_interest) {
|
|
|
|
interest = dev->xkb_interest;
|
|
|
|
if (interest && (interest->resource == id)) {
|
|
|
|
dev->xkb_interest = interest->next;
|
|
|
|
autoCtrls = interest->autoCtrls;
|
|
|
|
autoValues = interest->autoCtrlValues;
|
|
|
|
client = interest->client;
|
|
|
|
free(interest);
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
while ((!found) && (interest->next)) {
|
|
|
|
if (interest->next->resource == id) {
|
|
|
|
XkbInterestPtr victim = interest->next;
|
|
|
|
|
|
|
|
interest->next = victim->next;
|
|
|
|
autoCtrls = victim->autoCtrls;
|
|
|
|
autoValues = victim->autoCtrlValues;
|
|
|
|
client = victim->client;
|
|
|
|
free(victim);
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
interest = interest->next;
|
|
|
|
}
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2012-06-10 07:21:05 -06:00
|
|
|
if (found && autoCtrls && dev->key && dev->key->xkbInfo) {
|
|
|
|
XkbEventCauseRec cause;
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
xkbi = dev->key->xkbInfo;
|
|
|
|
XkbSetCauseXkbReq(&cause, X_kbPerClientFlags, client);
|
|
|
|
XkbEnableDisableControls(xkbi, autoCtrls, autoValues, NULL, &cause);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
return found;
|
|
|
|
}
|