]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
macosx: fixed crash when selecting a QTKit capture device
[vlc] / modules / gui / macosx / intf.m
index 86edffd990e1480f07000b8a7abae5445a831899..97341c974d4dc506d0b64a972ed456d09ba696d2 100644 (file)
@@ -524,7 +524,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     o_msg_arr = [[NSMutableArray arrayWithCapacity: 600] retain];
 
     o_open = [[VLCOpen alloc] init];
-    //o_embedded_list = [[VLCEmbeddedList alloc] init];
     o_coredialogs = [[VLCCoreDialogProvider alloc] init];
     o_info = [[VLCInfo alloc] init];
     o_mainmenu = [[VLCMainMenu alloc] init];
@@ -594,8 +593,9 @@ static VLCMain *_o_sharedMainInstance = nil;
             var_SetBool(p_playlist, "fullscreen", YES);
     }
 
-    /* load our Core Dialogs nib */
+    /* load our Core and Shared Dialogs nibs */
     nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
+    [NSBundle loadNibNamed:@"SharedDialogs" owner: NSApp];
 
     /* subscribe to various interactive dialogues */
     var_Create(p_intf, "dialog-error", VLC_VAR_ADDRESS);
@@ -617,11 +617,10 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     [o_msgs_refresh_btn setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
 
-     BOOL b_video_deco = var_InheritBool(VLCIntf, "video-deco");
     /* yeah, we are done */
     b_nativeFullscreenMode = NO;
 #ifdef MAC_OS_X_VERSION_10_7
-    if (!OSX_SNOW_LEOPARD && b_video_deco)
+    if (!OSX_SNOW_LEOPARD)
         b_nativeFullscreenMode = var_InheritBool(p_intf, "macosx-nativefullscreenmode");
 #endif
 
@@ -793,7 +792,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     [crashLogURLConnection cancel];
     [crashLogURLConnection release];
 
-    [o_embedded_list release];
     [o_coredialogs release];
     [o_eyetv release];
 
@@ -1306,12 +1304,21 @@ static VLCMain *_o_sharedMainInstance = nil;
         if (state == PLAYING_S) {
             /* prevent the system from sleeping */
             IOReturn success;
-            CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
-            if ([self activeVideoPlayback])
-                success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
-            else
-                success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
-            CFRelease(reasonForActivity);
+            /* work-around a bug in 10.7.4 and 10.7.5, so check for 10.7.x < 10.7.4, 10.8 and 10.6 */
+            if ((NSAppKitVersionNumber >= 1115.2 && NSAppKitVersionNumber < 1138.45) || OSX_MOUNTAIN_LION || OSX_SNOW_LEOPARD) {
+                CFStringRef reasonForActivity= CFStringCreateWithCString(kCFAllocatorDefault, _("VLC media playback"), kCFStringEncodingUTF8);
+                if ([self activeVideoPlayback])
+                    success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
+                else
+                    success = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, reasonForActivity, &systemSleepAssertionID);
+                CFRelease(reasonForActivity);
+            } else {
+                /* fall-back on the 10.5 mode, which also works on 10.7.4 and 10.7.5 */
+                if ([self activeVideoPlayback])
+                    success = IOPMAssertionCreate(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+                else
+                    success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &systemSleepAssertionID);
+            }
 
             if (success == kIOReturnSuccess)
                 msg_Dbg(VLCIntf, "prevented sleep through IOKit (%i)", systemSleepAssertionID);
@@ -1353,17 +1360,17 @@ static VLCMain *_o_sharedMainInstance = nil;
     bool loop = var_GetBool(p_playlist, "loop");
     bool repeat = var_GetBool(p_playlist, "repeat");
     if (repeat) {
-        [o_mainwindow setRepeatOne];
+        [[o_mainwindow controlsBar] setRepeatOne];
         [o_mainmenu setRepeatOne];
     } else if (loop) {
-        [o_mainwindow setRepeatAll];
+        [[o_mainwindow controlsBar] setRepeatAll];
         [o_mainmenu setRepeatAll];
     } else {
-        [o_mainwindow setRepeatOff];
+        [[o_mainwindow controlsBar] setRepeatOff];
         [o_mainmenu setRepeatOff];
     }
 
-    [o_mainwindow setShuffle];
+    [[o_mainwindow controlsBar] setShuffle];
     [o_mainmenu setShuffle];
 }
 
@@ -1373,7 +1380,7 @@ static VLCMain *_o_sharedMainInstance = nil;
 
 - (void)setWindowLevel:(NSNumber*)state
 {
-    if (var_InheritBool(p_intf, "macosx-background"))
+    if (var_InheritBool(p_intf, "video-wallpaper") || [[[[VLCMainWindow sharedInstance] videoView] window] level] < NSNormalWindowLevel)
         return;
 
     if ([state unsignedIntValue] & VOUT_WINDOW_STATE_ABOVE)
@@ -1404,7 +1411,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     return o_mainmenu;
 }
 
-- (id)mainWindow
+- (VLCMainWindow *)mainWindow
 {
     return o_mainwindow;
 }
@@ -1509,14 +1516,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     return videoView;
 }
 
-- (id)embeddedList
-{
-    if (o_embedded_list)
-        return o_embedded_list;
-
-    return nil;
-}
-
 - (id)coreDialogProvider
 {
     if (o_coredialogs)