Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xnest / Pointer.c
CommitLineData
a09e091a
JB
1/*
2
3Copyright 1993 by Davor Matic
4
5Permission to use, copy, modify, distribute, and sell this software
6and its documentation for any purpose is hereby granted without fee,
7provided that the above copyright notice appear in all copies and that
8both that copyright notice and this permission notice appear in
9supporting documentation. Davor Matic makes no representations about
10the suitability of this software for any purpose. It is provided "as
11is" without express or implied warranty.
12
13*/
14
15#ifdef HAVE_XNEST_CONFIG_H
16#include <xnest-config.h>
17#endif
18
19#include <X11/X.h>
20#include <X11/Xproto.h>
21#include "screenint.h"
22#include "inputstr.h"
23#include "input.h"
24#include "misc.h"
25#include "scrnintstr.h"
26#include "servermd.h"
27#include "mipointer.h"
28
29#include "Xnest.h"
30
31#include "Display.h"
32#include "Screen.h"
33#include "Pointer.h"
34#include "Args.h"
35
36#include "xserver-properties.h"
37#include "exevents.h" /* For XIGetKnownProperty */
38
39DeviceIntPtr xnestPointerDevice = NULL;
40
41void
42xnestChangePointerControl(DeviceIntPtr pDev, PtrCtrl * ctrl)
43{
44 XChangePointerControl(xnestDisplay, True, True,
45 ctrl->num, ctrl->den, ctrl->threshold);
46}
47
48int
49xnestPointerProc(DeviceIntPtr pDev, int onoff)
50{
51 CARD8 map[MAXBUTTONS];
52 Atom btn_labels[MAXBUTTONS] = { 0 };
53 Atom axes_labels[2] = { 0 };
54 int nmap;
55 int i;
56
57 switch (onoff) {
58 case DEVICE_INIT:
59 nmap = XGetPointerMapping(xnestDisplay, map, MAXBUTTONS);
60 for (i = 0; i <= nmap; i++)
61 map[i] = i; /* buttons are already mapped */
62
63 btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
64 btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
65 btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
66 btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
67 btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
68 btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
69 btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
70
71 axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
72 axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
73
74 XGetPointerControl(xnestDisplay,
75 &defaultPointerControl.num,
76 &defaultPointerControl.den,
77 &defaultPointerControl.threshold);
78 InitPointerDeviceStruct(&pDev->public, map, nmap, btn_labels,
79 xnestChangePointerControl,
80 GetMotionHistorySize(), 2, axes_labels);
81 break;
82 case DEVICE_ON:
83 xnestEventMask |= XNEST_POINTER_EVENT_MASK;
84 for (i = 0; i < xnestNumScreens; i++)
85 XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
86 break;
87 case DEVICE_OFF:
88 xnestEventMask &= ~XNEST_POINTER_EVENT_MASK;
89 for (i = 0; i < xnestNumScreens; i++)
90 XSelectInput(xnestDisplay, xnestDefaultWindows[i], xnestEventMask);
91 break;
92 case DEVICE_CLOSE:
93 break;
94 }
95 return Success;
96}