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:
@@ -18,7 +18,6 @@
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Rect.h>
|
||||
#include <Screen.h>
|
||||
#include <Deskbar.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@
|
||||
#include "PulseWindow.h"
|
||||
#include "PulseApp.h"
|
||||
#include "Common.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 <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
|
||||
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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user