From 54476b5e4461ff523e935961affabcf0de12c556 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 7 Jun 2012 16:52:20 +1000 Subject: [PATCH 1/5] dix: if the scroll valuator reaches INT_MAX, reset to 0 Too much scrolling down may eventually trigger an overflow of the valuator. If this happens, reset the valuator to 0 and skip this event for button emulation. Clients will have to figure out a way to deal with this, but a scroll event from (close to) INT_MAX to 0 is a hint of that it needs to be ignored. Signed-off-by: Peter Hutterer Reviewed-by: Chase Douglas --- dix/getevents.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index baa26c4b8..75708520f 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "misc.h" #include "resource.h" @@ -756,6 +757,29 @@ clipAbsolute(DeviceIntPtr dev, ValuatorMask *mask) } } +static void +add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, double value) +{ + double v; + + if (!valuator_mask_fetch_double(mask, valuator, &v)) + return; + + /* protect against scrolling overflow. INT_MAX for double, because + * we'll eventually write this as 32.32 fixed point */ + if ((value > 0 && v > INT_MAX - value) || (value < 0 && v < INT_MIN - value)) { + v = 0; + + /* reset last.scroll to avoid a button storm */ + valuator_mask_set_double(dev->last.scroll, valuator, 0); + } + else + v += value; + + valuator_mask_set_double(mask, valuator, v); +} + + /** * Move the device's pointer by the values given in @valuators. * @@ -774,13 +798,17 @@ moveRelative(DeviceIntPtr dev, ValuatorMask *mask) if (!valuator_mask_isset(mask, i)) continue; - val += valuator_mask_get_double(mask, i); + + add_to_scroll_valuator(dev, mask, i, val); + /* x & y need to go over the limits to cross screens if the SD * isn't currently attached; otherwise, clip to screen bounds. */ if (valuator_get_mode(dev, i) == Absolute && - ((i != 0 && i != 1) || clip_xy)) + ((i != 0 && i != 1) || clip_xy)) { + val = valuator_mask_get_double(mask, i); clipAxis(dev, i, &val); - valuator_mask_set_double(mask, i, val); + valuator_mask_set_double(mask, i, val); + } } } @@ -1506,6 +1534,7 @@ emulate_scroll_button_events(InternalEvent *events, return num_events; } + /** * Generate a complete series of InternalEvents (filled into the EventList) * representing pointer motion, or button presses. If the device is a slave @@ -1560,7 +1589,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, * necessary. This only needs to cater for the XIScrollFlagPreferred * axis (if more than one scrolling axis is present) */ if (type == ButtonPress) { - double val, adj; + double adj; int axis; int h_scroll_axis = -1; int v_scroll_axis = -1; @@ -1596,8 +1625,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, if (adj != 0.0 && axis != -1) { adj *= pDev->valuator->axes[axis].scroll.increment; - val = valuator_mask_get_double(&mask, axis) + adj; - valuator_mask_set_double(&mask, axis, val); + add_to_scroll_valuator(pDev, &mask, axis, adj); type = MotionNotify; buttons = 0; flags |= POINTER_EMULATED; From e1f86a7c77ed49e001ea42ef76ab83e87dbdf126 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Mon, 18 Jun 2012 01:13:21 +0300 Subject: [PATCH 2/5] test/.gitignore: add hashtabletest Signed-off-by: Sergei Trofimovich Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- test/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/test/.gitignore b/test/.gitignore index 5d4fdfa99..23d4c8f4f 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,4 +1,5 @@ fixes +hashtabletest input list misc From 014ad46f1b353a95e2c4289443ee857cfbabb3ae Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 21 Jun 2012 14:26:15 +1000 Subject: [PATCH 3/5] os: print newline after printing display name Much easier for scripts that try to read the display value off the file descriptor. Plus, this restores the behaviour we had for this patch in Fedora since server 1.6 (April 2009). Signed-off-by: Peter Hutterer Reviewed-by: Dave Airlie Reviewed-by: Chase Douglas --- os/connection.c | 1 + 1 file changed, 1 insertion(+) diff --git a/os/connection.c b/os/connection.c index 039942f91..344147220 100644 --- a/os/connection.c +++ b/os/connection.c @@ -353,6 +353,7 @@ NotifyParentProcess(void) #if !defined(WIN32) if (dynamic_display[0]) { write(displayfd, dynamic_display, strlen(dynamic_display)); + write(displayfd, "\n", 1); close(displayfd); } if (RunFromSmartParent) { From 7100118c8d3314d73bfef0a262af56686b227055 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 18 Jun 2012 11:28:52 +1000 Subject: [PATCH 4/5] AC_SUBST the GLX_SYS_LIBS libxservertest needs -lpthread from glxapi.c's pthread_once() call. Usually this would be pulled in by the XORG_LIBS but not when building without Xorg. This commit has no visible effect on the current tree, preparation for test cleanups. Signed-off-by: Peter Hutterer Reviewed-by: Alan Coopersmith --- test/Makefile.am | 2 +- test/xi2/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index b2a53aa64..a5a2e5c2b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -20,7 +20,7 @@ INCLUDES += -I$(top_srcdir)/hw/xfree86/parser \ -I$(top_srcdir)/hw/xfree86/i2c -I$(top_srcdir)/hw/xfree86/modes \ -I$(top_srcdir)/hw/xfree86/ramdac endif -TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) +TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS) if XORG if SPECIAL_DTRACE_OBJECTS diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am index 913ba0f8b..9de7abf5d 100644 --- a/test/xi2/Makefile.am +++ b/test/xi2/Makefile.am @@ -18,7 +18,7 @@ TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV) AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ INCLUDES = @XORG_INCS@ -TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) +TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS) COMMON_SOURCES=protocol-common.h protocol-common.c if SPECIAL_DTRACE_OBJECTS From 191b630656ba206ad78b7803c3a76f7d9567d9d8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 21 Jun 2012 11:25:24 +1000 Subject: [PATCH 5/5] include: document _XkbErrCode2 macros Why sending the number of the (implementation-dependent) error statement to the client is a good idea is a bit beyond me, but at least document it so we can all share the despair. Signed-off-by: Peter Hutterer Reviewed-by: Daniel Stone --- include/xkbsrv.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xkbsrv.h b/include/xkbsrv.h index a19c8fb29..d58478543 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -301,6 +301,11 @@ extern _X_EXPORT const char *XkbBinDirectory; extern _X_EXPORT CARD32 xkbDebugFlags; #define _XkbLibError(c,l,d) /* Epoch fail */ + +/* "a" is a "unique" numeric identifier that just defines which error + * code statement it is. _XkbErrCode2(4, foo) means "this is the 4th error + * statement in this function". lovely. + */ #define _XkbErrCode2(a,b) ((XID)((((unsigned int)(a))<<24)|((b)&0xffffff))) #define _XkbErrCode3(a,b,c) _XkbErrCode2(a,(((unsigned int)(b))<<16)|(c)) #define _XkbErrCode4(a,b,c,d) _XkbErrCode3(a,b,((((unsigned int)(c))<<8)|(d)))