浏览代码

fix platform specific window configs `settings()`

Berke 10 月之前
父节点
当前提交
dcac29a1a1
共有 1 个文件被更改,包括 42 次插入0 次删除
  1. 42 0
      src/window.rs

+ 42 - 0
src/window.rs

@@ -105,6 +105,20 @@ where
         })
 }
 
+#[cfg(target_os = "linux")]
+pub fn settings() -> Settings {
+    use data::environment;
+    use iced::window;
+
+    Settings {
+        platform_specific: window::settings::PlatformSpecific {
+            application_id: environment::APPLICATION_ID.to_string(),
+            override_redirect: false,
+        },
+        ..Default::default()
+    }
+}
+
 #[cfg(target_os = "macos")]
 pub fn settings() -> Settings {
     use iced::window;
@@ -117,4 +131,32 @@ pub fn settings() -> Settings {
         },
         ..Default::default()
     }
+}
+
+#[cfg(target_os = "windows")]
+pub fn settings() -> Settings {
+    use iced::window;
+    use image::EncodableLayout;
+
+    let img = image::load_from_memory_with_format(
+        include_bytes!("../assets/logo.png"),
+        image::ImageFormat::Png,
+    );
+    match img {
+        Ok(img) => match img.as_rgba8() {
+            Some(icon) => Settings {
+                icon: window::icon::from_rgba(
+                    icon.as_bytes().to_vec(),
+                    icon.width(),
+                    icon.height(),
+                )
+                .ok(),
+                ..Default::default()
+            },
+            None => Default::default(),
+        },
+        Err(_) => Settings {
+            ..Default::default()
+        },
+    }
 }