* Moved about window into the view and made it accessible from the
replicant as well. * Added a context menu that allows you to change how Workspaces looks and behaves (previously accessible only using command line options). * The settings changes are now remembered; we're now using a new settings file (flattened BMessage), but can still read old settings files if it exists. * Renamed WorkspacesPreferences to WorkspacesSettings. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,7 +17,9 @@
|
|||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
@@ -32,26 +34,50 @@
|
|||||||
#include <WindowPrivate.h>
|
#include <WindowPrivate.h>
|
||||||
|
|
||||||
|
|
||||||
static const char *kSignature = "application/x-vnd.Be-WORK";
|
static const char* kSignature = "application/x-vnd.Be-WORK";
|
||||||
static const char *kWorkspacesSettingFile = "Workspace_data";
|
static const char* kOldSettingFile = "Workspace_data";
|
||||||
|
static const char* kSettingsFile = "Workspaces_settings";
|
||||||
|
|
||||||
|
static const uint32 kMsgChangeCount = 'chWC';
|
||||||
|
static const uint32 kMsgToggleTitle = 'tgTt';
|
||||||
|
static const uint32 kMsgToggleBorder = 'tgBd';
|
||||||
|
static const uint32 kMsgToggleAutoRaise = 'tgAR';
|
||||||
|
static const uint32 kMsgToggleAlwaysOnTop = 'tgAT';
|
||||||
|
|
||||||
static const float kScreenBorderOffset = 10.0;
|
static const float kScreenBorderOffset = 10.0;
|
||||||
|
|
||||||
|
|
||||||
class WorkspacesPreferences {
|
class WorkspacesSettings {
|
||||||
public:
|
public:
|
||||||
WorkspacesPreferences();
|
WorkspacesSettings();
|
||||||
virtual ~WorkspacesPreferences();
|
virtual ~WorkspacesSettings();
|
||||||
|
|
||||||
BRect WindowFrame() const { return fWindowFrame; }
|
BRect WindowFrame() const { return fWindowFrame; }
|
||||||
BRect ScreenFrame() const { return fScreenFrame; }
|
BRect ScreenFrame() const { return fScreenFrame; }
|
||||||
|
|
||||||
|
bool AutoRaising() const { return fAutoRaising; }
|
||||||
|
bool AlwaysOnTop() const { return fAlwaysOnTop; }
|
||||||
|
bool HasTitle() const { return fHasTitle; }
|
||||||
|
bool HasBorder() const { return fHasBorder; }
|
||||||
|
|
||||||
void UpdateFramesForScreen(BRect screenFrame);
|
void UpdateFramesForScreen(BRect screenFrame);
|
||||||
void UpdateScreenFrame();
|
void UpdateScreenFrame();
|
||||||
|
|
||||||
void SetWindowFrame(BRect);
|
void SetWindowFrame(BRect);
|
||||||
|
void SetAutoRaising(bool enable) { fAutoRaising = enable; }
|
||||||
|
void SetAlwaysOnTop(bool enable) { fAlwaysOnTop = enable; }
|
||||||
|
void SetHasTitle(bool enable) { fHasTitle = enable; }
|
||||||
|
void SetHasBorder(bool enable) { fHasBorder = enable; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BRect fWindowFrame, fScreenFrame;
|
status_t _Open(BFile& file, int mode);
|
||||||
|
|
||||||
|
BRect fWindowFrame;
|
||||||
|
BRect fScreenFrame;
|
||||||
|
bool fAutoRaising;
|
||||||
|
bool fAlwaysOnTop;
|
||||||
|
bool fHasTitle;
|
||||||
|
bool fHasBorder;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorkspacesView : public BView {
|
class WorkspacesView : public BView {
|
||||||
@@ -63,14 +89,18 @@ class WorkspacesView : public BView {
|
|||||||
static WorkspacesView* Instantiate(BMessage* archive);
|
static WorkspacesView* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
|
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage);
|
const BMessage* dragMessage);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _AboutRequested();
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorkspacesWindow : public BWindow {
|
class WorkspacesWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
WorkspacesWindow(WorkspacesPreferences *fPreferences);
|
WorkspacesWindow(WorkspacesSettings *settings);
|
||||||
virtual ~WorkspacesWindow();
|
virtual ~WorkspacesWindow();
|
||||||
|
|
||||||
virtual void ScreenChanged(BRect frame, color_space mode);
|
virtual void ScreenChanged(BRect frame, color_space mode);
|
||||||
@@ -81,11 +111,13 @@ class WorkspacesWindow : public BWindow {
|
|||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
void SetAutoRaise();
|
void SetAutoRaise(bool enable);
|
||||||
|
bool IsAutoRaising() const { return fAutoRaising; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorkspacesPreferences *fPreferences;
|
WorkspacesSettings *fSettings;
|
||||||
BRect fPreviousFrame;
|
BRect fPreviousFrame;
|
||||||
|
bool fAutoRaising;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WorkspacesApp : public BApplication {
|
class WorkspacesApp : public BApplication {
|
||||||
@@ -104,40 +136,67 @@ class WorkspacesApp : public BApplication {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WorkspacesPreferences::WorkspacesPreferences()
|
WorkspacesSettings::WorkspacesSettings()
|
||||||
|
:
|
||||||
|
fAutoRaising(false),
|
||||||
|
fAlwaysOnTop(false),
|
||||||
|
fHasTitle(true),
|
||||||
|
fHasBorder(true)
|
||||||
{
|
{
|
||||||
UpdateScreenFrame();
|
UpdateScreenFrame();
|
||||||
|
|
||||||
bool settingsValid = false;
|
bool loaded = false;
|
||||||
BPath path;
|
BScreen screen;
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
BFile file;
|
||||||
path.Append(kWorkspacesSettingFile);
|
if (_Open(file, B_READ_ONLY) == B_OK) {
|
||||||
BFile file(path.Path(), B_READ_ONLY);
|
BMessage settings;
|
||||||
if (file.InitCheck() == B_OK
|
if (settings.Unflatten(&file) == B_OK) {
|
||||||
&& file.Read(&fWindowFrame, sizeof(BRect)) == sizeof(BRect)) {
|
if (settings.FindRect("window", &fWindowFrame) == B_OK
|
||||||
// we now also store the frame of the screen to know
|
&& settings.FindRect("screen", &fScreenFrame) == B_OK)
|
||||||
// in which context the window frame has been chosen
|
loaded = true;
|
||||||
BScreen screen;
|
|
||||||
BRect frame;
|
settings.FindBool("auto-raise", &fAutoRaising);
|
||||||
if (file.Read(&frame, sizeof(BRect)) == sizeof(BRect)) {
|
settings.FindBool("always on top", &fAlwaysOnTop);
|
||||||
fScreenFrame = frame;
|
|
||||||
// if the current screen frame is different from the one
|
if (settings.FindBool("has title", &fHasTitle) != B_OK)
|
||||||
// just loaded, we need to alter the window frame accordingly
|
fHasTitle = true;
|
||||||
if (fScreenFrame != screen.Frame())
|
if (settings.FindBool("has border", &fHasBorder) != B_OK)
|
||||||
UpdateFramesForScreen(screen.Frame());
|
fHasBorder = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// try reading BeOS compatible settings
|
||||||
|
BPath path;
|
||||||
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
|
path.Append(kOldSettingFile);
|
||||||
|
BFile file(path.Path(), B_READ_ONLY);
|
||||||
|
if (file.InitCheck() == B_OK
|
||||||
|
&& file.Read(&fWindowFrame, sizeof(BRect)) == sizeof(BRect)) {
|
||||||
|
// we now also store the frame of the screen to know
|
||||||
|
// in which context the window frame has been chosen
|
||||||
|
BRect frame;
|
||||||
|
if (file.Read(&frame, sizeof(BRect)) == sizeof(BRect))
|
||||||
|
fScreenFrame = frame;
|
||||||
|
else
|
||||||
|
fScreenFrame = screen.Frame();
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if loaded values are valid
|
|
||||||
if (screen.Frame().right + 5 >= fWindowFrame.right
|
|
||||||
&& screen.Frame().bottom + 5 >= fWindowFrame.bottom
|
|
||||||
&& screen.Frame().left - 5 <= fWindowFrame.left
|
|
||||||
&& screen.Frame().top - 5 <= fWindowFrame.top)
|
|
||||||
settingsValid = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settingsValid) {
|
if (loaded) {
|
||||||
|
// if the current screen frame is different from the one
|
||||||
|
// just loaded, we need to alter the window frame accordingly
|
||||||
|
if (fScreenFrame != screen.Frame())
|
||||||
|
UpdateFramesForScreen(screen.Frame());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!loaded
|
||||||
|
|| !(screen.Frame().right + 5 >= fWindowFrame.right
|
||||||
|
&& screen.Frame().bottom + 5 >= fWindowFrame.bottom
|
||||||
|
&& screen.Frame().left - 5 <= fWindowFrame.left
|
||||||
|
&& screen.Frame().top - 5 <= fWindowFrame.top)) {
|
||||||
// set to some usable defaults
|
// set to some usable defaults
|
||||||
fWindowFrame = fScreenFrame;
|
fWindowFrame = fScreenFrame;
|
||||||
fWindowFrame.OffsetBy(-kScreenBorderOffset, -kScreenBorderOffset);
|
fWindowFrame.OffsetBy(-kScreenBorderOffset, -kScreenBorderOffset);
|
||||||
@@ -147,25 +206,51 @@ WorkspacesPreferences::WorkspacesPreferences()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WorkspacesPreferences::~WorkspacesPreferences()
|
WorkspacesSettings::~WorkspacesSettings()
|
||||||
{
|
{
|
||||||
// write settings file
|
// write settings file
|
||||||
BPath path;
|
BFile file;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
|
if (_Open(file, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path.Append(kWorkspacesSettingFile);
|
BMessage settings('wksp');
|
||||||
|
|
||||||
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
|
if (settings.AddRect("window", fWindowFrame) == B_OK
|
||||||
if (file.InitCheck() == B_OK) {
|
&& settings.AddRect("screen", fScreenFrame) == B_OK
|
||||||
file.Write(&fWindowFrame, sizeof(BRect));
|
&& settings.AddBool("auto-raise", fAutoRaising) == B_OK
|
||||||
file.Write(&fScreenFrame, sizeof(BRect));
|
&& settings.AddBool("always on top", fAlwaysOnTop) == B_OK
|
||||||
|
&& settings.AddBool("has title", fHasTitle) == B_OK
|
||||||
|
&& settings.AddBool("has border", fHasBorder) == B_OK)
|
||||||
|
settings.Flatten(&file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
WorkspacesSettings::_Open(BFile& file, int mode)
|
||||||
|
{
|
||||||
|
BPath path;
|
||||||
|
status_t status = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
|
||||||
|
if (status != B_OK)
|
||||||
|
status = find_directory(B_COMMON_SETTINGS_DIRECTORY, &path);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
path.Append(kSettingsFile);
|
||||||
|
|
||||||
|
status = file.SetTo(path.Path(), mode);
|
||||||
|
if (mode == B_READ_ONLY && status == B_ENTRY_NOT_FOUND) {
|
||||||
|
if (find_directory(B_COMMON_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
|
path.Append(kSettingsFile);
|
||||||
|
status = file.SetTo(path.Path(), mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesPreferences::UpdateFramesForScreen(BRect newScreenFrame)
|
WorkspacesSettings::UpdateFramesForScreen(BRect newScreenFrame)
|
||||||
{
|
{
|
||||||
// don't change the position if the screen frame hasn't changed
|
// don't change the position if the screen frame hasn't changed
|
||||||
if (newScreenFrame == fScreenFrame)
|
if (newScreenFrame == fScreenFrame)
|
||||||
@@ -186,7 +271,7 @@ WorkspacesPreferences::UpdateFramesForScreen(BRect newScreenFrame)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesPreferences::UpdateScreenFrame()
|
WorkspacesSettings::UpdateScreenFrame()
|
||||||
{
|
{
|
||||||
BScreen screen;
|
BScreen screen;
|
||||||
fScreenFrame = screen.Frame();
|
fScreenFrame = screen.Frame();
|
||||||
@@ -194,7 +279,7 @@ WorkspacesPreferences::UpdateScreenFrame()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesPreferences::SetWindowFrame(BRect frame)
|
WorkspacesSettings::SetWindowFrame(BRect frame)
|
||||||
{
|
{
|
||||||
fWindowFrame = frame;
|
fWindowFrame = frame;
|
||||||
}
|
}
|
||||||
@@ -249,6 +334,47 @@ WorkspacesView::Archive(BMessage* archive, bool deep) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WorkspacesView::_AboutRequested()
|
||||||
|
{
|
||||||
|
BAlert *alert = new BAlert("about", "Workspaces\n"
|
||||||
|
"written by François Revol, Axel Dörfler, and Matt Madia.\n\n"
|
||||||
|
"Copyright 2002-2008, Haiku.\n\n"
|
||||||
|
"Send windows behind using the Option key. "
|
||||||
|
"Move windows to front using the Control key.\n", "Ok");
|
||||||
|
BTextView *view = alert->TextView();
|
||||||
|
BFont font;
|
||||||
|
|
||||||
|
view->SetStylable(true);
|
||||||
|
|
||||||
|
view->GetFont(&font);
|
||||||
|
font.SetSize(18);
|
||||||
|
font.SetFace(B_BOLD_FACE);
|
||||||
|
view->SetFontAndColor(0, 10, &font);
|
||||||
|
|
||||||
|
alert->Go();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WorkspacesView::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case B_ABOUT_REQUESTED:
|
||||||
|
_AboutRequested();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgChangeCount:
|
||||||
|
be_roster->Launch("application/x-vnd.Be-SCRN");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesView::MouseMoved(BPoint where, uint32 transit,
|
WorkspacesView::MouseMoved(BPoint where, uint32 transit,
|
||||||
const BMessage* dragMessage)
|
const BMessage* dragMessage)
|
||||||
@@ -280,38 +406,92 @@ WorkspacesView::MouseDown(BPoint where)
|
|||||||
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
|
if ((buttons & B_SECONDARY_MOUSE_BUTTON) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: open menu
|
// open context menu
|
||||||
|
|
||||||
|
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
|
||||||
|
menu->SetFont(be_plain_font);
|
||||||
|
|
||||||
|
// TODO: alternatively change the count here directly?
|
||||||
|
BMenuItem* changeItem = new BMenuItem("Change Workspace Count"
|
||||||
|
B_UTF8_ELLIPSIS, new BMessage(kMsgChangeCount));
|
||||||
|
menu->AddItem(changeItem);
|
||||||
|
|
||||||
|
WorkspacesWindow* window = dynamic_cast<WorkspacesWindow*>(Window());
|
||||||
|
if (window != NULL) {
|
||||||
|
BMenuItem* item;
|
||||||
|
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
menu->AddItem(item = new BMenuItem("No title",
|
||||||
|
new BMessage(kMsgToggleTitle)));
|
||||||
|
if (window->Look() == B_MODAL_WINDOW_LOOK)
|
||||||
|
item->SetMarked(true);
|
||||||
|
menu->AddItem(item = new BMenuItem("No Border",
|
||||||
|
new BMessage(kMsgToggleBorder)));
|
||||||
|
if (window->Look() == B_NO_BORDER_WINDOW_LOOK)
|
||||||
|
item->SetMarked(true);
|
||||||
|
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
menu->AddItem(item = new BMenuItem("Always On Top",
|
||||||
|
new BMessage(kMsgToggleAlwaysOnTop)));
|
||||||
|
if (window->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
|
||||||
|
item->SetMarked(true);
|
||||||
|
menu->AddItem(item = new BMenuItem("Auto-Raise",
|
||||||
|
new BMessage(kMsgToggleAutoRaise)));
|
||||||
|
if (window->IsAutoRaising())
|
||||||
|
item->SetMarked(true);
|
||||||
|
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
menu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
|
||||||
|
new BMessage(B_ABOUT_REQUESTED)));
|
||||||
|
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
|
||||||
|
menu->SetTargetForItems(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeItem->SetTarget(this);
|
||||||
|
ConvertToScreen(&where);
|
||||||
|
menu->Go(where, true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
WorkspacesWindow::WorkspacesWindow(WorkspacesPreferences *preferences)
|
WorkspacesWindow::WorkspacesWindow(WorkspacesSettings *settings)
|
||||||
: BWindow(preferences->WindowFrame(), "Workspaces", B_TITLED_WINDOW_LOOK,
|
: BWindow(settings->WindowFrame(), "Workspaces", B_TITLED_WINDOW_LOOK,
|
||||||
B_NORMAL_WINDOW_FEEL, B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK,
|
B_NORMAL_WINDOW_FEEL, B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK,
|
||||||
B_ALL_WORKSPACES),
|
B_ALL_WORKSPACES),
|
||||||
fPreferences(preferences)
|
fSettings(settings),
|
||||||
|
fAutoRaising(false)
|
||||||
{
|
{
|
||||||
AddChild(new WorkspacesView(Bounds()));
|
AddChild(new WorkspacesView(Bounds()));
|
||||||
fPreviousFrame = Frame();
|
fPreviousFrame = Frame();
|
||||||
|
|
||||||
|
if (!fSettings->HasTitle())
|
||||||
|
SetLook(B_MODAL_WINDOW_LOOK);
|
||||||
|
else if (!fSettings->HasBorder())
|
||||||
|
SetLook(B_NO_BORDER_WINDOW_LOOK);
|
||||||
|
|
||||||
|
if (fSettings->AlwaysOnTop())
|
||||||
|
SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||||
|
else
|
||||||
|
SetAutoRaise(fSettings->AutoRaising());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WorkspacesWindow::~WorkspacesWindow()
|
WorkspacesWindow::~WorkspacesWindow()
|
||||||
{
|
{
|
||||||
delete fPreferences;
|
delete fSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesWindow::ScreenChanged(BRect rect, color_space mode)
|
WorkspacesWindow::ScreenChanged(BRect rect, color_space mode)
|
||||||
{
|
{
|
||||||
fPreviousFrame = fPreferences->WindowFrame();
|
fPreviousFrame = fSettings->WindowFrame();
|
||||||
// work-around for a bug in BeOS, see explanation in FrameMoved()
|
// work-around for a bug in BeOS, see explanation in FrameMoved()
|
||||||
|
|
||||||
fPreferences->UpdateFramesForScreen(rect);
|
fSettings->UpdateFramesForScreen(rect);
|
||||||
MoveTo(fPreferences->WindowFrame().LeftTop());
|
MoveTo(fSettings->WindowFrame().LeftTop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -326,14 +506,14 @@ WorkspacesWindow::FrameMoved(BPoint origin)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPreferences->SetWindowFrame(Frame());
|
fSettings->SetWindowFrame(Frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesWindow::FrameResized(float width, float height)
|
WorkspacesWindow::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
fPreferences->SetWindowFrame(Frame());
|
fSettings->SetWindowFrame(Frame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,23 +522,84 @@ WorkspacesWindow::Zoom(BPoint origin, float width, float height)
|
|||||||
{
|
{
|
||||||
BScreen screen;
|
BScreen screen;
|
||||||
origin = screen.Frame().RightBottom();
|
origin = screen.Frame().RightBottom();
|
||||||
origin.x -= kScreenBorderOffset + fPreferences->WindowFrame().Width();
|
origin.x -= kScreenBorderOffset + fSettings->WindowFrame().Width();
|
||||||
origin.y -= kScreenBorderOffset + fPreferences->WindowFrame().Height();
|
origin.y -= kScreenBorderOffset + fSettings->WindowFrame().Height();
|
||||||
|
|
||||||
MoveTo(origin);
|
MoveTo(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesWindow::MessageReceived(BMessage *msg)
|
WorkspacesWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
if (msg->what == 'DATA') {
|
switch (message->what) {
|
||||||
// Drop from Tracker
|
case B_SIMPLE_DATA:
|
||||||
entry_ref ref;
|
{
|
||||||
for (int i = 0; (msg->FindRef("refs", i, &ref) == B_OK); i++)
|
// Drop from Tracker
|
||||||
be_roster->Launch(&ref);
|
entry_ref ref;
|
||||||
} else
|
for (int i = 0; (message->FindRef("refs", i, &ref) == B_OK); i++)
|
||||||
BWindow::MessageReceived(msg);
|
be_roster->Launch(&ref);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_ABOUT_REQUESTED:
|
||||||
|
PostMessage(message, ChildAt(0));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgToggleBorder:
|
||||||
|
{
|
||||||
|
bool enable = false;
|
||||||
|
if (Look() == B_NO_BORDER_WINDOW_LOOK)
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
SetLook(B_TITLED_WINDOW_LOOK);
|
||||||
|
else
|
||||||
|
SetLook(B_NO_BORDER_WINDOW_LOOK);
|
||||||
|
|
||||||
|
fSettings->SetHasBorder(enable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kMsgToggleTitle:
|
||||||
|
{
|
||||||
|
bool enable = false;
|
||||||
|
if (Look() == B_MODAL_WINDOW_LOOK)
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
SetLook(B_TITLED_WINDOW_LOOK);
|
||||||
|
else
|
||||||
|
SetLook(B_MODAL_WINDOW_LOOK);
|
||||||
|
|
||||||
|
fSettings->SetHasTitle(enable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kMsgToggleAutoRaise:
|
||||||
|
SetAutoRaise(!IsAutoRaising());
|
||||||
|
SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kMsgToggleAlwaysOnTop:
|
||||||
|
{
|
||||||
|
bool enable = false;
|
||||||
|
if (Feel() != B_FLOATING_ALL_WINDOW_FEEL)
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||||
|
else
|
||||||
|
SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||||
|
|
||||||
|
fSettings->SetAlwaysOnTop(enable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -371,9 +612,18 @@ WorkspacesWindow::QuitRequested()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WorkspacesWindow::SetAutoRaise()
|
WorkspacesWindow::SetAutoRaise(bool enable)
|
||||||
{
|
{
|
||||||
ChildAt(0)->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
if (enable == fAutoRaising)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fAutoRaising = enable;
|
||||||
|
fSettings->SetAutoRaising(enable);
|
||||||
|
|
||||||
|
if (enable)
|
||||||
|
ChildAt(0)->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||||
|
else
|
||||||
|
ChildAt(0)->SetEventMask(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -383,7 +633,7 @@ WorkspacesWindow::SetAutoRaise()
|
|||||||
WorkspacesApp::WorkspacesApp()
|
WorkspacesApp::WorkspacesApp()
|
||||||
: BApplication(kSignature)
|
: BApplication(kSignature)
|
||||||
{
|
{
|
||||||
fWindow = new WorkspacesWindow(new WorkspacesPreferences());
|
fWindow = new WorkspacesWindow(new WorkspacesSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -395,21 +645,7 @@ WorkspacesApp::~WorkspacesApp()
|
|||||||
void
|
void
|
||||||
WorkspacesApp::AboutRequested()
|
WorkspacesApp::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert *alert = new BAlert("about", "Workspaces\n"
|
fWindow->PostMessage(B_ABOUT_REQUESTED);
|
||||||
"\twritten by François Revol, Axel Dörfler,\n"
|
|
||||||
"\t\tand Matt Madia.\n"
|
|
||||||
"\tCopyright 2002-2007, Haiku.\n", "Ok");
|
|
||||||
BTextView *view = alert->TextView();
|
|
||||||
BFont font;
|
|
||||||
|
|
||||||
view->SetStylable(true);
|
|
||||||
|
|
||||||
view->GetFont(&font);
|
|
||||||
font.SetSize(18);
|
|
||||||
font.SetFace(B_BOLD_FACE);
|
|
||||||
view->SetFontAndColor(0, 10, &font);
|
|
||||||
|
|
||||||
alert->Go();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -451,7 +687,7 @@ WorkspacesApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
else if (!strcmp(argv[i], "--alwaysontop"))
|
else if (!strcmp(argv[i], "--alwaysontop"))
|
||||||
fWindow->SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
fWindow->SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
|
||||||
else if (!strcmp(argv[i], "--autoraise"))
|
else if (!strcmp(argv[i], "--autoraise"))
|
||||||
fWindow->SetAutoRaise();
|
fWindow->SetAutoRaise(true);
|
||||||
else {
|
else {
|
||||||
const char *programName = strrchr(argv[0], '/');
|
const char *programName = strrchr(argv[0], '/');
|
||||||
programName = programName ? programName + 1 : argv[0];
|
programName = programName ? programName + 1 : argv[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user