Pulse: do not run the preferences and about windows in DeskBar process
Now Pulse can be both in a normal window and in DeskBar at the same time. The Replicant starts the app if needed to show the settings and about box there, instead of showing the window in the DeskBar process. Fixes #6901 Change-Id: I3cede07df9216c54e4ad97b50618d42c2fa5e12e Reviewed-on: https://review.haiku-os.org/c/haiku/+/83 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
db3a94141a
commit
e04f6f31b0
@ -277,7 +277,7 @@ CPUButton::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case B_ABOUT_REQUESTED: {
|
||||
PulseApp::ShowAbout(false);
|
||||
be_app->PostMessage(B_ABOUT_REQUESTED);
|
||||
break;
|
||||
}
|
||||
case PV_REPLICANT_PULSE: {
|
||||
@ -330,7 +330,7 @@ CPUButton::AttachedToWindow()
|
||||
delete prefs;
|
||||
} else {
|
||||
PulseApp *pulseapp = (PulseApp *)be_app;
|
||||
UpdateColors(pulseapp->prefs->normal_bar_color);
|
||||
UpdateColors(pulseapp->fPrefs->normal_bar_color);
|
||||
_AddDragger();
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,17 @@
|
||||
#define B_TRANSLATION_CONTEXT "DeskbarPulseView"
|
||||
|
||||
|
||||
DeskbarPulseView::DeskbarPulseView(BRect rect) : MiniPulseView(rect, "DeskbarPulseView") {
|
||||
DeskbarPulseView::DeskbarPulseView(BRect rect)
|
||||
: MiniPulseView(rect, "DeskbarPulseView")
|
||||
{
|
||||
messagerunner = NULL;
|
||||
prefs = NULL;
|
||||
prefswindow = NULL;
|
||||
}
|
||||
|
||||
DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) {
|
||||
|
||||
DeskbarPulseView::DeskbarPulseView(BMessage *message)
|
||||
: MiniPulseView(message)
|
||||
{
|
||||
mode1->SetLabel(B_TRANSLATE("Normal mode"));
|
||||
mode1->SetMessage(new BMessage(PV_NORMAL_MODE));
|
||||
mode2->SetLabel(B_TRANSLATE("Mini mode"));
|
||||
@ -61,10 +65,12 @@ DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) {
|
||||
SetViewColor(idle_color);
|
||||
|
||||
messagerunner = NULL;
|
||||
prefswindow = NULL;
|
||||
}
|
||||
|
||||
void DeskbarPulseView::AttachedToWindow() {
|
||||
|
||||
void
|
||||
DeskbarPulseView::AttachedToWindow()
|
||||
{
|
||||
BMessenger messenger(this);
|
||||
mode1->SetTarget(messenger);
|
||||
mode2->SetTarget(messenger);
|
||||
@ -86,7 +92,10 @@ void DeskbarPulseView::AttachedToWindow() {
|
||||
200000, -1);
|
||||
}
|
||||
|
||||
void DeskbarPulseView::MouseDown(BPoint point) {
|
||||
|
||||
void
|
||||
DeskbarPulseView::MouseDown(BPoint point)
|
||||
{
|
||||
BPoint cursor;
|
||||
uint32 buttons;
|
||||
MakeFocus(true);
|
||||
@ -103,11 +112,17 @@ void DeskbarPulseView::MouseDown(BPoint point) {
|
||||
} else MiniPulseView::MouseDown(point);
|
||||
}
|
||||
|
||||
void DeskbarPulseView::Pulse() {
|
||||
|
||||
void
|
||||
DeskbarPulseView::Pulse()
|
||||
{
|
||||
// Override and do nothing here
|
||||
}
|
||||
|
||||
void DeskbarPulseView::MessageReceived(BMessage *message) {
|
||||
|
||||
void
|
||||
DeskbarPulseView::MessageReceived(BMessage *message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case PV_NORMAL_MODE:
|
||||
SetMode(true);
|
||||
@ -118,16 +133,16 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
|
||||
Remove();
|
||||
break;
|
||||
case PV_PREFERENCES:
|
||||
if (prefswindow != NULL) {
|
||||
prefswindow->Activate(true);
|
||||
break;
|
||||
}
|
||||
prefswindow = new PrefsWindow(prefs->prefs_window_rect,
|
||||
"Pulse settings", new BMessenger(this), prefs);
|
||||
prefswindow->Show();
|
||||
{
|
||||
message->AddMessenger("settingsListener", this);
|
||||
// Spawn the app and open the window there, not in DeskBar process.
|
||||
be_roster->Launch("applicaiton/x-vnd.Haiku-Pulse", message);
|
||||
break;
|
||||
case PV_ABOUT: {
|
||||
PulseApp::ShowAbout(false);
|
||||
}
|
||||
case PV_ABOUT:
|
||||
{
|
||||
BMessage aboutRequest(B_ABOUT_REQUESTED);
|
||||
be_roster->Launch("applicaiton/x-vnd.Haiku-Pulse", &aboutRequest);
|
||||
break;
|
||||
}
|
||||
case PV_QUIT:
|
||||
@ -146,9 +161,6 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
|
||||
Update();
|
||||
Draw(Bounds());
|
||||
break;
|
||||
case PRV_QUIT:
|
||||
prefswindow = NULL;
|
||||
break;
|
||||
case PV_CPU_MENU_ITEM:
|
||||
ChangeCPUState(message);
|
||||
break;
|
||||
@ -158,19 +170,28 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
|
||||
}
|
||||
}
|
||||
|
||||
DeskbarPulseView *DeskbarPulseView::Instantiate(BMessage *data) {
|
||||
if (!validate_instantiation(data, "DeskbarPulseView")) return NULL;
|
||||
|
||||
DeskbarPulseView *
|
||||
DeskbarPulseView::Instantiate(BMessage *data)
|
||||
{
|
||||
if (!validate_instantiation(data, "DeskbarPulseView"))
|
||||
return NULL;
|
||||
return new DeskbarPulseView(data);
|
||||
}
|
||||
|
||||
status_t DeskbarPulseView::Archive(BMessage *data, bool deep) const {
|
||||
status_t
|
||||
DeskbarPulseView::Archive(BMessage *data, bool deep) const
|
||||
{
|
||||
PulseView::Archive(data, deep);
|
||||
data->AddString("add_on", APP_SIGNATURE);
|
||||
data->AddString("class", "DeskbarPulseView");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void DeskbarPulseView::Remove() {
|
||||
|
||||
void
|
||||
DeskbarPulseView::Remove()
|
||||
{
|
||||
// Remove ourselves from the deskbar by name
|
||||
BDeskbar *deskbar = new BDeskbar();
|
||||
status_t err = deskbar->RemoveItem("DeskbarPulseView");
|
||||
@ -187,15 +208,19 @@ void DeskbarPulseView::Remove() {
|
||||
delete deskbar;
|
||||
}
|
||||
|
||||
void DeskbarPulseView::SetMode(bool normal) {
|
||||
|
||||
void
|
||||
DeskbarPulseView::SetMode(bool normal)
|
||||
{
|
||||
if (normal) prefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
else prefs->window_mode = MINI_WINDOW_MODE;
|
||||
prefs->Save();
|
||||
be_roster->Launch(APP_SIGNATURE);
|
||||
}
|
||||
|
||||
DeskbarPulseView::~DeskbarPulseView() {
|
||||
|
||||
DeskbarPulseView::~DeskbarPulseView()
|
||||
{
|
||||
if (messagerunner != NULL) delete messagerunner;
|
||||
if (prefswindow != NULL && prefswindow->Lock()) prefswindow->Quit();
|
||||
if (prefs != NULL) delete prefs;
|
||||
}
|
||||
|
@ -15,7 +15,9 @@
|
||||
#include "PrefsWindow.h"
|
||||
#include <app/MessageRunner.h>
|
||||
|
||||
class DeskbarPulseView : public MiniPulseView {
|
||||
|
||||
class DeskbarPulseView : public MiniPulseView
|
||||
{
|
||||
public:
|
||||
DeskbarPulseView(BRect rect);
|
||||
DeskbarPulseView(BMessage *message);
|
||||
@ -32,7 +34,6 @@ class DeskbarPulseView : public MiniPulseView {
|
||||
void Remove();
|
||||
void SetMode(bool normal);
|
||||
|
||||
PrefsWindow *prefswindow;
|
||||
Prefs *prefs;
|
||||
BMessageRunner *messagerunner;
|
||||
};
|
||||
|
@ -135,6 +135,6 @@ PrefsWindow::MessageReceived(BMessage *message)
|
||||
bool
|
||||
PrefsWindow::QuitRequested()
|
||||
{
|
||||
fTarget.SendMessage(new BMessage(PRV_QUIT));
|
||||
be_app->PostMessage(new BMessage(PRV_QUIT));
|
||||
return true;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ ProgressBar::UpdateColors(int32 color, bool fade)
|
||||
void
|
||||
ProgressBar::AttachedToWindow()
|
||||
{
|
||||
Prefs *prefs = ((PulseApp *)be_app)->prefs;
|
||||
Prefs *prefs = ((PulseApp *)be_app)->fPrefs;
|
||||
UpdateColors(prefs->normal_bar_color, prefs->normal_fade_colors);
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,12 @@
|
||||
|
||||
|
||||
PulseApp::PulseApp(int argc, char **argv)
|
||||
: BApplication(APP_SIGNATURE)
|
||||
: BApplication(APP_SIGNATURE),
|
||||
fPrefs(new Prefs()),
|
||||
fRunFromReplicant(false),
|
||||
fIsRunning(false),
|
||||
fPrefsWindow(NULL)
|
||||
{
|
||||
prefs = new Prefs();
|
||||
|
||||
int mini = false, deskbar = false, normal = false;
|
||||
uint32 framecolor = 0, activecolor = 0, idlecolor = 0;
|
||||
|
||||
@ -84,10 +86,10 @@ PulseApp::PulseApp(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
prefs->deskbar_icon_width = atoi(optarg);
|
||||
if (prefs->deskbar_icon_width < GetMinimumViewWidth())
|
||||
prefs->deskbar_icon_width = GetMinimumViewWidth();
|
||||
else if (prefs->deskbar_icon_width > 50) prefs->deskbar_icon_width = 50;
|
||||
fPrefs->deskbar_icon_width = atoi(optarg);
|
||||
if (fPrefs->deskbar_icon_width < GetMinimumViewWidth())
|
||||
fPrefs->deskbar_icon_width = GetMinimumViewWidth();
|
||||
else if (fPrefs->deskbar_icon_width > 50) fPrefs->deskbar_icon_width = 50;
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
@ -100,48 +102,47 @@ PulseApp::PulseApp(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (deskbar) {
|
||||
prefs->window_mode = DESKBAR_MODE;
|
||||
fPrefs->window_mode = DESKBAR_MODE;
|
||||
if (activecolor != 0)
|
||||
prefs->deskbar_active_color = activecolor;
|
||||
fPrefs->deskbar_active_color = activecolor;
|
||||
if (idlecolor != 0)
|
||||
prefs->deskbar_idle_color = idlecolor;
|
||||
fPrefs->deskbar_idle_color = idlecolor;
|
||||
if (framecolor != 0)
|
||||
prefs->deskbar_frame_color = framecolor;
|
||||
fPrefs->deskbar_frame_color = framecolor;
|
||||
} else if (mini) {
|
||||
prefs->window_mode = MINI_WINDOW_MODE;
|
||||
fPrefs->window_mode = MINI_WINDOW_MODE;
|
||||
if (activecolor != 0)
|
||||
prefs->mini_active_color = activecolor;
|
||||
fPrefs->mini_active_color = activecolor;
|
||||
if (idlecolor != 0)
|
||||
prefs->mini_idle_color = idlecolor;
|
||||
fPrefs->mini_idle_color = idlecolor;
|
||||
if (framecolor != 0)
|
||||
prefs->mini_frame_color = framecolor;
|
||||
fPrefs->mini_frame_color = framecolor;
|
||||
} else if (normal)
|
||||
prefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
fPrefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
|
||||
prefs->Save();
|
||||
BuildPulse();
|
||||
fPrefs->Save();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PulseApp::ReadyToRun()
|
||||
{
|
||||
if (!fRunFromReplicant)
|
||||
BuildPulse();
|
||||
|
||||
fIsRunning = true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PulseApp::BuildPulse()
|
||||
{
|
||||
// Remove this case for Deskbar add on API
|
||||
|
||||
// If loading the replicant fails, launch the app instead
|
||||
// This allows having the replicant and the app open simultaneously
|
||||
if (prefs->window_mode == DESKBAR_MODE && LoadInDeskbar()) {
|
||||
PostMessage(new BMessage(B_QUIT_REQUESTED));
|
||||
return;
|
||||
} else if (prefs->window_mode == DESKBAR_MODE)
|
||||
prefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
|
||||
PulseWindow *pulseWindow = NULL;
|
||||
|
||||
if (prefs->window_mode == MINI_WINDOW_MODE)
|
||||
pulseWindow = new PulseWindow(prefs->mini_window_rect);
|
||||
if (fPrefs->window_mode == MINI_WINDOW_MODE)
|
||||
pulseWindow = new PulseWindow(fPrefs->mini_window_rect);
|
||||
else
|
||||
pulseWindow = new PulseWindow(prefs->normal_window_rect);
|
||||
pulseWindow = new PulseWindow(fPrefs->normal_window_rect);
|
||||
|
||||
pulseWindow->MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||
pulseWindow->Show();
|
||||
@ -150,32 +151,75 @@ PulseApp::BuildPulse()
|
||||
|
||||
PulseApp::~PulseApp()
|
||||
{
|
||||
// Load the replicant after we save our preferences so they don't
|
||||
// get overwritten by DeskbarPulseView's instance
|
||||
prefs->Save();
|
||||
if (prefs->window_mode == DESKBAR_MODE)
|
||||
LoadInDeskbar();
|
||||
fPrefs->Save();
|
||||
|
||||
delete prefs;
|
||||
delete fPrefs;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PulseApp::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case PV_PREFERENCES:
|
||||
{
|
||||
// This message can be posted before ReadyToRun from
|
||||
// BRoster::Launch, in that case, take note to not show the main
|
||||
// window but only the preferences
|
||||
if (!fIsRunning)
|
||||
fRunFromReplicant = true;
|
||||
BMessenger from;
|
||||
message->FindMessenger("settingsListener", &from);
|
||||
|
||||
|
||||
if (fPrefsWindow != NULL) {
|
||||
fPrefsWindow->Activate(true);
|
||||
break;
|
||||
}
|
||||
// If the window is already open, bring it to the front
|
||||
if (fPrefsWindow != NULL) {
|
||||
fPrefsWindow->Activate(true);
|
||||
break;
|
||||
}
|
||||
// Otherwise launch a new preferences window
|
||||
PulseApp *pulseapp = (PulseApp *)be_app;
|
||||
fPrefsWindow = new PrefsWindow(pulseapp->fPrefs->prefs_window_rect,
|
||||
B_TRANSLATE("Pulse settings"), &from,
|
||||
pulseapp->fPrefs);
|
||||
if (fRunFromReplicant) {
|
||||
fPrefsWindow->SetFlags(fPrefsWindow->Flags()
|
||||
| B_QUIT_ON_WINDOW_CLOSE);
|
||||
}
|
||||
fPrefsWindow->Show();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case PV_ABOUT:
|
||||
// This message can be posted before ReadyToRun from
|
||||
// BRoster::Launch, in that case, take note to not show the main
|
||||
// window but only the about box
|
||||
if (!fIsRunning)
|
||||
fRunFromReplicant = true;
|
||||
PostMessage(B_ABOUT_REQUESTED);
|
||||
break;
|
||||
|
||||
case PRV_QUIT:
|
||||
fPrefsWindow = NULL;
|
||||
fRunFromReplicant = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
BApplication::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PulseApp::AboutRequested()
|
||||
{
|
||||
PulseApp::ShowAbout(true);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PulseApp::ShowAbout(bool asApplication)
|
||||
{
|
||||
// static version to be used in replicant mode
|
||||
BString name;
|
||||
if (asApplication)
|
||||
name = B_TRANSLATE_SYSTEM_NAME("Pulse");
|
||||
else
|
||||
name = B_TRANSLATE("Pulse");
|
||||
BString name = B_TRANSLATE("Pulse");
|
||||
|
||||
BString message = B_TRANSLATE(
|
||||
"%s\n\nBy David Ramsey and Arve Hjønnevåg\n"
|
||||
@ -184,6 +228,9 @@ PulseApp::ShowAbout(bool asApplication)
|
||||
BAlert *alert = new BAlert(B_TRANSLATE("Info"),
|
||||
message.String(), B_TRANSLATE("OK"));
|
||||
|
||||
if (fRunFromReplicant)
|
||||
alert->SetFlags(alert->Flags() | B_QUIT_ON_WINDOW_CLOSE);
|
||||
|
||||
BTextView* view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
@ -196,6 +243,7 @@ PulseApp::ShowAbout(bool asApplication)
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
// Use the asynchronous version so we don't block the window's thread
|
||||
alert->Go(NULL);
|
||||
fRunFromReplicant = false;
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@ -259,10 +307,10 @@ LoadInDeskbar()
|
||||
}
|
||||
|
||||
// Must be 16 pixels high, the width is retrieved from the Prefs class
|
||||
int width = pulseapp->prefs->deskbar_icon_width;
|
||||
int width = pulseapp->fPrefs->deskbar_icon_width;
|
||||
int min_width = GetMinimumViewWidth();
|
||||
if (width < min_width) {
|
||||
pulseapp->prefs->deskbar_icon_width = min_width;
|
||||
pulseapp->fPrefs->deskbar_icon_width = min_width;
|
||||
width = min_width;
|
||||
}
|
||||
|
||||
|
@ -16,20 +16,28 @@
|
||||
#include <Catalog.h>
|
||||
|
||||
#include "Prefs.h"
|
||||
#include "PrefsWindow.h"
|
||||
|
||||
|
||||
class PulseApp : public BApplication {
|
||||
public:
|
||||
PulseApp(int argc, char **argv);
|
||||
~PulseApp();
|
||||
PulseApp(int argc, char **argv);
|
||||
~PulseApp();
|
||||
|
||||
virtual void AboutRequested();
|
||||
static void ShowAbout(bool asApplication);
|
||||
|
||||
Prefs* prefs;
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void ReadyToRun();
|
||||
virtual void AboutRequested();
|
||||
|
||||
private:
|
||||
void BuildPulse();
|
||||
void BuildPulse();
|
||||
|
||||
public:
|
||||
Prefs* fPrefs;
|
||||
|
||||
private:
|
||||
bool fRunFromReplicant;
|
||||
bool fIsRunning;
|
||||
PrefsWindow* fPrefsWindow;
|
||||
};
|
||||
|
||||
extern bool LastEnabledCPU(unsigned int cpu);
|
||||
|
@ -30,7 +30,7 @@
|
||||
PulseWindow::PulseWindow(BRect rect)
|
||||
:
|
||||
BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Pulse"), B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_QUIT_ON_WINDOW_CLOSE)
|
||||
{
|
||||
SetPulseRate(200000);
|
||||
|
||||
@ -40,10 +40,10 @@ PulseWindow::PulseWindow(BRect rect)
|
||||
AddChild(fNormalPulseView);
|
||||
|
||||
fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView",
|
||||
pulseapp->prefs);
|
||||
pulseapp->fPrefs);
|
||||
AddChild(fMiniPulseView);
|
||||
|
||||
fMode = pulseapp->prefs->window_mode;
|
||||
fMode = pulseapp->fPrefs->window_mode;
|
||||
if (fMode == MINI_WINDOW_MODE) {
|
||||
SetLook(B_MODAL_WINDOW_LOOK);
|
||||
SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
@ -53,8 +53,6 @@ PulseWindow::PulseWindow(BRect rect)
|
||||
ResizeTo(rect.Width(), rect.Height());
|
||||
} else
|
||||
fMiniPulseView->Hide();
|
||||
|
||||
fPrefsWindow = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -63,9 +61,9 @@ PulseWindow::~PulseWindow()
|
||||
PulseApp *pulseapp = (PulseApp *)be_app;
|
||||
|
||||
if (fMode == NORMAL_WINDOW_MODE)
|
||||
pulseapp->prefs->normal_window_rect = Frame();
|
||||
pulseapp->fPrefs->normal_window_rect = Frame();
|
||||
else if (fMode == MINI_WINDOW_MODE)
|
||||
pulseapp->prefs->mini_window_rect = Frame();
|
||||
pulseapp->fPrefs->mini_window_rect = Frame();
|
||||
}
|
||||
|
||||
|
||||
@ -85,25 +83,14 @@ PulseWindow::MessageReceived(BMessage *message)
|
||||
case PRV_MINI_CHANGE_COLOR:
|
||||
fMiniPulseView->UpdateColors(message);
|
||||
break;
|
||||
case PRV_QUIT:
|
||||
fPrefsWindow = NULL;
|
||||
break;
|
||||
case PV_PREFERENCES: {
|
||||
// If the window is already open, bring it to the front
|
||||
if (fPrefsWindow != NULL) {
|
||||
fPrefsWindow->Activate(true);
|
||||
break;
|
||||
}
|
||||
// Otherwise launch a new preferences window
|
||||
PulseApp *pulseapp = (PulseApp *)be_app;
|
||||
fPrefsWindow = new PrefsWindow(pulseapp->prefs->prefs_window_rect,
|
||||
B_TRANSLATE("Pulse settings"), new BMessenger(this),
|
||||
pulseapp->prefs);
|
||||
fPrefsWindow->Show();
|
||||
DetachCurrentMessage();
|
||||
message->AddMessenger("settingsListener", this);
|
||||
be_app->PostMessage(message);
|
||||
break;
|
||||
}
|
||||
case PV_ABOUT: {
|
||||
PulseApp::ShowAbout(true);
|
||||
be_app->PostMessage(B_ABOUT_REQUESTED);
|
||||
break;
|
||||
}
|
||||
case PV_QUIT:
|
||||
@ -131,27 +118,27 @@ PulseWindow::SetMode(int newmode)
|
||||
switch (newmode) {
|
||||
case PV_NORMAL_MODE:
|
||||
if (fMode == MINI_WINDOW_MODE) {
|
||||
pulseapp->prefs->mini_window_rect = Frame();
|
||||
pulseapp->prefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
pulseapp->prefs->Save();
|
||||
pulseapp->fPrefs->mini_window_rect = Frame();
|
||||
pulseapp->fPrefs->window_mode = NORMAL_WINDOW_MODE;
|
||||
pulseapp->fPrefs->Save();
|
||||
}
|
||||
fMiniPulseView->Hide();
|
||||
fNormalPulseView->Show();
|
||||
fMode = NORMAL_WINDOW_MODE;
|
||||
SetType(B_TITLED_WINDOW);
|
||||
SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
|
||||
ResizeTo(pulseapp->prefs->normal_window_rect.IntegerWidth(),
|
||||
pulseapp->prefs->normal_window_rect.IntegerHeight());
|
||||
MoveTo(pulseapp->prefs->normal_window_rect.left,
|
||||
pulseapp->prefs->normal_window_rect.top);
|
||||
ResizeTo(pulseapp->fPrefs->normal_window_rect.IntegerWidth(),
|
||||
pulseapp->fPrefs->normal_window_rect.IntegerHeight());
|
||||
MoveTo(pulseapp->fPrefs->normal_window_rect.left,
|
||||
pulseapp->fPrefs->normal_window_rect.top);
|
||||
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||
break;
|
||||
|
||||
case PV_MINI_MODE:
|
||||
if (fMode == NORMAL_WINDOW_MODE) {
|
||||
pulseapp->prefs->normal_window_rect = Frame();
|
||||
pulseapp->prefs->window_mode = MINI_WINDOW_MODE;
|
||||
pulseapp->prefs->Save();
|
||||
pulseapp->fPrefs->normal_window_rect = Frame();
|
||||
pulseapp->fPrefs->window_mode = MINI_WINDOW_MODE;
|
||||
pulseapp->fPrefs->Save();
|
||||
}
|
||||
fNormalPulseView->Hide();
|
||||
fMiniPulseView->Show();
|
||||
@ -160,10 +147,10 @@ PulseWindow::SetMode(int newmode)
|
||||
SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
SetFlags(B_NOT_ZOOMABLE);
|
||||
SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
|
||||
ResizeTo(pulseapp->prefs->mini_window_rect.IntegerWidth(),
|
||||
pulseapp->prefs->mini_window_rect.IntegerHeight());
|
||||
MoveTo(pulseapp->prefs->mini_window_rect.left,
|
||||
pulseapp->prefs->mini_window_rect.top);
|
||||
ResizeTo(pulseapp->fPrefs->mini_window_rect.IntegerWidth(),
|
||||
pulseapp->fPrefs->mini_window_rect.IntegerHeight());
|
||||
MoveTo(pulseapp->fPrefs->mini_window_rect.left,
|
||||
pulseapp->fPrefs->mini_window_rect.top);
|
||||
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
|
||||
break;
|
||||
|
||||
@ -171,8 +158,8 @@ PulseWindow::SetMode(int newmode)
|
||||
// Do not set window's mode to DESKBAR_MODE because the
|
||||
// destructor needs to save the correct BRect. ~PulseApp()
|
||||
// will handle launching the replicant after our prefs are saved.
|
||||
pulseapp->prefs->window_mode = DESKBAR_MODE;
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
pulseapp->fPrefs->window_mode = DESKBAR_MODE;
|
||||
LoadInDeskbar();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -181,6 +168,5 @@ PulseWindow::SetMode(int newmode)
|
||||
bool
|
||||
PulseWindow::QuitRequested()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include "NormalPulseView.h"
|
||||
#include "MiniPulseView.h"
|
||||
#include "PrefsWindow.h"
|
||||
|
||||
|
||||
class PulseWindow : public BWindow {
|
||||
@ -32,7 +31,6 @@ class PulseWindow : public BWindow {
|
||||
private:
|
||||
NormalPulseView* fNormalPulseView;
|
||||
MiniPulseView* fMiniPulseView;
|
||||
PrefsWindow* fPrefsWindow;
|
||||
int32 fMode;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user