slint icon indicating copy to clipboard operation
slint copied to clipboard

ui.window().set_position() Incorrect window position in case of no-frame

Open LeeeSe opened this issue 1 year ago • 5 comments

image

I'm now using i_slint_backend_winit as a temporary alternative

    let mut backend = i_slint_backend_winit::Backend::new().unwrap();
    backend.window_builder_hook = Some(Box::new(|builder| {
        builder
        .with_titlebar_buttons_hidden(true)
        .with_titlebar_transparent(true)
        // .with_titlebar_hidden(true) same with no-frame
        .with_title_hidden(true)
    }));

But it has an extra transparent title_bar, which is not a perfect solution

LeeeSe avatar Mar 11 '24 19:03 LeeeSe

Thanks for the bug report.

If you don't set no-frame it works?

This is most likely a problem in winit or a limitation of the platform.

ogoffart avatar Mar 12 '24 08:03 ogoffart

If set no-frame false

everything is work

But not in the style of a float window

LeeeSe avatar Mar 12 '24 08:03 LeeeSe

Can you try if you can reproduc by changing a simple winit example like this one: https://github.com/rust-windowing/winit/blob/v0.29.x/examples/window.rs

eg, adding a call to set_decorations(false) and set_outer_position


use winit::{
    event::{Event, WindowEvent},
    event_loop::EventLoop,
    window::WindowBuilder,
};

//#[path = "util/fill.rs"]
//mod fill;

fn main() -> Result<(), impl std::error::Error> {
    let event_loop = EventLoop::new().unwrap();

    let window = WindowBuilder::new()
        .with_title("A fantastic window!")
        .with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
        //.with_title_bar_hidden(true)
        .build(&event_loop)
        .unwrap();

    window.set_decorations(false);
    window.set_outer_position(winit::dpi::LogicalPosition::new(0.0, 0.0));


    event_loop.run(move |event, elwt| {
        println!("{event:?}");

        match event {
            Event::WindowEvent { event, window_id } if window_id == window.id() => match event {
                WindowEvent::CloseRequested => elwt.exit(),
                WindowEvent::RedrawRequested => {
                    // Notify the windowing system that we'll be presenting to the window.
                    window.pre_present_notify();
                    //fill::fill_window(&window);
                }
                _ => (),
            },

            _ => (),
        }
    })
}

It works well for me on Linux.

You can also try to change set_outer_position by set_inner_position.

If this is not working as expected, one should submit a bug to winit. (If this works with set_inner_position, we can change Slint to call that if the no-frame flag is set)

ogoffart avatar Mar 12 '24 09:03 ogoffart

Hi ogoffart. Nice to meet you. I am a developer who has just started developing slint. Each and every one of your articles and projects has been of great help to me. However, I ran into a problem during the development process, so I hope you can help me. How can I connect with app.slint and window.rs? Can you explain about it more detail using sample code. I wish you success in your business.

panda6151025 avatar May 26 '24 14:05 panda6151025

@panda6151025 Sorry, we were all at a conference for the last few days...

@ogoffart suggested to just try that winit-only code to test whether the problem is in winit or in Slint.

It would be wonderful if you could run the test program stand-alone and report back what actually happens when you run that.

It is not integrating with your slint file at all :-)

hunger avatar May 31 '24 10:05 hunger