From 114752ff214af64cd0616b0b71e6e19bebadb026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 1 May 2006 10:17:34 +0000 Subject: [PATCH] In FFM mode, clicking a window will not bring it to front immediately. Only if the mouse is released within a certain time window (half a sec) and if it was not dragged (as on R5). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17285 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/WindowLayer.cpp | 38 ++++++++++++++++++++++++++++++--- src/servers/app/WindowLayer.h | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index 7be1ea018d..acf4ce1186 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -97,6 +97,7 @@ WindowLayer::WindowLayer(const BRect& frame, const char *name, fIsResizing(false), fIsSlidingTab(false), fIsDragging(false), + fActivateOnMouseUp(false), fDecorator(NULL), fTopLayer(NULL), @@ -723,7 +724,8 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken) if (fDecorator) action = _ActionFor(message); - // deactivate border buttons on first click (select) + // ignore clicks on decorator buttons if the + // window doesn't have focus if (!IsFocus() && action != DEC_MOVETOBACK && action != DEC_RESIZE && action != DEC_SLIDETAB) action = DEC_DRAG; @@ -792,7 +794,21 @@ WindowLayer::MouseDown(BMessage* message, BPoint where, int32* _viewToken) fDesktop->SendWindowBehind(this); } else { fDesktop->SetMouseEventWindow(this); - fDesktop->ActivateWindow(this); + + // activate window if not in FFM mode + DesktopSettings desktopSettings(fDesktop); + if (desktopSettings.MouseMode() == B_NORMAL_MOUSE) { + fDesktop->ActivateWindow(this); + } else { + // actually, the window should already be + // focused since the mouse would have to + // be over it, but just for completeness... + fDesktop->SetFocusWindow(this); + if (action == DEC_DRAG) { + fActivateOnMouseUp = true; + fLastMoveTime = system_time(); + } + } } } else { if (ViewLayer* view = ViewAt(where)) { @@ -866,6 +882,18 @@ WindowLayer::MouseUp(BMessage* message, BPoint where, int32* _viewToken) fRegionPool.Recycle(visibleBorder); } + + // in FFM mode, activate the window and bring it + // to front in case this was a drag click but the + // mouse was not moved + if (fActivateOnMouseUp) { + 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) + fDesktop->ActivateWindow(this); + } + fIsDragging = false; fIsResizing = false; fIsSlidingTab = false; @@ -896,7 +924,7 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, // are handled that move or resize the window if (fIsDragging || fIsResizing) { bigtime_t now = system_time(); - if (now - fLastMoveTime < 20000) { + if (now - fLastMoveTime < 13333) { // TODO: add a "timed event" to query for // the then current mouse position return; @@ -963,6 +991,10 @@ WindowLayer::MouseMoved(BMessage *message, BPoint where, int32* _viewToken, // used for window moving/resizing/sliding the tab fLastMousePosition += delta; + // the window was moved, it doesn't come to + // the front in FFM mode when the mouse is released + fActivateOnMouseUp = false; + // change focus in FFM mode DesktopSettings desktopSettings(fDesktop); if (desktopSettings.MouseMode() != B_NORMAL_MOUSE diff --git a/src/servers/app/WindowLayer.h b/src/servers/app/WindowLayer.h index 6db8efeca7..c9e001afea 100644 --- a/src/servers/app/WindowLayer.h +++ b/src/servers/app/WindowLayer.h @@ -274,6 +274,7 @@ class WindowLayer { bool fIsResizing; bool fIsSlidingTab; bool fIsDragging; + bool fActivateOnMouseUp; ::Decorator* fDecorator; ViewLayer* fTopLayer;