summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-10-02 12:44:25 +0000
committerAlexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>2004-10-02 12:44:25 +0000
commit902b64bbf5dfeb8e16ea6088c00acf64ad8f6152 (patch)
treec56db2cef53afbabaf2b58d444c7892274a5b853 /hw
parent5162b87e9fd3f2e49d78dd52f69603204c9e7b11 (diff)
Make sure buttons 1-3 are mouse buttons and wheel events are 4-5 Document
code Replace ErrorF with appropriate winMsg use a symbolic name for the wheel event offset
Diffstat (limited to 'hw')
-rw-r--r--hw/xwin/ChangeLog8
-rw-r--r--hw/xwin/winmouse.c28
2 files changed, 31 insertions, 5 deletions
diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog
index 9ddb0eb8e..2e3dd19a8 100644
--- a/hw/xwin/ChangeLog
+++ b/hw/xwin/ChangeLog
@@ -1,3 +1,11 @@
+2004-10-02 Alexander Gottwald <ago at freedesktop dot org>
+
+ * winmouse.c (winMouseProc):
+ Make sure buttons 1-3 are mouse buttons and wheel events are 4-5
+ Document code
+ Replace ErrorF with appropriate winMsg
+ use a symbolic name for the wheel event offset
+
2004-10-01 Alexander Gottwald <ago at freedesktop dot org>
* wincreatewnd.c (winCreateBoundingWindowWindowed):
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 6411d7989..93b38acd4 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -65,21 +65,39 @@ int
winMouseProc (DeviceIntPtr pDeviceInt, int iState)
{
int lngMouseButtons, i;
+ int lngWheelEvents = 2;
CARD8 *map;
DevicePtr pDevice = (DevicePtr) pDeviceInt;
switch (iState)
{
case DEVICE_INIT:
+ /* Get number of mouse buttons */
lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
- ErrorF ("%d mouse buttons found\n", lngMouseButtons);
- map = malloc(sizeof(CARD8) * (lngMouseButtons + 1 + 2));
-
- for (i=1; i <= lngMouseButtons + 2; i++)
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+ winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons);
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
map[i] = i;
InitPointerDeviceStruct (pDevice,
map,
- lngMouseButtons + 2, /* Buttons 4 and 5 are mouse wheel events */
+ lngMouseButtons + lngWheelEvents,
miPointerGetMotionEvents,
winMouseCtrl,
miPointerGetMotionBufferSize ());