diff --git a/headers/os/interface/Deskbar.h b/headers/os/interface/Deskbar.h index 5c21e2cf14..0781139ef5 100644 --- a/headers/os/interface/Deskbar.h +++ b/headers/os/interface/Deskbar.h @@ -41,6 +41,15 @@ public: bool IsExpanded() const; status_t Expand(bool expand); + bool IsAlwaysOnTop() const; + status_t SetAlwaysOnTop(bool alwaysOnTop); + + bool IsAutoRaise() const; + status_t SetAutoRaise(bool autoRaise); + + bool IsAutoHide() const; + status_t SetAutoHide(bool autoHide); + // Item querying methods status_t GetItemInfo(int32 id, const char** _name) const; status_t GetItemInfo(const char* name, int32* _id) const; diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 03ff77069d..6f64a98e4a 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -366,17 +366,41 @@ void TBarApp::MessageReceived(BMessage* message) { switch (message->what) { - case 'gloc': - case 'sloc': - case 'gexp': - case 'sexp': - case 'info': - case 'exst': - case 'cwnt': - case 'icon': - case 'remv': - case 'adon': - // pass any BDeskbar originating messages on to the window + // BDeskbar originating messages we can handle + case kMsgIsAlwaysOnTop: + { + BMessage reply('rply'); + reply.AddBool("always on top", fSettings.alwaysOnTop); + message->SendReply(&reply); + break; + } + case kMsgIsAutoRaise: + { + BMessage reply('rply'); + reply.AddBool("auto raise", fSettings.autoRaise); + message->SendReply(&reply); + break; + } + case kMsgIsAutoHide: + { + BMessage reply('rply'); + reply.AddBool("auto hide", fSettings.autoHide); + message->SendReply(&reply); + break; + } + + // pass rest of BDeskbar originating messages onto the window + // (except for setters handled below) + case kMsgLocation: + case kMsgSetLocation: + case kMsgIsExpanded: + case kMsgExpand: + case kMsgGetItemInfo: + case kMsgHasItem: + case kMsgCountItems: + case kMsgAddView: + case kMsgRemoveItem: + case kMsgAddAddOn: fBarWindow->PostMessage(message); break; @@ -469,6 +493,7 @@ TBarApp::MessageReceived(BMessage* message) BDragger::ShowAllDraggers(); break; + case kMsgAlwaysOnTop: // from BDeskbar case kAlwaysTop: fSettings.alwaysOnTop = !fSettings.alwaysOnTop; @@ -480,6 +505,7 @@ TBarApp::MessageReceived(BMessage* message) : B_NORMAL_WINDOW_FEEL); break; + case kMsgAutoRaise: // from BDeskbar case kAutoRaise: fSettings.autoRaise = fSettings.alwaysOnTop ? false : !fSettings.autoRaise; @@ -488,6 +514,7 @@ TBarApp::MessageReceived(BMessage* message) fPreferencesWindow->PostMessage(kUpdatePreferences); break; + case kMsgAutoHide: // from BDeskbar case kAutoHide: fSettings.autoHide = !fSettings.autoHide; diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index d85763848d..71d10a9482 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -79,6 +79,25 @@ const uint32 kUpdatePreferences = 'Pref'; // realign replicants message constant const uint32 kRealignReplicants = 'Algn'; +// BDeskbar message constants +static const uint32 kMsgIsAlwaysOnTop = 'gtop'; +static const uint32 kMsgAlwaysOnTop = 'stop'; +static const uint32 kMsgIsAutoRaise = 'grse'; +static const uint32 kMsgAutoRaise = 'srse'; +static const uint32 kMsgIsAutoHide = 'ghid'; +static const uint32 kMsgAutoHide = 'shid'; + +static const uint32 kMsgAddView = 'icon'; +static const uint32 kMsgAddAddOn = 'adon'; +static const uint32 kMsgHasItem = 'exst'; +static const uint32 kMsgGetItemInfo = 'info'; +static const uint32 kMsgCountItems = 'cwnt'; +static const uint32 kMsgRemoveItem = 'remv'; +static const uint32 kMsgLocation = 'gloc'; +static const uint32 kMsgIsExpanded = 'gexp'; +static const uint32 kMsgSetLocation = 'sloc'; +static const uint32 kMsgExpand = 'sexp'; + /* --------------------------------------------- */ class BBitmap; diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp index e9aee53ba2..cfae6e0891 100644 --- a/src/apps/deskbar/BarWindow.cpp +++ b/src/apps/deskbar/BarWindow.cpp @@ -168,40 +168,40 @@ TBarWindow::MessageReceived(BMessage* message) break; } - case 'gloc': + case kMsgLocation: GetLocation(message); break; - case 'sloc': + case kMsgSetLocation: SetLocation(message); break; - case 'gexp': + case kMsgIsExpanded: IsExpanded(message); break; - case 'sexp': + case kMsgExpand: Expand(message); break; - case 'info': + case kMsgGetItemInfo: ItemInfo(message); break; - case 'exst': + case kMsgHasItem: ItemExists(message); break; - case 'cwnt': + case kMsgCountItems: CountItems(message); break; - case 'adon': - case 'icon': + case kMsgAddAddOn: + case kMsgAddView: AddItem(message); break; - case 'remv': + case kMsgRemoveItem: RemoveItem(message); break; diff --git a/src/kits/interface/Deskbar.cpp b/src/kits/interface/Deskbar.cpp index 7d0048db45..cd404306a7 100644 --- a/src/kits/interface/Deskbar.cpp +++ b/src/kits/interface/Deskbar.cpp @@ -33,6 +33,13 @@ static const char* kDeskbarSignature = "application/x-vnd.Be-TSKB"; +static const uint32 kMsgIsAlwaysOnTop = 'gtop'; +static const uint32 kMsgAlwaysOnTop = 'stop'; +static const uint32 kMsgIsAutoRaise = 'grse'; +static const uint32 kMsgAutoRaise = 'srse'; +static const uint32 kMsgIsAutoHide = 'ghid'; +static const uint32 kMsgAutoHide = 'shid'; + static const uint32 kMsgAddView = 'icon'; static const uint32 kMsgAddAddOn = 'adon'; static const uint32 kMsgHasItem = 'exst'; @@ -149,12 +156,10 @@ BDeskbar::IsExpanded() const { BMessage request(kMsgIsExpanded); BMessage reply; - bool isExpanded; + bool isExpanded = true; - if (fMessenger->SendMessage(&request, &reply) != B_OK - || reply.FindBool("expanded", &isExpanded) != B_OK) { - isExpanded = true; - } + if (fMessenger->SendMessage(&request, &reply) == B_OK) + reply.FindBool("expanded", &isExpanded); return isExpanded; } @@ -170,6 +175,78 @@ BDeskbar::Expand(bool expand) } +bool +BDeskbar::IsAlwaysOnTop() const +{ + BMessage request(kMsgIsAlwaysOnTop); + BMessage reply; + bool isAlwaysOnTop = false; + + if (fMessenger->SendMessage(&request, &reply) == B_OK) + reply.FindBool("always on top", &isAlwaysOnTop); + + return isAlwaysOnTop; +} + + +status_t +BDeskbar::SetAlwaysOnTop(bool alwaysOnTop) +{ + BMessage request(kMsgAlwaysOnTop); + request.AddBool("always on top", alwaysOnTop); + + return fMessenger->SendMessage(&request); +} + + +bool +BDeskbar::IsAutoRaise() const +{ + BMessage request(kMsgIsAutoRaise); + BMessage reply; + bool isAutoRaise = false; + + if (fMessenger->SendMessage(&request, &reply) == B_OK) + reply.FindBool("auto raise", &isAutoRaise); + + return isAutoRaise; +} + + +status_t +BDeskbar::SetAutoRaise(bool autoRaise) +{ + BMessage request(kMsgAutoRaise); + request.AddBool("auto raise", autoRaise); + + return fMessenger->SendMessage(&request); +} + + +bool +BDeskbar::IsAutoHide() const +{ + BMessage request(kMsgIsAutoHide); + BMessage reply; + bool isAutoHidden; + + if (fMessenger->SendMessage(&request, &reply) == B_OK) + reply.FindBool("auto hide", &isAutoHidden); + + return isAutoHidden; +} + + +status_t +BDeskbar::SetAutoHide(bool autoHide) +{ + BMessage request(kMsgAutoHide); + request.AddBool("auto hide", autoHide); + + return fMessenger->SendMessage(&request); +} + + // #pragma mark - Item querying methods @@ -249,7 +326,7 @@ BDeskbar::HasItem(const char* name) const uint32 -BDeskbar::CountItems(void) const +BDeskbar::CountItems() const { BMessage request(kMsgCountItems); BMessage reply;