mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
xkb: ProcXGetDeviceKeyMapping(): use x_rpcbuf_t
Using x_rpcbuf_t for payload assembly and byte swapping. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
7d8d609121
commit
946eb68ff3
35
Xi/getkmap.c
35
Xi/getkmap.c
@@ -52,9 +52,13 @@ SOFTWARE.
|
||||
|
||||
#include <dix-config.h>
|
||||
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include <X11/extensions/XI.h>
|
||||
#include <X11/extensions/XIproto.h>
|
||||
|
||||
#include "dix/dix_priv.h"
|
||||
#include "dix/rpcbuf_priv.h"
|
||||
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include "exglobals.h"
|
||||
#include "swaprep.h"
|
||||
#include "xkbsrv.h"
|
||||
@@ -101,27 +105,36 @@ ProcXGetDeviceKeyMapping(ClientPtr client)
|
||||
if (!syms)
|
||||
return BadAlloc;
|
||||
|
||||
const size_t mapWidth = syms->mapWidth;
|
||||
const size_t numKeySyms = (mapWidth * stuff->count);
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
x_rpcbuf_write_CARD32s(
|
||||
&rpcbuf,
|
||||
&syms->map[mapWidth * (stuff->firstKeyCode - syms->minKeyCode)],
|
||||
numKeySyms);
|
||||
|
||||
free(syms->map);
|
||||
free(syms);
|
||||
|
||||
if (rpcbuf.error)
|
||||
return BadAlloc;
|
||||
|
||||
xGetDeviceKeyMappingReply rep = {
|
||||
.repType = X_Reply,
|
||||
.RepType = X_GetDeviceKeyMapping,
|
||||
.sequenceNumber = client->sequence,
|
||||
.keySymsPerKeyCode = syms->mapWidth,
|
||||
.length = (syms->mapWidth * stuff->count) /* KeySyms are 4 bytes */
|
||||
.keySymsPerKeyCode = mapWidth,
|
||||
.length = numKeySyms /* KeySyms are 4 bytes */
|
||||
};
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
swapl(&rep.length);
|
||||
}
|
||||
WriteToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
|
||||
|
||||
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
|
||||
WriteSwappedDataToClient(client,
|
||||
syms->mapWidth * stuff->count * sizeof(KeySym),
|
||||
&syms->map[syms->mapWidth * (stuff->firstKeyCode -
|
||||
syms->minKeyCode)]);
|
||||
free(syms->map);
|
||||
free(syms);
|
||||
WriteToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep);
|
||||
WriteRpcbufToClient(client, &rpcbuf);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user