summaryrefslogtreecommitdiffstats
path: root/src/glfw_impl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/glfw_impl.zig')
-rw-r--r--src/glfw_impl.zig41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/glfw_impl.zig b/src/glfw_impl.zig
index 8bfbec2..dffd7bf 100644
--- a/src/glfw_impl.zig
+++ b/src/glfw_impl.zig
@@ -4,9 +4,9 @@ const debug = @import("std").debug;
const math = @import("std").math;
pub const ClientApi = enum {
- Unknown,
- OpenGL,
- Vulkan,
+ Unknown,
+ OpenGL,
+ Vulkan,
};
// Data
@@ -145,7 +145,40 @@ pub fn NewFrame() void {
}
fn UpdateMonitors() void {
- // @TODO
+ const platform_io = c.igGetPlatformIO();
+ var monitors_count : c_int = 0;
+ const glfw_monitors = c.glfwGetMonitors(&monitors_count)[0..@intCast(usize, monitors_count)];
+
+ c.ImVector_ImGuiPlatformMonitor_Resize(&platform_io.*.Monitors, monitors_count);
+ for (glfw_monitors) |glfw_monitor, n| {
+ var monitor = &platform_io.*.Monitors.Data[n];
+ var x : c_int = undefined;
+ var y : c_int = undefined;
+ c.glfwGetMonitorPos(glfw_monitor, &x, &y);
+ const vid_mode = c.glfwGetVideoMode(glfw_monitor); // glfw_monitors[n]);
+
+ monitor.*.MainPos = c.ImVec2{ .x = @intToFloat(f32, x), .y = @intToFloat(f32, y) };
+ monitor.*.MainSize = c.ImVec2{
+ .x = @intToFloat(f32, vid_mode.*.width),
+ .y = @intToFloat(f32, vid_mode.*.height),
+ };
+ if (false and c.GLFW_HAS_MONITOR_WORK_AREA) {
+ var w : c_int = undefined;
+ var h : c_int = undefined;
+ c.glfwGetMonitorWorkarea(glfw_monitor, &x, &y, &w, &h);
+ monitor.*.WorkPos = ImVec2{ .x = @intToFloat(f32, x), .y = @intToFloat(f32, y) };
+ monitor.*.WorkSize = ImVec2{ .x = @intToFloat(f32, w), .y = @intToFloat(f32, h) };
+ }
+ if (false and c.GLFW_HAS_PER_MONITOR_DPI) {
+ // Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings,
+ // which generally needs to be set in the manifest or at runtime.
+ var x_scale : f32 = undefined;
+ var y_scale : f32 = undefined;
+ c.glfwGetMonitorContentScale(glfw_monitor, &x_scale, &y_scale);
+ monitor.*.DpiScale = x_scale;
+ }
+ }
+ g_WantUpdateMonitors = false;
}
fn UpdateMousePosAndButtons() void {