Implemented AS_IDLE_TIME, this closes bug #1593.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22758 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-10-29 09:11:25 +00:00
parent 3fc0398b6f
commit 6ae06ef86a
3 changed files with 26 additions and 4 deletions

View File

@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -237,6 +237,8 @@ EventDispatcher::EventDispatcher()
fKeyboardFilter(NULL), fKeyboardFilter(NULL),
fTargets(10), fTargets(10),
fNextLatestMouseMoved(NULL), fNextLatestMouseMoved(NULL),
fLastButtons(0),
fLastUpdate(system_time()),
fCursorLock("cursor loop lock"), fCursorLock("cursor loop lock"),
fHWInterface(NULL), fHWInterface(NULL),
fDesktop(NULL) fDesktop(NULL)
@ -521,6 +523,14 @@ EventDispatcher::SendFakeMouseMoved(EventTarget& target, int32 viewToken)
} }
bigtime_t
EventDispatcher::IdleTime()
{
BAutolock _(this);
return system_time() - fLastUpdate;
}
bool bool
EventDispatcher::HasCursorThread() EventDispatcher::HasCursorThread()
{ {
@ -714,6 +724,7 @@ EventDispatcher::_EventLoop()
} }
BAutolock _(this); BAutolock _(this);
fLastUpdate = system_time();
EventTarget* current = NULL; EventTarget* current = NULL;
EventTarget* previous = NULL; EventTarget* previous = NULL;

View File

@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -84,12 +84,13 @@ class EventDispatcher : public BLocker {
void GetMouse(BPoint& where, int32& buttons); void GetMouse(BPoint& where, int32& buttons);
void SendFakeMouseMoved(EventTarget& target, int32 viewToken); void SendFakeMouseMoved(EventTarget& target, int32 viewToken);
bigtime_t IdleTime();
bool HasCursorThread(); bool HasCursorThread();
void SetHWInterface(HWInterface* interface); void SetHWInterface(HWInterface* interface);
void SetDragMessage(BMessage& message, ServerBitmap* bitmap, void SetDragMessage(BMessage& message, ServerBitmap* bitmap,
const BPoint& offsetFromCursor); const BPoint& offsetFromCursor);
// the message should be delivered on the next // the message should be delivered on the next
// "mouse up". // "mouse up".
// if the mouse is not pressed, it should // if the mouse is not pressed, it should
@ -101,7 +102,8 @@ class EventDispatcher : public BLocker {
status_t _Run(); status_t _Run();
void _Unset(); 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, bool _AddTokens(BMessage* message, EventTarget* target, uint32 eventMask,
BMessage* nextMouseMoved = NULL, int32* _viewToken = NULL); BMessage* nextMouseMoved = NULL, int32* _viewToken = NULL);
@ -141,6 +143,7 @@ class EventDispatcher : public BLocker {
BMessage* fNextLatestMouseMoved; BMessage* fNextLatestMouseMoved;
BPoint fLastCursorPosition; BPoint fLastCursorPosition;
int32 fLastButtons; int32 fLastButtons;
bigtime_t fLastUpdate;
BMessage fDragMessage; BMessage fDragMessage;
bool fDraggingMessage; bool fDraggingMessage;

View File

@ -808,6 +808,14 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break; break;
} }
case AS_IDLE_TIME:
STRACE(("ServerApp %s: idle time\n", Signature()));
fLink.StartMessage(B_OK);
fLink.Attach<bigtime_t>(fDesktop->EventDispatcher().IdleTime());
fLink.Flush();
break;
case AS_SHOW_CURSOR: case AS_SHOW_CURSOR:
{ {
STRACE(("ServerApp %s: Show Cursor\n", Signature())); STRACE(("ServerApp %s: Show Cursor\n", Signature()));