Added an auto-raise feature.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21954 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+27
-12
@@ -204,6 +204,7 @@ TBarApp::SaveSettings()
|
||||
fSettingsFile->Write(&fSettings.sortRunningApps, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.superExpando, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.expandNewTeams, sizeof(bool));
|
||||
fSettingsFile->Write(&fSettings.autoRaise, sizeof(bool));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +233,7 @@ TBarApp::InitSettings()
|
||||
settings.sortRunningApps = false;
|
||||
settings.superExpando = false;
|
||||
settings.expandNewTeams = false;
|
||||
settings.autoRaise = true;
|
||||
|
||||
BPath dirPath;
|
||||
const char *settingsFileName = "Deskbar_settings";
|
||||
@@ -250,10 +252,10 @@ TBarApp::InitSettings()
|
||||
}
|
||||
|
||||
if (fSettingsFile->InitCheck() == B_OK) {
|
||||
off_t theSize = 0;
|
||||
fSettingsFile->GetSize(&theSize);
|
||||
|
||||
if (theSize >= kValidSettingsSize1) {
|
||||
off_t size = 0;
|
||||
fSettingsFile->GetSize(&size);
|
||||
|
||||
if (size >= kValidSettingsSize1) {
|
||||
fSettingsFile->Seek(0, SEEK_SET);
|
||||
fSettingsFile->Read(&settings.vertical, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.left, sizeof(bool));
|
||||
@@ -263,32 +265,34 @@ TBarApp::InitSettings()
|
||||
fSettingsFile->Read(&settings.width, sizeof(float));
|
||||
fSettingsFile->Read(&settings.showTime, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize2)
|
||||
if (size >= kValidSettingsSize2)
|
||||
fSettingsFile->Read(&settings.switcherLoc, sizeof(BPoint));
|
||||
if (theSize >= kValidSettingsSize3) {
|
||||
if (size >= kValidSettingsSize3) {
|
||||
fSettingsFile->Read(&settings.recentAppsCount, sizeof(int32));
|
||||
fSettingsFile->Read(&settings.recentDocsCount, sizeof(int32));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize4) {
|
||||
if (size >= kValidSettingsSize4) {
|
||||
fSettingsFile->Read(&settings.timeShowSeconds, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.timeShowMil, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize5)
|
||||
if (size >= kValidSettingsSize5)
|
||||
fSettingsFile->Read(&settings.recentFoldersCount, sizeof(int32));
|
||||
if (theSize >= kValidSettingsSize6) {
|
||||
if (size >= kValidSettingsSize6) {
|
||||
fSettingsFile->Read(&settings.timeShowEuro, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.alwaysOnTop, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize7)
|
||||
if (size >= kValidSettingsSize7)
|
||||
fSettingsFile->Read(&settings.timeFullDate, sizeof(bool));
|
||||
if (theSize >= kValidSettingsSize8) {
|
||||
if (size >= kValidSettingsSize8) {
|
||||
fSettingsFile->Read(&settings.trackerAlwaysFirst, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.sortRunningApps, sizeof(bool));
|
||||
}
|
||||
if (theSize >= kValidSettingsSize9) {
|
||||
if (size >= kValidSettingsSize9) {
|
||||
fSettingsFile->Read(&settings.superExpando, sizeof(bool));
|
||||
fSettingsFile->Read(&settings.expandNewTeams, sizeof(bool));
|
||||
}
|
||||
if (size >= kValidSettingsSize10)
|
||||
fSettingsFile->Read(&settings.autoRaise, sizeof(bool));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,6 +420,17 @@ TBarApp::MessageReceived(BMessage *message)
|
||||
B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
|
||||
break;
|
||||
|
||||
case msg_AutoRaise:
|
||||
{
|
||||
fSettings.autoRaise = !fSettings.autoRaise;
|
||||
|
||||
TBarView *barView = static_cast<TBarApp *>(be_app)->BarView();
|
||||
fBarWindow->Lock();
|
||||
barView->UpdateAutoRaise();
|
||||
fBarWindow->Unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
case msg_trackerFirst:
|
||||
{
|
||||
fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
|
||||
|
||||
@@ -77,6 +77,7 @@ const uint32 msg_trackerFirst = 'TkFt';
|
||||
const uint32 msg_sortRunningApps = 'SAps';
|
||||
const uint32 msg_superExpando = 'SprE';
|
||||
const uint32 msg_expandNewTeams = 'ExTm';
|
||||
const uint32 msg_AutoRaise = 'AtRs';
|
||||
|
||||
// from roster_private.h
|
||||
const uint32 CMD_SHUTDOWN_SYSTEM = 301;
|
||||
@@ -109,6 +110,7 @@ struct desk_settings {
|
||||
bool sortRunningApps;
|
||||
bool superExpando; // version 9
|
||||
bool expandNewTeams;
|
||||
bool autoRaise; // version 10
|
||||
};
|
||||
|
||||
// the following structures are defined to compute
|
||||
@@ -123,6 +125,7 @@ const uint32 kValidSettingsSize6 = 2 * sizeof(bool) + kValidSettingsSize5;
|
||||
const uint32 kValidSettingsSize7 = sizeof(bool) + kValidSettingsSize6;
|
||||
const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
|
||||
const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
|
||||
const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9;
|
||||
|
||||
class TBarView;
|
||||
class BFile;
|
||||
|
||||
@@ -117,6 +117,7 @@ TBarView::AttachedToWindow()
|
||||
if (fTrayLocation != 0)
|
||||
AddChild(fDragRegion);
|
||||
|
||||
UpdateAutoRaise();
|
||||
UpdatePlacement();
|
||||
|
||||
fTrackingHookData.fTrackingHook = MenuTrackingHook;
|
||||
@@ -174,6 +175,26 @@ TBarView::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
|
||||
{
|
||||
if (Window() == NULL || EventMask() == 0)
|
||||
return;
|
||||
|
||||
// Auto-Raise
|
||||
|
||||
where = ConvertToScreen(where);
|
||||
BScreen screen(Window());
|
||||
BRect frame = screen.Frame();
|
||||
if (where.x == frame.left || where.x == frame.right
|
||||
|| where.y == frame.top || where.y == frame.bottom) {
|
||||
// cursor is on screen edge
|
||||
if (Window()->Frame().Contains(where))
|
||||
Window()->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::PlaceBeMenu()
|
||||
{
|
||||
@@ -388,6 +409,16 @@ TBarView::SaveSettings()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::UpdateAutoRaise()
|
||||
{
|
||||
if (((TBarApp*)be_app)->Settings()->autoRaise)
|
||||
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
else
|
||||
SetEventMask(0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TBarView::UpdatePlacement()
|
||||
{
|
||||
|
||||
@@ -72,10 +72,13 @@ class TBarView : public BView {
|
||||
~TBarView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect);
|
||||
virtual void MessageReceived(BMessage *);
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||
const BMessage* dragMessage);
|
||||
|
||||
void SaveSettings();
|
||||
void UpdateAutoRaise();
|
||||
void UpdatePlacement();
|
||||
void ChangeState(int32 state, bool vertical, bool left, bool top);
|
||||
|
||||
|
||||
@@ -285,6 +285,11 @@ TBeMenu::AddStandardBeMenuItems()
|
||||
item->SetMarked((window->Feel() & B_FLOATING_ALL_WINDOW_FEEL) != 0);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Auto Raise", new BMessage(msg_AutoRaise));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->autoRaise);
|
||||
subMenu->AddItem(item);
|
||||
|
||||
item = new BMenuItem("Sort Running Applications", new BMessage(msg_sortRunningApps));
|
||||
item->SetTarget(be_app);
|
||||
item->SetMarked(static_cast<TBarApp *>(be_app)->Settings()->sortRunningApps);
|
||||
|
||||
Reference in New Issue
Block a user