From ed9737215b0ee7b1ea8ce0cfe3d4d0898a61d000 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 19 Oct 2017 06:35:01 -0700 Subject: [PATCH] Manager: Fixes to allow building 64-bit application on Macintosh. --- clientgui/BOINCGUIApp.h | 1 - clientgui/mac/BOINCGUIApp.mm | 36 +++++++++++++++++++++++++--- clientgui/mac/MacNotification.mm | 5 ---- clientgui/mac/Mac_GUI.cpp | 41 -------------------------------- 4 files changed, 33 insertions(+), 50 deletions(-) diff --git a/clientgui/BOINCGUIApp.h b/clientgui/BOINCGUIApp.h index 9e3576b71c..5857e1a138 100644 --- a/clientgui/BOINCGUIApp.h +++ b/clientgui/BOINCGUIApp.h @@ -223,7 +223,6 @@ public: // bool WasFileModifiedBeforeSystemBoot(char * filePath); void HideThisApp(void); - CGFloat GetMenuBarHeight(void); #if !wxCHECK_VERSION(3,0,1) // This should be fixed after wxCocoa 3.0.0: diff --git a/clientgui/mac/BOINCGUIApp.mm b/clientgui/mac/BOINCGUIApp.mm index e0772df67a..f2d35f7fe5 100644 --- a/clientgui/mac/BOINCGUIApp.mm +++ b/clientgui/mac/BOINCGUIApp.mm @@ -136,9 +136,39 @@ void CBOINCGUIApp::ShowApplication(bool bShow) { } } -CGFloat CBOINCGUIApp::GetMenuBarHeight() { - CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight]; - return menuBarHeight; + +// Returns true if at least a 5 X 5 pixel area of the +// window's title bar is entirely on the displays +// Note: Arguments are Quickdraw-style coordinates, +// but CGDisplayBounds() sets top left corner as (0, 0) +Boolean IsWindowOnScreen(int iLeft, int iTop, int iWidth, int iHeight) { + CGRect intersectedRect; + CGRect titleRect = CGRectMake(iLeft, iTop, iWidth, 22); + // Make sure at least a 5X5 piece of title bar is visible + titleRect = CGRectInset(titleRect, 5, 5); + + + NSArray *allScreens = [NSScreen screens]; + unsigned int i; + // The geometries of windows and display arangements are such + // that even if the title bar spans multiple windows, a 5X5 + // section is on-screen only if at least one 5X5 section is + // entirely on one or more displays, so this test is sufficient. + unsigned int numDisplays = [ allScreens count ]; + for (i=0; iGetNSImage(); [buf lockFocus]; - [appIcon drawAtPoint:NSMakePoint(0, 0) - fromRect:NSZeroRect - operation:NSCompositeSourceOver - fraction:1.0f - ]; [badge drawAtPoint:NSMakePoint(0, 0) fromRect:NSZeroRect operation:NSCompositeSourceOver diff --git a/clientgui/mac/Mac_GUI.cpp b/clientgui/mac/Mac_GUI.cpp index 52b22795fa..d3466d20db 100644 --- a/clientgui/mac/Mac_GUI.cpp +++ b/clientgui/mac/Mac_GUI.cpp @@ -83,44 +83,3 @@ Boolean Mac_Authorize() return sIsAuthorized; } - - -#define MAX_DISPLAYS 32 - -// Returns true if at least a 5 X 5 pixel area of the -// window's title bar is entirely on the displays -// Note: Arguments are Quickdraw-style coordinates, -// but CGDisplayBounds() sets top left corner as (0, 0) -Boolean IsWindowOnScreen(int iLeft, int iTop, int iWidth, int iHeight) { - CGDirectDisplayID displays[MAX_DISPLAYS]; - CGDisplayCount numDisplays; - CGDisplayCount i; - CGRect displayRect, intersectedRect; - CGFloat mBarHeight = wxGetApp().GetMenuBarHeight(); - - CGRect titleRect = CGRectMake(iLeft, iTop, iWidth, 22); - // Make sure at least a 5X5 piece of title bar is visible - titleRect = CGRectInset(titleRect, 5, 5); - - CGGetActiveDisplayList (MAX_DISPLAYS, displays, &numDisplays); - - // The geometries of windows and display arangements are such - // that even if the title bar spans multiple windows, a 5X5 - // section is on-screen only if at least one 5X5 section is - // entirely on one or more displays, so this test is sufficient. - for (i = 0; i < numDisplays; i++) - { - displayRect = CGDisplayBounds(displays[i]); - if (i == 0) { // CGDisplayBounds returns main display first - displayRect.origin.y += mBarHeight; - displayRect.size.height -= mBarHeight; - } - - intersectedRect = CGRectIntersection(displayRect, titleRect); - if (! CGRectIsNull(intersectedRect)) { - return true; - } - } - - return false; -}