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-18 18:50:30 +03:00
|
|
|
bool AddListener(const BMessenger& messenger, int32 token,
|
2005-11-21 19:25:23 +03:00
|
|
|
uint32 eventMask, uint32 options);
|
2005-11-18 18:50:30 +03:00
|
|
|
bool AddTemporaryListener(const BMessenger& messenger,
|
2005-11-21 19:25:23 +03:00
|
|
|
int32 token, uint32 eventMask, uint32 options);
|
2005-11-18 18:50:30 +03:00
|
|
|
void RemoveListener(const BMessenger& messenger, int32 token);
|
|
|
|
void RemoveTemporaryListener(const BMessenger& messenger, int32 token);
|
2005-11-17 21:46:55 +03:00
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
void SetMouseFilter(BMessageFilter* filter);
|
2005-11-18 16:51:32 +03:00
|
|
|
void SetKeyboardFilter(BMessageFilter* filter);
|
2005-11-17 17:58:19 +03:00
|
|
|
|
2005-11-23 14:27:09 +03:00
|
|
|
void GetMouse(BPoint& where, int32& buttons);
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
bool HasCursorThread();
|
|
|
|
void SetHWInterface(HWInterface* interface);
|
|
|
|
|
|
|
|
private:
|
2005-11-24 19:04:29 +03:00
|
|
|
struct event_listener;
|
|
|
|
class Target;
|
2005-11-17 21:46:55 +03:00
|
|
|
|
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-22 15:49:35 +03:00
|
|
|
|
2005-11-24 19:04:29 +03:00
|
|
|
bool _AddTokens(BMessage* message, Target* target, uint32 eventMask);
|
2005-11-17 21:46:55 +03:00
|
|
|
void _RemoveTokens(BMessage* message);
|
2005-11-22 15:49:35 +03:00
|
|
|
void _SetFeedFocus(BMessage* message);
|
|
|
|
void _UnsetFeedFocus(BMessage* message);
|
2005-11-17 21:46:55 +03:00
|
|
|
|
2005-11-24 19:04:29 +03:00
|
|
|
void _UnsetLastFocus();
|
|
|
|
|
|
|
|
Target* _FindTarget(const BMessenger& messenger, int32* _index = NULL);
|
|
|
|
Target* _AddTarget(const BMessenger& messenger);
|
|
|
|
void _RemoveTarget(Target* target);
|
|
|
|
|
2005-11-18 18:50:30 +03:00
|
|
|
bool _AddListener(const BMessenger& messenger, int32 token,
|
2005-11-21 19:25:23 +03:00
|
|
|
uint32 eventMask, uint32 options, bool temporary);
|
2005-11-17 21:46:55 +03:00
|
|
|
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-24 19:04:29 +03:00
|
|
|
Target* fFocus;
|
|
|
|
Target* fLastFocus;
|
2005-11-17 17:58:19 +03:00
|
|
|
bool fTransit;
|
2005-11-17 21:46:55 +03:00
|
|
|
bool fSuspendFocus;
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
BMessageFilter* fMouseFilter;
|
2005-11-18 16:51:32 +03:00
|
|
|
BMessageFilter* fKeyboardFilter;
|
2005-11-17 17:58:19 +03:00
|
|
|
|
2005-11-24 19:04:29 +03:00
|
|
|
BObjectList<Target> fTargets;
|
2005-11-17 21:46:55 +03:00
|
|
|
|
2005-11-23 14:27:09 +03:00
|
|
|
BPoint fLastCursorPosition;
|
|
|
|
int32 fLastButtons;
|
|
|
|
|
2005-11-17 17:58:19 +03:00
|
|
|
BLocker fCursorLock;
|
|
|
|
HWInterface* fHWInterface;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* EVENT_DISPATCHER_H */
|