@@ -76,6 +76,8 @@ enum Renderer3dData {
76
76
struct EmuState {
77
77
playing : bool ,
78
78
title : String ,
79
+ #[ cfg( target_os = "macos" ) ]
80
+ path : Option < PathBuf > ,
79
81
game_loaded : bool ,
80
82
save_path_update : Option < emu:: SavePathUpdate > ,
81
83
#[ cfg( feature = "gdb-server" ) ]
@@ -217,8 +219,8 @@ pub struct UiState {
217
219
218
220
audio_channel : Option < audio:: output:: Channel > ,
219
221
220
- #[ cfg( target_os = "windows " ) ]
221
- icon_update : Option < Option < [ u32 ; 32 * 32 ] > > ,
222
+ #[ cfg( target_os = "macos " ) ]
223
+ shown_file_path : Option < PathBuf > ,
222
224
223
225
#[ cfg( feature = "logging" ) ]
224
226
log : Log ,
@@ -499,7 +501,7 @@ impl UiState {
499
501
let ( ds_slot_rom, _ds_slot_rom_path) = ds_slot_rom. unzip ( ) ;
500
502
#[ allow( unused_mut, clippy:: bind_instead_of_map) ]
501
503
let ds_slot = ds_slot_rom. and_then ( |mut rom| {
502
- #[ cfg( target_os = "windows" ) ]
504
+ #[ cfg( any ( target_os = "linux" , target_os = " windows") ) ]
503
505
{
504
506
use dust_core:: { ds_slot, utils:: Bytes } ;
505
507
let mut header_bytes = Bytes :: new ( [ 0 ; 0x170 ] ) ;
@@ -508,7 +510,14 @@ impl UiState {
508
510
// NOTE: The ROM file's size is ensured beforehand, this should never occur.
509
511
. expect ( "couldn't read DS slot ROM header" ) ;
510
512
let icon_title_offset = header. icon_title_offset ( ) as usize ;
511
- self . icon_update = Some ( ds_slot:: rom:: icon:: decode ( icon_title_offset, & mut rom) ) ;
513
+ let icon_pixels = ds_slot:: rom:: icon:: decode ( icon_title_offset, & mut rom) ;
514
+ window. set_icon ( icon_pixels. and_then ( |icon_pixels| {
515
+ let mut rgba = Vec :: with_capacity ( 32 * 32 * 4 ) ;
516
+ for pixel in icon_pixels {
517
+ rgba. extend_from_slice ( & pixel. to_le_bytes ( ) ) ;
518
+ }
519
+ winit:: window:: Icon :: from_rgba ( rgba, 32 , 32 ) . ok ( )
520
+ } ) ) ;
512
521
}
513
522
514
523
let game_code = rom. game_code ( ) ;
@@ -658,6 +667,8 @@ impl UiState {
658
667
self . emu = Some ( EmuState {
659
668
playing,
660
669
title,
670
+ #[ cfg( target_os = "macos" ) ]
671
+ path : _ds_slot_rom_path. map ( Path :: to_path_buf) ,
661
672
game_loaded,
662
673
save_path_update : None ,
663
674
#[ cfg( feature = "gdb-server" ) ]
@@ -725,9 +736,9 @@ impl UiState {
725
736
} ,
726
737
) ;
727
738
728
- #[ cfg( target_os = "windows" ) ]
739
+ #[ cfg( any ( target_os = "linux" , target_os = " windows") ) ]
729
740
{
730
- self . icon_update = Some ( None ) ;
741
+ window . set_icon ( None ) ;
731
742
}
732
743
733
744
#[ cfg( feature = "discord-presence" ) ]
@@ -749,10 +760,8 @@ impl UiState {
749
760
}
750
761
751
762
#[ cfg( target_os = "macos" ) ]
752
- {
753
- if let Some ( mode) = config_changed_value ! ( config, title_bar_mode) {
754
- _window. set_macos_title_bar_hidden ( mode. system_title_bar_is_hidden ( ) ) ;
755
- }
763
+ if let Some ( mode) = config_changed_value ! ( config, title_bar_mode) {
764
+ _window. set_macos_title_bar_transparent ( mode. system_title_bar_is_transparent ( ) ) ;
756
765
}
757
766
}
758
767
@@ -789,19 +798,26 @@ impl UiState {
789
798
buffer
790
799
}
791
800
792
- fn update_title ( & self , _config : & config:: Config , window : & window:: Window ) {
793
- #[ cfg( target_os = "macos" ) ]
794
- if match config ! ( _config, title_bar_mode) {
795
- TitleBarMode :: System => false ,
796
- TitleBarMode :: Mixed => !self . show_menu_bar ,
797
- TitleBarMode :: Imgui => true ,
798
- } {
799
- window. window ( ) . set_title ( "" ) ;
800
- return ;
801
+ #[ cfg( not( target_os = "macos" ) ) ]
802
+ fn update_title_bar ( & mut self , _config : & config:: Config , window : & window:: Window ) {
803
+ window. set_title ( & self . title ( TitleComponents :: all ( ) ) ) ;
804
+ }
805
+
806
+ #[ cfg( target_os = "macos" ) ]
807
+ fn update_title_bar ( & mut self , _config : & config:: Config , window : & window:: Window ) {
808
+ let show_system_title_bar =
809
+ config ! ( _config, title_bar_mode) . should_show_system_title_bar ( self . show_menu_bar ) ;
810
+ let shown_file_path = if show_system_title_bar {
811
+ window. set_title ( & self . title ( TitleComponents :: all ( ) ) ) ;
812
+ self . emu . as_ref ( ) . and_then ( |emu| emu. path . as_deref ( ) )
813
+ } else {
814
+ window. set_title ( "" ) ;
815
+ None
816
+ } ;
817
+ if shown_file_path != self . shown_file_path . as_deref ( ) {
818
+ self . shown_file_path = shown_file_path. map ( Path :: to_path_buf) ;
819
+ window. set_file_path ( shown_file_path) ;
801
820
}
802
- window
803
- . window ( )
804
- . set_title ( & self . title ( TitleComponents :: all ( ) ) ) ;
805
821
}
806
822
}
807
823
@@ -934,7 +950,7 @@ pub fn main() {
934
950
config. config . window_size ,
935
951
window:: SrgbMode :: None ,
936
952
#[ cfg( target_os = "macos" ) ]
937
- config ! ( config. config, title_bar_mode) . system_title_bar_is_hidden ( ) ,
953
+ config ! ( config. config, title_bar_mode) . system_title_bar_is_transparent ( ) ,
938
954
) ) ;
939
955
// TODO: Allow custom styles
940
956
window_builder. apply_default_imgui_style ( ) ;
@@ -985,8 +1001,8 @@ pub fn main() {
985
1001
986
1002
audio_channel,
987
1003
988
- #[ cfg( target_os = "windows " ) ]
989
- icon_update : None ,
1004
+ #[ cfg( target_os = "macos " ) ]
1005
+ shown_file_path : None ,
990
1006
991
1007
#[ cfg( feature = "logging" ) ]
992
1008
log,
@@ -1024,7 +1040,9 @@ pub fn main() {
1024
1040
state. load_from_rom_path ( path, config, window) ;
1025
1041
}
1026
1042
1027
- state. input . process_event ( event, state. screen_focused ) ;
1043
+ state
1044
+ . input
1045
+ . process_event ( event, window. scale_factor ( ) , state. screen_focused ) ;
1028
1046
1029
1047
if let Some ( config_editor) = & mut state. config_editor {
1030
1048
config_editor. process_event ( event, config) ;
@@ -1680,18 +1698,15 @@ pub fn main() {
1680
1698
}
1681
1699
}
1682
1700
1683
- let window_size = window. window ( ) . inner_size ( ) ;
1701
+ let window_size = window. inner_size ( ) ;
1684
1702
let screen_integer_scale = config ! ( config. config, screen_integer_scale) ;
1685
1703
let screen_rot = ( config ! ( config. config, screen_rot) as f32 ) . to_radians ( ) ;
1686
1704
if config ! ( config. config, full_window_screen) {
1687
1705
let ( center, points) = scale_to_fit_rotated (
1688
1706
[ SCREEN_WIDTH as f32 , ( 2 * SCREEN_HEIGHT ) as f32 ] ,
1689
1707
screen_integer_scale,
1690
1708
screen_rot,
1691
- [
1692
- ( window_size. width as f64 / window. scale_factor ( ) ) as f32 ,
1693
- ( window_size. height as f64 / window. scale_factor ( ) ) as f32 ,
1694
- ] ,
1709
+ window_size. into ( ) ,
1695
1710
) ;
1696
1711
ui. get_background_draw_list ( )
1697
1712
. add_image_quad (
@@ -1704,12 +1719,9 @@ pub fn main() {
1704
1719
. build ( ) ;
1705
1720
state. screen_focused =
1706
1721
!ui. is_window_focused_with_flags ( imgui:: WindowFocusedFlags :: ANY_WINDOW ) ;
1707
- state. input . set_touchscreen_bounds_from_points (
1708
- center,
1709
- & points,
1710
- screen_rot,
1711
- window. scale_factor ( ) ,
1712
- ) ;
1722
+ state
1723
+ . input
1724
+ . set_touchscreen_bounds_from_points ( center, & points, screen_rot) ;
1713
1725
} else {
1714
1726
let _window_padding = ui. push_style_var ( imgui:: StyleVar :: WindowPadding ( [ 0.0 ; 2 ] ) ) ;
1715
1727
let title_bar_height = style ! ( ui, frame_padding) [ 1 ] * 2.0 + ui. current_font_size ( ) ;
@@ -1725,8 +1737,8 @@ pub fn main() {
1725
1737
)
1726
1738
. position (
1727
1739
[
1728
- ( window_size. width as f64 * 0.5 / window . scale_factor ( ) ) as f32 ,
1729
- ( window_size. height as f64 * 0.5 / window . scale_factor ( ) ) as f32 ,
1740
+ ( window_size. width * 0.5 ) as f32 ,
1741
+ ( window_size. height * 0.5 ) as f32 ,
1730
1742
] ,
1731
1743
imgui:: Condition :: FirstUseEver ,
1732
1744
)
@@ -1769,26 +1781,12 @@ pub fn main() {
1769
1781
[ center[ 0 ] + upper_left[ 0 ] , center[ 1 ] + upper_left[ 1 ] ] ,
1770
1782
& abs_points,
1771
1783
screen_rot,
1772
- window. scale_factor ( ) ,
1773
1784
) ;
1774
1785
} ) ;
1775
1786
} ;
1776
1787
1777
- // Process icon and title changes
1778
- #[ cfg( target_os = "windows" ) ]
1779
- if let Some ( icon) = state. icon_update . take ( ) {
1780
- window
1781
- . window ( )
1782
- . set_window_icon ( icon. and_then ( |icon_pixels| {
1783
- let mut rgba = Vec :: with_capacity ( 32 * 32 * 4 ) ;
1784
- for pixel in icon_pixels {
1785
- rgba. extend_from_slice ( & pixel. to_le_bytes ( ) ) ;
1786
- }
1787
- winit:: window:: Icon :: from_rgba ( rgba, 32 , 32 ) . ok ( )
1788
- } ) ) ;
1789
- }
1790
-
1791
- state. update_title ( & config. config , window) ;
1788
+ // Process title bar changes
1789
+ state. update_title_bar ( & config. config , window) ;
1792
1790
1793
1791
window:: ControlFlow :: Continue
1794
1792
} ,
@@ -1829,11 +1827,7 @@ pub fn main() {
1829
1827
move |window, ( mut config, mut state) | {
1830
1828
state. stop_emu ( & mut config) ;
1831
1829
1832
- config. config . window_size = window
1833
- . window ( )
1834
- . inner_size ( )
1835
- . to_logical :: < u32 > ( window. scale_factor ( ) )
1836
- . into ( ) ;
1830
+ config. config . window_size = window. inner_size ( ) . into ( ) ;
1837
1831
1838
1832
if let Some ( path) = config. global_path {
1839
1833
let global_config = config:: File {
0 commit comments