From 6ae06ef86a9612a2fb6ce22d177c48722b28a9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 29 Oct 2007 09:11:25 +0000 Subject: [PATCH] Implemented AS_IDLE_TIME, this closes bug #1593. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22758 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/EventDispatcher.cpp | 13 ++++++++++++- src/servers/app/EventDispatcher.h | 9 ++++++--- src/servers/app/ServerApp.cpp | 8 ++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/servers/app/EventDispatcher.cpp b/src/servers/app/EventDispatcher.cpp index e2a3b0af63..73d6c57b98 100644 --- a/src/servers/app/EventDispatcher.cpp +++ b/src/servers/app/EventDispatcher.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2005-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -237,6 +237,8 @@ EventDispatcher::EventDispatcher() fKeyboardFilter(NULL), fTargets(10), fNextLatestMouseMoved(NULL), + fLastButtons(0), + fLastUpdate(system_time()), fCursorLock("cursor loop lock"), fHWInterface(NULL), fDesktop(NULL) @@ -521,6 +523,14 @@ EventDispatcher::SendFakeMouseMoved(EventTarget& target, int32 viewToken) } +bigtime_t +EventDispatcher::IdleTime() +{ + BAutolock _(this); + return system_time() - fLastUpdate; +} + + bool EventDispatcher::HasCursorThread() { @@ -714,6 +724,7 @@ EventDispatcher::_EventLoop() } BAutolock _(this); + fLastUpdate = system_time(); EventTarget* current = NULL; EventTarget* previous = NULL; diff --git a/src/servers/app/EventDispatcher.h b/src/servers/app/EventDispatcher.h index d6dc4b5492..ab079e84f5 100644 --- a/src/servers/app/EventDispatcher.h +++ b/src/servers/app/EventDispatcher.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2005-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -84,12 +84,13 @@ class EventDispatcher : public BLocker { void GetMouse(BPoint& where, int32& buttons); void SendFakeMouseMoved(EventTarget& target, int32 viewToken); + bigtime_t IdleTime(); bool HasCursorThread(); void SetHWInterface(HWInterface* interface); void SetDragMessage(BMessage& message, ServerBitmap* bitmap, - const BPoint& offsetFromCursor); + const BPoint& offsetFromCursor); // the message should be delivered on the next // "mouse up". // if the mouse is not pressed, it should @@ -101,7 +102,8 @@ class EventDispatcher : public BLocker { status_t _Run(); void _Unset(); - bool _SendMessage(BMessenger& messenger, BMessage* message, float importance); + bool _SendMessage(BMessenger& messenger, BMessage* message, + float importance); bool _AddTokens(BMessage* message, EventTarget* target, uint32 eventMask, BMessage* nextMouseMoved = NULL, int32* _viewToken = NULL); @@ -141,6 +143,7 @@ class EventDispatcher : public BLocker { BMessage* fNextLatestMouseMoved; BPoint fLastCursorPosition; int32 fLastButtons; + bigtime_t fLastUpdate; BMessage fDragMessage; bool fDraggingMessage; diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 766663ebe8..62e8a9fc8f 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -808,6 +808,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } + case AS_IDLE_TIME: + STRACE(("ServerApp %s: idle time\n", Signature())); + + fLink.StartMessage(B_OK); + fLink.Attach(fDesktop->EventDispatcher().IdleTime()); + fLink.Flush(); + break; + case AS_SHOW_CURSOR: { STRACE(("ServerApp %s: Show Cursor\n", Signature()));