diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 3b8c1bb6d8..5c3626effe 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -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() { diff --git a/src/apps/mediaplayer/MainWin.h b/src/apps/mediaplayer/MainWin.h index 6cadb333ae..1e73dce3d6 100644 --- a/src/apps/mediaplayer/MainWin.h +++ b/src/apps/mediaplayer/MainWin.h @@ -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);