Moved the move-window-on-screen code into PulseWindow::MoveOnScreen().

When you change the appearance during runtime, the screen location is
now checked again.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13386 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-07-01 11:03:43 +00:00
parent c030c6fa68
commit 0a7d4d9991
3 changed files with 35 additions and 21 deletions
+1 -15
View File
@@ -18,7 +18,6 @@
#include <Alert.h> #include <Alert.h>
#include <Rect.h> #include <Rect.h>
#include <Screen.h>
#include <Deskbar.h> #include <Deskbar.h>
#include <stdlib.h> #include <stdlib.h>
@@ -136,20 +135,7 @@ PulseApp::BuildPulse()
else else
pulseWindow = new PulseWindow(prefs->normal_window_rect); pulseWindow = new PulseWindow(prefs->normal_window_rect);
// check if the window is on screen, and move it if not pulseWindow->MoveOnScreen();
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->Show(); pulseWindow->Show();
} }
+28 -3
View File
@@ -12,10 +12,11 @@
#include "PulseWindow.h" #include "PulseWindow.h"
#include "PulseApp.h" #include "PulseApp.h"
#include "Common.h" #include "Common.h"
#include "DeskbarPulseView.h" #include "DeskbarPulseView.h"
#include <interface/Alert.h>
#include <interface/Deskbar.h> #include <Alert.h>
#include <Deskbar.h>
#include <Screen.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -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 void
PulseWindow::SetMode(int newmode) PulseWindow::SetMode(int newmode)
{ {
PulseApp *pulseapp = (PulseApp *)be_app; PulseApp *pulseapp = (PulseApp *)be_app;
switch (newmode) { switch (newmode) {
case PV_NORMAL_MODE: case PV_NORMAL_MODE:
if (fMode == MINI_WINDOW_MODE) { if (fMode == MINI_WINDOW_MODE) {
@@ -135,7 +156,9 @@ PulseWindow::SetMode(int newmode)
pulseapp->prefs->normal_window_rect.IntegerHeight()); pulseapp->prefs->normal_window_rect.IntegerHeight());
MoveTo(pulseapp->prefs->normal_window_rect.left, MoveTo(pulseapp->prefs->normal_window_rect.left,
pulseapp->prefs->normal_window_rect.top); pulseapp->prefs->normal_window_rect.top);
MoveOnScreen();
break; break;
case PV_MINI_MODE: case PV_MINI_MODE:
if (fMode == NORMAL_WINDOW_MODE) { if (fMode == NORMAL_WINDOW_MODE) {
pulseapp->prefs->normal_window_rect = Frame(); pulseapp->prefs->normal_window_rect = Frame();
@@ -153,7 +176,9 @@ PulseWindow::SetMode(int newmode)
pulseapp->prefs->mini_window_rect.IntegerHeight()); pulseapp->prefs->mini_window_rect.IntegerHeight());
MoveTo(pulseapp->prefs->mini_window_rect.left, MoveTo(pulseapp->prefs->mini_window_rect.left,
pulseapp->prefs->mini_window_rect.top); pulseapp->prefs->mini_window_rect.top);
MoveOnScreen();
break; break;
case PV_DESKBAR_MODE: case PV_DESKBAR_MODE:
// Do not set window's mode to DESKBAR_MODE because the // Do not set window's mode to DESKBAR_MODE because the
// destructor needs to save the correct BRect. ~PulseApp() // destructor needs to save the correct BRect. ~PulseApp()
+6 -3
View File
@@ -22,9 +22,12 @@
class PulseWindow : public BWindow { class PulseWindow : public BWindow {
public: public:
PulseWindow(BRect rect); PulseWindow(BRect rect);
~PulseWindow(); virtual ~PulseWindow();
bool QuitRequested();
void MessageReceived(BMessage *message); virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
void MoveOnScreen();
void SetMode(int newmode); void SetMode(int newmode);
private: private: