BMenuBar & Deskbar: Make the hack to call ShowMenuBar a lot less ugly.
The previous hack, which as the comment (and __MWERKS__) implies dates all the way back to the Be era, finally broke: int32 is "int" on non-x86, not "long", and so this generated an undefined symbol error on ARM. The best solution seems to be to make StartMenuBar merely protected, and then make a subclass where it is fully public to call it. This is a lot less fragile (and much less ugly.) Change-Id: I0519d0d9eeb1cc4523d0c6dd4fdfe8688ed1092c Reviewed-on: https://review.haiku-os.org/c/1516 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
581a586f95
commit
74c38cab40
|
@ -79,6 +79,11 @@ public:
|
||||||
|
|
||||||
virtual status_t Perform(perform_code code, void* data);
|
virtual status_t Perform(perform_code code, void* data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void StartMenuBar(int32 menuIndex,
|
||||||
|
bool sticky = true, bool showMenu = false,
|
||||||
|
BRect* special_rect = NULL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BWindow;
|
friend class BWindow;
|
||||||
friend class BMenuField;
|
friend class BMenuField;
|
||||||
|
@ -91,12 +96,6 @@ private:
|
||||||
|
|
||||||
BMenuBar &operator=(const BMenuBar &);
|
BMenuBar &operator=(const BMenuBar &);
|
||||||
|
|
||||||
// TODO: Tracker uses this function so we can't change
|
|
||||||
// its signature without breaking it
|
|
||||||
void StartMenuBar(int32 menuIndex,
|
|
||||||
bool sticky = true, bool showMenu = false,
|
|
||||||
BRect* special_rect = NULL);
|
|
||||||
|
|
||||||
static int32 _TrackTask(void *arg);
|
static int32 _TrackTask(void *arg);
|
||||||
BMenuItem* _Track(int32 *action, int32 startIndex = -1,
|
BMenuItem* _Track(int32 *action, int32 startIndex = -1,
|
||||||
bool showMenu = false);
|
bool showMenu = false);
|
||||||
|
|
|
@ -68,24 +68,14 @@ All rights reserved.
|
||||||
#define B_TRANSLATION_CONTEXT "MainWindow"
|
#define B_TRANSLATION_CONTEXT "MainWindow"
|
||||||
|
|
||||||
|
|
||||||
// This is a very ugly hack to be able to call the private
|
// This is a bit of a hack to be able to call BMenuBar::StartMenuBar(), which
|
||||||
// BMenuBar::StartMenuBar() method from the TBarWindow::ShowBeMenu() method.
|
// is private. Don't do this at home!
|
||||||
// Don't do this at home -- but why the hell is this method private?
|
class TStartableMenuBar : public BMenuBar {
|
||||||
#if __MWERKS__
|
public:
|
||||||
#define BMenuBar_StartMenuBar_Hack StartMenuBar__8BMenuBarFlbbP5BRect
|
void StartMenuBar(int32 menuIndex, bool sticky = true, bool showMenu = false,
|
||||||
#elif __GNUC__ <= 2
|
BRect* special_rect = NULL) { BMenuBar::StartMenuBar(menuIndex, sticky, showMenu,
|
||||||
#define BMenuBar_StartMenuBar_Hack StartMenuBar__8BMenuBarlbT2P5BRect
|
special_rect); }
|
||||||
#elif __GNUC__ > 2
|
};
|
||||||
#if B_HAIKU_64_BIT
|
|
||||||
#define BMenuBar_StartMenuBar_Hack _ZN8BMenuBar12StartMenuBarEibbP5BRect
|
|
||||||
#else
|
|
||||||
#define BMenuBar_StartMenuBar_Hack _ZN8BMenuBar12StartMenuBarElbbP5BRect
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
# error "You may want to port this ugly hack to your compiler ABI"
|
|
||||||
#endif
|
|
||||||
extern "C" void
|
|
||||||
BMenuBar_StartMenuBar_Hack(BMenuBar*, int32, bool, bool, BRect*);
|
|
||||||
|
|
||||||
|
|
||||||
TDeskbarMenu* TBarWindow::sDeskbarMenu = NULL;
|
TDeskbarMenu* TBarWindow::sDeskbarMenu = NULL;
|
||||||
|
@ -323,14 +313,14 @@ TBarWindow::DeskbarMenu()
|
||||||
void
|
void
|
||||||
TBarWindow::ShowDeskbarMenu()
|
TBarWindow::ShowDeskbarMenu()
|
||||||
{
|
{
|
||||||
BMenuBar* menuBar = fBarView->BarMenuBar();
|
TStartableMenuBar* menuBar = (TStartableMenuBar*)fBarView->BarMenuBar();
|
||||||
if (menuBar == NULL)
|
if (menuBar == NULL)
|
||||||
menuBar = KeyMenuBar();
|
menuBar = (TStartableMenuBar*)KeyMenuBar();
|
||||||
|
|
||||||
if (menuBar == NULL)
|
if (menuBar == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BMenuBar_StartMenuBar_Hack(menuBar, 0, true, true, NULL);
|
menuBar->StartMenuBar(0, true, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -344,7 +334,7 @@ TBarWindow::ShowTeamMenu()
|
||||||
if (KeyMenuBar() == NULL)
|
if (KeyMenuBar() == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BMenuBar_StartMenuBar_Hack(KeyMenuBar(), index, true, true, NULL);
|
((TStartableMenuBar*)KeyMenuBar())->StartMenuBar(index, true, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue