Skip to content

Commit

Permalink
Minor fixups for Darwin (#49)
Browse files Browse the repository at this point in the history
* interprocesscommunicator.cpp: add missing cstring

* filesystemwatcher.cpp: provide kFSEventStream* values when undefined

* suspendinhibitor.cpp: fix for < 10.7
  • Loading branch information
barracuda156 authored Nov 14, 2024
1 parent 723b2ae commit aca9e1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/interprocesscommunicator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "app/interprocesscommunicator.h"
#include <cstdlib>
#include <cstring>
#include <stdexcept>
#include "helpers/stringhelpers.h"
#ifndef _WIN32
Expand Down
11 changes: 11 additions & 0 deletions src/filesystem/filesystemwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
#include <sys/inotify.h>
#endif

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
// Only available in 10.7+
#define kFSEventStreamCreateFlagFileEvents 0x00000010
#define kFSEventStreamEventFlagItemCreated 0x00000100
#define kFSEventStreamEventFlagItemRemoved 0x00000200
#define kFSEventStreamEventFlagItemRenamed 0x00000800
#endif
#endif

namespace Nickvision::Filesystem
{
FileSystemWatcher::FileSystemWatcher(const std::filesystem::path& path, bool incudeSubdirectories, WatcherFlags watcherFlags)
Expand Down
6 changes: 6 additions & 0 deletions src/system/suspendinhibitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <windows.h>
#elif defined(__linux__)
#include <gio/gio.h>
#elif defined(__APPLE__)
#include <AvailabilityMacros.h>
#endif

namespace Nickvision::System
Expand Down Expand Up @@ -77,11 +79,15 @@ namespace Nickvision::System
g_variant_unref(result);
g_object_unref(proxy);
#elif defined(__APPLE__)
#if MAC_OS_X_VERSION_MIN_REQUIRED > 1060
IOReturn result{ IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleSystemSleep, kIOPMAssertionLevelOn, CFSTR("Nickvision preventing suspend"), &m_cookie) };
if(result != kIOReturnSuccess)
{
return false;
}
#else
return false;
#endif
#endif
m_inhibiting = true;
return true;
Expand Down

0 comments on commit aca9e1c

Please sign in to comment.