core: ability to get screen size #1014

Open
opened 2023-09-19 20:32:36 +00:00 by ghost · 1 comment
ghost commented 2023-09-19 20:32:36 +00:00 (Migrated from github.com)

github.com/hexops/mach-core@9243a331a3/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:

image

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.

https://github.com/hexops/mach-core/blob/9243a331a3eb0d4ba97aec7f793e60f1cf90bd8b/src/main.zig#L107 ```zig 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: ![image](https://github.com/hexops/mach/assets/35064754/3c336eb7-a51b-4f91-9346-fc6250678f7b) 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.
emidoots commented 2023-11-05 05:13:42 +00:00 (Migrated from github.com)

Related #1102

Related #1102
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1014
No description provided.