Skip to content

Commit 10db961

Browse files
authored
Merge pull request #2146 from City-busz/window-icon-linux
Set window icon also on Linux
2 parents 909c053 + 00845b1 commit 10db961

2 files changed

Lines changed: 29 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ Changed:
3838
- Renamed `actions.buffer.click_username` to `actions.buffer.click_nickname` for more consistent terminology
3939
- Moved functionality from `buffer.nickname.click``actions.buffer.click_nickname` and `buffer.channel.nicklist.click``actions.nicklist.click_nickname`
4040
- Windows release artifacts are signed using SignPath
41+
- Set window icon also on Linux for X11
4142

4243
Thanks:
4344

44-
- Contributions: @englut, @luca020400, @classabbyamp, @KaiKorla, @TheDcoder
45+
- Contributions: @englut, @luca020400, @classabbyamp, @KaiKorla, @TheDcoder, @City-busz
4546
- Bug reports: @luca020400, agent314
4647

4748
# 2026.7.2 (2026-06-08)

src/window.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ pub enum Event {
110110
FileDropped(std::path::PathBuf),
111111
}
112112

113+
#[cfg(any(target_os = "linux", target_os = "windows"))]
114+
fn load_icon() -> Option<iced::window::Icon> {
115+
use iced::window;
116+
use image::EncodableLayout;
117+
118+
let img = image::load_from_memory_with_format(
119+
include_bytes!("../assets/logo.png"),
120+
image::ImageFormat::Png,
121+
)
122+
.ok()?;
123+
124+
let rgba = img.as_rgba8()?;
125+
126+
window::icon::from_rgba(
127+
rgba.as_bytes().to_vec(),
128+
rgba.width(),
129+
rgba.height(),
130+
)
131+
.ok()
132+
}
133+
113134
#[cfg(not(any(
114135
target_os = "macos",
115136
target_os = "linux",
@@ -125,6 +146,7 @@ pub fn settings(config: &Config) -> Settings {
125146
use iced::window;
126147

127148
Settings {
149+
icon: load_icon(),
128150
platform_specific: window::settings::PlatformSpecific {
129151
application_id: environment::APPLICATION_ID.to_string(),
130152
override_redirect: false,
@@ -153,31 +175,11 @@ pub fn settings(config: &Config) -> Settings {
153175

154176
#[cfg(target_os = "windows")]
155177
pub fn settings(config: &Config) -> Settings {
156-
use iced::window;
157-
use image::EncodableLayout;
158-
159-
let img = image::load_from_memory_with_format(
160-
include_bytes!("../assets/logo.png"),
161-
image::ImageFormat::Png,
162-
);
163-
match img {
164-
Ok(img) => match img.as_rgba8() {
165-
Some(icon) => Settings {
166-
icon: window::icon::from_rgba(
167-
icon.as_bytes().to_vec(),
168-
icon.width(),
169-
icon.height(),
170-
)
171-
.ok(),
172-
decorations: config.platform_specific.windows.decorations,
173-
transparent: true,
174-
..Default::default()
175-
},
176-
None => Settings::default(),
177-
},
178-
Err(_) => Settings {
179-
..Default::default()
180-
},
178+
Settings {
179+
icon: load_icon(),
180+
decorations: config.platform_specific.windows.decorations,
181+
transparent: true,
182+
..Default::default()
181183
}
182184
}
183185

0 commit comments

Comments
 (0)