[Xquartz-changes] xserver: Branch 'master'
Jeremy Huddleston
jeremyhu at freedesktop.org
Thu Apr 19 16:04:55 PDT 2012
hw/xquartz/X11Application.m | 39 ++++----
hw/xquartz/darwinEvents.c | 204 +++++++++++++++++++-------------------------
hw/xquartz/darwinEvents.h | 12 +-
3 files changed, 116 insertions(+), 139 deletions(-)
New commits:
commit cdf36d69bb628685c2af1a51eab14e0f71ed5d15
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date: Wed Apr 18 17:50:55 2012 -0700
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 <jeremyhu at apple.com>
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index a203f78..f700c67 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -215,9 +215,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);
@@ -1549,9 +1547,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;
}
@@ -1563,9 +1561,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;
}
@@ -1596,14 +1594,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;
@@ -1627,9 +1631,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:
@@ -1643,8 +1647,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
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index c62dd44..9fc23a3 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -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)
{
@@ -521,27 +472,78 @@ DarwinInputReleaseButtonsAndKeys(DeviceIntPtr pDev)
}
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) {
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 61ace6e..812a5dc 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -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
More information about the Xquartz-changes
mailing list