--- a/src/window.c Sun Jun 15 19:50:51 2025 +0200 +++ b/src/window.c Sun Jun 15 21:02:29 2025 +0200 @@ -77,6 +77,9 @@ } window->resized = true; // count initial sizing as resize + // default UI scale + window->ui_scale = 1.0f; + if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) { asc_scene_init(&window->ui, .type = ASC_CAMERA_ORTHO, @@ -198,3 +201,34 @@ AscScene *asc_window_scene(unsigned int index) { return &asc_active_window->scenes[index]; } + +asc_vec2u asc_window_display_resolution(void) { + const AscWindow *window = asc_active_window; + SDL_DisplayMode dm; + const int display = SDL_GetWindowDisplayIndex(window->window); + if (SDL_GetDesktopDisplayMode(display, &dm)) { + asc_error("Failed to get display mode for window %u on display %d: %s", + window->id, display, SDL_GetError()); + } + return asc_vec2u_new(dm.w, dm.h); +} + +void asc_ui_scale(float scale) { + asc_active_window->ui_scale = scale; +} + +float asc_ui_get_scale(void) { + return asc_active_window->ui_scale; +} + +void asc_ui_scale_auto(void) { + asc_vec2u res = asc_window_display_resolution(); + // TODO: debug why this is wrong under GNOME or just throw GNOME away + if (res.width > 3000) { + asc_ui_scale(1.5f); + } else if (res.width > 2000) { + asc_ui_scale(1.2f); + } else { + return asc_ui_scale(1.f); + } +}