diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 91e32f2..931581c 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -7,15 +7,21 @@ static bool isCached = false; #ifdef _WIN32 -#include -static WCHAR szStyle[8] = {0}; -static WCHAR szTile[8] = {0}; -static WCHAR szFile[MAX_PATH+1] = {0}; -static DWORD oldcolor = 0; -static DWORD szStyleSize = sizeof(szStyle) - 1; -static DWORD szTileSize = sizeof(szTile) - 1; -static bool setStyle = false; -static bool setTile = false; + #include + static WCHAR szStyle[8] = {0}; + static WCHAR szTile[8] = {0}; + static WCHAR szFile[MAX_PATH+1] = {0}; + static DWORD oldcolor = 0; + static DWORD szStyleSize = sizeof(szStyle) - 1; + static DWORD szTileSize = sizeof(szTile) - 1; + static bool setStyle = false; + static bool setTile = false; +#else + #ifdef __APPLE__ + #include "mac-desktop.h" + #else + // XXX Implement me! + #endif #endif RB_METHOD(wallpaperSet) @@ -93,6 +99,11 @@ end: if (hKey) RegCloseKey(hKey); #else + #ifdef __APPLE__ + // XXX Implement me! + #else + // XXX Implement me! + #endif #endif return Qnil; } @@ -126,6 +137,11 @@ RB_METHOD(wallpaperReset) RegCloseKey(hKey); } #else + #ifdef __APPLE__ + // XXX Implement me! + #else + // XXX Implement me! + #endif #endif return Qnil; } diff --git a/mkxp.pro b/mkxp.pro index 8ccb4b2..6791250 100644 --- a/mkxp.pro +++ b/mkxp.pro @@ -41,8 +41,10 @@ unix { LIBS += -ldl macx: { INCLUDEPATH += $$QMAKE_MAC_SDK_PATH/System/Library/Frameworks/OpenAL.framework/Versions/A/Headers - LIBS += -framework OpenAL + LIBS += -framework OpenAL -framework AppKit QMAKE_LFLAGS += -L/usr/local/opt/ruby@2.3/lib -L/usr/local/opt/openal-soft/lib + HEADERS += src/mac-desktop.h + SOURCES += src/mac-desktop.mm } !macx: { # PKGCONFIG += openal zlib diff --git a/src/mac-desktop.h b/src/mac-desktop.h new file mode 100644 index 0000000..961a705 --- /dev/null +++ b/src/mac-desktop.h @@ -0,0 +1,12 @@ +// +// SyngleChance Engine - mac-desktop.h +// ©2018 Vinyl Darkscratch. You may use this code for anything you'd like. +// https://www.queengoob.org +// + +#pragma once + +#include + +bool ChangeBackground(std::string imageURL); +bool ResetBackground(); \ No newline at end of file diff --git a/src/mac-desktop.mm b/src/mac-desktop.mm new file mode 100644 index 0000000..47a8675 --- /dev/null +++ b/src/mac-desktop.mm @@ -0,0 +1,25 @@ +// +// SyngleChance Engine - mac-desktop.mm +// ©2018 Vinyl Darkscratch. You may use this code for anything you'd like. +// https://www.queengoob.org +// + +#include "mac-desktop.h" +#include + +#import +#import + +bool ChangeBackground(std::string imageURL) { + NSURL *URL = [NSURL fileURLWithPath:@(imageURL.c_str())]; + NSScreen *mainscreen = [NSScreen mainScreen]; + NSWorkspace *sharedworkspace = [NSWorkspace sharedWorkspace]; + + BOOL success = [sharedworkspace setDesktopImageURL:[URL absoluteURL] forScreen:mainscreen options:[sharedworkspace desktopImageOptionsForScreen:mainscreen] error:nil]; + return (bool)success; +} + +bool ResetBackground() { + // XXX Implement me! + return false; +}