BWindow::MoveOnScreen() now has a flags field.
* You can now specify whether or not you want to resize the window, and move it on screen, or center it. * Removed PulseWindow::MoveOnScreen() method.
This commit is contained in:
@@ -83,6 +83,12 @@ enum {
|
|||||||
#define B_CURRENT_WORKSPACE 0
|
#define B_CURRENT_WORKSPACE 0
|
||||||
#define B_ALL_WORKSPACES 0xffffffff
|
#define B_ALL_WORKSPACES 0xffffffff
|
||||||
|
|
||||||
|
// MoveOnScreen() flags
|
||||||
|
enum {
|
||||||
|
B_DO_NOT_RESIZE_TO_FIT = 0x0001,
|
||||||
|
B_MOVE_IF_PARTIALLY_OFFSCREEN = 0x0002
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class BWindow : public BLooper {
|
class BWindow : public BLooper {
|
||||||
public:
|
public:
|
||||||
@@ -170,7 +176,7 @@ public:
|
|||||||
void CenterIn(const BRect& rect);
|
void CenterIn(const BRect& rect);
|
||||||
void CenterOnScreen();
|
void CenterOnScreen();
|
||||||
void CenterOnScreen(screen_id id);
|
void CenterOnScreen(screen_id id);
|
||||||
void MoveOnScreen(bool resize = false);
|
void MoveOnScreen(uint32 flags = 0);
|
||||||
|
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
virtual void Hide();
|
virtual void Hide();
|
||||||
|
|||||||
@@ -671,7 +671,7 @@ MainWindow::_RestoreWindowFrame(const BMessage& settings)
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
|
|
||||||
if (fromSettings)
|
if (fromSettings)
|
||||||
MoveOnScreen(true);
|
MoveOnScreen();
|
||||||
else
|
else
|
||||||
CenterOnScreen();
|
CenterOnScreen();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ PulseApp::BuildPulse()
|
|||||||
else
|
else
|
||||||
pulseWindow = new PulseWindow(prefs->normal_window_rect);
|
pulseWindow = new PulseWindow(prefs->normal_window_rect);
|
||||||
|
|
||||||
pulseWindow->MoveOnScreen();
|
pulseWindow->MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||||
pulseWindow->Show();
|
pulseWindow->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,25 +123,6 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -163,7 +144,7 @@ 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();
|
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PV_MINI_MODE:
|
case PV_MINI_MODE:
|
||||||
@@ -183,7 +164,7 @@ 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();
|
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PV_DESKBAR_MODE:
|
case PV_DESKBAR_MODE:
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class PulseWindow : public BWindow {
|
|||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
void MoveOnScreen();
|
|
||||||
void SetMode(int newmode);
|
void SetMode(int newmode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
* Siarzhuk Zharski, [email protected]
|
* Siarzhuk Zharski, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "TermWindow.h"
|
#include "TermWindow.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
@@ -231,7 +232,7 @@ TermWindow::TermWindow(const BString& title, Arguments* args)
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
|
|
||||||
MoveTo(frame.LeftTop());
|
MoveTo(frame.LeftTop());
|
||||||
MoveOnScreen();
|
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||||
|
|
||||||
SetWorkspaces(workspaces);
|
SetWorkspaces(workspaces);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2569,7 +2569,7 @@ BWindow::CenterOnScreen(screen_id id)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BWindow::MoveOnScreen(bool resize)
|
BWindow::MoveOnScreen(uint32 flags)
|
||||||
{
|
{
|
||||||
// Set size limits now if needed
|
// Set size limits now if needed
|
||||||
UpdateSizeLimits();
|
UpdateSizeLimits();
|
||||||
@@ -2584,7 +2584,7 @@ BWindow::MoveOnScreen(bool resize)
|
|||||||
frame.InsetBy(-borderWidth, -borderWidth);
|
frame.InsetBy(-borderWidth, -borderWidth);
|
||||||
frame.top -= tabHeight;
|
frame.top -= tabHeight;
|
||||||
|
|
||||||
if (resize) {
|
if ((flags & B_DO_NOT_RESIZE_TO_FIT) == 0) {
|
||||||
// Make sure the window fits on the screen
|
// Make sure the window fits on the screen
|
||||||
if (frame.Width() > screenFrame.Width())
|
if (frame.Width() > screenFrame.Width())
|
||||||
frame.right -= frame.Width() - screenFrame.Width();
|
frame.right -= frame.Width() - screenFrame.Width();
|
||||||
@@ -2594,7 +2594,9 @@ BWindow::MoveOnScreen(bool resize)
|
|||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!frame.Intersects(screenFrame)) {
|
if ((flags & B_MOVE_IF_PARTIALLY_OFFSCREEN) == 0
|
||||||
|
&& !screenFrame.Contains(frame)
|
||||||
|
|| !frame.Intersects(screenFrame)) {
|
||||||
// Off and away
|
// Off and away
|
||||||
CenterOnScreen();
|
CenterOnScreen();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user