Search
lxdream.org :: lxdream/src/cocoaui/cocoaui.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoaui.c
changeset 874:e3007b8799f3
prev844:0e645cc6dc59
next889:5baaea6d9722
author nkeynes
date Tue Oct 14 08:43:01 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change 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
file annotate diff log raw
1.1 --- a/src/cocoaui/cocoaui.c Sat Sep 06 05:21:57 2008 +0000
1.2 +++ b/src/cocoaui/cocoaui.c Tue Oct 14 08:43:01 2008 +0000
1.3 @@ -53,6 +53,7 @@
1.4 static struct timeval cocoa_gui_lasttv;
1.5 static BOOL cocoa_gui_autorun = NO;
1.6 static BOOL cocoa_gui_is_running = NO;
1.7 +static LxdreamMainWindow *mainWindow = NULL;
1.8
1.9 @interface NSApplication (PrivateAdditions)
1.10 - (void) setAppleMenu:(NSMenu *)aMenu;
1.11 @@ -188,7 +189,7 @@
1.12 - (void)windowDidResignKey: (NSNotification *)notice
1.13 {
1.14 display_set_focused( FALSE );
1.15 - [((LxdreamMainWindow *)[NSApp mainWindow]) setIsGrabbed: NO];
1.16 + [mainWindow setIsGrabbed: NO];
1.17 }
1.18 - (BOOL)application: (NSApplication *)app openFile: (NSString *)filename
1.19 {
1.20 @@ -327,11 +328,11 @@
1.21 [iconImage setName: @"NSApplicationIcon"];
1.22 [NSApp setApplicationIconImage: iconImage];
1.23 cocoa_gui_create_menu();
1.24 - NSWindow *window = cocoa_gui_create_main_window();
1.25 - [window makeKeyAndOrderFront: nil];
1.26 + mainWindow = cocoa_gui_create_main_window();
1.27 + [mainWindow makeKeyAndOrderFront: nil];
1.28 [NSApp activateIgnoringOtherApps: YES];
1.29
1.30 - register_gdrom_disc_change_hook( cocoa_gui_disc_changed, window );
1.31 + register_gdrom_disc_change_hook( cocoa_gui_disc_changed, mainWindow );
1.32
1.33 [pool release];
1.34 return TRUE;
1.35 @@ -354,7 +355,7 @@
1.36
1.37 void gui_set_use_grab( gboolean grab )
1.38 {
1.39 - [((LxdreamMainWindow *)[NSApp mainWindow]) setUseGrab: (grab ? YES : NO)];
1.40 + [mainWindow setUseGrab: (grab ? YES : NO)];
1.41 }
1.42
1.43 gboolean gui_error_dialog( const char *msg, ... )
1.44 @@ -420,7 +421,7 @@
1.45 cocoa_gui_lasttv.tv_sec = tv.tv_sec;
1.46 cocoa_gui_lasttv.tv_usec = tv.tv_usec;
1.47 snprintf( buf, 32, _("Running (%2.4f%%)"), speed );
1.48 - [((LxdreamMainWindow *)[NSApp mainWindow]) setStatusText: buf];
1.49 + [mainWindow setStatusText: buf];
1.50
1.51 }
1.52 }
1.53 @@ -434,16 +435,14 @@
1.54
1.55 void cocoa_gui_start( void )
1.56 {
1.57 - LxdreamMainWindow *win = (LxdreamMainWindow *)[NSApp mainWindow];
1.58 - [win setRunning: YES];
1.59 + [mainWindow setRunning: YES];
1.60 cocoa_gui_nanos = 0;
1.61 gettimeofday(&cocoa_gui_lasttv,NULL);
1.62 }
1.63
1.64 void cocoa_gui_stop( void )
1.65 {
1.66 - LxdreamMainWindow *win = (LxdreamMainWindow *)[NSApp mainWindow];
1.67 - [win setRunning: NO];
1.68 + [mainWindow setRunning: NO];
1.69 }
1.70
1.71 /**
.