2005-04-19 00:34:41 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
//
|
|
|
|
// macglutfix.m
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#include "boinc_api.h"
|
|
|
|
|
|
|
|
void MacGLUTFix(bool isScreenSaver);
|
|
|
|
void BringAppToFront(void);
|
|
|
|
|
2005-04-24 12:31:55 +00:00
|
|
|
// The standard ScreenSaverView class actually sets the window
|
|
|
|
// level to 2002, not the 1000 defined by NSScreenSaverWindowLevel
|
|
|
|
// and kCGScreenSaverWindowLevel
|
|
|
|
#define RealSaverLevel 2002
|
2005-05-05 14:31:51 +00:00
|
|
|
// Glut sets the window level to 100 when it sets full screen mode
|
|
|
|
#define GlutFullScreenWindowLevel 100
|
2005-04-24 12:31:55 +00:00
|
|
|
|
2005-04-25 11:09:40 +00:00
|
|
|
// Delay when switching to screensaver mode to reduce annoying flashes
|
|
|
|
#define SAVERDELAY 30
|
|
|
|
|
2005-04-19 00:34:41 +00:00
|
|
|
void MacGLUTFix(bool isScreenSaver) {
|
|
|
|
static NSMenu * emptyMenu;
|
2005-04-24 12:31:55 +00:00
|
|
|
NSOpenGLContext * myContext = nil;
|
|
|
|
NSView *myView = nil;
|
2005-04-19 00:34:41 +00:00
|
|
|
NSWindow* myWindow = nil;
|
|
|
|
|
|
|
|
if (! boinc_is_standalone()) {
|
|
|
|
if (emptyMenu == nil) {
|
|
|
|
emptyMenu = [ NSMenu alloc ];
|
|
|
|
[ NSApp setMainMenu:emptyMenu ];
|
|
|
|
}
|
|
|
|
}
|
2005-04-24 12:31:55 +00:00
|
|
|
|
|
|
|
// In screensaver mode, set our window's level just above
|
|
|
|
// our BOINC screensaver's window level so it can appear
|
|
|
|
// over it. This doesn't interfere with the screensaver
|
|
|
|
// password dialog because the dialog appears only after
|
|
|
|
// our screensaver is closed.
|
|
|
|
myContext = [ NSOpenGLContext currentContext ];
|
|
|
|
if (myContext)
|
|
|
|
myView = [ myContext view ];
|
|
|
|
if (myView)
|
|
|
|
myWindow = [ myView window ];
|
2005-04-19 00:34:41 +00:00
|
|
|
if (myWindow == nil)
|
|
|
|
return;
|
2005-04-24 12:31:55 +00:00
|
|
|
|
2006-07-22 02:12:39 +00:00
|
|
|
if (!isScreenSaver) {
|
2006-08-21 15:59:16 +00:00
|
|
|
NSButton *closeButton = [myWindow standardWindowButton:NSWindowCloseButton ];
|
|
|
|
[closeButton setEnabled:YES];
|
2006-07-22 02:12:39 +00:00
|
|
|
[myWindow setDocumentEdited: NO];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-05-05 14:31:51 +00:00
|
|
|
if ([ myWindow level ] == GlutFullScreenWindowLevel)
|
|
|
|
[ myWindow setLevel:RealSaverLevel+20 ];
|
2005-04-19 00:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BringAppToFront() {
|
|
|
|
[ NSApp activateIgnoringOtherApps:YES ];
|
|
|
|
}
|
2005-09-06 12:58:56 +00:00
|
|
|
|
|
|
|
void HideThisApp() {
|
|
|
|
[ NSApp hide:NSApp ];
|
|
|
|
}
|
|
|
|
|