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 <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Adrien Destugues
2020-05-10 15:48:57 +00:00
committed by waddlesplash
parent db3a94141a
commit e04f6f31b0
9 changed files with 199 additions and 133 deletions
+2 -2
View File
@@ -277,7 +277,7 @@ CPUButton::MessageReceived(BMessage *message)
{ {
switch (message->what) { switch (message->what) {
case B_ABOUT_REQUESTED: { case B_ABOUT_REQUESTED: {
PulseApp::ShowAbout(false); be_app->PostMessage(B_ABOUT_REQUESTED);
break; break;
} }
case PV_REPLICANT_PULSE: { case PV_REPLICANT_PULSE: {
@@ -330,7 +330,7 @@ CPUButton::AttachedToWindow()
delete prefs; delete prefs;
} else { } else {
PulseApp *pulseapp = (PulseApp *)be_app; PulseApp *pulseapp = (PulseApp *)be_app;
UpdateColors(pulseapp->prefs->normal_bar_color); UpdateColors(pulseapp->fPrefs->normal_bar_color);
_AddDragger(); _AddDragger();
} }
+51 -26
View File
@@ -29,13 +29,17 @@
#define B_TRANSLATION_CONTEXT "DeskbarPulseView" #define B_TRANSLATION_CONTEXT "DeskbarPulseView"
DeskbarPulseView::DeskbarPulseView(BRect rect) : MiniPulseView(rect, "DeskbarPulseView") { DeskbarPulseView::DeskbarPulseView(BRect rect)
: MiniPulseView(rect, "DeskbarPulseView")
{
messagerunner = NULL; messagerunner = NULL;
prefs = NULL; prefs = NULL;
prefswindow = NULL;
} }
DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) {
DeskbarPulseView::DeskbarPulseView(BMessage *message)
: MiniPulseView(message)
{
mode1->SetLabel(B_TRANSLATE("Normal mode")); mode1->SetLabel(B_TRANSLATE("Normal mode"));
mode1->SetMessage(new BMessage(PV_NORMAL_MODE)); mode1->SetMessage(new BMessage(PV_NORMAL_MODE));
mode2->SetLabel(B_TRANSLATE("Mini mode")); mode2->SetLabel(B_TRANSLATE("Mini mode"));
@@ -61,10 +65,12 @@ DeskbarPulseView::DeskbarPulseView(BMessage *message) : MiniPulseView(message) {
SetViewColor(idle_color); SetViewColor(idle_color);
messagerunner = NULL; messagerunner = NULL;
prefswindow = NULL;
} }
void DeskbarPulseView::AttachedToWindow() {
void
DeskbarPulseView::AttachedToWindow()
{
BMessenger messenger(this); BMessenger messenger(this);
mode1->SetTarget(messenger); mode1->SetTarget(messenger);
mode2->SetTarget(messenger); mode2->SetTarget(messenger);
@@ -86,7 +92,10 @@ void DeskbarPulseView::AttachedToWindow() {
200000, -1); 200000, -1);
} }
void DeskbarPulseView::MouseDown(BPoint point) {
void
DeskbarPulseView::MouseDown(BPoint point)
{
BPoint cursor; BPoint cursor;
uint32 buttons; uint32 buttons;
MakeFocus(true); MakeFocus(true);
@@ -103,11 +112,17 @@ void DeskbarPulseView::MouseDown(BPoint point) {
} else MiniPulseView::MouseDown(point); } else MiniPulseView::MouseDown(point);
} }
void DeskbarPulseView::Pulse() {
void
DeskbarPulseView::Pulse()
{
// Override and do nothing here // Override and do nothing here
} }
void DeskbarPulseView::MessageReceived(BMessage *message) {
void
DeskbarPulseView::MessageReceived(BMessage *message)
{
switch (message->what) { switch (message->what) {
case PV_NORMAL_MODE: case PV_NORMAL_MODE:
SetMode(true); SetMode(true);
@@ -118,16 +133,16 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
Remove(); Remove();
break; break;
case PV_PREFERENCES: case PV_PREFERENCES:
if (prefswindow != NULL) { {
prefswindow->Activate(true); 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; break;
} }
prefswindow = new PrefsWindow(prefs->prefs_window_rect, case PV_ABOUT:
"Pulse settings", new BMessenger(this), prefs); {
prefswindow->Show(); BMessage aboutRequest(B_ABOUT_REQUESTED);
break; be_roster->Launch("applicaiton/x-vnd.Haiku-Pulse", &aboutRequest);
case PV_ABOUT: {
PulseApp::ShowAbout(false);
break; break;
} }
case PV_QUIT: case PV_QUIT:
@@ -146,9 +161,6 @@ void DeskbarPulseView::MessageReceived(BMessage *message) {
Update(); Update();
Draw(Bounds()); Draw(Bounds());
break; break;
case PRV_QUIT:
prefswindow = NULL;
break;
case PV_CPU_MENU_ITEM: case PV_CPU_MENU_ITEM:
ChangeCPUState(message); ChangeCPUState(message);
break; 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); 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); PulseView::Archive(data, deep);
data->AddString("add_on", APP_SIGNATURE); data->AddString("add_on", APP_SIGNATURE);
data->AddString("class", "DeskbarPulseView"); data->AddString("class", "DeskbarPulseView");
return B_OK; return B_OK;
} }
void DeskbarPulseView::Remove() {
void
DeskbarPulseView::Remove()
{
// Remove ourselves from the deskbar by name // Remove ourselves from the deskbar by name
BDeskbar *deskbar = new BDeskbar(); BDeskbar *deskbar = new BDeskbar();
status_t err = deskbar->RemoveItem("DeskbarPulseView"); status_t err = deskbar->RemoveItem("DeskbarPulseView");
@@ -187,15 +208,19 @@ void DeskbarPulseView::Remove() {
delete deskbar; delete deskbar;
} }
void DeskbarPulseView::SetMode(bool normal) {
void
DeskbarPulseView::SetMode(bool normal)
{
if (normal) prefs->window_mode = NORMAL_WINDOW_MODE; if (normal) prefs->window_mode = NORMAL_WINDOW_MODE;
else prefs->window_mode = MINI_WINDOW_MODE; else prefs->window_mode = MINI_WINDOW_MODE;
prefs->Save(); prefs->Save();
be_roster->Launch(APP_SIGNATURE); be_roster->Launch(APP_SIGNATURE);
} }
DeskbarPulseView::~DeskbarPulseView() {
DeskbarPulseView::~DeskbarPulseView()
{
if (messagerunner != NULL) delete messagerunner; if (messagerunner != NULL) delete messagerunner;
if (prefswindow != NULL && prefswindow->Lock()) prefswindow->Quit();
if (prefs != NULL) delete prefs; if (prefs != NULL) delete prefs;
} }
+3 -2
View File
@@ -15,7 +15,9 @@
#include "PrefsWindow.h" #include "PrefsWindow.h"
#include <app/MessageRunner.h> #include <app/MessageRunner.h>
class DeskbarPulseView : public MiniPulseView {
class DeskbarPulseView : public MiniPulseView
{
public: public:
DeskbarPulseView(BRect rect); DeskbarPulseView(BRect rect);
DeskbarPulseView(BMessage *message); DeskbarPulseView(BMessage *message);
@@ -32,7 +34,6 @@ class DeskbarPulseView : public MiniPulseView {
void Remove(); void Remove();
void SetMode(bool normal); void SetMode(bool normal);
PrefsWindow *prefswindow;
Prefs *prefs; Prefs *prefs;
BMessageRunner *messagerunner; BMessageRunner *messagerunner;
}; };
+1 -1
View File
@@ -135,6 +135,6 @@ PrefsWindow::MessageReceived(BMessage *message)
bool bool
PrefsWindow::QuitRequested() PrefsWindow::QuitRequested()
{ {
fTarget.SendMessage(new BMessage(PRV_QUIT)); be_app->PostMessage(new BMessage(PRV_QUIT));
return true; return true;
} }
+1 -1
View File
@@ -67,7 +67,7 @@ ProgressBar::UpdateColors(int32 color, bool fade)
void void
ProgressBar::AttachedToWindow() ProgressBar::AttachedToWindow()
{ {
Prefs *prefs = ((PulseApp *)be_app)->prefs; Prefs *prefs = ((PulseApp *)be_app)->fPrefs;
UpdateColors(prefs->normal_bar_color, prefs->normal_fade_colors); UpdateColors(prefs->normal_bar_color, prefs->normal_fade_colors);
} }
+99 -51
View File
@@ -35,10 +35,12 @@
PulseApp::PulseApp(int argc, char **argv) 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; int mini = false, deskbar = false, normal = false;
uint32 framecolor = 0, activecolor = 0, idlecolor = 0; uint32 framecolor = 0, activecolor = 0, idlecolor = 0;
@@ -84,10 +86,10 @@ PulseApp::PulseApp(int argc, char **argv)
} }
break; break;
case 'w': case 'w':
prefs->deskbar_icon_width = atoi(optarg); fPrefs->deskbar_icon_width = atoi(optarg);
if (prefs->deskbar_icon_width < GetMinimumViewWidth()) if (fPrefs->deskbar_icon_width < GetMinimumViewWidth())
prefs->deskbar_icon_width = GetMinimumViewWidth(); fPrefs->deskbar_icon_width = GetMinimumViewWidth();
else if (prefs->deskbar_icon_width > 50) prefs->deskbar_icon_width = 50; else if (fPrefs->deskbar_icon_width > 50) fPrefs->deskbar_icon_width = 50;
break; break;
case 'h': case 'h':
case '?': case '?':
@@ -100,48 +102,47 @@ PulseApp::PulseApp(int argc, char **argv)
} }
if (deskbar) { if (deskbar) {
prefs->window_mode = DESKBAR_MODE; fPrefs->window_mode = DESKBAR_MODE;
if (activecolor != 0) if (activecolor != 0)
prefs->deskbar_active_color = activecolor; fPrefs->deskbar_active_color = activecolor;
if (idlecolor != 0) if (idlecolor != 0)
prefs->deskbar_idle_color = idlecolor; fPrefs->deskbar_idle_color = idlecolor;
if (framecolor != 0) if (framecolor != 0)
prefs->deskbar_frame_color = framecolor; fPrefs->deskbar_frame_color = framecolor;
} else if (mini) { } else if (mini) {
prefs->window_mode = MINI_WINDOW_MODE; fPrefs->window_mode = MINI_WINDOW_MODE;
if (activecolor != 0) if (activecolor != 0)
prefs->mini_active_color = activecolor; fPrefs->mini_active_color = activecolor;
if (idlecolor != 0) if (idlecolor != 0)
prefs->mini_idle_color = idlecolor; fPrefs->mini_idle_color = idlecolor;
if (framecolor != 0) if (framecolor != 0)
prefs->mini_frame_color = framecolor; fPrefs->mini_frame_color = framecolor;
} else if (normal) } else if (normal)
prefs->window_mode = NORMAL_WINDOW_MODE; fPrefs->window_mode = NORMAL_WINDOW_MODE;
prefs->Save(); fPrefs->Save();
}
void
PulseApp::ReadyToRun()
{
if (!fRunFromReplicant)
BuildPulse(); BuildPulse();
fIsRunning = true;
} }
void void
PulseApp::BuildPulse() 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; PulseWindow *pulseWindow = NULL;
if (prefs->window_mode == MINI_WINDOW_MODE) if (fPrefs->window_mode == MINI_WINDOW_MODE)
pulseWindow = new PulseWindow(prefs->mini_window_rect); pulseWindow = new PulseWindow(fPrefs->mini_window_rect);
else else
pulseWindow = new PulseWindow(prefs->normal_window_rect); pulseWindow = new PulseWindow(fPrefs->normal_window_rect);
pulseWindow->MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN); pulseWindow->MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
pulseWindow->Show(); pulseWindow->Show();
@@ -150,32 +151,75 @@ PulseApp::BuildPulse()
PulseApp::~PulseApp() PulseApp::~PulseApp()
{ {
// Load the replicant after we save our preferences so they don't fPrefs->Save();
// get overwritten by DeskbarPulseView's instance
prefs->Save();
if (prefs->window_mode == DESKBAR_MODE)
LoadInDeskbar();
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 void
PulseApp::AboutRequested() PulseApp::AboutRequested()
{ {
PulseApp::ShowAbout(true); BString name = B_TRANSLATE("Pulse");
}
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 message = B_TRANSLATE( BString message = B_TRANSLATE(
"%s\n\nBy David Ramsey and Arve Hjønnevåg\n" "%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"), BAlert *alert = new BAlert(B_TRANSLATE("Info"),
message.String(), B_TRANSLATE("OK")); message.String(), B_TRANSLATE("OK"));
if (fRunFromReplicant)
alert->SetFlags(alert->Flags() | B_QUIT_ON_WINDOW_CLOSE);
BTextView* view = alert->TextView(); BTextView* view = alert->TextView();
BFont font; BFont font;
@@ -196,6 +243,7 @@ PulseApp::ShowAbout(bool asApplication)
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
// Use the asynchronous version so we don't block the window's thread // Use the asynchronous version so we don't block the window's thread
alert->Go(NULL); alert->Go(NULL);
fRunFromReplicant = false;
} }
// #pragma mark - // #pragma mark -
@@ -259,10 +307,10 @@ LoadInDeskbar()
} }
// Must be 16 pixels high, the width is retrieved from the Prefs class // 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(); int min_width = GetMinimumViewWidth();
if (width < min_width) { if (width < min_width) {
pulseapp->prefs->deskbar_icon_width = min_width; pulseapp->fPrefs->deskbar_icon_width = min_width;
width = min_width; width = min_width;
} }
+11 -3
View File
@@ -16,6 +16,7 @@
#include <Catalog.h> #include <Catalog.h>
#include "Prefs.h" #include "Prefs.h"
#include "PrefsWindow.h"
class PulseApp : public BApplication { class PulseApp : public BApplication {
@@ -23,13 +24,20 @@ public:
PulseApp(int argc, char **argv); PulseApp(int argc, char **argv);
~PulseApp(); ~PulseApp();
virtual void MessageReceived(BMessage* message);
virtual void ReadyToRun();
virtual void AboutRequested(); virtual void AboutRequested();
static void ShowAbout(bool asApplication);
Prefs* prefs;
private: private:
void BuildPulse(); void BuildPulse();
public:
Prefs* fPrefs;
private:
bool fRunFromReplicant;
bool fIsRunning;
PrefsWindow* fPrefsWindow;
}; };
extern bool LastEnabledCPU(unsigned int cpu); extern bool LastEnabledCPU(unsigned int cpu);
+25 -39
View File
@@ -30,7 +30,7 @@
PulseWindow::PulseWindow(BRect rect) PulseWindow::PulseWindow(BRect rect)
: :
BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Pulse"), B_TITLED_WINDOW, 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); SetPulseRate(200000);
@@ -40,10 +40,10 @@ PulseWindow::PulseWindow(BRect rect)
AddChild(fNormalPulseView); AddChild(fNormalPulseView);
fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView", fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView",
pulseapp->prefs); pulseapp->fPrefs);
AddChild(fMiniPulseView); AddChild(fMiniPulseView);
fMode = pulseapp->prefs->window_mode; fMode = pulseapp->fPrefs->window_mode;
if (fMode == MINI_WINDOW_MODE) { if (fMode == MINI_WINDOW_MODE) {
SetLook(B_MODAL_WINDOW_LOOK); SetLook(B_MODAL_WINDOW_LOOK);
SetFeel(B_NORMAL_WINDOW_FEEL); SetFeel(B_NORMAL_WINDOW_FEEL);
@@ -53,8 +53,6 @@ PulseWindow::PulseWindow(BRect rect)
ResizeTo(rect.Width(), rect.Height()); ResizeTo(rect.Width(), rect.Height());
} else } else
fMiniPulseView->Hide(); fMiniPulseView->Hide();
fPrefsWindow = NULL;
} }
@@ -63,9 +61,9 @@ PulseWindow::~PulseWindow()
PulseApp *pulseapp = (PulseApp *)be_app; PulseApp *pulseapp = (PulseApp *)be_app;
if (fMode == NORMAL_WINDOW_MODE) if (fMode == NORMAL_WINDOW_MODE)
pulseapp->prefs->normal_window_rect = Frame(); pulseapp->fPrefs->normal_window_rect = Frame();
else if (fMode == MINI_WINDOW_MODE) 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: case PRV_MINI_CHANGE_COLOR:
fMiniPulseView->UpdateColors(message); fMiniPulseView->UpdateColors(message);
break; break;
case PRV_QUIT:
fPrefsWindow = NULL;
break;
case PV_PREFERENCES: { case PV_PREFERENCES: {
// If the window is already open, bring it to the front DetachCurrentMessage();
if (fPrefsWindow != NULL) { message->AddMessenger("settingsListener", this);
fPrefsWindow->Activate(true); be_app->PostMessage(message);
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();
break; break;
} }
case PV_ABOUT: { case PV_ABOUT: {
PulseApp::ShowAbout(true); be_app->PostMessage(B_ABOUT_REQUESTED);
break; break;
} }
case PV_QUIT: case PV_QUIT:
@@ -131,27 +118,27 @@ PulseWindow::SetMode(int newmode)
switch (newmode) { switch (newmode) {
case PV_NORMAL_MODE: case PV_NORMAL_MODE:
if (fMode == MINI_WINDOW_MODE) { if (fMode == MINI_WINDOW_MODE) {
pulseapp->prefs->mini_window_rect = Frame(); pulseapp->fPrefs->mini_window_rect = Frame();
pulseapp->prefs->window_mode = NORMAL_WINDOW_MODE; pulseapp->fPrefs->window_mode = NORMAL_WINDOW_MODE;
pulseapp->prefs->Save(); pulseapp->fPrefs->Save();
} }
fMiniPulseView->Hide(); fMiniPulseView->Hide();
fNormalPulseView->Show(); fNormalPulseView->Show();
fMode = NORMAL_WINDOW_MODE; fMode = NORMAL_WINDOW_MODE;
SetType(B_TITLED_WINDOW); SetType(B_TITLED_WINDOW);
SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE); SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
ResizeTo(pulseapp->prefs->normal_window_rect.IntegerWidth(), ResizeTo(pulseapp->fPrefs->normal_window_rect.IntegerWidth(),
pulseapp->prefs->normal_window_rect.IntegerHeight()); pulseapp->fPrefs->normal_window_rect.IntegerHeight());
MoveTo(pulseapp->prefs->normal_window_rect.left, MoveTo(pulseapp->fPrefs->normal_window_rect.left,
pulseapp->prefs->normal_window_rect.top); pulseapp->fPrefs->normal_window_rect.top);
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN); MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
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->fPrefs->normal_window_rect = Frame();
pulseapp->prefs->window_mode = MINI_WINDOW_MODE; pulseapp->fPrefs->window_mode = MINI_WINDOW_MODE;
pulseapp->prefs->Save(); pulseapp->fPrefs->Save();
} }
fNormalPulseView->Hide(); fNormalPulseView->Hide();
fMiniPulseView->Show(); fMiniPulseView->Show();
@@ -160,10 +147,10 @@ PulseWindow::SetMode(int newmode)
SetFeel(B_NORMAL_WINDOW_FEEL); SetFeel(B_NORMAL_WINDOW_FEEL);
SetFlags(B_NOT_ZOOMABLE); SetFlags(B_NOT_ZOOMABLE);
SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096); SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
ResizeTo(pulseapp->prefs->mini_window_rect.IntegerWidth(), ResizeTo(pulseapp->fPrefs->mini_window_rect.IntegerWidth(),
pulseapp->prefs->mini_window_rect.IntegerHeight()); pulseapp->fPrefs->mini_window_rect.IntegerHeight());
MoveTo(pulseapp->prefs->mini_window_rect.left, MoveTo(pulseapp->fPrefs->mini_window_rect.left,
pulseapp->prefs->mini_window_rect.top); pulseapp->fPrefs->mini_window_rect.top);
MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN); MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN);
break; break;
@@ -171,8 +158,8 @@ PulseWindow::SetMode(int newmode)
// 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()
// will handle launching the replicant after our prefs are saved. // will handle launching the replicant after our prefs are saved.
pulseapp->prefs->window_mode = DESKBAR_MODE; pulseapp->fPrefs->window_mode = DESKBAR_MODE;
PostMessage(B_QUIT_REQUESTED); LoadInDeskbar();
break; break;
} }
} }
@@ -181,6 +168,5 @@ PulseWindow::SetMode(int newmode)
bool bool
PulseWindow::QuitRequested() PulseWindow::QuitRequested()
{ {
be_app->PostMessage(B_QUIT_REQUESTED);
return true; return true;
} }
-2
View File
@@ -16,7 +16,6 @@
#include "NormalPulseView.h" #include "NormalPulseView.h"
#include "MiniPulseView.h" #include "MiniPulseView.h"
#include "PrefsWindow.h"
class PulseWindow : public BWindow { class PulseWindow : public BWindow {
@@ -32,7 +31,6 @@ class PulseWindow : public BWindow {
private: private:
NormalPulseView* fNormalPulseView; NormalPulseView* fNormalPulseView;
MiniPulseView* fMiniPulseView; MiniPulseView* fMiniPulseView;
PrefsWindow* fPrefsWindow;
int32 fMode; int32 fMode;
}; };