2 * Copyright 2008 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
23 * Author: Peter Hutterer
25 /***********************************************************************
27 * Request to set and get an input device's focus.
31 #ifdef HAVE_DIX_CONFIG_H
32 #include <dix-config.h>
35 #include "inputstr.h" /* DeviceIntPtr */
36 #include "windowstr.h" /* window structure */
37 #include <X11/extensions/XI2.h>
38 #include <X11/extensions/XI2proto.h>
40 #include "exglobals.h" /* BadDevice */
41 #include "xisetdevfocus.h"
44 SProcXISetFocus(ClientPtr client
)
46 REQUEST(xXISetFocusReq
);
47 swaps(&stuff
->length
);
48 swaps(&stuff
->deviceid
);
52 return ProcXISetFocus(client
);
56 SProcXIGetFocus(ClientPtr client
)
58 REQUEST(xXIGetFocusReq
);
59 swaps(&stuff
->length
);
60 swaps(&stuff
->deviceid
);
62 return ProcXIGetFocus(client
);
66 ProcXISetFocus(ClientPtr client
)
71 REQUEST(xXISetFocusReq
);
72 REQUEST_AT_LEAST_SIZE(xXISetFocusReq
);
74 ret
= dixLookupDevice(&dev
, stuff
->deviceid
, client
, DixSetFocusAccess
);
80 return SetInputFocus(client
, dev
, stuff
->focus
, RevertToParent
,
85 ProcXIGetFocus(ClientPtr client
)
91 REQUEST(xXIGetFocusReq
);
92 REQUEST_AT_LEAST_SIZE(xXIGetFocusReq
);
94 ret
= dixLookupDevice(&dev
, stuff
->deviceid
, client
, DixGetFocusAccess
);
100 rep
= (xXIGetFocusReply
) {
102 .RepType
= X_XIGetFocus
,
103 .sequenceNumber
= client
->sequence
,
107 if (dev
->focus
->win
== NoneWin
)
109 else if (dev
->focus
->win
== PointerRootWin
)
110 rep
.focus
= PointerRoot
;
111 else if (dev
->focus
->win
== FollowKeyboardWin
)
112 rep
.focus
= FollowKeyboard
;
114 rep
.focus
= dev
->focus
->win
->drawable
.id
;
116 WriteReplyToClient(client
, sizeof(xXIGetFocusReply
), &rep
);
121 SRepXIGetFocus(ClientPtr client
, int len
, xXIGetFocusReply
* rep
)
123 swaps(&rep
->sequenceNumber
);
126 WriteToClient(client
, len
, rep
);