mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Add OS detection
This commit is contained in:
parent
6fdc87454a
commit
1344638c52
2 changed files with 13 additions and 0 deletions
|
|
@ -83,6 +83,11 @@ void ShowMouse() {
|
|||
msg_reg(c("NSCursor"), s("unhide"));
|
||||
}
|
||||
|
||||
OSVersion getOSVersion() {
|
||||
id processInfo = msg_reg(c("NSProcessInfo"), s("processInfo"));
|
||||
return GET_OSVERSION(processInfo);
|
||||
}
|
||||
|
||||
struct Application {
|
||||
|
||||
// Cocoa data
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@
|
|||
#include "hashmap.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
typedef struct {
|
||||
long maj;
|
||||
long min;
|
||||
long patch;
|
||||
} OSVersion;
|
||||
|
||||
// Macros to make it slightly more sane
|
||||
#define msg objc_msgSend
|
||||
#define msg_reg ((id(*)(id, SEL))objc_msgSend)
|
||||
|
|
@ -37,11 +43,13 @@
|
|||
#if defined (__aarch64__)
|
||||
#define GET_FRAME(receiver) ((CGRect(*)(id, SEL))objc_msgSend)(receiver, s("frame"))
|
||||
#define GET_BOUNDS(receiver) ((CGRect(*)(id, SEL))objc_msgSend)(receiver, s("bounds"))
|
||||
#define GET_OSVERSION(receiver) ((OSVersion(*)(id, SEL))objc_msgSend)(processInfo, s("operatingSystemVersion"));
|
||||
#endif
|
||||
|
||||
#if defined (__x86_64__)
|
||||
#define GET_FRAME(receiver) ((CGRect(*)(id, SEL))objc_msgSend_stret)(receiver, s("frame"))
|
||||
#define GET_BOUNDS(receiver) ((CGRect(*)(id, SEL))objc_msgSend_stret)(receiver, s("bounds"))
|
||||
#define GET_OSVERSION(receiver) ((OSVersion(*)(id, SEL))objc_msgSend_stret)(processInfo, s("operatingSystemVersion"));
|
||||
#endif
|
||||
|
||||
#define GET_BACKINGSCALEFACTOR(receiver) ((CGFloat(*)(id, SEL))objc_msgSend)(receiver, s("backingScaleFactor"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue