~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to Xi/grabdevb.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: grabdevb.c,v 1.4 2001/02/09 02:04:34 xorgcvs Exp $ */
 
2
 
 
3
/************************************************************
 
4
 
 
5
Copyright 1989, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
 
28
 
 
29
                        All Rights Reserved
 
30
 
 
31
Permission to use, copy, modify, and distribute this software and its
 
32
documentation for any purpose and without fee is hereby granted,
 
33
provided that the above copyright notice appear in all copies and that
 
34
both that copyright notice and this permission notice appear in
 
35
supporting documentation, and that the name of Hewlett-Packard not be
 
36
used in advertising or publicity pertaining to distribution of the
 
37
software without specific, written prior permission.
 
38
 
 
39
HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
40
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
41
HEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
42
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
43
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
44
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
45
SOFTWARE.
 
46
 
 
47
********************************************************/
 
48
/* $XFree86: xc/programs/Xserver/Xi/grabdevb.c,v 3.2 2001/01/17 22:13:25 dawes Exp $ */
 
49
 
 
50
/***********************************************************************
 
51
 *
 
52
 * Extension function to grab a button on an extension device.
 
53
 *
 
54
 */
 
55
 
 
56
#define  NEED_EVENTS
 
57
#define  NEED_REPLIES
 
58
#ifdef HAVE_DIX_CONFIG_H
 
59
#include <dix-config.h>
 
60
#endif
 
61
 
 
62
#include <X11/X.h>                              /* for inputstr.h    */
 
63
#include <X11/Xproto.h>                 /* Request macro     */
 
64
#include "inputstr.h"                   /* DeviceIntPtr      */
 
65
#include "windowstr.h"                  /* window structure  */
 
66
#include <X11/extensions/XI.h>
 
67
#include <X11/extensions/XIproto.h>
 
68
#include "exevents.h"
 
69
#include "extnsionst.h"
 
70
#include "extinit.h"                    /* LookupDeviceIntRec */
 
71
#include "exglobals.h"
 
72
 
 
73
#include "grabdev.h"
 
74
#include "grabdevb.h"
 
75
 
 
76
/***********************************************************************
 
77
 *
 
78
 * Handle requests from clients with a different byte order.
 
79
 *
 
80
 */
 
81
 
 
82
int
 
83
SProcXGrabDeviceButton(client)
 
84
    register ClientPtr client;
 
85
    {
 
86
    register char n;
 
87
    register long *p;
 
88
    register int i;
 
89
 
 
90
    REQUEST(xGrabDeviceButtonReq);
 
91
    swaps(&stuff->length, n);
 
92
    REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
 
93
    swapl(&stuff->grabWindow, n);
 
94
    swaps(&stuff->modifiers, n);
 
95
    swaps(&stuff->event_count, n);
 
96
    p = (long *) &stuff[1];
 
97
    for (i=0; i<stuff->event_count; i++)
 
98
        {
 
99
        swapl(p, n);
 
100
        p++;
 
101
        }
 
102
 
 
103
    return(ProcXGrabDeviceButton(client));
 
104
    }
 
105
 
 
106
/***********************************************************************
 
107
 *
 
108
 * Grab a button on an extension device.
 
109
 *
 
110
 */
 
111
 
 
112
int
 
113
ProcXGrabDeviceButton(client)
 
114
    ClientPtr client;
 
115
    {
 
116
    int                 ret;
 
117
    DeviceIntPtr        dev;
 
118
    DeviceIntPtr        mdev;
 
119
    XEventClass         *class;
 
120
    struct tmask        tmp[EMASKSIZE];
 
121
 
 
122
    REQUEST(xGrabDeviceButtonReq);
 
123
    REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq);
 
124
 
 
125
    if (stuff->length !=(sizeof(xGrabDeviceButtonReq)>>2) + stuff->event_count)
 
126
        {
 
127
        SendErrorToClient (client, IReqCode, X_GrabDeviceButton, 0, BadLength);
 
128
        return Success;
 
129
        }
 
130
 
 
131
    dev = LookupDeviceIntRec (stuff->grabbed_device);
 
132
    if (dev == NULL)
 
133
        {
 
134
        SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, 
 
135
            BadDevice);
 
136
        return Success;
 
137
        }
 
138
    if (stuff->modifier_device != UseXKeyboard)
 
139
        {
 
140
        mdev = LookupDeviceIntRec (stuff->modifier_device);
 
141
        if (mdev == NULL)
 
142
            {
 
143
            SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, 
 
144
                BadDevice);
 
145
            return Success;
 
146
            }
 
147
        if (mdev->key == NULL)
 
148
            {
 
149
            SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, 
 
150
                BadMatch);
 
151
            return Success;
 
152
            }
 
153
        }
 
154
    else
 
155
        mdev = (DeviceIntPtr) LookupKeyboardDevice();
 
156
 
 
157
    class = (XEventClass *) (&stuff[1]);        /* first word of values */
 
158
 
 
159
    if ((ret = CreateMaskFromList (client, class,
 
160
        stuff->event_count, tmp, dev, X_GrabDeviceButton)) != Success)
 
161
            return Success;
 
162
    ret = GrabButton(client, dev, stuff->this_device_mode, 
 
163
        stuff->other_devices_mode, stuff->modifiers, mdev, stuff->button, 
 
164
        stuff->grabWindow, stuff->ownerEvents, (Cursor)0, (Window)0, 
 
165
        tmp[stuff->grabbed_device].mask);
 
166
 
 
167
    if (ret != Success)
 
168
        SendErrorToClient(client, IReqCode, X_GrabDeviceButton, 0, ret);
 
169
    return(Success);
 
170
    }