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:
parent
731e2b1287
commit
caafb26fe4
2 changed files with 17 additions and 4 deletions
|
|
@ -316,11 +316,21 @@ pub const Platform = struct {
|
||||||
.double => .fifo,
|
.double => .fifo,
|
||||||
.triple => .mailbox,
|
.triple => .mailbox,
|
||||||
};
|
};
|
||||||
if (options.fullscreen) {
|
|
||||||
platform.last_position = try platform.window.getPos();
|
|
||||||
|
|
||||||
const monitor = glfw.Monitor.getPrimary().?;
|
platform.last_position = try platform.window.getPos();
|
||||||
const video_mode = try monitor.getVideoMode();
|
|
||||||
|
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);
|
try platform.window.setMonitor(monitor, 0, 0, video_mode.getWidth(), video_mode.getHeight(), null);
|
||||||
} else {
|
} else {
|
||||||
const position = platform.last_position;
|
const position = platform.last_position;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ pub const Options = struct {
|
||||||
/// Fullscreen window.
|
/// Fullscreen window.
|
||||||
fullscreen: bool = false,
|
fullscreen: bool = false,
|
||||||
|
|
||||||
|
/// Fullscreen monitor index
|
||||||
|
monitor: ?u32 = null,
|
||||||
|
|
||||||
/// Headless mode.
|
/// Headless mode.
|
||||||
headless: bool = false,
|
headless: bool = false,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue