mach: add option to set the monitor index on fullscreen (#611)

* add option to set the monitor index on fullscreen
* make monitor index optional

Co-authored-by: Tobias Simetsreiter <tobias.simetsreiter@meliot.de>
This commit is contained in:
dasimmet 2022-11-14 23:46:42 +01:00 committed by GitHub
parent 731e2b1287
commit caafb26fe4
Failed to generate hash of commit
2 changed files with 17 additions and 4 deletions

View file

@ -316,11 +316,21 @@ pub const Platform = struct {
.double => .fifo,
.triple => .mailbox,
};
if (options.fullscreen) {
platform.last_position = try platform.window.getPos();
const monitor = glfw.Monitor.getPrimary().?;
const video_mode = try monitor.getVideoMode();
platform.last_position = try platform.window.getPos();
if (options.fullscreen) {
var monitor: ?glfw.Monitor = null;
if (options.monitor) |monitorIndex| {
const monitorList = try glfw.Monitor.getAll(platform.allocator);
defer platform.allocator.free(monitorList);
monitor = monitorList[monitorIndex];
} else {
monitor = glfw.Monitor.getPrimary();
}
const video_mode = try monitor.?.getVideoMode();
try platform.window.setMonitor(monitor, 0, 0, video_mode.getWidth(), video_mode.getHeight(), null);
} else {
const position = platform.last_position;

View file

@ -36,6 +36,9 @@ pub const Options = struct {
/// Fullscreen window.
fullscreen: bool = false,
/// Fullscreen monitor index
monitor: ?u32 = null,
/// Headless mode.
headless: bool = false,