From 6e4ad063022b391720a385d03d439f0556d3beae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 27 Jul 2009 22:37:07 +0000 Subject: [PATCH] Improved the anti-accidental-window-nudge feature: Use the activation delay also in the MouseMoved() hook for a timeout. So window moving begins after either a timeout of half a second, or after having moved the mouse at least 4 pixels. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31834 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Window.cpp | 39 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/servers/app/Window.cpp b/src/servers/app/Window.cpp index a1731bbaa3..bac56ae3dd 100644 --- a/src/servers/app/Window.cpp +++ b/src/servers/app/Window.cpp @@ -755,6 +755,9 @@ Window::EnableUpdateRequests() // #pragma mark - +static const bigtime_t kWindowActivationTimeout = 500000LL; + + void Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken) { @@ -957,7 +960,7 @@ Window::MouseUp(BMessage* message, BPoint where, int32* _viewToken) fActivateOnMouseUp = false; // on R5, there is a time window for this feature // ie, click and press too long, nothing will happen - if (system_time() - fLastMoveTime < 500000) + if (system_time() - fLastMoveTime < kWindowActivationTimeout) fDesktop->ActivateWindow(this); } @@ -1007,7 +1010,13 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, // the then current mouse position return; } - fLastMoveTime = now; + if (fActivateOnMouseUp) { + if (now - fLastMoveTime >= kWindowActivationTimeout) { + // This click is too long already for window activation. + fActivateOnMouseUp = false; + } + } else + fLastMoveTime = now; } if (fDecorator) { @@ -1040,6 +1049,20 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, // sliding...) stays fixed when the mouse is moved so that // changes are taking effect again. + // If the window was moved enough, it doesn't come to + // the front in FFM mode when the mouse is released. + if (fActivateOnMouseUp) { + fMouseMoveDistance += delta.x * delta.x + delta.y * delta.y; + if (fMouseMoveDistance > 16.0f) + fActivateOnMouseUp = false; + else + delta = B_ORIGIN; + } + + // NOTE: fLastMousePosition is currently only + // used for window moving/resizing/sliding the tab + fLastMousePosition += delta; + // moving if (fIsDragging) { if (!(Flags() & B_NOT_MOVABLE)) { @@ -1080,18 +1103,6 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, delta = BPoint(0, 0); } - // NOTE: fLastMousePosition is currently only - // used for window moving/resizing/sliding the tab - fLastMousePosition += delta; - - // If the window was moved enough, it doesn't come to - // the front in FFM mode when the mouse is released. - if (fActivateOnMouseUp) { - fMouseMoveDistance += sqrtf(delta.x * delta.x + delta.y * delta.y); - if (fMouseMoveDistance > 4.0f) - fActivateOnMouseUp = false; - } - // change focus in FFM mode DesktopSettings desktopSettings(fDesktop); if (desktopSettings.FocusFollowsMouse()