2005-11-17 17:58:19 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Axel Dörfler, axeld@pinc-software.de
|
|
|
|
*/
|
|
|
|
#ifndef EVENT_DISPATCHER_H
|
|
|
|
#define EVENT_DISPATCHER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <Locker.h>
|
2005-11-17 19:08:04 +03:00
|
|
|
#include <Messenger.h>
|
2005-11-17 21:46:55 +03:00
|
|
|
#include <ObjectList.h>
|
2005-11-17 17:58:19 +03:00
|
|
|
|
|
|
|
class BMessageFilter;
|
|
|
|
|
|
|
|
class EventStream;
|
|
|
|
class HWInterface;
|
|
|
|
|
|
|
|
|
|
|
|
class EventDispatcher : public BLocker {
|
|
|
|
public:
|
|
|
|
EventDispatcher();
|
|
|
|
~EventDispatcher();
|
|
|
|
|
* the new input event dispatcher is now actually used, although it doesn't
distribute any messages to the clients yet.
* removed the working thread from RootLayer - for now, its event handlers are
still called using input filters in the new event dispatcher, though (to
get things started).
* ServerApp is now using a BMessenger to identify its client, and no longer
stores the port/token separately.
* the input_server handshake is a bit simpler now, as it can now just reply
to the app_server message, removed unused code from ServerProtocol.h
* calmed down the MultiLocker (it always printed thread statistics on startup,
because it's compiled in debug mode).
* removed the cursor thread stuff from AppServer.cpp
* the new event dispatcher now uses a cursor thread when supported (only in
native mode, not in the test environment), although it improves cursor
movement under Qemu, the effect is not as good as expected - this might
need some more investigations (might just be a thread priority problem).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15012 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-18 14:30:06 +03:00
|
|
|
status_t SetTo(EventStream* stream);
|
2005-11-17 17:58:19 +03:00
|
|
|
status_t InitCheck();
|
|
|
|
|
2005-11-18 16:21:07 +03:00
|
|
|
void SetFocus(const BMessenger* messenger);
|
2005-11-17 17:58:19 +03:00
|
|
|
|
2005-11-17 21:46:55 +03:00
|
|
|
bool AddListener(BMessenger& messenger, int32 token,
|
|
|
|
uint32 events, uint32 options);
|
|
|
|
bool AddTemporaryListener(BMessenger& messenger, int32 token,
|
|
|
|
uint32 events, uint32 options);
|
|
|
|
void RemoveListener(BMessenger& messenger, int32 token);
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
void SetMouseFilter(BMessageFilter* filter);
|
|
|
|
void SetKeyFilter(BMessageFilter* filter);
|
|
|
|
|
|
|
|
bool HasCursorThread();
|
|
|
|
void SetHWInterface(HWInterface* interface);
|
|
|
|
|
|
|
|
private:
|
2005-11-17 21:46:55 +03:00
|
|
|
struct event_target;
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
status_t _Run();
|
|
|
|
void _Unset();
|
|
|
|
|
2005-11-17 21:46:55 +03:00
|
|
|
bool _SendMessage(BMessenger& messenger, BMessage* message, float importance);
|
2005-11-17 17:58:19 +03:00
|
|
|
void _SetTransit(BMessage* message, int32 transit);
|
2005-11-17 21:46:55 +03:00
|
|
|
void _UnsetTransit(BMessage* message);
|
|
|
|
bool _AddTokens(BMessage* message, BList& tokens);
|
|
|
|
void _RemoveTokens(BMessage* message);
|
|
|
|
void _SetToken(BMessage* message, int32 token);
|
|
|
|
|
|
|
|
event_target* _FindListener(BMessenger& messenger, int32 token,
|
|
|
|
int32* _index = NULL);
|
|
|
|
bool _AddListener(BMessenger& messenger, int32 token, uint32 events,
|
|
|
|
uint32 options, bool temporary);
|
|
|
|
void _RemoveTemporaryListeners();
|
2005-11-17 17:58:19 +03:00
|
|
|
|
|
|
|
void _EventLoop();
|
|
|
|
void _CursorLoop();
|
|
|
|
|
|
|
|
static status_t _event_looper(void* dispatcher);
|
|
|
|
static status_t _cursor_looper(void* dispatcher);
|
|
|
|
|
|
|
|
private:
|
|
|
|
EventStream* fStream;
|
|
|
|
thread_id fThread;
|
|
|
|
thread_id fCursorThread;
|
|
|
|
|
2005-11-17 19:08:04 +03:00
|
|
|
BMessenger fFocus;
|
|
|
|
BMessenger fLastFocus;
|
|
|
|
bool fHasFocus;
|
|
|
|
bool fHasLastFocus;
|
2005-11-17 17:58:19 +03:00
|
|
|
bool fTransit;
|
2005-11-17 21:46:55 +03:00
|
|
|
BList fLastFocusTokens;
|
|
|
|
BList fFocusTokens;
|
|
|
|
bool fSuspendFocus;
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
BMessageFilter* fMouseFilter;
|
|
|
|
BMessageFilter* fKeyFilter;
|
|
|
|
|
2005-11-17 21:46:55 +03:00
|
|
|
BObjectList<event_target> fListeners;
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
BLocker fCursorLock;
|
|
|
|
HWInterface* fHWInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EVENT_DISPATCHER_H */
|