Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-10-14 13:49:56 +0300
committerBastien Montagne <bastien@blender.org>2020-10-15 14:55:09 +0300
commitd6fd03616ec2fab836610422f177d54ab3e2fd85 (patch)
treec584eb4ee07c0af3a134dd4aa8c1601e6defa4b5 /intern
parentf1aa55b6e9cd8ec4d7eb7fead853a4436b35d4cd (diff)
Fix part of T74918: 3D Viewport: Jump, when mouse crosses a window corner.
We need a separate time stamp for each axis, and we have to add a few milliseconds of padding to those, to ensure wrapping on both axes get properly performed when it happens almost simultaneously, and avoid extra wrapping caused by very close events sometimes. This only addresses the Linux (X11 backend) case. Differential Revision: https://developer.blender.org/D9209
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp28
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h3
2 files changed, 20 insertions, 11 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 8d4b7ff767c..1906ec67c33 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -175,7 +175,8 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), m_xkb_descr(NULL), m_start_
#undef GHOST_INTERN_ATOM_IF_EXISTS
#undef GHOST_INTERN_ATOM
- m_last_warp = 0;
+ m_last_warp_x = 0;
+ m_last_warp_y = 0;
m_last_release_keycode = 0;
m_last_release_time = 0;
@@ -981,17 +982,24 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
window->getCursorGrabAccum(x_accum, y_accum);
if (x_new != xme.x_root || y_new != xme.y_root) {
- if (xme.time > m_last_warp) {
- /* when wrapping we don't need to add an event because the
- * setCursorPosition call will cause a new event after */
- setCursorPosition(x_new, y_new); /* wrap */
- window->setCursorGrabAccum(x_accum + (xme.x_root - x_new),
- y_accum + (xme.y_root - y_new));
- m_last_warp = lastEventTime(xme.time);
+ /* Use time of last event to avoid wrapping several times on the 'same' actual wrap.
+ * Note that we need to deal with X and Y separately as those might wrap at the same time
+ * but still in two different events (corner case, see T74918).
+ * We also have to add a few extra milliseconds of 'padding', as sometimes we get two
+ * close events that will generate extra wrap on the same axis within those few
+ * milliseconds. */
+ if (x_new != xme.x_root && xme.time > m_last_warp_x) {
+ x_accum += (xme.x_root - x_new);
+ m_last_warp_x = lastEventTime(xme.time) + 25;
}
- else {
- setCursorPosition(x_new, y_new); /* wrap but don't accumulate */
+ if (y_new != xme.y_root && xme.time > m_last_warp_y) {
+ y_accum += (xme.y_root - y_new);
+ m_last_warp_y = lastEventTime(xme.time) + 25;
}
+ window->setCursorGrabAccum(x_accum, y_accum);
+ /* When wrapping we don't need to add an event because the
+ * #setCursorPosition call will cause a new event after. */
+ setCursorPosition(x_new, y_new); /* wrap */
}
else {
g_event = new GHOST_EventCursor(getMilliSeconds(),
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index a852675acfb..ee29f463fb6 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -361,7 +361,8 @@ class GHOST_SystemX11 : public GHOST_System {
* To prevent multiple warp, we store the time of the last warp event
* and stop accumulating all events generated before that.
*/
- Time m_last_warp;
+ Time m_last_warp_x;
+ Time m_last_warp_y;
/* Detect auto-repeat glitch. */
unsigned int m_last_release_keycode;