Skip to content

add getWindowMonitor and getMonitorPhysicalSize #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/zglfw.zig
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ pub const Monitor = opaque {
pub const getName = zglfw.getMonitorName;
pub const getVideoMode = zglfw.getVideoMode;
pub const getVideoModes = zglfw.getVideoModes;
pub const getPhysicalSize = zglfw.getMonitorPhysicalSize;

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

pub fn getMonitorPhysicalSize(monitor: *Monitor) Error![2]i32 {
var width_mm: c_int = undefined;
var height_mm: c_int = undefined;
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
try maybeError();
return .{ width_mm, height_mm };
}
extern fn glfwGetMonitorPhysicalSize(*Monitor, width_mm: ?*c_int, height_mm: ?*c_int) void;

pub const getMonitorPos = glfwGetMonitorPos;
extern fn glfwGetMonitorPos(*Monitor, xpos: ?*c_int, ypos: ?*c_int) void;

Expand Down Expand Up @@ -691,6 +701,7 @@ pub const Window = opaque {
pub const setScrollCallback = zglfw.setScrollCallback;
pub const setCursorPosCallback = zglfw.setCursorPosCallback;
pub const setCursorEnterCallback = zglfw.setCursorEnterCallback;
pub const getMonitor = zglfw.getWindowMonitor;
pub const setMonitor = zglfw.setWindowMonitor;
pub const show = zglfw.showWindow;
pub const focus = zglfw.focusWindow;
Expand Down Expand Up @@ -853,6 +864,9 @@ pub const MouseButtonFn = *const fn (
mods: Mods,
) callconv(.C) void;

pub const getWindowMonitor = glfwGetWindowMonitor;
extern fn glfwGetWindowMonitor(window: *Window) ?*Monitor;

pub const setCursorPosCallback = glfwSetCursorPosCallback;
extern fn glfwSetCursorPosCallback(window: *Window, callback: ?CursorPosFn) ?CursorPosFn;
pub const CursorPosFn = *const fn (
Expand Down
Loading