From 68b8f65f337919d92beff339ba404f65470c8047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 29 Mar 2009 11:54:06 +0000 Subject: [PATCH] * Reworked r29180 to make _HandleKeyDown() no longer rely on the active window but if the message was targeted to the focus view. It will now only handle shortcuts in this case. * This also fixes bug #3513. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29776 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index bb97883561..f45d2a49f8 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1028,7 +1028,7 @@ FrameMoved(origin); case B_KEY_DOWN: { - if (!fActive || !_HandleKeyDown(msg)) { + if (!_HandleKeyDown(msg)) { if (BView* view = dynamic_cast(target)) { // TODO: cannot use "string" here if we support having different // font encoding per view (it's supposed to be converted by @@ -3027,8 +3027,29 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target) } -/*! - \brief Distributes the message to its intended targets. This is done for +/*! \brief Determines whether or not this message has targeted the focus view. + + This will return \c false only if the message did not go to the preferred + handler, or if the packed message does not contain address the focus view + at all. +*/ +bool +BWindow::_IsFocusMessage(BMessage* message) +{ + BMessage::Private messagePrivate(message); + if (!messagePrivate.UsePreferredTarget()) + return false; + + bool feedFocus; + if (message->HasInt32("_token") + && (message->FindBool("_feed_focus", &feedFocus) != B_OK || !feedFocus)) + return false; + + return true; +} + + +/*! \brief Distributes the message to its intended targets. This is done for all messages that should go to the preferred handler. Returns \c true in case the message should still be dispatched @@ -3296,6 +3317,11 @@ BWindow::_TransitForMouseMoved(BView* view, BView* viewUnderMouse) const bool BWindow::_HandleKeyDown(BMessage* event) { + // Only handle special functions when the event targeted the active focus + // view + if (!_IsFocusMessage(event)) + return false; + const char *string = NULL; if (event->FindString("bytes", &string) != B_OK) return false;