Removed BWindow::_DetermineTarget(). BWindow's task_looper() just calls BLooper's one. Took Message4 stuff from BWindow's task_looper() and put it in BLooper::task_looper() - guess this is wanted...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15037 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -335,7 +335,6 @@ private:
|
|||||||
//void post_message(BMessage* message);
|
//void post_message(BMessage* message);
|
||||||
//void SetLocalTitle(const char* new_title);
|
//void SetLocalTitle(const char* new_title);
|
||||||
//void enable_pulsing(bool enable);
|
//void enable_pulsing(bool enable);
|
||||||
BHandler *_DetermineTarget(BMessage* message, BHandler* target);
|
|
||||||
//void kb_navigate();
|
//void kb_navigate();
|
||||||
//void navigate_to_next(int32 direction, bool group = false);
|
//void navigate_to_next(int32 direction, bool group = false);
|
||||||
//void set_focus(BView* focus, bool notify_input_server); // what does notify_input_server mean??? why???
|
//void set_focus(BView* focus, bool notify_input_server); // what does notify_input_server mean??? why???
|
||||||
|
|||||||
+16
-1
@@ -1259,10 +1259,20 @@ BLooper::task_looper()
|
|||||||
DBG(fLastMessage->PrintToStream());
|
DBG(fLastMessage->PrintToStream());
|
||||||
|
|
||||||
// Get the target handler
|
// Get the target handler
|
||||||
|
#ifdef USING_MESSAGE4
|
||||||
|
// Use the private BMessage accessor to determine if we are
|
||||||
|
// using the preferred handler, or if a target has been
|
||||||
|
// specified
|
||||||
|
BHandler *handler = NULL;
|
||||||
|
BMessage::Private messagePrivate(fLastMessage);
|
||||||
|
bool usePreferred = messagePrivate.UsePreferredTarget();
|
||||||
|
#else
|
||||||
// Use BMessage friend functions to determine if we are using the
|
// Use BMessage friend functions to determine if we are using the
|
||||||
// preferred handler, or if a target has been specified
|
// preferred handler, or if a target has been specified
|
||||||
BHandler* handler = NULL;
|
BHandler* handler = NULL;
|
||||||
if (_use_preferred_target_(fLastMessage)) {
|
bool usePreferred = _use_preferred_target_(fLastMessage);
|
||||||
|
#endif
|
||||||
|
if (usePreferred) {
|
||||||
PRINT(("LOOPER: use preferred target\n"));
|
PRINT(("LOOPER: use preferred target\n"));
|
||||||
handler = fPreferred;
|
handler = fPreferred;
|
||||||
} else {
|
} else {
|
||||||
@@ -1276,8 +1286,13 @@ BLooper::task_looper()
|
|||||||
of BHandler pointers to int32s!
|
of BHandler pointers to int32s!
|
||||||
*/
|
*/
|
||||||
PRINT(("LOOPER: use: %ld\n", _get_message_target_(fLastMessage)));
|
PRINT(("LOOPER: use: %ld\n", _get_message_target_(fLastMessage)));
|
||||||
|
#ifndef USING_MESSAGE4
|
||||||
gDefaultTokens.GetToken(_get_message_target_(fLastMessage),
|
gDefaultTokens.GetToken(_get_message_target_(fLastMessage),
|
||||||
B_HANDLER_TOKEN, (void **)&handler);
|
B_HANDLER_TOKEN, (void **)&handler);
|
||||||
|
#else
|
||||||
|
gDefaultTokens.GetToken(messagePrivate.GetTarget(),
|
||||||
|
B_HANDLER_TOKEN, (void **)&handler);
|
||||||
|
#endif
|
||||||
PRINT(("LOOPER: handler: %p, this: %p\n", handler, this));
|
PRINT(("LOOPER: handler: %p, this: %p\n", handler, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -913,8 +913,8 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
// will show this message, and not what it used to be on R5. This might break apps and
|
// will show this message, and not what it used to be on R5. This might break apps and
|
||||||
// we need to fix this here or change the way this feature is implemented. However, this
|
// we need to fix this here or change the way this feature is implemented. However, this
|
||||||
// implementation shows what has to be done when Layers are moved or resized inside the
|
// implementation shows what has to be done when Layers are moved or resized inside the
|
||||||
// app_server. This message is generated from Layer::move_by() and resize_by() in
|
// app_server. This message is generated from Layer::MoveByHook() and ResizeByHook() in
|
||||||
// Layer::AddToViewsWithInvalidCoords().
|
// Layer::_AddToViewsWithInvalidCoords().
|
||||||
int32 token;
|
int32 token;
|
||||||
BPoint frameLeftTop;
|
BPoint frameLeftTop;
|
||||||
float width;
|
float width;
|
||||||
@@ -928,7 +928,6 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
if ((view = findView(fTopView, token))) {
|
if ((view = findView(fTopView, token))) {
|
||||||
// update the views offset in parent
|
// update the views offset in parent
|
||||||
if (view->LeftTop() != frameLeftTop) {
|
if (view->LeftTop() != frameLeftTop) {
|
||||||
//printf("updating position (%.1f, %.1f): %s\n", frameLeftTop.x, frameLeftTop.y, view->Name());
|
|
||||||
view->fParentOffset = frameLeftTop;
|
view->fParentOffset = frameLeftTop;
|
||||||
|
|
||||||
// optionally call FrameMoved
|
// optionally call FrameMoved
|
||||||
@@ -940,7 +939,6 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
|||||||
}
|
}
|
||||||
// update the views width and height
|
// update the views width and height
|
||||||
if (view->fBounds.Width() != width || view->fBounds.Height() != height) {
|
if (view->fBounds.Width() != width || view->fBounds.Height() != height) {
|
||||||
//printf("updating size (%.1f, %.1f): %s\n", width, height, view->Name());
|
|
||||||
// TODO: does this work when a views left/top side is resized?
|
// TODO: does this work when a views left/top side is resized?
|
||||||
view->fBounds.right = view->fBounds.left + width;
|
view->fBounds.right = view->fBounds.left + width;
|
||||||
view->fBounds.bottom = view->fBounds.top + height;
|
view->fBounds.bottom = view->fBounds.top + height;
|
||||||
@@ -2196,114 +2194,7 @@ BWindow::task_looper()
|
|||||||
{
|
{
|
||||||
STRACE(("info: BWindow::task_looper() started.\n"));
|
STRACE(("info: BWindow::task_looper() started.\n"));
|
||||||
|
|
||||||
// Check that looper is locked (should be)
|
BLooper::task_looper();
|
||||||
AssertLocked();
|
|
||||||
// Unlock the looper
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
if (IsLocked())
|
|
||||||
debugger("window must not be locked!");
|
|
||||||
|
|
||||||
// loop: As long as we are not terminating.
|
|
||||||
while (!fTerminating) {
|
|
||||||
// TODO: timeout determination algo
|
|
||||||
// Read from message port (how do we determine what the timeout is?)
|
|
||||||
BMessage* msg = MessageFromPort();
|
|
||||||
|
|
||||||
// Did we get a message?
|
|
||||||
if (msg) {
|
|
||||||
// Add to queue
|
|
||||||
fQueue->AddMessage(msg);
|
|
||||||
} else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Get message count from port
|
|
||||||
int32 msgCount = port_count(fMsgPort);
|
|
||||||
for (int32 i = 0; i < msgCount; ++i) {
|
|
||||||
// Read 'count' messages from port (so we will not block)
|
|
||||||
// We use zero as our timeout since we know there is stuff there
|
|
||||||
msg = MessageFromPort(0);
|
|
||||||
// Add messages to queue
|
|
||||||
if (msg)
|
|
||||||
fQueue->AddMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop: As long as there are messages in the queue and the port is
|
|
||||||
// empty... and we are not terminating, of course.
|
|
||||||
bool dispatchNextMessage = true;
|
|
||||||
while (!fTerminating && dispatchNextMessage) {
|
|
||||||
// Get next message from queue (assign to fLastMessage)
|
|
||||||
fLastMessage = fQueue->NextMessage();
|
|
||||||
|
|
||||||
// Lock the looper
|
|
||||||
Lock();
|
|
||||||
if (!fLastMessage) {
|
|
||||||
// No more messages: Unlock the looper and terminate the
|
|
||||||
// dispatch loop.
|
|
||||||
dispatchNextMessage = false;
|
|
||||||
} else {
|
|
||||||
// Get the target handler
|
|
||||||
#ifdef USING_MESSAGE4
|
|
||||||
// Use the private BMessage accessor to determine if we are
|
|
||||||
// using the preferred handler, or if a target has been
|
|
||||||
// specified
|
|
||||||
BHandler *handler = NULL;
|
|
||||||
BMessage::Private messagePrivate(fLastMessage);
|
|
||||||
bool usePreferred = messagePrivate.UsePreferredTarget();
|
|
||||||
#else
|
|
||||||
// Use BMessage friend functions to determine if we are using the
|
|
||||||
// preferred handler, or if a target has been specified
|
|
||||||
BHandler* handler = NULL;
|
|
||||||
bool usePreferred = _use_preferred_target_(fLastMessage);
|
|
||||||
#endif
|
|
||||||
if (usePreferred) {
|
|
||||||
handler = PreferredHandler();
|
|
||||||
} else {
|
|
||||||
#ifndef USING_MESSAGE4
|
|
||||||
gDefaultTokens.GetToken(_get_message_target_(fLastMessage),
|
|
||||||
B_HANDLER_TOKEN, (void **)&handler);
|
|
||||||
#else
|
|
||||||
gDefaultTokens.GetToken(messagePrivate.GetTarget(),
|
|
||||||
B_HANDLER_TOKEN, (void **)&handler);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// if a target was given, and we should not use the preferred
|
|
||||||
// handler, we can just use that one
|
|
||||||
if (handler == NULL || usePreferred)
|
|
||||||
handler = _DetermineTarget(fLastMessage, handler);
|
|
||||||
if (handler == NULL)
|
|
||||||
handler = this;
|
|
||||||
|
|
||||||
// Is this a scripting message? (BMessage::HasSpecifiers())
|
|
||||||
if (fLastMessage->HasSpecifiers()) {
|
|
||||||
int32 index = 0;
|
|
||||||
// Make sure the current specifier is kosher
|
|
||||||
if (fLastMessage->GetCurrentSpecifier(&index) == B_OK)
|
|
||||||
handler = resolve_specifier(handler, fLastMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handler) {
|
|
||||||
// Do filtering and dispatch message
|
|
||||||
handler = top_level_filter(fLastMessage, handler);
|
|
||||||
if (handler && handler->Looper() == this)
|
|
||||||
DispatchMessage(fLastMessage, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
|
||||||
|
|
||||||
// Delete the current message (fLastMessage)
|
|
||||||
delete fLastMessage;
|
|
||||||
fLastMessage = NULL;
|
|
||||||
|
|
||||||
// Are any messages on the port?
|
|
||||||
if (port_count(fMsgPort) > 0) {
|
|
||||||
// Do outer loop
|
|
||||||
dispatchNextMessage = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2458,57 +2349,6 @@ BWindow::handleActivation(bool active)
|
|||||||
fTopView->_Activate(active);
|
fTopView->_Activate(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\brief Determines the target of a message received.
|
|
||||||
*/
|
|
||||||
BHandler *
|
|
||||||
BWindow::_DetermineTarget(BMessage *message, BHandler *target)
|
|
||||||
{
|
|
||||||
// TODO: this is mostly guessed; check for correctness.
|
|
||||||
|
|
||||||
switch (message->what) {
|
|
||||||
case B_KEY_DOWN:
|
|
||||||
case B_KEY_UP:
|
|
||||||
case B_UNMAPPED_KEY_DOWN:
|
|
||||||
case B_UNMAPPED_KEY_UP:
|
|
||||||
case B_MODIFIERS_CHANGED:
|
|
||||||
// these messages will be dispatched by the focus view later
|
|
||||||
return CurrentFocus();
|
|
||||||
|
|
||||||
case B_MOUSE_DOWN:
|
|
||||||
case B_MOUSE_UP:
|
|
||||||
case B_MOUSE_MOVED:
|
|
||||||
case B_MOUSE_WHEEL_CHANGED:
|
|
||||||
// TODO: the app_server should tell us which view is the target
|
|
||||||
break;
|
|
||||||
|
|
||||||
case B_PULSE:
|
|
||||||
case B_QUIT_REQUESTED:
|
|
||||||
// TODO: test wether R5 will let BView dispatch these messages
|
|
||||||
return this;
|
|
||||||
|
|
||||||
case B_VIEW_RESIZED:
|
|
||||||
case B_VIEW_MOVED:
|
|
||||||
{
|
|
||||||
int32 token;
|
|
||||||
if (message->FindInt32("_token", &token) != B_OK)
|
|
||||||
token = B_NULL_TOKEN;
|
|
||||||
|
|
||||||
BView *view = findView(fTopView, token);
|
|
||||||
if (view)
|
|
||||||
return view;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BWindow::_HandleKeyDown(char key, uint32 modifiers)
|
BWindow::_HandleKeyDown(char key, uint32 modifiers)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user