Mac: Enable close button when running "Show Graphics" from BOINC Manager under MacOS 11 Big Sur

This commit is contained in:
Charlie Fenton 2020-08-06 05:12:49 -07:00
parent bab861df05
commit 90cbb1ab2b
3 changed files with 22 additions and 6 deletions

View File

@ -137,9 +137,13 @@ static void maybe_render() {
ypos = new_ypos;
width = new_width;
height = new_height;
} else {
if (size_changed && (++size_changed > 10)) {
size_changed = 0;
#ifdef __APPLE__
ClearDocumentEditedDot();
#endif
FILE *f = boinc_fopen("gfx_info", "w");
if (f) {
// ToDo: change this to XML

View File

@ -59,16 +59,23 @@ int compareOSVersionTo(int toMajor, int toMinor);
// Delay when switching to screensaver mode to reduce annoying flashes
#define SAVERDELAY 30
// NSClosableWindowMask is deprecated in OS 10.12 and is replaced by
// NSWindowStyleMaskClosable, which is not defined before OS 10.12
#ifndef NSWindowStyleMaskClosable
#define NSWindowStyleMaskClosable NSClosableWindowMask
#endif
static NSWindow* myWindow = nil;
void MacGLUTFix(bool isScreenSaver) {
static int count = 0;
static NSMenu * emptyMenu;
NSOpenGLContext * myContext = nil;
NSView *myView = nil;
NSWindow* myWindow = nil;
static int requestedWidth, requestedHeight;
if (count > 1) return; // Do this only twice
count++;
if (count == 2) ClearDocumentEditedDot();
if (count++ > 2) return; // Do the code below only twice
if (! boinc_is_standalone()) {
if (emptyMenu == nil) {
@ -109,9 +116,7 @@ void MacGLUTFix(bool isScreenSaver) {
glutReshapeWindow(requestedWidth, requestedHeight);
}
NSButton *closeButton = [myWindow standardWindowButton:NSWindowCloseButton ];
[closeButton setEnabled:YES];
[myWindow setDocumentEdited: NO];
[myWindow setStyleMask:[myWindow styleMask] | NSWindowStyleMaskClosable];
return;
}
@ -131,6 +136,12 @@ void MacGLUTFix(bool isScreenSaver) {
}
}
void ClearDocumentEditedDot(void) {
if (myWindow) {
[myWindow setDocumentEdited: NO];
}
}
#if 0
// NOT USED: See comments in animateOneFrame in Mac_Saver_ModuleView.m
// <https://developer.apple.com/library/content/technotes/tn2169>

View File

@ -26,6 +26,7 @@ extern int xwin_glut_is_initialized();
#ifdef __APPLE__
extern void MacGLUTFix(bool isScreenSaver);
extern void ClearDocumentEditedDot(void);
extern void MacPassOffscreenBufferToScreenSaver(void);
extern void BringAppToFront(void);
extern void HideThisApp(void);