* Added a new flag kAcceptKeyboardFocusFlag that allows B_AVOID_FOCUS windows

to still receive keyboard events. This is now used for menu windows (before,
  the menu feel alone would trigger that behaviour).
* This also fixes bug #4691, as tool tip windows use the menu feel as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33481 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-10-07 16:26:32 +00:00
parent 7f954bd566
commit 931cd377aa
4 changed files with 13 additions and 6 deletions

View File

@ -28,5 +28,7 @@ const window_type kWindowScreenWindow = window_type(1026);
/* Private window flags */
const uint32 kWindowScreenFlag = 0x10000;
const uint32 kAcceptKeyboardFocusFlag = 0x40000;
// Accept keyboard input even if B_AVOID_FOCUS is set
#endif // _WINDOW_PRIVATE_H

View File

@ -250,7 +250,8 @@ BMenuFrame::Draw(BRect updateRect)
BMenuWindow::BMenuWindow(const char *name)
// The window will be resized by BMenu, so just pass a dummy rect
: BWindow(BRect(0, 0, 0, 0), name, B_BORDERED_WINDOW_LOOK, kMenuWindowFeel,
B_NOT_MOVABLE | B_NOT_ZOOMABLE | B_AVOID_FOCUS),
B_NOT_MOVABLE | B_NOT_ZOOMABLE | B_AVOID_FOCUS
| kAcceptKeyboardFocusFlag),
fMenu(NULL),
fMenuFrame(NULL),
fUpperScroller(NULL),
@ -424,14 +425,14 @@ BMenuWindow::_Scroll(const BPoint& where)
delta = 1;
else if (fUpperScroller->IsEnabled() && upperFrame.Contains(cursor))
delta = -1;
if (delta == 0)
return false;
float smallStep;
GetSteps(&smallStep, NULL);
_ScrollBy(smallStep * delta);
snooze(5000);
return true;

View File

@ -1553,17 +1553,20 @@ Desktop::ViewUnderMouse(const Window* window)
/*! Returns the current keyboard event target candidate - which is either the
top-most window (in case it's a menu), or the one having focus.
top-most window (in case it has the kAcceptKeyboardFocusFlag flag set), or
the one having focus.
The window lock must be held when calling this function.
*/
EventTarget*
Desktop::KeyboardEventTarget()
{
// Get the top most non-hidden window
Window* window = _CurrentWindows().LastWindow();
while (window != NULL && window->IsHidden()) {
window = window->PreviousWindow(fCurrentWorkspace);
}
if (window != NULL && window->Feel() == kMenuWindowFeel)
if (window != NULL && (window->Flags() & kAcceptKeyboardFocusFlag) != 0)
return &window->EventTarget();
if (FocusWindow() != NULL)

View File

@ -1867,7 +1867,8 @@ Window::ValidWindowFlags()
| B_AUTO_UPDATE_SIZE_LIMITS
| B_CLOSE_ON_ESCAPE
| B_NO_SERVER_SIDE_WINDOW_MODIFIERS
| kWindowScreenFlag;
| kWindowScreenFlag
| kAcceptKeyboardFocusFlag;
}