From e337e55fdd21d454353f148ea7ca6d3f3c95161c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 18 Nov 2009 23:25:02 +0000 Subject: [PATCH] * Fixed some regressions I introduced. The video is now correctly layouted again. Bute this commit seems to make the old bug that some parts of the GUI are black much more likely. Will look into it tomorrow. * The calculations to move the window wholy into the screen frame were buggy. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34120 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/MainApp.cpp | 62 ++++++++++++++++---------------- src/apps/mediaplayer/MainApp.h | 4 ++- src/apps/mediaplayer/MainWin.cpp | 13 +++++-- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/apps/mediaplayer/MainApp.cpp b/src/apps/mediaplayer/MainApp.cpp index e31bdbdc26..14fa4b77c6 100644 --- a/src/apps/mediaplayer/MainApp.cpp +++ b/src/apps/mediaplayer/MainApp.cpp @@ -64,6 +64,32 @@ MainApp::MainApp() { mpSettings settings = Settings::CurrentSettings(); fLastFilePanelFolder = settings.filePanelFolder; + + // Now tell the application roster, that we're interested + // in getting notifications of apps being launched or quit. + // In this way we are going to detect a media_server restart. + be_roster->StartWatching(BMessenger(this, this), + B_REQUEST_LAUNCHED | B_REQUEST_QUIT); + // we will keep track of the status of media_server + // and media_addon_server + fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); + fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); + + if (!fMediaServerRunning || !fMediaAddOnServerRunning) { + BAlert* alert = new BAlert("start_media_server", + "It appears the Media Server is not running.\n" + "Would you like to start it ?", "Quit", "Start Media Server", NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); + if (alert->Go() == 0) { + PostMessage(B_QUIT_REQUESTED); + return; + } + + launch_media_server(); + + fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); + fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); + } } @@ -116,32 +142,7 @@ MainApp::PlayerCount() const void MainApp::ReadyToRun() { - // Now tell the application roster, that we're interested - // in getting notifications of apps being launched or quit. - // In this way we are going to detect a media_server restart. - be_roster->StartWatching(BMessenger(this, this), - B_REQUEST_LAUNCHED | B_REQUEST_QUIT); - // we will keep track of the status of media_server - // and media_addon_server - fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); - fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); - - if (!fMediaServerRunning || !fMediaAddOnServerRunning) { - BAlert* alert = new BAlert("start_media_server", - "It appears the Media Server is not running.\n" - "Would you like to start it ?", "Quit", "Start Media Server", NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); - if (alert->Go() == 0) { - PostMessage(B_QUIT_REQUESTED); - return; - } - - launch_media_server(); - - fMediaServerRunning = be_roster->IsRunning(kMediaServerSig); - fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig); - } - +printf("MainApp::ReadyToRun()\n"); // make sure we have at least one window open if (fPlayerCount == 0) { MainWin* window = NewWindow(); @@ -150,10 +151,11 @@ MainApp::ReadyToRun() return; } BMessage lastPlaylistArchive; - if (_RestoreCurrentPlaylist(&lastPlaylistArchive) == B_OK) - window->OpenPlaylist(&lastPlaylistArchive); - - window->Show(); + if (_RestoreCurrentPlaylist(&lastPlaylistArchive) == B_OK) { + lastPlaylistArchive.what = M_OPEN_PREVIOUS_PLAYLIST; + window->PostMessage(&lastPlaylistArchive); + } else + window->Show(); } // setup the settings window now, we need to have it diff --git a/src/apps/mediaplayer/MainApp.h b/src/apps/mediaplayer/MainApp.h index d64d46bb67..dc1f5bdd3b 100644 --- a/src/apps/mediaplayer/MainApp.h +++ b/src/apps/mediaplayer/MainApp.h @@ -46,7 +46,9 @@ enum { M_SAVE_PANEL_RESULT = 'sprs', M_MEDIA_SERVER_STARTED = 'msst', - M_MEDIA_SERVER_QUIT = 'msqt' + M_MEDIA_SERVER_QUIT = 'msqt', + + M_OPEN_PREVIOUS_PLAYLIST = 'oppp' }; diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 4e6320fd2e..88be077535 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -218,6 +218,9 @@ MainWin::MainWin(bool isFirstWindow) AddShortcut('y', B_COMMAND_KEY, new BMessage(B_UNDO)); AddShortcut('z', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(B_REDO)); AddShortcut('y', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(B_REDO)); + + Hide(); + Show(); } @@ -384,6 +387,9 @@ MainWin::MessageReceived(BMessage* msg) _RefsReceived(msg); } break; + case M_OPEN_PREVIOUS_PLAYLIST: + OpenPlaylist(msg); + break; case B_UNDO: case B_REDO: @@ -765,6 +771,9 @@ MainWin::OpenPlaylist(const BMessage* playlistArchive) playlistLocker.Unlock(); playlistArchive->FindInt64("position", (int64*)&fInitialSeekPosition); + + if (IsHidden()) + Show(); } @@ -1305,9 +1314,9 @@ MainWin::_ResizeWindow(int percent, bool useNoVideoWidth, bool stayOnScreen) else if (frame.right > screenFrame.right) offsetX = (int)(screenFrame.right - frame.right); if (frame.top < screenFrame.top) - offsetX = (int)(screenFrame.top - frame.top); + offsetY = (int)(screenFrame.top - frame.top); else if (frame.bottom > screenFrame.bottom) - offsetX = (int)(screenFrame.bottom - frame.bottom); + offsetY = (int)(screenFrame.bottom - frame.bottom); MoveBy(offsetX, offsetY); } }