* removed adding "be:transit" stuff in the EventDispatcher - this is now only done
client side (or will be, with the next commit). * added GetMouse() functionality. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15084 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -398,6 +398,16 @@ EventDispatcher::SetKeyboardFilter(BMessageFilter* filter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EventDispatcher::GetMouse(BPoint& where, int32& buttons)
|
||||||
|
{
|
||||||
|
BAutolock _(this);
|
||||||
|
|
||||||
|
where = fLastCursorPosition;
|
||||||
|
buttons = fLastButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EventDispatcher::HasCursorThread()
|
EventDispatcher::HasCursorThread()
|
||||||
{
|
{
|
||||||
@@ -448,21 +458,6 @@ EventDispatcher::_SendMessage(BMessenger& messenger, BMessage* message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
EventDispatcher::_SetTransit(BMessage* message, int32 transit)
|
|
||||||
{
|
|
||||||
if (message->ReplaceInt32("be:transit", transit) != B_OK)
|
|
||||||
message->AddInt32("be:transit", transit);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
EventDispatcher::_UnsetTransit(BMessage* message)
|
|
||||||
{
|
|
||||||
message->RemoveName("be:transit");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
EventDispatcher::_AddTokens(BMessage* message, BList& tokens)
|
EventDispatcher::_AddTokens(BMessage* message, BList& tokens)
|
||||||
{
|
{
|
||||||
@@ -532,6 +527,7 @@ EventDispatcher::_EventLoop()
|
|||||||
|
|
||||||
switch (event->what) {
|
switch (event->what) {
|
||||||
case B_MOUSE_MOVED:
|
case B_MOUSE_MOVED:
|
||||||
|
{
|
||||||
if (!HasCursorThread()) {
|
if (!HasCursorThread()) {
|
||||||
// there is no cursor thread, we need to move the cursor ourselves
|
// there is no cursor thread, we need to move the cursor ourselves
|
||||||
BAutolock _(fCursorLock);
|
BAutolock _(fCursorLock);
|
||||||
@@ -545,7 +541,6 @@ EventDispatcher::_EventLoop()
|
|||||||
// target has changed, we need to add the be:transit field
|
// target has changed, we need to add the be:transit field
|
||||||
// to the message
|
// to the message
|
||||||
if (fHasLastFocus) {
|
if (fHasLastFocus) {
|
||||||
_SetTransit(event, B_EXITED_VIEW);
|
|
||||||
addedTokens = _AddTokens(event, fLastFocusTokens);
|
addedTokens = _AddTokens(event, fLastFocusTokens);
|
||||||
_SendMessage(fLastFocus, event, kMouseTransitImportance);
|
_SendMessage(fLastFocus, event, kMouseTransitImportance);
|
||||||
sendToLastFocus = true;
|
sendToLastFocus = true;
|
||||||
@@ -554,13 +549,17 @@ EventDispatcher::_EventLoop()
|
|||||||
fHasLastFocus = false;
|
fHasLastFocus = false;
|
||||||
fLastFocusTokens.MakeEmpty();
|
fLastFocusTokens.MakeEmpty();
|
||||||
}
|
}
|
||||||
if (fHasFocus)
|
|
||||||
_SetTransit(event, B_ENTERED_VIEW);
|
|
||||||
|
|
||||||
fTransit = false;
|
fTransit = false;
|
||||||
addedTransit = true;
|
addedTransit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BPoint where;
|
||||||
|
if (event->FindPoint("where", &where) == B_OK)
|
||||||
|
fLastCursorPosition = where;
|
||||||
|
|
||||||
// supposed to fall through
|
// supposed to fall through
|
||||||
|
}
|
||||||
case B_MOUSE_DOWN:
|
case B_MOUSE_DOWN:
|
||||||
case B_MOUSE_UP:
|
case B_MOUSE_UP:
|
||||||
if (fMouseFilter != NULL
|
if (fMouseFilter != NULL
|
||||||
@@ -574,6 +573,17 @@ EventDispatcher::_EventLoop()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32 buttons;
|
||||||
|
if (event->FindInt32("buttons", &buttons) == B_OK)
|
||||||
|
fLastButtons = buttons;
|
||||||
|
else
|
||||||
|
fLastButtons = 0;
|
||||||
|
|
||||||
|
// the "where" field will be filled in by the receiver
|
||||||
|
// (it's supposed to be expressed in local window coordinates)
|
||||||
|
event->RemoveName("where");
|
||||||
|
event->AddPoint("screen_where", fLastCursorPosition);
|
||||||
|
|
||||||
pointerEvent = true;
|
pointerEvent = true;
|
||||||
|
|
||||||
if (fHasFocus) {
|
if (fHasFocus) {
|
||||||
@@ -617,12 +627,15 @@ EventDispatcher::_EventLoop()
|
|||||||
if (keyboardEvent || pointerEvent) {
|
if (keyboardEvent || pointerEvent) {
|
||||||
// send the event to the additional listeners
|
// send the event to the additional listeners
|
||||||
|
|
||||||
if (addedTransit) {
|
if (addedTokens) {
|
||||||
_UnsetTransit(event);
|
_RemoveTokens(event);
|
||||||
_UnsetFeedFocus(event);
|
_UnsetFeedFocus(event);
|
||||||
}
|
}
|
||||||
if (addedTokens)
|
if (pointerEvent) {
|
||||||
_RemoveTokens(event);
|
// this is added in the RootLayer mouse processing
|
||||||
|
// but it's only intended for the focus view
|
||||||
|
event->RemoveName("_view_token");
|
||||||
|
}
|
||||||
|
|
||||||
for (int32 i = fListeners.CountItems(); i-- > 0;) {
|
for (int32 i = fListeners.CountItems(); i-- > 0;) {
|
||||||
event_target* target = fListeners.ItemAt(i);
|
event_target* target = fListeners.ItemAt(i);
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ class EventDispatcher : public BLocker {
|
|||||||
void SetMouseFilter(BMessageFilter* filter);
|
void SetMouseFilter(BMessageFilter* filter);
|
||||||
void SetKeyboardFilter(BMessageFilter* filter);
|
void SetKeyboardFilter(BMessageFilter* filter);
|
||||||
|
|
||||||
|
void GetMouse(BPoint& where, int32& buttons);
|
||||||
|
|
||||||
bool HasCursorThread();
|
bool HasCursorThread();
|
||||||
void SetHWInterface(HWInterface* interface);
|
void SetHWInterface(HWInterface* interface);
|
||||||
|
|
||||||
@@ -50,8 +52,6 @@ class EventDispatcher : public BLocker {
|
|||||||
|
|
||||||
bool _SendMessage(BMessenger& messenger, BMessage* message, float importance);
|
bool _SendMessage(BMessenger& messenger, BMessage* message, float importance);
|
||||||
|
|
||||||
void _SetTransit(BMessage* message, int32 transit);
|
|
||||||
void _UnsetTransit(BMessage* message);
|
|
||||||
bool _AddTokens(BMessage* message, BList& tokens);
|
bool _AddTokens(BMessage* message, BList& tokens);
|
||||||
void _RemoveTokens(BMessage* message);
|
void _RemoveTokens(BMessage* message);
|
||||||
void _SetToken(BMessage* message, int32 token);
|
void _SetToken(BMessage* message, int32 token);
|
||||||
@@ -90,6 +90,9 @@ class EventDispatcher : public BLocker {
|
|||||||
|
|
||||||
BObjectList<event_target> fListeners;
|
BObjectList<event_target> fListeners;
|
||||||
|
|
||||||
|
BPoint fLastCursorPosition;
|
||||||
|
int32 fLastButtons;
|
||||||
|
|
||||||
BLocker fCursorLock;
|
BLocker fCursorLock;
|
||||||
HWInterface* fHWInterface;
|
HWInterface* fHWInterface;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user