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
This commit is contained in:
+24
-13
@@ -755,6 +755,9 @@ Window::EnableUpdateRequests()
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
static const bigtime_t kWindowActivationTimeout = 500000LL;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
Window::MouseDown(BMessage* message, BPoint where, int32* _viewToken)
|
||||||
{
|
{
|
||||||
@@ -957,7 +960,7 @@ Window::MouseUp(BMessage* message, BPoint where, int32* _viewToken)
|
|||||||
fActivateOnMouseUp = false;
|
fActivateOnMouseUp = false;
|
||||||
// on R5, there is a time window for this feature
|
// on R5, there is a time window for this feature
|
||||||
// ie, click and press too long, nothing will happen
|
// ie, click and press too long, nothing will happen
|
||||||
if (system_time() - fLastMoveTime < 500000)
|
if (system_time() - fLastMoveTime < kWindowActivationTimeout)
|
||||||
fDesktop->ActivateWindow(this);
|
fDesktop->ActivateWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,6 +1010,12 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
// the then current mouse position
|
// the then current mouse position
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (fActivateOnMouseUp) {
|
||||||
|
if (now - fLastMoveTime >= kWindowActivationTimeout) {
|
||||||
|
// This click is too long already for window activation.
|
||||||
|
fActivateOnMouseUp = false;
|
||||||
|
}
|
||||||
|
} else
|
||||||
fLastMoveTime = now;
|
fLastMoveTime = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1040,6 +1049,20 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
// sliding...) stays fixed when the mouse is moved so that
|
// sliding...) stays fixed when the mouse is moved so that
|
||||||
// changes are taking effect again.
|
// 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
|
// moving
|
||||||
if (fIsDragging) {
|
if (fIsDragging) {
|
||||||
if (!(Flags() & B_NOT_MOVABLE)) {
|
if (!(Flags() & B_NOT_MOVABLE)) {
|
||||||
@@ -1080,18 +1103,6 @@ Window::MouseMoved(BMessage *message, BPoint where, int32* _viewToken,
|
|||||||
delta = BPoint(0, 0);
|
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
|
// change focus in FFM mode
|
||||||
DesktopSettings desktopSettings(fDesktop);
|
DesktopSettings desktopSettings(fDesktop);
|
||||||
if (desktopSettings.FocusFollowsMouse()
|
if (desktopSettings.FocusFollowsMouse()
|
||||||
|
|||||||
Reference in New Issue
Block a user