diff --git a/CMakeLists.txt b/CMakeLists.txt index ecb4f4a..eb69d99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,9 +32,9 @@ else() endif() endif() -add_library(tray SHARED ${SRCS}) +add_library(tray STATIC ${SRCS}) set_property(TARGET tray PROPERTY C_STANDARD 99) -target_compile_definitions(tray PRIVATE TRAY_EXPORTS) +target_include_directories(tray SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(tray PROPERTIES C_VISIBILITY_PRESET hidden) if(WIN32) diff --git a/tray.h b/tray.h index 10e9813..912c838 100644 --- a/tray.h +++ b/tray.h @@ -6,19 +6,7 @@ extern "C" { #endif -#if WIN32 -#ifdef TRAY_EXPORTS -#define TRAY_EXPORT __declspec(dllexport) -#else -#define TRAY_EXPORT __declspec(dllimport) -#endif -#else -#if __GNUC__ >= 4 || defined(__clang__) -#define TRAY_EXPORT extern __attribute__((visibility("default"))) -#else -#define TRAY_EXPORT extern -#endif -#endif +#define TRAY_EXPORT struct tray { const char *icon_filepath; diff --git a/tray_darwin.m b/tray_darwin.m index 545c9eb..1701dfc 100644 --- a/tray_darwin.m +++ b/tray_darwin.m @@ -83,7 +83,8 @@ int tray_loop(int blocking) { void tray_update(struct tray *tray) { tray_instance = tray; double iconHeight = [[NSStatusBar systemStatusBar] thickness]; - NSImage *image = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:tray_instance->icon_filepath]]; + NSImage *image = [NSImage imageNamed:[NSString stringWithUTF8String:tray_instance->icon_filepath]]; + if (image == nil) image = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:tray_instance->icon_filepath]]; double width = image.size.width * (iconHeight / image.size.height); [image setSize:NSMakeSize(width, iconHeight)]; statusItem.button.image = image;