diff --git a/src/apps/tv/MainWin.cpp b/src/apps/tv/MainWin.cpp index 95cbba738a..6ae2d5eb0e 100644 --- a/src/apps/tv/MainWin.cpp +++ b/src/apps/tv/MainWin.cpp @@ -132,6 +132,8 @@ MainWin::MainWin(BRect frame_rect) SetChannelMenuMarker(); VideoFormatChange(fSourceWidth, fSourceHeight, fWidthScale, fHeightScale); + + CenterWindow(); } @@ -1175,3 +1177,25 @@ MainWin::MessageReceived(BMessage *msg) } } } + + +void +MainWin::CenterWindow() +{ + BScreen screen(this); + if (!screen.IsValid()) + return; + + BRect frame = screen.Frame(); + BRect windowFrame = Frame(); + + float left = floor((frame.Width() - windowFrame.Width()) / 2); + float top = floor((frame.Height() - windowFrame.Height()) / 2); + + if (left < 20) + left = 20; + if (top < 20) + top = 20; + + MoveTo(left, top); +} diff --git a/src/apps/tv/MainWin.h b/src/apps/tv/MainWin.h index c676b89418..d9ea486784 100644 --- a/src/apps/tv/MainWin.h +++ b/src/apps/tv/MainWin.h @@ -61,7 +61,7 @@ public: void SetInterfaceMenuMarker(); void SetChannelMenuMarker(); - + void VideoFormatChange(int width, int height, float width_scale, float height_scale); void UpdateWindowTitle(); @@ -75,7 +75,8 @@ public: void ToggleNoBorder(); void ToggleNoMenu(); void ToggleNoBorderNoMenu(); - + void CenterWindow(); + void ShowContextMenu(const BPoint &screen_point); BMenuBar * fMenuBar;