Skip to content

Commit

Permalink
gg: add linux support in fn screen_size() Size
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Oates committed Dec 31, 2024
1 parent 7b9b3dd commit 5a7f668
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion vlib/gg/gg.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import sokol.sapp
import sokol.sgl
import sokol.gfx

struct C.Display {}

fn C.XOpenDisplay(int) &C.Display
fn C.DefaultScreen(&C.Display) int
fn C.DisplayHeight(&C.Display, int) int
fn C.DisplayWidth(&C.Display, int) int

$if windows {
#flag -lgdi32
#include "windows.h"
Expand Down Expand Up @@ -739,7 +746,14 @@ pub fn screen_size() Size {
height: int(C.GetSystemMetrics(C.SM_CYSCREEN))
}
}
// TODO: linux, etc
$if linux {
display := C.XOpenDisplay(0)
screen := C.DefaultScreen(display)
return Size{
width: C.DisplayWidth(display, screen)
height: C.DisplayHeight(display, screen)
}
}
return Size{}
}

Expand Down

0 comments on commit 5a7f668

Please sign in to comment.