From 9faec1c204d64757a91e707c089ff7ed5f59852e Mon Sep 17 00:00:00 2001 From: Oliver Bock <oliver.bock@aei.mpg.de> Date: Wed, 1 Oct 2008 18:32:57 +0200 Subject: [PATCH] Added Charlie Fenton's fixes for SDL problems on Mac OS (fullscreen, z-level vs. BOINCSaver) --- src/framework/WindowManager.cpp | 11 ++++++- src/starsphere/Makefile.macos | 11 ++++--- src/starsphere/SetMacSSLevel.m | 53 +++++++++++++++++++++++++++++++++ src/starsphere/main.cpp | 15 +++++++++- 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/starsphere/SetMacSSLevel.m diff --git a/src/framework/WindowManager.cpp b/src/framework/WindowManager.cpp index 3e9bce0..e8df303 100644 --- a/src/framework/WindowManager.cpp +++ b/src/framework/WindowManager.cpp @@ -392,7 +392,16 @@ void WindowManager::toggleFullscreen() m_CurrentHeight = m_DesktopHeight; // (un)set video mode flags - m_VideoModeFlags |= SDL_FULLSCREEN; +#ifdef __APPLE__ + if (m_ScreensaverMode) { + m_CurrentWidth = m_DesktopWidth; + m_CurrentHeight = m_DesktopHeight; + m_VideoModeFlags |= SDL_NOFRAME; + } else +#endif + { + m_VideoModeFlags |= SDL_FULLSCREEN; + } m_VideoModeFlags &= ~SDL_RESIZABLE; // hide cursor diff --git a/src/starsphere/Makefile.macos b/src/starsphere/Makefile.macos index 0113ff6..064e27d 100644 --- a/src/starsphere/Makefile.macos +++ b/src/starsphere/Makefile.macos @@ -29,7 +29,7 @@ CXX ?= g++ LIBS = -lframework -loglft -L$(STARSPHERE_INSTALL)/lib LIBS += $(shell $(STARSPHERE_INSTALL)/bin/freetype-config --libs) LIBS += $(shell $(STARSPHERE_INSTALL)/bin/xml2-config --libs) -LIBS += -lboinc_api -lboinc -L/usr/lib +LIBS += -lboinc_api -lboinc -L$(STARSPHERE_INSTALL)/lib LIBS += $(shell $(STARSPHERE_INSTALL)/bin/sdl-config --static-libs) LDFLAGS = -static-libgcc @@ -41,7 +41,7 @@ CPPFLAGS += $(shell $(STARSPHERE_INSTALL)/bin/xml2-config --cflags) CPPFLAGS += -I$(STARSPHERE_INSTALL)/include/BOINC -I/usr/include DEPS = Makefile -OBJS = Starsphere.o StarsphereS5R3.o StarsphereRadio.o EinsteinS5R3Adapter.o EinsteinRadioAdapter.o starlist.o snr_list.o pulsar_list.o $(RESOURCESPEC).o +OBJS = Starsphere.o StarsphereS5R3.o StarsphereRadio.o EinsteinS5R3Adapter.o EinsteinRadioAdapter.o starlist.o snr_list.o pulsar_list.o SetMacSSLevel.o $(RESOURCESPEC).o RESOURCESPEC = resources # TODO: GraphicsEngineFactory obviously depends on the actual implementations (here starsphere)! need to change the structure! what about plugins? @@ -94,6 +94,9 @@ snr_list.o: $(DEPS) $(STARSPHERE_SRC)/snr_list.C pulsar_list.o: $(DEPS) $(STARSPHERE_SRC)/pulsar_list.C $(CXX) -g $(CPPFLAGS) -c $(STARSPHERE_SRC)/pulsar_list.C + +SetMacSSLevel.o: $(DEPS) $(STARSPHERE_SRC)/SetMacSSLevel.m + $(CXX) -g $(CPPFLAGS) -c $(STARSPHERE_SRC)/SetMacSSLevel.m # resource compiler $(RESOURCESPEC).o: $(STARSPHERE_SRC)/$(RESOURCESPEC).orc @@ -109,7 +112,7 @@ callgrind: valgrind --tool=callgrind --track-fds=yes --time-stamp=yes $(PWD)/starsphere install: - cp starsphere_* $(STARSPHERE_INSTALL)/bin + cp -R starsphere_* $(STARSPHERE_INSTALL)/bin clean: - rm -f $(RESOURCESPEC).cpp $(OBJS) starsphere_* + rm -Rf $(RESOURCESPEC).cpp $(OBJS) starsphere_* diff --git a/src/starsphere/SetMacSSLevel.m b/src/starsphere/SetMacSSLevel.m new file mode 100644 index 0000000..828c192 --- /dev/null +++ b/src/starsphere/SetMacSSLevel.m @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2008 by Charlie Fenton for Oliver Bock * + * contact: oliver.bock[AT]aei.mpg.de * + * * + * This file is part of Einstein@Home. * + * * + * Einstein@Home is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published * + * by the Free Software Foundation, version 2 of the License. * + * * + * Einstein@Home 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 General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with Einstein@Home. If not, see <http://www.gnu.org/licenses/>. * + * * + ***************************************************************************/ + + +#include <Cocoa/Cocoa.h> + +void SetMacSSLevel(); + +// The standard ScreenSaverView class actually sets the window +// level to 2002, not the 1000 defined by NSScreenSaverWindowLevel +// and kCGScreenSaverWindowLevel +#define RealSaverLevel 2002 +// Glut sets the window level to 100 when it sets full screen mode +#define GlutFullScreenWindowLevel 100 + +void SetMacSSLevel() { + static NSMenu * emptyMenu; + NSOpenGLContext * myContext = nil; + NSView *myView = nil; + NSWindow* myWindow = nil; + + // 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 ]; + if (myWindow == nil) + return; + + [ myWindow setLevel:RealSaverLevel+20 ]; +} diff --git a/src/starsphere/main.cpp b/src/starsphere/main.cpp index d05f39d..df13f6e 100644 --- a/src/starsphere/main.cpp +++ b/src/starsphere/main.cpp @@ -28,6 +28,16 @@ #include "AbstractGraphicsEngine.h" #include "GraphicsEngineFactory.h" +#ifdef __APPLE__ +#ifdef __cplusplus +extern "C" { +#endif + void SetMacSSLevel(); +#ifdef __cplusplus +} // extern "C" +#endif +#endif + int main(int argc, char **argv) { @@ -92,8 +102,11 @@ int main(int argc, char **argv) string param(argv[1]); if(param == "--fullscreen") { // switch to fullscreen (on windoze: after init!) + window.setScreensaverMode(true); // Must do this first on Apple window.toggleFullscreen(); - window.setScreensaverMode(true); +#ifdef __APPLE__ + SetMacSSLevel(); +#endif } } -- GitLab