add support for horizontal scrolling (buttons 6 and 7)
(cherry picked from commit f525a4a432ebd0545ad1dd0a7ad84ad3e47e8b61)
This commit is contained in:
parent
612e901ef6
commit
a440eebf25
|
@ -899,7 +899,7 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSScrollWheel:
|
case NSScrollWheel:
|
||||||
DarwinSendScrollEvents([e deltaY], pointer_x, pointer_y,
|
DarwinSendScrollEvents([e deltaX], [e deltaY], pointer_x, pointer_y,
|
||||||
pressure, tilt_x, tilt_y);
|
pressure, tilt_x, tilt_y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ static int DarwinMouseProc(
|
||||||
DeviceIntPtr pPointer,
|
DeviceIntPtr pPointer,
|
||||||
int what )
|
int what )
|
||||||
{
|
{
|
||||||
CARD8 map[6];
|
CARD8 map[8] = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||||
|
|
||||||
switch (what) {
|
switch (what) {
|
||||||
|
|
||||||
|
@ -345,15 +345,10 @@ static int DarwinMouseProc(
|
||||||
pPointer->public.on = FALSE;
|
pPointer->public.on = FALSE;
|
||||||
|
|
||||||
// Set button map.
|
// Set button map.
|
||||||
map[1] = 1;
|
InitPointerDeviceStruct( (DevicePtr)pPointer, map, 7,
|
||||||
map[2] = 2;
|
|
||||||
map[3] = 3;
|
|
||||||
map[4] = 4;
|
|
||||||
map[5] = 5;
|
|
||||||
InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
|
|
||||||
GetMotionHistory,
|
GetMotionHistory,
|
||||||
(PtrCtrlProcPtr)NoopDDA,
|
(PtrCtrlProcPtr)NoopDDA,
|
||||||
GetMotionHistorySize(), 5);
|
GetMotionHistorySize(), 7);
|
||||||
InitProximityClassDeviceStruct( (DevicePtr)pPointer);
|
InitProximityClassDeviceStruct( (DevicePtr)pPointer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Darwin event queue and event handling
|
Darwin event queue and event handling
|
||||||
|
|
||||||
Copyright 2007 Apple Inc.
|
Copyright 2007-2008 Apple Inc.
|
||||||
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
|
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
|
||||||
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
|
Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
|
||||||
|
|
||||||
|
@ -56,6 +56,12 @@ in this Software without prior written authorization from The Open Group.
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <IOKit/hidsystem/IOLLEvent.h>
|
#include <IOKit/hidsystem/IOLLEvent.h>
|
||||||
|
|
||||||
|
/* Fake button press/release for scroll wheel move. */
|
||||||
|
#define SCROLLWHEELUPFAKE 4
|
||||||
|
#define SCROLLWHEELDOWNFAKE 5
|
||||||
|
#define SCROLLWHEELLEFTFAKE 6
|
||||||
|
#define SCROLLWHEELRIGHTFAKE 7
|
||||||
|
|
||||||
#define _APPLEWM_SERVER_
|
#define _APPLEWM_SERVER_
|
||||||
#include "applewmExt.h"
|
#include "applewmExt.h"
|
||||||
#include <X11/extensions/applewm.h>
|
#include <X11/extensions/applewm.h>
|
||||||
|
@ -65,10 +71,6 @@ in this Software without prior written authorization from The Open Group.
|
||||||
#include "rootlessWindow.h"
|
#include "rootlessWindow.h"
|
||||||
WindowPtr xprGetXWindow(xp_window_id wid);
|
WindowPtr xprGetXWindow(xp_window_id wid);
|
||||||
|
|
||||||
/* Fake button press/release for scroll wheel move. */
|
|
||||||
#define SCROLLWHEELUPFAKE 4
|
|
||||||
#define SCROLLWHEELDOWNFAKE 5
|
|
||||||
|
|
||||||
int input_check_zero, input_check_flag;
|
int input_check_zero, input_check_flag;
|
||||||
|
|
||||||
static int old_flags = 0; // last known modifier state
|
static int old_flags = 0; // last known modifier state
|
||||||
|
@ -452,30 +454,32 @@ void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Send the appropriate number of button 4 / 5 clicks to emulate scroll wheel */
|
/* Send the appropriate number of button clicks to emulate scroll wheel */
|
||||||
void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
|
void DarwinSendScrollEvents(float count_x, float count_y,
|
||||||
float pressure, float tilt_x, float tilt_y) {
|
int pointer_x, int pointer_y,
|
||||||
int i;
|
float pressure, float tilt_x, float tilt_y) {
|
||||||
int ev_button = count > 0.0f ? 4 : 5;
|
|
||||||
int valuators[5] = {pointer_x, pointer_y,
|
|
||||||
pressure * INT32_MAX * 1.0f,
|
|
||||||
tilt_x * INT32_MAX * 1.0f,
|
|
||||||
tilt_y * INT32_MAX * 1.0f};
|
|
||||||
|
|
||||||
if(!darwinEvents) {
|
if(!darwinEvents) {
|
||||||
ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
|
ErrorF("DarwinSendScrollEvents called before darwinEvents was initialized\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ErrorF("scroll(%f, %f)\n", count_x, count_y);
|
||||||
for (count = fabs(count); count > 0.0; count = count - 1.0f) {
|
int sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
|
||||||
int num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonPress, ev_button,
|
int sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
|
||||||
POINTER_ABSOLUTE, 0, 5, valuators);
|
count_x = fabs(count_x);
|
||||||
for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
|
count_y = fabs(count_y);
|
||||||
num_events = GetPointerEvents(darwinEvents, darwinPointer, ButtonRelease, ev_button,
|
|
||||||
POINTER_ABSOLUTE, 0, 5, valuators);
|
while ((count_x > 0.0f) || (count_y > 0.0f)) {
|
||||||
for(i=0; i<num_events; i++) mieqEnqueue(darwinPointer,&darwinEvents[i]);
|
if (count_x > 0.0f) {
|
||||||
}
|
DarwinSendPointerEvents(ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
DarwinPokeEQ();
|
DarwinSendPointerEvents(ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
|
count_x = count_x - 1.0f;
|
||||||
|
}
|
||||||
|
if (count_y > 0.0f) {
|
||||||
|
DarwinSendPointerEvents(ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
|
DarwinSendPointerEvents(ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
|
||||||
|
count_y = count_y - 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
|
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
|
||||||
|
|
|
@ -38,7 +38,7 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
|
||||||
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
void DarwinSendProximityEvents(int ev_type, int pointer_x, int pointer_y,
|
||||||
float pressure, float tilt_x, float tilt_y);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
void DarwinSendKeyboardEvents(int ev_type, int keycode);
|
void DarwinSendKeyboardEvents(int ev_type, int keycode);
|
||||||
void DarwinSendScrollEvents(float count, int pointer_x, int pointer_y,
|
void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
|
||||||
float pressure, float tilt_x, float tilt_y);
|
float pressure, float tilt_x, float tilt_y);
|
||||||
void DarwinUpdateModKeys(int flags);
|
void DarwinUpdateModKeys(int flags);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue