1786032381
This commit is contained in:
11
src/main.rs
11
src/main.rs
@@ -17,12 +17,15 @@ fn main() -> Result<(), slint::PlatformError> {
|
|||||||
let main_window = MainWindow::new()?;
|
let main_window = MainWindow::new()?;
|
||||||
|
|
||||||
let weak_window = main_window.as_weak();
|
let weak_window = main_window.as_weak();
|
||||||
thread::spawn(move || {
|
slint::spawn_local(async move {
|
||||||
sleep(Duration::from_secs(3));
|
sleep(Duration::from_secs(3));
|
||||||
weak_window.upgrade_in_event_loop(move |ui| {
|
if let Some(strong) = weak_window.upgrade() {
|
||||||
println!("Goodbye!");
|
println!("Goodbye!");
|
||||||
ui.set_text("GoodBye!".into());
|
strong.set_text("Goodbye!".into());
|
||||||
})
|
};
|
||||||
|
// weak_window.upgrade_in_event_loop(move |ui| {
|
||||||
|
// ui.set_text("GoodBye!".into());
|
||||||
|
// })
|
||||||
});
|
});
|
||||||
|
|
||||||
main_window.run()
|
main_window.run()
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
|
use std::cell::OnceCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
use evdev::KeyCode;
|
use evdev::KeyCode;
|
||||||
use linfb::shape::Color;
|
use linfb::shape::Color;
|
||||||
use slint::platform::software_renderer::{MinimalSoftwareWindow, RepaintBufferType, Rgb565Pixel};
|
use slint::platform::software_renderer::{MinimalSoftwareWindow, RepaintBufferType, Rgb565Pixel};
|
||||||
use slint::platform::{Platform, WindowEvent};
|
use slint::platform::{EventLoopProxy, Platform, WindowEvent};
|
||||||
use slint::{LogicalPosition, PhysicalSize, Rgb8Pixel, WindowSize};
|
use slint::{EventLoopError, LogicalPosition, PhysicalSize, Rgb8Pixel, WindowSize};
|
||||||
|
|
||||||
use self::input::InputState;
|
use self::input::InputState;
|
||||||
use self::screen::Screen;
|
use self::screen::Screen;
|
||||||
@@ -12,6 +15,8 @@ use self::screen::Screen;
|
|||||||
mod input;
|
mod input;
|
||||||
mod screen;
|
mod screen;
|
||||||
|
|
||||||
|
static EVENTLOOP_PROXY: OnceCell<Box<dyn EventLoopProxy + 'static>> = OnceCell::new();
|
||||||
|
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
pub screen: Screen,
|
pub screen: Screen,
|
||||||
pub input: InputState,
|
pub input: InputState,
|
||||||
@@ -100,4 +105,53 @@ impl Platform for Trekstor {
|
|||||||
ctx.input.finish();
|
ctx.input.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_event_loop_proxy(&self) -> Option<Box<dyn EventLoopProxy>> {
|
||||||
|
// struct Proxy(
|
||||||
|
// winit::event_loop::EventLoopProxy<SlintEvent>,
|
||||||
|
// Arc<AtomicUsize>,
|
||||||
|
// );
|
||||||
|
// impl EventLoopProxy for Proxy {
|
||||||
|
// fn quit_event_loop(&self) -> Result<(), EventLoopError> {
|
||||||
|
// Err(EventLoopError::EventLoopTerminated)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// fn invoke_from_event_loop(
|
||||||
|
// &self,
|
||||||
|
// event: Box<dyn FnOnce() + Send>,
|
||||||
|
// ) -> Result<(), EventLoopError> {
|
||||||
|
// self.0
|
||||||
|
// .send_event(SlintEvent(CustomEvent::UserEvent(event)))
|
||||||
|
// .map_err(|_| EventLoopError::EventLoopTerminated)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// Some(Box::new(Proxy(
|
||||||
|
// self.shared_data.event_loop_proxy.clone(),
|
||||||
|
// Arc::clone(&self.shared_data.event_loop_generation),
|
||||||
|
// )))
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn click_interval(&self) -> core::time::Duration {
|
||||||
|
// 500ms is the default delay according to https://en.wikipedia.org/wiki/Double-click#Speed_and_timing
|
||||||
|
core::time::Duration::from_millis(500)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cursor_flash_cycle(&self) -> core::time::Duration {
|
||||||
|
core::time::Duration::from_millis(1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_clipboard_text(&self, _text: &str, _clipboard: slint::platform::Clipboard) {}
|
||||||
|
|
||||||
|
fn clipboard_text(&self, _clipboard: slint::platform::Clipboard) -> Option<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
fn debug_log(&self, _arguments: core::fmt::Arguments) {
|
||||||
|
crate::debug_log::default_log_message(_arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_url(&self, _url: &str) -> Result<(), slint::PlatformError> {
|
||||||
|
Err(slint::PlatformError::Unsupported)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user