Skip to content

Commit 75ab44d

Browse files
authored
add getWindowMonitor and getMonitorPhysicalSize (#29)
1 parent dcb1dae commit 75ab44d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/zglfw.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ pub const Monitor = opaque {
545545
pub const getName = zglfw.getMonitorName;
546546
pub const getVideoMode = zglfw.getVideoMode;
547547
pub const getVideoModes = zglfw.getVideoModes;
548+
pub const getPhysicalSize = zglfw.getMonitorPhysicalSize;
548549

549550
pub fn getPos(self: *Monitor) [2]c_int {
550551
var xpos: c_int = 0;
@@ -566,6 +567,15 @@ pub fn getMonitors() []*Monitor {
566567
}
567568
extern fn glfwGetMonitors(count: *c_int) ?[*]*Monitor;
568569

570+
pub fn getMonitorPhysicalSize(monitor: *Monitor) Error![2]i32 {
571+
var width_mm: c_int = undefined;
572+
var height_mm: c_int = undefined;
573+
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
574+
try maybeError();
575+
return .{ width_mm, height_mm };
576+
}
577+
extern fn glfwGetMonitorPhysicalSize(*Monitor, width_mm: ?*c_int, height_mm: ?*c_int) void;
578+
569579
pub const getMonitorPos = glfwGetMonitorPos;
570580
extern fn glfwGetMonitorPos(*Monitor, xpos: ?*c_int, ypos: ?*c_int) void;
571581

@@ -691,6 +701,7 @@ pub const Window = opaque {
691701
pub const setScrollCallback = zglfw.setScrollCallback;
692702
pub const setCursorPosCallback = zglfw.setCursorPosCallback;
693703
pub const setCursorEnterCallback = zglfw.setCursorEnterCallback;
704+
pub const getMonitor = zglfw.getWindowMonitor;
694705
pub const setMonitor = zglfw.setWindowMonitor;
695706
pub const show = zglfw.showWindow;
696707
pub const focus = zglfw.focusWindow;
@@ -853,6 +864,9 @@ pub const MouseButtonFn = *const fn (
853864
mods: Mods,
854865
) callconv(.C) void;
855866

867+
pub const getWindowMonitor = glfwGetWindowMonitor;
868+
extern fn glfwGetWindowMonitor(window: *Window) ?*Monitor;
869+
856870
pub const setCursorPosCallback = glfwSetCursorPosCallback;
857871
extern fn glfwSetCursorPosCallback(window: *Window, callback: ?CursorPosFn) ?CursorPosFn;
858872
pub const CursorPosFn = *const fn (

0 commit comments

Comments
 (0)