Get screen size from libGUI insted of hardcoding

Also use DPI 96 instead of 1 pixel == 1 milli meter
This commit is contained in:
Oskari Alaranta 2026-02-21 03:48:05 +02:00
parent d0b289d77b
commit ed57950ee0
1 changed files with 17 additions and 4 deletions

View File

@ -17,6 +17,19 @@
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
static const xRectangle s_screen_bounds =
[]() {
auto attributes = LibGUI::Window::default_attributes;
attributes.shown = false;
auto window = MUST(LibGUI::Window::create(0, 0, ""_sv, attributes));
return xRectangle {
.x = 0,
.y = 0,
.width = static_cast<CARD16>(window->width()),
.height = static_cast<CARD16>(window->height()),
};
}();
const xPixmapFormat g_formats[6] { const xPixmapFormat g_formats[6] {
{ {
.depth = 1, .depth = 1,
@ -71,10 +84,10 @@ const xWindowRoot g_root {
.whitePixel = 0xFFFFFF, .whitePixel = 0xFFFFFF,
.blackPixel = 0x000000, .blackPixel = 0x000000,
.currentInputMask = 0, .currentInputMask = 0,
.pixWidth = 1280, .pixWidth = s_screen_bounds.width,
.pixHeight = 800, .pixHeight = s_screen_bounds.height,
.mmWidth = 1280, .mmWidth = static_cast<CARD16>(s_screen_bounds.width * 254 / 960), // 96 DPI
.mmHeight = 800, .mmHeight = static_cast<CARD16>(s_screen_bounds.height * 254 / 960), // 96 DPI
.minInstalledMaps = 1, .minInstalledMaps = 1,
.maxInstalledMaps = 1, .maxInstalledMaps = 1,
.rootVisualID = g_visual.visualID, .rootVisualID = g_visual.visualID,