diff --git a/src/apps/pulse/PulseApp.cpp b/src/apps/pulse/PulseApp.cpp index 4feba5d491..c84b363823 100644 --- a/src/apps/pulse/PulseApp.cpp +++ b/src/apps/pulse/PulseApp.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -136,20 +135,7 @@ PulseApp::BuildPulse() else pulseWindow = new PulseWindow(prefs->normal_window_rect); - // check if the window is on screen, and move it if not - BRect frame = pulseWindow->Frame(); - BRect screenFrame = BScreen().Frame(); - - if (frame.left > screenFrame.right) - pulseWindow->MoveBy(screenFrame.right - frame.right - 10, 0); - else if (frame.right < 0) - pulseWindow->MoveTo(10, frame.top); - - if (frame.top > screenFrame.bottom) - pulseWindow->MoveBy(0, screenFrame.bottom - frame.bottom - 10); - else if (frame.bottom < 0) - pulseWindow->MoveTo(frame.left, 10); - + pulseWindow->MoveOnScreen(); pulseWindow->Show(); } diff --git a/src/apps/pulse/PulseWindow.cpp b/src/apps/pulse/PulseWindow.cpp index 844f7fcc44..16a7d49aba 100644 --- a/src/apps/pulse/PulseWindow.cpp +++ b/src/apps/pulse/PulseWindow.cpp @@ -12,10 +12,11 @@ #include "PulseWindow.h" #include "PulseApp.h" #include "Common.h" - #include "DeskbarPulseView.h" -#include -#include + +#include +#include +#include #include #include @@ -115,10 +116,30 @@ PulseWindow::MessageReceived(BMessage *message) } +void +PulseWindow::MoveOnScreen() +{ + // check if the window is on screen, and move it if not + BRect frame = Frame(); + BRect screenFrame = BScreen().Frame(); + + if (frame.left > screenFrame.right) + MoveBy(screenFrame.right - frame.right - 10, 0); + else if (frame.right < 0) + MoveTo(10, frame.top); + + if (frame.top > screenFrame.bottom) + MoveBy(0, screenFrame.bottom - frame.bottom - 10); + else if (frame.bottom < 0) + MoveTo(frame.left, 10); +} + + void PulseWindow::SetMode(int newmode) { PulseApp *pulseapp = (PulseApp *)be_app; + switch (newmode) { case PV_NORMAL_MODE: if (fMode == MINI_WINDOW_MODE) { @@ -135,7 +156,9 @@ PulseWindow::SetMode(int newmode) pulseapp->prefs->normal_window_rect.IntegerHeight()); MoveTo(pulseapp->prefs->normal_window_rect.left, pulseapp->prefs->normal_window_rect.top); + MoveOnScreen(); break; + case PV_MINI_MODE: if (fMode == NORMAL_WINDOW_MODE) { pulseapp->prefs->normal_window_rect = Frame(); @@ -153,7 +176,9 @@ PulseWindow::SetMode(int newmode) pulseapp->prefs->mini_window_rect.IntegerHeight()); MoveTo(pulseapp->prefs->mini_window_rect.left, pulseapp->prefs->mini_window_rect.top); + MoveOnScreen(); break; + case PV_DESKBAR_MODE: // Do not set window's mode to DESKBAR_MODE because the // destructor needs to save the correct BRect. ~PulseApp() diff --git a/src/apps/pulse/PulseWindow.h b/src/apps/pulse/PulseWindow.h index 0a263d4da4..4896db7bde 100644 --- a/src/apps/pulse/PulseWindow.h +++ b/src/apps/pulse/PulseWindow.h @@ -22,9 +22,12 @@ class PulseWindow : public BWindow { public: PulseWindow(BRect rect); - ~PulseWindow(); - bool QuitRequested(); - void MessageReceived(BMessage *message); + virtual ~PulseWindow(); + + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + + void MoveOnScreen(); void SetMode(int newmode); private: