Terminal: Move the find window under your cursor

on open moving the window back into the screen if necessary.
This commit is contained in:
John Scipione 2013-05-10 00:52:58 -04:00
parent 88c2518b23
commit 55eb18ef2f
2 changed files with 25 additions and 3 deletions

View File

@ -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();
}

View File

@ -39,6 +39,7 @@
#include <Path.h>
#include <PopUpMenu.h>
#include <PrintJob.h>
#include <Rect.h>
#include <Roster.h>
#include <Screen.h>
#include <ScrollBar.h>
@ -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;