Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,25 @@ pub mod window {
.unwrap();
}

/// Set the application's window title.
/// TODO: This is not implemented for all platforms yet.
pub fn set_window_title(title: &str) {
let d = native_display().lock().unwrap();
d.native_requests
.send(native::Request::SetWindowTitle(title.to_string()))
.unwrap();
}

// Since icons are large structs, wrap them in a Box to avoid excessive stack consumption.
/// Set the application's icon.
/// TODO: This is not implemented for all platforms yet.
pub fn set_window_icon(icon: Box<conf::Icon>) {
let d = native_display().lock().unwrap();
d.native_requests
.send(native::Request::SetWindowIcon(icon))
.unwrap();
}

/// Get the position of the window.
/// TODO: implement for other platforms
#[cfg(any(target_os = "windows", target_os = "linux"))]
Expand Down
2 changes: 2 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub(crate) enum Request {
SetWindowPosition { new_x: u32, new_y: u32 },
SetFullscreen(bool),
ShowKeyboard(bool),
SetWindowTitle(String),
SetWindowIcon(Box<crate::conf::Icon>),
}

pub trait Clipboard: Send + Sync {
Expand Down
6 changes: 6 additions & 0 deletions src/native/linux_x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ impl X11Display {
ShowKeyboard(..) => {
eprintln!("Not implemented for X11")
}
SetWindowTitle(title) => {
self.libx11.update_window_title(self.display, self.window, &title);
}
SetWindowIcon(icon) => {
self.libx11.update_window_icon(self.display, self.window, &icon);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/native/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,12 @@ impl WindowsDisplay {
ShowKeyboard(_show) => {
eprintln!("Not implemented for windows")
}
SetWindowTitle(_title) => {
eprintln!("SetWindowTitle is not yet implemented on windows");
}
SetWindowIcon(icon) => unsafe {
set_icon(self.wnd, &icon);
},
}
}
}
Expand Down
Loading