iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
22.82k stars 1.05k forks source link

App resolution is too high and does not follow system settings #2404

Open sang-shelton opened 1 week ago

sang-shelton commented 1 week ago

Is there an existing issue for this?

Is this issue related to iced?

What happened?

This issue is mentioned in detail here and here.

Screenshots of the issue with iced apps

![Screenshot_2024-04-24_22-40-21](https://github.com/iced-rs/iced/assets/154356073/beeb4635-d01d-4874-a6b2-4ca5dd98a044) ![Screenshot_2024-04-24_22-38-38](https://github.com/iced-rs/iced/assets/154356073/bff32a35-84bf-4a06-ab68-744d569942ce)

As you can see, the resolution is too high and the components are smaller than normal on the screen.

What is the expected behavior?

The apps should display correctly respecting the custom window scaling and DPI. GTK3 and 4 apps display well as far as i tested.

Version

master

Operating System

Linux

Do you have any log output?

cargo r --package tour

    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `/home/chakra/Projects/rust/iced/target/debug/tour`
2024-04-24T19:49:36.514414Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 0.78125    
2024-04-24T19:49:36.538735Z  WARN wgpu_hal::vulkan::instance: InstanceFlags::VALIDATION requested, but unable to find layer: VK_LAYER_KHRONOS_validation    
2024-04-24T19:49:36.544730Z  INFO wgpu_hal::vulkan::instance: Debug utils not enabled: debug_utils_user_data not passed to Instance::from_raw    
2024-04-24T19:49:36.548421Z  INFO wgpu_hal::gles::egl: Using X11 platform    
2024-04-24T19:49:36.550329Z  WARN wgpu_hal::gles::egl: No config found!    
2024-04-24T19:49:36.550343Z  WARN wgpu_hal::gles::egl: EGL says it can present to the window but not natively    
2024-04-24T19:49:36.554307Z  INFO iced_wgpu::window::compositor: Settings {
    present_mode: AutoVsync,
    backends: Backends(
        VULKAN | GL | METAL | DX12 | BROWSER_WEBGPU,
    ),
    default_font: Font {
        family: SansSerif,
        weight: Normal,
        stretch: Normal,
        style: Normal,
    },
    default_text_size: Pixels(
        16.0,
    ),
    antialiasing: None,
}    
2024-04-24T19:49:36.577351Z  INFO wgpu_core::instance: Adapter Vulkan AdapterInfo { name: "NVIDIA GeForce RTX 3060", vendor: 4318, device: 9351, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "525.147.05", backend: Vulkan }    
2024-04-24T19:49:36.577416Z  INFO wgpu_core::instance: Adapter Vulkan AdapterInfo { name: "llvmpipe (LLVM 15.0.6, 256 bits)", vendor: 65541, device: 0, device_type: Cpu, driver: "llvmpipe", driver_info: "Mesa 23.1.2-1~mx23ahs (LLVM 15.0.6)", backend: Vulkan }    
2024-04-24T19:49:36.614211Z  INFO wgpu_core::instance: Adapter Gl AdapterInfo { name: "NVIDIA GeForce RTX 3060/PCIe/SSE2", vendor: 4318, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }    
2024-04-24T19:49:36.614296Z  INFO iced_wgpu::window::compositor: Available adapters: [
    AdapterInfo {
        name: "NVIDIA GeForce RTX 3060",
        vendor: 4318,
        device: 9351,
        device_type: DiscreteGpu,
        driver: "NVIDIA",
        driver_info: "525.147.05",
        backend: Vulkan,
    },
    AdapterInfo {
        name: "llvmpipe (LLVM 15.0.6, 256 bits)",
        vendor: 65541,
        device: 0,
        device_type: Cpu,
        driver: "llvmpipe",
        driver_info: "Mesa 23.1.2-1~mx23ahs (LLVM 15.0.6)",
        backend: Vulkan,
    },
    AdapterInfo {
        name: "NVIDIA GeForce RTX 3060/PCIe/SSE2",
        vendor: 4318,
        device: 0,
        device_type: Other,
        driver: "",
        driver_info: "",
        backend: Gl,
    },
]    
2024-04-24T19:49:36.621105Z  INFO wgpu_core::instance: Adapter Vulkan AdapterInfo { name: "NVIDIA GeForce RTX 3060", vendor: 4318, device: 9351, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "525.147.05", backend: Vulkan }    
2024-04-24T19:49:36.621138Z  INFO iced_wgpu::window::compositor: Selected: AdapterInfo {
    name: "NVIDIA GeForce RTX 3060",
    vendor: 4318,
    device: 9351,
    device_type: DiscreteGpu,
    driver: "NVIDIA",
    driver_info: "525.147.05",
    backend: Vulkan,
}    
2024-04-24T19:49:36.621269Z  INFO iced_wgpu::window::compositor: Available formats: Copied {
    it: Iter(
        [
            Bgra8UnormSrgb,
            Bgra8Unorm,
        ],
    ),
}    
2024-04-24T19:49:36.621281Z  INFO iced_wgpu::window::compositor: Available alpha modes: [
    Opaque,
]    
2024-04-24T19:49:36.621289Z  INFO iced_wgpu::window::compositor: Selected format: Bgra8UnormSrgb with alpha mode: Auto    
2024-04-24T19:49:36.742533Z  WARN fontdb: Failed to load a font face 0 from '/home/chakra/.fonts/PIE4MAP.TTF' cause font doesn't have a family name.    
2024-04-24T19:49:36.742673Z  INFO cosmic_text::font::system: Parsed 491 font faces in 30ms.
hecrj commented 1 week ago

winit has a hard time figuring out the proper DPI scaling on Linux. As you can see from your logs:

INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 0.78125

You probably want that to be 2.0. I believe you can add yet another hint for winit and other Linux apps to use proper scaling in your ~/.Xresources file. Try:

Xft.dpi: 192
sang-shelton commented 1 week ago

I believe you can add yet another hint for winit and other Linux apps to use proper scaling in your ~/.Xresources file.

.Xresources was not in my home dir so i had to create it and add that line. I rebooted and nothing changed.

sang-shelton commented 1 week ago

Is it possible when developing an iced app to let the user setup the interface scaling manually from within the app, like veloren does ?