-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong window size on linux mint #219
Comments
Hello, which one is the right one? Linux or Wine? Should the white line be there as in the first image, or not? I tried to replicate this behavior but the setup method returns the same size that I pass in the config, no matter that I use |
White line means background is not same size as window size, it happens on linux. |
@Nazariglez So gfx.size() returns wrong size in a |
hey @LedinecMing Can you try with this branch? https://github.com/Nazariglez/notan/tree/log/size and paste here all the logs? Thanks |
@LedinecMing are you using mint with wayland? We think that this issue could be related to #265 and rust-windowing/winit#1446, I'll try to find a solution in the next few days/weeks if it's related. |
I will try soon, still X. |
@Nazariglez https://pastebin.com/t4pWVHj4 here is log and a minimal reproduction code resize seems to be a key of an issue, everything works fine if I remove it. |
This is weird, I do think that the changes made in the next version of winit will help, let's keep this on hold until then. Thanks! |
Hi there. I don't know if I'm experiencing similar issues. I come here from a discord thread. I made a simple example to showcase the problem: use notan::{draw::*, init_with, prelude::*};
#[notan_main]
fn main() -> Result<(), String> {
let win_config = WindowConfig::default()
// .set_size(300, 300) // window pixel size would be auto-scaled by dpi==1.66
.set_high_dpi(true) // doesn't seem to change anything
.set_resizable(true);
init_with(setup).add_config(win_config).add_config(DrawConfig).draw(draw).build()
}
fn setup(app: &mut App) {
let window = app.window();
let dpi = window.dpi();
// here we scale back the window size to a REAL pixel size of 300x300x
window.set_size(unscale(300, dpi), unscale(300, dpi));
println!("dpi: {dpi}");
}
fn draw(app: &mut App, gfx: &mut Graphics) {
let _dpi = app.window().dpi(); // == 1.66
// FIX 1: this causes the square to render at the BOTTOM left:
// gfx.set_size(unscale(100, _dpi), unscale(100, _dpi));
// FIX 2: this causes the square to render 80 pixels over the BOTTOM left:
// gfx.set_dpi(1.0);
let mut draw = gfx.create_draw();
draw.clear(Color::BLUE);
// When not changing gfx's size or dpi this renders at the TOP left:
draw.rect((0.0, 0.0), (100.0, 100.0));
gfx.render(&draw);
}
/// Removes a `dpi` scaling factor from a `value` in pixels.
#[inline]
fn unscale(value: u32, dpi: f64) -> u32 { (value as f64 / dpi) as u32 } I'm using Linux Mint + XFCE. Notan was detecting a dpi of 1.66..., which derived in these problems. But after updating my custom DPI settings in "Settings -> Appearance -> Fonts" from the 96 dpi by default to another value, and back, notan then reports a dpi of 1, which fixed my problems. Additionally changing the DPI settings away from 96 dpi makes the gfx rendering on the y axis diverge by about 3.5 pixels per dpi point, so there maybe something there worth looking into. |
gfx.device.size() gives different results when on linux or on windows(using wine) in setup function
attached first is linux, second is windows
The text was updated successfully, but these errors were encountered: