Skip to content

Commit

Permalink
added functions/requests for changing icon
Browse files Browse the repository at this point in the history
  • Loading branch information
arshavirmirzakhani committed Jan 9, 2025
1 parent 3a5b563 commit cd780ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ fn native_display() -> &'static Mutex<native::NativeDisplayData> {
/// Window and associated to window rendering context related functions.
/// in macroquad <= 0.3, it was ctx.screen_size(). Now it is window::screen_size()
pub mod window {
use conf::Icon;

use super::*;

/// The same as
Expand Down Expand Up @@ -251,6 +253,13 @@ pub mod window {
.unwrap();
}

pub fn set_window_icon(new_icon: Icon) {
let d = native_display().lock().unwrap();
d.native_requests
.send(native::Request::SetWindowIcon { new_icon })
.unwrap();
}

/// Get the position of the window.
/// TODO: implement for other platforms
#[cfg(any(target_os = "windows", target_os = "linux"))]
Expand Down
3 changes: 3 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub(crate) enum Request {
SetMouseCursor(crate::CursorIcon),
SetWindowSize { new_width: u32, new_height: u32 },
SetWindowPosition { new_x: u32, new_y: u32 },
SetWindowIcon {new_icon: Icon},
SetFullscreen(bool),
ShowKeyboard(bool),
}
Expand Down Expand Up @@ -118,4 +119,6 @@ pub mod gl;
#[cfg(target_arch = "wasm32")]
pub use wasm::webgl as gl;

use crate::conf::Icon;

pub mod query_stab;
1 change: 1 addition & 0 deletions src/native/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl MacosDisplay {
SetWindowPosition { .. } => {
eprintln!("Not implemented for macos");
}
SetWindowIcon {new_icon} => self.set_icon(new_icon),

Check failure on line 207 in src/native/macos.rs

View workflow job for this annotation

GitHub Actions / Build (macos-latest, x86_64-apple-darwin)

no method named `set_icon` found for mutable reference `&mut MacosDisplay` in the current scope
_ => {}
}
}
Expand Down

0 comments on commit cd780ac

Please sign in to comment.