Skip to content
\n
import { Button, StandardButton, ProgressIndicator, VerticalBox } from \"std-widgets.slint\";\n\nexport component SettingsDialog inherits Dialog {\n\n    title: \"Settings\";\n\n    VerticalBox {\n        spacing: 5px;\n        ProgressIndicator {\n            indeterminate: true;\n        }\n\n        Text {\n            text: \"Multi-window trial\";\n        }\n    }\n\n    StandardButton {\n        kind: ok;\n    }\n\n    StandardButton {\n        kind: cancel;\n    }\n}\n\nexport component AppWindow inherits Window {\n    height: 200px;\n    width: 200px;\n\n    callback show-settings();\n    property <int> value: 100;\n    timer := Timer {\n        interval: 1s;\n        running: true;\n        triggered() => {\n            value -= 1;\n            if (value == 0) {\n                self.running = false;\n            }\n        }\n    }\n\n    VerticalBox {\n        spacing: 10px;\n        Text {\n            text: value;\n        }\n\n        ProgressIndicator {\n            indeterminate: true;\n        }\n\n        Button {\n            text: \"Show settings\";\n            clicked => {\n                root.show-settings()\n            }\n        }\n    }\n}
\n

For completeness I have tried this:

\n\n

I thought this was an winit issue to begin with, but the RenderRequested events seem to come through no matter the focus using the winit only code below:

\n
use winit::event::{Event, WindowEvent};\nuse winit::event_loop::{ControlFlow, EventLoop};\nuse winit::window::WindowBuilder;\n\nfn main() {\n    let event_loop = EventLoop::new();\n    let window1 = WindowBuilder::new()\n        .with_title(\"Window 1\")\n        .build(&event_loop)\n        .unwrap();\n    let window2 = WindowBuilder::new()\n        .with_title(\"Window 2\")\n        .build(&event_loop)\n        .unwrap();\n\n    let mut counter1 = 0;\n    let mut counter2 = 0;\n\n    event_loop.run(move |event, _, control_flow| {\n        *control_flow = ControlFlow::Poll;\n        match event {\n            Event::WindowEvent {\n                event: WindowEvent::CloseRequested,\n                ..\n            } => {\n                *control_flow = ControlFlow::Exit;\n            }\n            Event::MainEventsCleared => {\n                counter1 += 1;\n                counter2 += 1;\n                window1.set_title(&format!(\"Window 1: {}\", counter1));\n                window2.set_title(&format!(\"Window 2: {}\", counter2));\n                window1.request_redraw();\n                window2.request_redraw();\n            }\n            Event::RedrawRequested(id) => {\n                // Add basic rendering logic here if needed\n                println!(\"Redraw requested for window_{:?}\", id);\n            }\n            _ => {}\n        }\n    });\n}
\n

Any help would be hugely appreciated as I have burnt way too many days trying work around this myself.

\n

Cheers, Chris.

","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

I think #8828 should fix this. Could you give it a try?

\n

With this PR, your example works, with one single change: It's important to avoid calling request_redraw() directly on the winit::window::Window and instead, in force_redraw_all_windows replace the call to winit_window.request_redraw() with window.window().request_redraw(). Otherwise Slint's built-in throttle won't help.

","upvoteCount":0,"url":"https://github.com/slint-ui/slint/discussions/8823#discussioncomment-13630246"}}}

Windows Multi-window Focus Based Rendering #8823

Answered by tronical
clneale asked this question in Q&A
Discussion options

You must be logged in to vote

I think #8828 should fix this. Could you give it a try?

With this PR, your example works, with one single change: It's important to avoid calling request_redraw() directly on the winit::window::Window and instead, in force_redraw_all_windows replace the call to winit_window.request_redraw() with window.window().request_redraw(). Otherwise Slint's built-in throttle won't help.

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@clneale
Comment options

@tronical
Comment options

@tronical
Comment options

Answer selected by clneale
Comment options

You must be logged in to vote
5 replies
@tronical
Comment options

@clneale
Comment options

@clneale
Comment options

@tronical
Comment options

@clneale
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants