Fix for #676, an oldie (from 2 years ago): if the MediaPlayer window is moved

off the screen at all, it will be moved back on when the window is activated.

I almost think this might be a reasonable default implementation for
WindowActivated in BWindow :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25234 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2008-04-29 03:37:41 +00:00
parent a1587d16d5
commit ef13436f1f
2 changed files with 31 additions and 0 deletions

View File

@ -656,6 +656,36 @@ MainWin::MessageReceived(BMessage *msg)
}
void
MainWin::WindowActivated(bool active)
{
if (active) {
BScreen screen;
BRect screenFrame = screen.Frame();
BRect frame = Frame();
float diffX = 0.0;
float diffY = 0.0;
// If the frame if off the edge of the screen at all
// we will move it so all the window is on the screen.
if (frame.left < screenFrame.left)
// Move right
diffX = screenFrame.left - frame.left;
if (frame.top < screenFrame.top)
// Move down
diffY = screenFrame.top - frame.top;
if (frame.right > screenFrame.right)
// Move left
diffX = screenFrame.right - frame.right;
if (frame.bottom > screenFrame.bottom)
// Move up
diffY = screenFrame.bottom - frame.bottom;
MoveBy(diffX, diffY);
}
}
bool
MainWin::QuitRequested()
{

View File

@ -48,6 +48,7 @@ public:
virtual void DispatchMessage(BMessage* message,
BHandler* handler);
virtual void MessageReceived(BMessage* message);
virtual void WindowActivated(bool active);
virtual bool QuitRequested();
void OpenFile(const entry_ref& ref);