XQuartz: Separate out tablet and mouse event delivery into separate functions

This should have no immediate impact aside from fake mouse buttons no longer
working with tablets (where they aren't needed or desired anyways).  This
prepares us for future changes.
Signed-off-by: Jeremy Huddleston Sequoia's avatarJeremy Huddleston <jeremyhu@apple.com>
(cherry picked from commit b99586c9)
parent 72226dc4
......@@ -214,9 +214,7 @@ message_kit_thread(SEL selector, NSObject *arg)
if (state) {
if (bgMouseLocationUpdated) {
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
bgMouseLocation.x, bgMouseLocation.y, 0.0,
0.0,
0.0);
bgMouseLocation.x, bgMouseLocation.y);
bgMouseLocationUpdated = FALSE;
}
DarwinSendDDXEvent(kXquartzActivate, 0);
......@@ -1501,9 +1499,9 @@ handle_mouse:
if ([e isEnteringProximity])
needsProximityIn = YES;
else
DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
location.x, location.y, pressure,
tilt.x, tilt.y);
DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0,
location.x, location.y, pressure,
tilt.x, tilt.y);
return;
}
......@@ -1515,9 +1513,9 @@ handle_mouse:
pDev = darwinTabletCurrent;
if (needsProximityIn) {
DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
location.x, location.y, pressure,
tilt.x, tilt.y);
DarwinSendTabletEvents(darwinTabletCurrent, ProximityIn, 0,
location.x, location.y, pressure,
tilt.x, tilt.y);
needsProximityIn = NO;
}
......@@ -1548,14 +1546,20 @@ handle_mouse:
if (bgMouseLocationUpdated) {
if (!(ev_type == MotionNotify && ev_button == 0)) {
DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x,
location.y, pressure, tilt.x, tilt.y);
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
location.x, location.y);
}
bgMouseLocationUpdated = FALSE;
}
DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x,
location.y, pressure, tilt.x, tilt.y);
if (pDev == darwinPointer) {
DarwinSendPointerEvents(pDev, ev_type, ev_button,
location.x, location.y);
} else {
DarwinSendTabletEvents(pDev, ev_type, ev_button,
location.x, location.y, pressure,
tilt.x, tilt.y);
}
break;
......@@ -1579,9 +1583,9 @@ handle_mouse:
if ([e isEnteringProximity])
needsProximityIn = YES;
else
DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
location.x, location.y, pressure,
tilt.x, tilt.y);
DarwinSendTabletEvents(darwinTabletCurrent, ProximityOut, 0,
location.x, location.y, pressure,
tilt.x, tilt.y);
break;
case NSScrollWheel:
......@@ -1595,8 +1599,7 @@ handle_mouse:
if (!XQuartzServerVisible && noTestExtensions) {
bgMouseLocationUpdated = FALSE;
DarwinSendPointerEvents(darwinPointer, MotionNotify, 0,
location.x, location.y, pressure,
tilt.x, tilt.y);
location.x, location.y);
}
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
......
......@@ -44,19 +44,20 @@
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "inputstr.h"
#include "inpututils.h"
#include "eventstr.h"
#include "mi.h"
#include "scrnintstr.h"
#include "mipointer.h"
#include "os.h"
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "inputstr.h"
#include "inpututils.h"
#include "eventstr.h"
#include "mi.h"
#include "scrnintstr.h"
#include "mipointer.h"
#include "os.h"
#include "exglobals.h"
#include "darwin.h"
#include "quartz.h"
......@@ -442,56 +443,6 @@ DarwinPokeEQ(void)
write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
}
/* Convert from Appkit pointer input values to X input values:
* Note: pointer_x and pointer_y are relative to the upper-left of primary
* display.
*/
static void
DarwinPrepareValuators(DeviceIntPtr pDev, ValuatorMask *pmask,
ScreenPtr screen,
double pointer_x, double pointer_y,
double pressure, double tilt_x,
double tilt_y)
{
valuator_mask_zero(pmask);
/* Fix offset between darwin and X screens */
pointer_x -= darwinMainScreenX + screen->x;
pointer_y -= darwinMainScreenY + screen->y;
if (pointer_x < 0.0)
pointer_x = 0.0;
if (pointer_y < 0.0)
pointer_y = 0.0;
if (pDev == darwinPointer) {
valuator_mask_set_double(pmask, 0, pointer_x);
valuator_mask_set_double(pmask, 1, pointer_y);
}
else {
valuator_mask_set_double(pmask, 0, XQUARTZ_VALUATOR_LIMIT *
(pointer_x /
(double)screenInfo.screens[0]->width));
valuator_mask_set_double(pmask, 1, XQUARTZ_VALUATOR_LIMIT *
(pointer_y /
(double)screenInfo.screens[0]->height));
valuator_mask_set_double(pmask, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
valuator_mask_set_double(pmask, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
valuator_mask_set_double(pmask, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y);
DEBUG_LOG("Pointer (%lf, %lf), Valuators: {%lf,%lf,%lf,%lf,%lf}\n",
pointer_x, pointer_y,
valuator_mask_get_double(pmask,
0),
valuator_mask_get_double(pmask, 1),
valuator_mask_get_double(pmask,
2),
valuator_mask_get_double(pmask, 3),
valuator_mask_get_double(pmask, 4));
}
}
void
DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
{
......@@ -520,28 +471,79 @@ DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
} darwinEvents_unlock();
}
void
DarwinSendTabletEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y,
double pressure, double tilt_x,
double tilt_y)
{
ScreenPtr screen;
ValuatorMask valuators;
if (!darwinEvents) {
DEBUG_LOG("%s called before darwinEvents was initialized\n",
__FUNCTION__);
return;
}
screen = miPointerGetScreen(pDev);
if (!screen) {
DEBUG_LOG("%s called before screen was initialized\n",
__FUNCTION__);
return;
}
/* Fix offset between darwin and X screens */
pointer_x -= darwinMainScreenX + screen->x;
pointer_y -= darwinMainScreenY + screen->y;
if (pointer_x < 0.0)
pointer_x = 0.0;
if (pointer_y < 0.0)
pointer_y = 0.0;
/* Adjust our pointer location to the [0,1] range */
pointer_x = pointer_x / (double)screenInfo.screens[0]->width;
pointer_y = pointer_y / (double)screenInfo.screens[0]->height;
valuator_mask_zero(&valuators);
valuator_mask_set_double(&valuators, 0, XQUARTZ_VALUATOR_LIMIT * pointer_x);
valuator_mask_set_double(&valuators, 1, XQUARTZ_VALUATOR_LIMIT * pointer_y);
valuator_mask_set_double(&valuators, 2, XQUARTZ_VALUATOR_LIMIT * pressure);
valuator_mask_set_double(&valuators, 3, XQUARTZ_VALUATOR_LIMIT * tilt_x);
valuator_mask_set_double(&valuators, 4, XQUARTZ_VALUATOR_LIMIT * tilt_y);
darwinEvents_lock();
{
if (ev_type == ProximityIn || ev_type == ProximityOut) {
QueueProximityEvents(pDev, ev_type, &valuators);
} else {
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
&valuators);
}
DarwinPokeEQ();
} darwinEvents_unlock();
}
void
DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y,
double pressure, double tilt_x,
double tilt_y)
double pointer_x, double pointer_y)
{
static int darwinFakeMouseButtonDown = 0;
ScreenPtr screen;
ValuatorMask valuators;
//DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
if (!darwinEvents) {
DEBUG_LOG(
"DarwinSendPointerEvents called before darwinEvents was initialized\n");
DEBUG_LOG("%s called before darwinEvents was initialized\n",
__FUNCTION__);
return;
}
screen = miPointerGetScreen(pDev);
if (!screen) {
DEBUG_LOG(
"DarwinSendPointerEvents called before screen was initialized\n");
DEBUG_LOG("%s called before screen was initialized\n",
__FUNCTION__);
return;
}
......@@ -550,9 +552,8 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
if (darwinFakeMouseButtonDown != 0) {
/* We're currently "down" with another button, so release it first */
DarwinSendPointerEvents(pDev, ButtonRelease,
darwinFakeMouseButtonDown, pointer_x,
pointer_y, pressure, tilt_x,
tilt_y);
darwinFakeMouseButtonDown,
pointer_x, pointer_y);
darwinFakeMouseButtonDown = 0;
}
if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
......@@ -586,9 +587,20 @@ DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
darwinFakeMouseButtonDown = 0;
}
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
pressure, tilt_x,
tilt_y);
/* Fix offset between darwin and X screens */
pointer_x -= darwinMainScreenX + screen->x;
pointer_y -= darwinMainScreenY + screen->y;
if (pointer_x < 0.0)
pointer_x = 0.0;
if (pointer_y < 0.0)
pointer_y = 0.0;
valuator_mask_zero(&valuators);
valuator_mask_set_double(&valuators, 0, pointer_x);
valuator_mask_set_double(&valuators, 1, pointer_y);
darwinEvents_lock();
{
QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE,
......@@ -615,42 +627,6 @@ DarwinSendKeyboardEvents(int ev_type, int keycode)
} darwinEvents_unlock();
}
void
DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
double pointer_y,
double pressure, double tilt_x,
double tilt_y)
{
ScreenPtr screen;
ValuatorMask valuators;
DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type,
pointer_x, pointer_y, pressure, tilt_x,
tilt_y);
if (!darwinEvents) {
DEBUG_LOG(
"DarwinSendProximityEvents called before darwinEvents was initialized\n");
return;
}
screen = miPointerGetScreen(pDev);
if (!screen) {
DEBUG_LOG(
"DarwinSendPointerEvents called before screen was initialized\n");
return;
}
DarwinPrepareValuators(pDev, &valuators, screen, pointer_x, pointer_y,
pressure, tilt_x,
tilt_y);
darwinEvents_lock();
{
QueueProximityEvents(pDev, ev_type, &valuators);
DarwinPokeEQ();
} darwinEvents_unlock();
}
/* Send the appropriate number of button clicks to emulate scroll wheel */
void
DarwinSendScrollEvents(double scroll_x, double scroll_y) {
......
......@@ -44,14 +44,12 @@ DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
void
DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev);
void
DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y, double pressure,
double tilt_x,
double tilt_y);
DarwinSendTabletEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y, double pressure,
double tilt_x, double tilt_y);
void
DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, double pointer_x,
double pointer_y, double pressure, double tilt_x,
double tilt_y);
DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button,
double pointer_x, double pointer_y);
void
DarwinSendKeyboardEvents(int ev_type, int keycode);
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment