revision 874:e3007b8799f3
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 874:e3007b8799f3 |
parent | 873:cb3a8c502727 |
child | 875:2147174fb320 |
author | nkeynes |
date | Tue Oct 14 08:43:01 2008 +0000 (15 years ago) |
Save the main window in a global rather than using [NSApp mainWindow]. This has
the advantage of working properly when the window isn't actually main at the time
the advantage of working properly when the window isn't actually main at the time
src/cocoaui/cocoa_win.c | view | annotate | diff | log | ||
src/cocoaui/cocoaui.c | view | annotate | diff | log | ||
src/cocoaui/cocoaui.h | view | annotate | diff | log |
1.1 --- a/src/cocoaui/cocoa_win.c Tue Oct 14 07:02:42 2008 +00001.2 +++ b/src/cocoaui/cocoa_win.c Tue Oct 14 08:43:01 2008 +00001.3 @@ -247,9 +247,8 @@1.4 }1.5 @end1.7 -NSWindow *cocoa_gui_create_main_window()1.8 +LxdreamMainWindow *cocoa_gui_create_main_window()1.9 {1.10 NSRect contentRect = {{0,0},{640,480}};1.11 - NSWindow *main_win = [[LxdreamMainWindow alloc] initWithContentRect: contentRect];1.12 - return main_win;1.13 + return [[LxdreamMainWindow alloc] initWithContentRect: contentRect];1.14 }
2.1 --- a/src/cocoaui/cocoaui.c Tue Oct 14 07:02:42 2008 +00002.2 +++ b/src/cocoaui/cocoaui.c Tue Oct 14 08:43:01 2008 +00002.3 @@ -53,6 +53,7 @@2.4 static struct timeval cocoa_gui_lasttv;2.5 static BOOL cocoa_gui_autorun = NO;2.6 static BOOL cocoa_gui_is_running = NO;2.7 +static LxdreamMainWindow *mainWindow = NULL;2.9 @interface NSApplication (PrivateAdditions)2.10 - (void) setAppleMenu:(NSMenu *)aMenu;2.11 @@ -188,7 +189,7 @@2.12 - (void)windowDidResignKey: (NSNotification *)notice2.13 {2.14 display_set_focused( FALSE );2.15 - [((LxdreamMainWindow *)[NSApp mainWindow]) setIsGrabbed: NO];2.16 + [mainWindow setIsGrabbed: NO];2.17 }2.18 - (BOOL)application: (NSApplication *)app openFile: (NSString *)filename2.19 {2.20 @@ -327,11 +328,11 @@2.21 [iconImage setName: @"NSApplicationIcon"];2.22 [NSApp setApplicationIconImage: iconImage];2.23 cocoa_gui_create_menu();2.24 - NSWindow *window = cocoa_gui_create_main_window();2.25 - [window makeKeyAndOrderFront: nil];2.26 + mainWindow = cocoa_gui_create_main_window();2.27 + [mainWindow makeKeyAndOrderFront: nil];2.28 [NSApp activateIgnoringOtherApps: YES];2.30 - register_gdrom_disc_change_hook( cocoa_gui_disc_changed, window );2.31 + register_gdrom_disc_change_hook( cocoa_gui_disc_changed, mainWindow );2.33 [pool release];2.34 return TRUE;2.35 @@ -354,7 +355,7 @@2.37 void gui_set_use_grab( gboolean grab )2.38 {2.39 - [((LxdreamMainWindow *)[NSApp mainWindow]) setUseGrab: (grab ? YES : NO)];2.40 + [mainWindow setUseGrab: (grab ? YES : NO)];2.41 }2.43 gboolean gui_error_dialog( const char *msg, ... )2.44 @@ -420,7 +421,7 @@2.45 cocoa_gui_lasttv.tv_sec = tv.tv_sec;2.46 cocoa_gui_lasttv.tv_usec = tv.tv_usec;2.47 snprintf( buf, 32, _("Running (%2.4f%%)"), speed );2.48 - [((LxdreamMainWindow *)[NSApp mainWindow]) setStatusText: buf];2.49 + [mainWindow setStatusText: buf];2.51 }2.52 }2.53 @@ -434,16 +435,14 @@2.55 void cocoa_gui_start( void )2.56 {2.57 - LxdreamMainWindow *win = (LxdreamMainWindow *)[NSApp mainWindow];2.58 - [win setRunning: YES];2.59 + [mainWindow setRunning: YES];2.60 cocoa_gui_nanos = 0;2.61 gettimeofday(&cocoa_gui_lasttv,NULL);2.62 }2.64 void cocoa_gui_stop( void )2.65 {2.66 - LxdreamMainWindow *win = (LxdreamMainWindow *)[NSApp mainWindow];2.67 - [win setRunning: NO];2.68 + [mainWindow setRunning: NO];2.69 }2.71 /**
3.1 --- a/src/cocoaui/cocoaui.h Tue Oct 14 07:02:42 2008 +00003.2 +++ b/src/cocoaui/cocoaui.h Tue Oct 14 08:43:01 2008 +00003.3 @@ -34,13 +34,6 @@3.4 #define LABEL_HEIGHT 173.5 #define TEXT_GAP 103.7 -NSWindow *cocoa_gui_create_main_window();3.8 -NSMenu *cocoa_gdrom_menu_new();3.9 -NSView *video_osx_create_drawable();3.10 -void cocoa_gui_show_preferences();3.11 -NSView *cocoa_gui_create_prefs_controller_pane();3.12 -NSView *cocoa_gui_create_prefs_path_pane();3.13 -3.14 /**3.15 * Convenience method to create a new text label in the specified parent.3.16 */3.17 @@ -103,6 +96,15 @@3.18 - (id)initWithContentRect:(NSRect)contentRect;3.19 @end3.21 +3.22 +LxdreamMainWindow *cocoa_gui_create_main_window();3.23 +NSMenu *cocoa_gdrom_menu_new();3.24 +NSView *video_osx_create_drawable();3.25 +void cocoa_gui_show_preferences();3.26 +NSView *cocoa_gui_create_prefs_controller_pane();3.27 +NSView *cocoa_gui_create_prefs_path_pane();3.28 +3.29 +3.30 #ifdef __cplusplus3.31 }3.32 #endif
.