diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index afb3a61083..66d5cfb0a6 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -581,6 +581,15 @@ pub fn (ctx &Context) draw_empty_rounded_rect(x f32, y f32, w f32, h f32, radius sgl.end() } + +pub fn screen_size() Size { + $if macos { + return C.gg_get_screen_size() + } + // TODO windows, linux, etc + return Size{} +} + fn C.WaitMessage() /* diff --git a/vlib/gg/gg_darwin.c.v b/vlib/gg/gg_darwin.c.v new file mode 100644 index 0000000000..808cd5fbed --- /dev/null +++ b/vlib/gg/gg_darwin.c.v @@ -0,0 +1,4 @@ +module gg + +#include "@VROOT/vlib/gg/gg_darwin.m" +fn C.gg_get_screen_size() Size diff --git a/vlib/gg/gg_darwin.m b/vlib/gg/gg_darwin.m new file mode 100644 index 0000000000..83b1a09284 --- /dev/null +++ b/vlib/gg/gg_darwin.m @@ -0,0 +1,14 @@ +#include + +gg__Size gg_get_screen_size() { + NSScreen *screen = [NSScreen mainScreen]; + NSDictionary *description = [screen deviceDescription]; + NSSize displayPixelSize = [[description objectForKey:NSDeviceSize] sizeValue]; + CGSize displayPhysicalSize = CGDisplayScreenSize( + [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]); + gg__Size res; + res.width = displayPixelSize.width; + res.height = displayPixelSize.height; + return res; +} +