summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fryatt <stevef@netsurf-browser.org>2014-04-05 19:59:07 +0100
committerSteve Fryatt <stevef@netsurf-browser.org>2014-04-05 19:59:07 +0100
commit99c47eb99be4309e996f4cb038916260fd2bcb44 (patch)
treeb4226d0407df0f1e2f89fb49d94266292175fb60
parentf0f05d691ba748314e57da754518dfbad6a7a339 (diff)
downloadnetsurf-99c47eb99be4309e996f4cb038916260fd2bcb44.tar.gz
netsurf-99c47eb99be4309e996f4cb038916260fd2bcb44.tar.bz2
Allow mouse tracking events to terminate without a PointerLeaving event being received.
This change should handle the situation where a PointerEntering event is received without a corresponding PointerLeaving event, which appears to be caused by some third-party OS addons. This could cause unexpected consequences, so all such terminations are currently logged.
-rw-r--r--riscos/mouse.c35
-rw-r--r--riscos/mouse.h8
2 files changed, 33 insertions, 10 deletions
diff --git a/riscos/mouse.c b/riscos/mouse.c
index a20965e31..e934c1cf4 100644
--- a/riscos/mouse.c
+++ b/riscos/mouse.c
@@ -163,9 +163,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged)
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/
@@ -175,12 +177,31 @@ void ro_mouse_track_start(void (*poll_end)(wimp_leaving *leaving, void *data),
void *data)
{
/* It should never be possible for the mouse to be in two windows
- * at the same time!
+ * at the same time! However, some third-party extensions to RISC OS
+ * appear to make this possible (MouseAxess being one), so in the
+ * event that there's still a claimant we tidy them up first and then
+ * log the fact in case there are any unexpected consequences.
+ *
+ * NB: The Poll End callback will get called with *leaving == NULL in
+ * this situation, as there's no PointerLeaving event to pass on.
*/
- assert(ro_mouse_poll_end_callback == NULL &&
- ro_mouse_poll_track_callback == NULL &&
- ro_mouse_poll_data == NULL);
+ if (ro_mouse_poll_end_callback != NULL ||
+ ro_mouse_poll_track_callback != NULL ||
+ ro_mouse_poll_data != NULL) {
+ if (ro_mouse_poll_end_callback != NULL &&
+ ro_mouse_ignore_leaving_event == false)
+ ro_mouse_poll_end_callback(NULL, ro_mouse_poll_data);
+
+ LOG(("Unexpected mouse track termination."));
+
+ ro_mouse_ignore_leaving_event = false;
+ ro_mouse_poll_end_callback = NULL;
+ ro_mouse_poll_track_callback = NULL;
+ ro_mouse_poll_data = NULL;
+ }
+
+ /* Now record details of the new claimant. */
ro_mouse_poll_end_callback = poll_end;
ro_mouse_poll_track_callback = poll_track;
diff --git a/riscos/mouse.h b/riscos/mouse.h
index bcb3b50bd..8a7405a2f 100644
--- a/riscos/mouse.h
+++ b/riscos/mouse.h
@@ -65,9 +65,11 @@ void ro_mouse_drag_end(wimp_dragged *dragged);
* Start tracking the mouse in a window, providing a function to be called on
* null polls and optionally one to be called when it leaves the window.
*
- * \param *drag_end Callback for when the pointer leaves the window, or
- * NULL for none.
- * \param *drag_track Callback for mouse tracking while the pointer remains
+ * \param *poll_end Callback for when the pointer leaves the window, or
+ * NULL for none. Claimants can receive *leaving==NULL if
+ * a new tracker is started before a PointerLeaving event
+ * is received.
+ * \param *poll_track Callback for mouse tracking while the pointer remains
* in the window, or NULL for none.
* \param *data Data to be passed to the callback functions, or NULL.
*/