File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -259,6 +259,25 @@ pub mod window {
259259 . unwrap ( ) ;
260260 }
261261
262+ /// Set the application's window title.
263+ /// TODO: This is not implemented for all platforms yet.
264+ pub fn set_window_title ( title : & str ) {
265+ let d = native_display ( ) . lock ( ) . unwrap ( ) ;
266+ d. native_requests
267+ . send ( native:: Request :: SetWindowTitle ( title. to_string ( ) ) )
268+ . unwrap ( ) ;
269+ }
270+
271+ // Since icons are large structs, wrap them in a Box to avoid excessive stack consumption.
272+ /// Set the application's icon.
273+ /// TODO: This is not implemented for all platforms yet.
274+ pub fn set_window_icon ( icon : Box < conf:: Icon > ) {
275+ let d = native_display ( ) . lock ( ) . unwrap ( ) ;
276+ d. native_requests
277+ . send ( native:: Request :: SetWindowIcon ( icon) )
278+ . unwrap ( ) ;
279+ }
280+
262281 /// Get the position of the window.
263282 /// TODO: implement for other platforms
264283 #[ cfg( any( target_os = "windows" , target_os = "linux" ) ) ]
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ pub(crate) enum Request {
7171 SetWindowPosition { new_x : u32 , new_y : u32 } ,
7272 SetFullscreen ( bool ) ,
7373 ShowKeyboard ( bool ) ,
74+ SetWindowTitle ( String ) ,
75+ SetWindowIcon ( Box < crate :: conf:: Icon > ) ,
7476}
7577
7678pub trait Clipboard : Send + Sync {
Original file line number Diff line number Diff line change @@ -420,6 +420,12 @@ impl X11Display {
420420 ShowKeyboard ( ..) => {
421421 eprintln ! ( "Not implemented for X11" )
422422 }
423+ SetWindowTitle ( title) => {
424+ self . libx11 . update_window_title ( self . display , self . window , & title) ;
425+ }
426+ SetWindowIcon ( icon) => {
427+ self . libx11 . update_window_icon ( self . display , self . window , & icon) ;
428+ }
423429 }
424430 }
425431 }
Original file line number Diff line number Diff line change @@ -869,6 +869,12 @@ impl WindowsDisplay {
869869 ShowKeyboard ( _show) => {
870870 eprintln ! ( "Not implemented for windows" )
871871 }
872+ SetWindowTitle ( _title) => {
873+ eprintln ! ( "SetWindowTitle is not yet implemented on windows" ) ;
874+ }
875+ SetWindowIcon ( icon) => unsafe {
876+ set_icon ( self . wnd , & icon) ;
877+ } ,
872878 }
873879 }
874880}
You can’t perform that action at this time.
0 commit comments