gg: screen_size()

pull/7127/head
Alexander Medvednikov 2020-12-03 23:17:00 +01:00
parent b37550c279
commit e160f6e7d2
3 changed files with 27 additions and 0 deletions

View File

@ -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()
/*

View File

@ -0,0 +1,4 @@
module gg
#include "@VROOT/vlib/gg/gg_darwin.m"
fn C.gg_get_screen_size() Size

View File

@ -0,0 +1,14 @@
#include <Cocoa/Cocoa.h>
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;
}