Search
lxdream.org :: lxdream :: r874:e3007b8799f3
lxdream 0.9.1
released Jun 29
Download Now
changeset874:e3007b8799f3
parent873:cb3a8c502727
child875:2147174fb320
authornkeynes
dateTue Oct 14 08:43:01 2008 +0000 (11 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
src/cocoaui/cocoa_win.c
src/cocoaui/cocoaui.c
src/cocoaui/cocoaui.h
1.1 --- a/src/cocoaui/cocoa_win.c Tue Oct 14 07:02:42 2008 +0000
1.2 +++ b/src/cocoaui/cocoa_win.c Tue Oct 14 08:43:01 2008 +0000
1.3 @@ -247,9 +247,8 @@
1.4 }
1.5 @end
1.6
1.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 +0000
2.2 +++ b/src/cocoaui/cocoaui.c Tue Oct 14 08:43:01 2008 +0000
2.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.8
2.9 @interface NSApplication (PrivateAdditions)
2.10 - (void) setAppleMenu:(NSMenu *)aMenu;
2.11 @@ -188,7 +189,7 @@
2.12 - (void)windowDidResignKey: (NSNotification *)notice
2.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 *)filename
2.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.29
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.32
2.33 [pool release];
2.34 return TRUE;
2.35 @@ -354,7 +355,7 @@
2.36
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.42
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.50
2.51 }
2.52 }
2.53 @@ -434,16 +435,14 @@
2.54
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.63
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.70
2.71 /**
3.1 --- a/src/cocoaui/cocoaui.h Tue Oct 14 07:02:42 2008 +0000
3.2 +++ b/src/cocoaui/cocoaui.h Tue Oct 14 08:43:01 2008 +0000
3.3 @@ -34,13 +34,6 @@
3.4 #define LABEL_HEIGHT 17
3.5 #define TEXT_GAP 10
3.6
3.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 @end
3.20
3.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 __cplusplus
3.31 }
3.32 #endif
.