diff --git a/src/apps/terminal/FindWindow.cpp b/src/apps/terminal/FindWindow.cpp index 4bcd81cf2e..02bd9c0fea 100644 --- a/src/apps/terminal/FindWindow.cpp +++ b/src/apps/terminal/FindWindow.cpp @@ -98,8 +98,6 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str, fFindButton->MakeDefault(true); AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); - - Show(); } diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index 67a884cb48..073a697279 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -730,9 +731,32 @@ TermWindow::MessageReceived(BMessage *message) break; case MENU_FIND_STRING: - if (!fFindPanel) { + if (fFindPanel == NULL) { fFindPanel = new FindWindow(this, fFindString, fFindSelection, fMatchWord, fMatchCase, fForwardSearch); + + // position the window under the mouse pointer + BPoint where; + uint32 buttons; + ChildAt(0)->GetMouse(&where, &buttons); + fFindPanel->MoveTo(ConvertToScreen(where)); + + // move window if outside of screen frame + BRect screenFrame = (BScreen(this)).Frame(); + BRect frame = fFindPanel->Frame(); + float extra = 30.0f; + if (frame.bottom + extra * 2 > screenFrame.bottom) { + fFindPanel->MoveBy(0, + screenFrame.bottom - frame.bottom - extra * 2); + } else if (frame.top - extra < screenFrame.top) + fFindPanel->MoveBy(0, screenFrame.top - frame.top + extra); + + if (frame.right + extra > screenFrame.right) { + fFindPanel->MoveBy(screenFrame.right - frame.right + - extra, 0); + } + + fFindPanel->Show(); } else fFindPanel->Activate(); break;