mach
mach copied to clipboard
core: ability to get screen size
https://github.com/hexops/mach-core/blob/9243a331a3eb0d4ba97aec7f793e60f1cf90bd8b/src/main.zig#L107
size: Size = .{ .width = 1920 / 2, .height = 1080 / 2 },
I think this is a pretty good default window size except it doesn't work for all screen sizes if it's supposed to. I would like to query the resolution of the monitor that the Mach window is active on. This way the size could be made to be half the actual screen size. Similar to core.size()
it could be queried as core.screenSize()
. Of course, there are other reasons why a user might want to query the screen size. This is a proposal to add such a function.
Setting the screen size is almost certainly not possible by a regular process. I do have this option in my system settings though:
For the implementation glfwGetVideoMode
(https://www.glfw.org/docs/3.0/group__monitor.html#gac3fe0f647f68b731f99756cd81897378) is probably relevant. I don't see a callback that fires when the screen size changes (like when I use my system settings above to change the monitor resolution) unless I'm missing something? glfwGetVideoMode
(https://www.glfw.org/docs/latest/group__monitor.html#gaba376fa7e76634b4788bddc505d6c9d5) only seems to fire when a monitor is connected or disconnected rather than when its size changes.
If there is such a callback it might be better for mach-core to keep track of the screen size internally and then change that value when the callback is called? And then core.screenSize()
won't actually call into GLFW.