chore: add video mode

This commit is contained in:
Raiden1411
2023-11-07 18:07:22 +00:00
parent fbe2b7c267
commit b9ad49acc3

View File

@ -153,13 +153,18 @@ pub const App = struct {
const monitor = win.getMonitor() orelse monitor: { const monitor = win.getMonitor() orelse monitor: {
log.warn("window had null monitor, getting primary monitor", .{}); log.warn("window had null monitor, getting primary monitor", .{});
break :monitor glfw.Monitor.getPrimary() orelse { break :monitor glfw.Monitor.getPrimary() orelse {
log.warn("window could not get any monitor. Will not perform action", .{}); log.warn("window could not get any monitor. will not perform action", .{});
return; return;
}; };
}; };
const video_mode = monitor.getVideoMode() orelse {
log.warn("failed to get video mode. will not perform action", .{});
return;
};
const position = win.getPos(); const position = win.getPos();
const size = surface.getSize() catch { const size = surface.getSize() catch {
log.warn("Failed to get window size. Will not perform fullscreen action", .{}); log.warn("failed to get window size. will not perform fullscreen action", .{});
return; return;
}; };
@ -170,7 +175,7 @@ pub const App = struct {
.position_y = position.y, .position_y = position.y,
}; };
win.setMonitor(monitor, 0, 0, surface.window_dimensions.width, surface.window_dimensions.height, 0); win.setMonitor(monitor, 0, 0, video_mode.getWidth(), video_mode.getHeight(), 0);
} else { } else {
win.setMonitor(null, @as(i32, @intCast(surface.window_dimensions.position_x)), @as(i32, @intCast(surface.window_dimensions.position_y)), surface.window_dimensions.width, surface.window_dimensions.height, 0); win.setMonitor(null, @as(i32, @intCast(surface.window_dimensions.position_x)), @as(i32, @intCast(surface.window_dimensions.position_y)), surface.window_dimensions.width, surface.window_dimensions.height, 0);
} }