Skip to content

Commit

Permalink
OSX: disable AppNap for QmlStreamers, move AppNapSuspender to Deflect…
Browse files Browse the repository at this point in the history
… library.
  • Loading branch information
Raphael Dumusc committed Nov 23, 2016
1 parent b024280 commit 1717912
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 10 deletions.
4 changes: 1 addition & 3 deletions apps/DesktopStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ if(APPLE)
set(DESKTOPSTREAMER_COPYRIGHT "EPFL/Blue Brain Project ${_CURRENT_YEAR}")
set(DESKTOPSTREAMER_ICON desktopstreamer.icns)

list(APPEND DESKTOPSTREAMER_SOURCES AppNapSuspender.mm)
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES "-framework Foundation")
if(TARGET Qt5::MacExtras)
list(APPEND DESKTOPSTREAMER_HEADERS DesktopWindowsModel.h)
list(APPEND DESKTOPSTREAMER_SOURCES DesktopWindowsModel.mm)
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES
Qt5::MacExtras "-framework AppKit"
Qt5::MacExtras "-framework AppKit" "-framework Foundation"
)
endif()
if(OSX_VERSION VERSION_LESS 10.9)
Expand Down
4 changes: 2 additions & 2 deletions apps/DesktopStreamer/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <apps/DesktopStreamer/ui_MainWindow.h>

#ifdef __APPLE__
# include "AppNapSuspender.h"
# include <deflect/AppNapSuspender.h>
#endif

#ifdef DEFLECT_USE_SERVUS
Expand Down Expand Up @@ -89,7 +89,7 @@ private slots:
float _averageUpdate;

#ifdef __APPLE__
AppNapSuspender _napSuspender;
deflect::AppNapSuspender _napSuspender;
#endif

void _showMultiWindowMode();
Expand Down
5 changes: 3 additions & 2 deletions apps/QmlStreamer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <QGuiApplication>
#include <QCommandLineParser>
#include <deflect/qt/QmlStreamer.h>
#include <deflect/version.h>

#include <QCommandLineParser>
#include <QGuiApplication>

int main( int argc, char** argv )
{
QGuiApplication app( argc,argv );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
/* or implied, of The Ecole Polytechnique Federale de Lausanne. */
/*********************************************************************/

#ifndef APPNAPSUSPENDER_H
#define APPNAPSUSPENDER_H
#ifndef DEFLECT_APPNAPSUSPENDER_H
#define DEFLECT_APPNAPSUSPENDER_H

namespace deflect
{

/**
* Suspend AppNap on OSX >= 10.9.
Expand All @@ -63,4 +66,6 @@ class AppNapSuspender
Impl* _impl;
};

#endif // APPNAPSUSPENDER_H
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#endif
#endif

namespace deflect
{

class AppNapSuspender::Impl
{
public:
Expand Down Expand Up @@ -97,3 +100,5 @@
_impl->activityId = nil;
}
}

}
6 changes: 6 additions & 0 deletions deflect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ set(DEFLECT_SOURCES

set(DEFLECT_LINK_LIBRARIES PRIVATE Qt5::Concurrent Qt5::Core Qt5::Network)

if(APPLE)
list(APPEND DEFLECT_PUBLIC_HEADERS AppNapSuspender.h)
list(APPEND DEFLECT_SOURCES AppNapSuspender.mm)
list(APPEND DEFLECT_LINK_LIBRARIES PRIVATE "-framework Foundation")
endif()

if(DEFLECT_USE_LIBJPEGTURBO)
list(APPEND DEFLECT_PUBLIC_HEADERS
SegmentDecoder.h
Expand Down
4 changes: 4 additions & 0 deletions deflect/qt/QmlStreamerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ QmlStreamer::Impl::Impl( const QString& qmlFile, const std::string& streamHost,

if( !_quickView->load( qmlFile ).get( ))
throw std::runtime_error( "Failed to setup/load QML" );

#ifdef __APPLE__
_napSuspender.suspend();
#endif
}

QmlStreamer::Impl::~Impl() {}
Expand Down
7 changes: 7 additions & 0 deletions deflect/qt/QmlStreamerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
#include "QmlStreamer.h"
#include "../SizeHints.h"

#ifdef __APPLE__
# include <deflect/AppNapSuspender.h>
#endif
#include <deflect/Stream.h>

namespace deflect
Expand Down Expand Up @@ -127,6 +130,10 @@ private slots:
bool _mouseMode{ false };
QPointF _touchStartPos;
QPointF _touchCurrentPos;

#ifdef __APPLE__
AppNapSuspender _napSuspender;
#endif
};

}
Expand Down
3 changes: 3 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog {#Changelog}

### 0.12.0 (git master)

* [139](https://github.com/BlueBrain/Deflect/pull/139):
OSX: AppNap is now disabled for all QmlStreamers. The AppNapSuspender class
is now available in Deflect library for use in external applications.
* [137](https://github.com/BlueBrain/Deflect/pull/137):
Deflect Qt: the offscreen Qml view used by the Qml streamer is now available
as a separate class.
Expand Down

0 comments on commit 1717912

Please sign in to comment.