* Now uses the B_ALL_WORKSPACES flag when it's supposed to show on all

workspaces.
* It uses the Haiku-specific B_SAME_POSITION_IN_ALL_WORKSPACES to behave
  in the same way as before (which I couldn't really test, though).
* Some cleanup, removed extraneous white space.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24633 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-03-28 19:12:50 +00:00
parent 9dbce7a4e7
commit 6c14516a18
+25 -19
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2006, Haiku.
* Copyright 2006-2008, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -28,11 +28,11 @@
// constructor
MainWindow::MainWindow(const char* name, BRect frame, bool addDefaultButtons)
: BWindow(frame, name,
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
: BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
| B_WILL_ACCEPT_FIRST_CLICK | B_NO_WORKSPACE_ACTIVATION
| B_AUTO_UPDATE_SIZE_LIMITS),
| B_AUTO_UPDATE_SIZE_LIMITS | B_SAME_POSITION_IN_ALL_WORKSPACES,
B_ALL_WORKSPACES),
fSettings(new BMessage('sett')),
fPadView(new PadView("pad view")),
fLastID(0),
@@ -60,7 +60,8 @@ MainWindow::MainWindow(const char* name, BRect frame, BMessage* settings)
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
| B_WILL_ACCEPT_FIRST_CLICK | B_NO_WORKSPACE_ACTIVATION
| B_AUTO_UPDATE_SIZE_LIMITS),
| B_AUTO_UPDATE_SIZE_LIMITS | B_SAME_POSITION_IN_ALL_WORKSPACES,
B_ALL_WORKSPACES),
fSettings(settings),
fPadView(new PadView("pad view")),
fLastID(0),
@@ -112,7 +113,8 @@ MainWindow::MessageReceived(BMessage* message)
case MSG_LAUNCH: {
BView* pointer;
if (message->FindPointer("be:source", (void**)&pointer) >= B_OK) {
if (LaunchButton* button = dynamic_cast<LaunchButton*>(pointer)) {
if (LaunchButton* button
= dynamic_cast<LaunchButton*>(pointer)) {
if (button->AppSignature()) {
be_roster->Launch(button->AppSignature());
} else {
@@ -139,8 +141,8 @@ MainWindow::MessageReceived(BMessage* message)
case MSG_ADD_SLOT: {
LaunchButton* button;
if (message->FindPointer("be:source", (void**)&button) >= B_OK) {
fPadView->AddButton(new LaunchButton("launch button", fLastID++, NULL,
new BMessage(MSG_LAUNCH)), button);
fPadView->AddButton(new LaunchButton("launch button", fLastID++,
NULL, new BMessage(MSG_LAUNCH)), button);
}
break;
}
@@ -173,10 +175,8 @@ MainWindow::MessageReceived(BMessage* message)
BString helper("Description for '");
helper << ref->name << "'";
// BRect* frame = fNamePanelFrame.IsValid() ? &fNamePanelFrame : NULL;
new NamePanel(helper.String(),
button->Description(),
this, this,
new BMessage(*message),
new NamePanel(helper.String(), button->Description(),
this, this, new BMessage(*message),
fNamePanelFrame);
}
}
@@ -201,6 +201,10 @@ MainWindow::MessageReceived(BMessage* message)
break;
case MSG_SHOW_ON_ALL_WORKSPACES:
fShowOnAllWorkspaces = !fShowOnAllWorkspaces;
if (fShowOnAllWorkspaces)
SetWorkspaces(B_ALL_WORKSPACES);
else
SetWorkspaces(1L << current_workspace());
break;
case B_SIMPLE_DATA:
case B_REFS_RECEIVED:
@@ -236,11 +240,10 @@ void
MainWindow::WorkspaceActivated(int32 workspace, bool active)
{
if (fShowOnAllWorkspaces) {
if (!active) {
SetWorkspaces(1 << current_workspace());
_AdjustLocation(Frame());
} else
if (!active)
_GetLocation();
else
_AdjustLocation(Frame());
}
}
@@ -321,8 +324,8 @@ MainWindow::LoadSettings(const BMessage* message)
const char* path;
bool buttonAdded = false;
for (int32 i = 0; message->FindString("path", i, &path) >= B_OK; i++) {
LaunchButton* button = new LaunchButton("launch button", fLastID++, NULL,
new BMessage(MSG_LAUNCH));
LaunchButton* button = new LaunchButton("launch button", fLastID++,
NULL, new BMessage(MSG_LAUNCH));
fPadView->AddButton(button);
BString signature;
if (message->FindString("signature", i, &signature) >= B_OK
@@ -348,6 +351,8 @@ MainWindow::LoadSettings(const BMessage* message)
bool showOnAllWorkspaces;
if (message->FindBool("all workspaces", &showOnAllWorkspaces) == B_OK)
fShowOnAllWorkspaces = showOnAllWorkspaces;
SetWorkspaces(showOnAllWorkspaces
? B_ALL_WORKSPACES : 1L << current_workspace());
if (!fShowOnAllWorkspaces) {
uint32 workspaces;
if (message->FindInt32("workspaces", (int32*)&workspaces) == B_OK)
@@ -421,7 +426,8 @@ MainWindow::_GetLocation()
{
BRect frame = Frame();
BPoint origin = frame.LeftTop();
BPoint center(origin.x + frame.Width() / 2.0, origin.y + frame.Height() / 2.0);
BPoint center(origin.x + frame.Width() / 2.0,
origin.y + frame.Height() / 2.0);
BScreen screen(this);
BRect screenFrame = screen.Frame();
fScreenPosition.x = center.x / screenFrame.Width();