Uses Winit from crates.io (#1338)

This commit is contained in:
Putta Khunchalee
2025-05-04 14:44:59 +02:00
committed by GitHub
parent 192e0c5751
commit 9fe21ca17a
10 changed files with 51 additions and 45 deletions
Generated
+26 -30
View File
@@ -1189,11 +1189,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
[[package]]
name = "dpi"
version = "0.1.1"
source = "git+https://github.com/obhq/winit.git#aed3fe997b69f5fbc12dc34a0cd7e3431c70c5be"
[[package]]
name = "either"
version = "1.13.0"
@@ -1241,12 +1236,12 @@ checksum = "2a235af404df0c0ceef5b773e9d641731dccea25f02e4e2714b4841df10f6c1c"
[[package]]
name = "errno"
version = "0.3.9"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -2810,7 +2805,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89fed9ce3e5c01700e3a129d3d74619bbf468645b58274b420885107e496ecff"
dependencies = [
"crossbeam-channel",
"dpi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dpi",
"gtk",
"keyboard-types",
"libxdo",
@@ -3689,9 +3684,9 @@ dependencies = [
[[package]]
name = "quick-xml"
version = "0.36.2"
version = "0.37.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe"
checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb"
dependencies = [
"memchr",
]
@@ -3945,15 +3940,15 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.38.37"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags 2.6.0",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5015,9 +5010,9 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]]
name = "wayland-backend"
version = "0.3.7"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "056535ced7a150d45159d3a8dc30f91a2e2d588ca0b23f70e56033622b8016f6"
checksum = "fe770181423e5fc79d3e2a7f4410b7799d5aab1de4372853de3c6aa13ca24121"
dependencies = [
"cc",
"downcast-rs",
@@ -5029,9 +5024,9 @@ dependencies = [
[[package]]
name = "wayland-client"
version = "0.31.7"
version = "0.31.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b66249d3fc69f76fd74c82cc319300faa554e9d865dab1f7cd66cc20db10b280"
checksum = "978fa7c67b0847dbd6a9f350ca2569174974cd4082737054dbb7fbb79d7d9a61"
dependencies = [
"bitflags 2.6.0",
"rustix",
@@ -5063,9 +5058,9 @@ dependencies = [
[[package]]
name = "wayland-protocols"
version = "0.32.5"
version = "0.32.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7cd0ade57c4e6e9a8952741325c30bf82f4246885dca8bf561898b86d0c1f58e"
checksum = "779075454e1e9a521794fed15886323ea0feda3f8b0fc1390f5398141310422a"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
@@ -5075,9 +5070,9 @@ dependencies = [
[[package]]
name = "wayland-protocols-plasma"
version = "0.3.5"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b31cab548ee68c7eb155517f2212049dc151f7cd7910c2b66abfd31c3ee12bd"
checksum = "4fd38cdad69b56ace413c6bcc1fbf5acc5e2ef4af9d5f8f1f9570c0c83eae175"
dependencies = [
"bitflags 2.6.0",
"wayland-backend",
@@ -5101,20 +5096,20 @@ dependencies = [
[[package]]
name = "wayland-scanner"
version = "0.31.5"
version = "0.31.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597f2001b2e5fc1121e3d5b9791d3e78f05ba6bfa4641053846248e3a13661c3"
checksum = "896fdafd5d28145fce7958917d69f2fd44469b1d4e861cb5961bcbeebc6d1484"
dependencies = [
"proc-macro2",
"quick-xml 0.36.2",
"quick-xml 0.37.5",
"quote",
]
[[package]]
name = "wayland-sys"
version = "0.31.5"
version = "0.31.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa8ac0d8e8ed3e3b5c9fc92c7881406a268e11555abe36493efabe649a29e09"
checksum = "dbcebb399c77d5aa9fa5db874806ee7b4eba4e73650948e8f93963f128896615"
dependencies = [
"dlib",
"log",
@@ -5496,8 +5491,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winit"
version = "0.30.8"
source = "git+https://github.com/obhq/winit.git#aed3fe997b69f5fbc12dc34a0cd7e3431c70c5be"
version = "0.30.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0d05bd8908e14618c9609471db04007e644fd9cce6529756046cfc577f9155e"
dependencies = [
"ahash",
"android-activity",
@@ -5511,7 +5507,7 @@ dependencies = [
"core-foundation 0.9.4",
"core-graphics 0.23.2",
"cursor-icon",
"dpi 0.1.1 (git+https://github.com/obhq/winit.git)",
"dpi",
"js-sys",
"libc",
"memmap2",
-3
View File
@@ -18,6 +18,3 @@ panic = "abort"
[profile.release]
panic = "abort"
lto = true
[patch.crates-io]
winit = { git = "https://github.com/obhq/winit.git" }
+1 -1
View File
@@ -40,7 +40,7 @@ slint = { version = "=1.11.0", features = [
thiserror = "2.0.3"
uuid = { version = "1.11.0", features = ["serde", "v4"] }
wae = "0.2.0"
winit = { version = "0.30.5", features = ["rwh_06"] }
winit = { version = "0.30.10", features = ["rwh_06"] }
[target.'cfg(target_arch = "aarch64")'.dependencies]
aarch64 = { path = "../lib/aarch64" }
+1 -1
View File
@@ -59,7 +59,7 @@ impl DesktopWindow for VulkanWindow {
}
#[cfg(target_os = "linux")]
fn xdg_toplevel(&self) -> *mut std::ffi::c_void {
fn xdg_toplevel(&self) -> Option<std::ptr::NonNull<std::ffi::c_void>> {
use winit::platform::wayland::WindowExtWayland;
self.window.xdg_toplevel()
+2 -1
View File
@@ -1,6 +1,7 @@
use super::PlatformError;
use crate::ui::DesktopWindow;
use crate::ui::backend::Wayland;
use std::ptr::null_mut;
use wayland_backend::sys::client::ObjectId;
use wayland_client::Proxy;
use wayland_protocols::xdg::dialog::v1::client::xdg_dialog_v1::XdgDialogV1;
@@ -41,7 +42,7 @@ pub unsafe fn set_modal(
/// # Safety
/// `win` must outlive the returned [`XdgToplevel`].
unsafe fn get_xdg_toplevel(wayland: &Wayland, win: &impl DesktopWindow) -> XdgToplevel {
let obj = win.xdg_toplevel();
let obj = win.xdg_toplevel().map(|v| v.as_ptr()).unwrap_or(null_mut());
let obj = unsafe { ObjectId::from_ptr(XdgToplevel::interface(), obj.cast()).unwrap() };
XdgToplevel::from_id(wayland.connection(), obj).unwrap()
+2 -2
View File
@@ -135,7 +135,7 @@ impl<T: ComponentHandle + WinitWindow> DesktopWindow for T {
}
#[cfg(target_os = "linux")]
fn xdg_toplevel(&self) -> *mut std::ffi::c_void {
fn xdg_toplevel(&self) -> Option<std::ptr::NonNull<std::ffi::c_void>> {
use winit::platform::wayland::WindowExtWayland;
let win = WindowInner::from_pub(self.window()).window_adapter();
@@ -160,7 +160,7 @@ pub trait App: Sized + 'static {
pub trait DesktopWindow: WinitWindow {
fn handle(&self) -> impl HasWindowHandle + '_;
#[cfg(target_os = "linux")]
fn xdg_toplevel(&self) -> *mut std::ffi::c_void;
fn xdg_toplevel(&self) -> Option<std::ptr::NonNull<std::ffi::c_void>>;
}
/// Provides methods to operate on a [`DesktopWindow`].
+5 -1
View File
@@ -27,7 +27,11 @@ export component AboutWindow inherits Dialog {
tab := TabBar {
tabs: [
{ text: "Obliteration", icon: @image-url("@root/assets/icon.png") },
{ text: "Slint", icon: @image-url("@root/assets/slint-logo-small-dark.svg") }
{
text: "Slint",
icon: @image-url("@root/assets/slint-logo-small-dark.svg"),
colorize-icon: true
}
];
}
+7 -3
View File
@@ -81,9 +81,13 @@ export component MainWindow inherits Window {
tab := TabBar {
tabs: [
{ text: "Display", icon: @image-url("@root/assets/monitor.svg") },
{ text: "CPU", icon: @image-url("@root/assets/cpu-64-bit.svg") },
{ text: "IDPS", icon: @image-url("@root/assets/sony-playstation.svg") }
{ text: "Display", icon: @image-url("@root/assets/monitor.svg"), colorize-icon: true },
{ text: "CPU", icon: @image-url("@root/assets/cpu-64-bit.svg"), colorize-icon: true },
{
text: "IDPS",
icon: @image-url("@root/assets/sony-playstation.svg"),
colorize-icon: true
}
];
}
+3 -1
View File
@@ -10,7 +10,9 @@ export component SettingsWindow inherits Dialog {
TabContainer {
tab := TabBar {
tabs: [{ text: "Graphics", icon: @image-url("@root/assets/monitor.svg") }];
tabs: [
{ text: "Graphics", icon: @image-url("@root/assets/monitor.svg"), colorize-icon: true }
];
}
if tab.current-page == 0: GraphicsTab {
+4 -2
View File
@@ -3,6 +3,7 @@ import { HorizontalBox, Palette } from "std-widgets.slint";
component Tab {
in property <string> text;
in property <image> icon;
in property <bool> colorize-icon;
in property <bool> selected;
callback clicked <=> touch.clicked;
@@ -36,7 +37,7 @@ component Tab {
Image {
source: root.icon;
width: 15px;
colorize: Palette.control-foreground;
colorize: root.colorize-icon ? Palette.control-foreground : transparent;
}
Text {
@@ -66,7 +67,7 @@ export component TabContainer {
}
export component TabBar {
in property <[{text: string, icon: image}]> tabs;
in property <[{text: string, icon: image, colorize-icon: bool}]> tabs;
out property <int> current-page;
Rectangle {
@@ -79,6 +80,7 @@ export component TabBar {
for tab[index] in root.tabs: Tab {
text: tab.text;
icon: tab.icon;
colorize-icon: tab.colorize-icon;
selected: index == root.current-page;
clicked => {
root.current-page = index;