From 79cb0db2ff7b9235fdeeec8e0252fb034403b46d Mon Sep 17 00:00:00 2001 From: Charles WANG Date: Fri, 21 Jan 2022 12:43:12 +0000 Subject: [PATCH] gg: add a working implementation for screen_size() on windows (#13237) --- vlib/gg/gg.c.v | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vlib/gg/gg.c.v b/vlib/gg/gg.c.v index 5022884142..7792ba23a6 100644 --- a/vlib/gg/gg.c.v +++ b/vlib/gg/gg.c.v @@ -12,6 +12,11 @@ import sokol.sgl import sokol.gfx import math +$if windows { + #flag -lgdi32 + #include "windows.h" +} + pub type TouchPoint = C.sapp_touchpoint pub struct Event { @@ -300,11 +305,20 @@ pub fn high_dpi() bool { return C.sapp_high_dpi() } +// call Windows API to get screen size +fn C.GetSystemMetrics(int) int + pub fn screen_size() Size { $if macos { return C.gg_get_screen_size() } - // TODO windows, linux, etc + $if windows { + return Size{ + width: int(C.GetSystemMetrics(C.SM_CXSCREEN)) + height: int(C.GetSystemMetrics(C.SM_CYSCREEN)) + } + } + // TODO linux, etc return Size{} }