Skip to content

Commit

Permalink
Mac: Enable close button when running "Show Graphics" from BOINC Mana…
Browse files Browse the repository at this point in the history
…ger under MacOS 11 Big Sur
  • Loading branch information
Charlie Fenton committed Aug 6, 2020
1 parent bab861d commit 90cbb1a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions api/graphics2_unix.cpp
Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions api/macglutfix.m
Expand Up @@ -59,16 +59,23 @@
// 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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions api/x_opengl.h
Expand Up @@ -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);
Expand Down

0 comments on commit 90cbb1a

Please sign in to comment.