VLCVoutWindowController.m 22.7 KB
Newer Older
1 2 3
/*****************************************************************************
 * VLCVoutWindowController.m: MacOS X interface module
 *****************************************************************************
4
 * Copyright (C) 2012-2014 VLC authors and VideoLAN
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * $Id$
 *
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
 *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

25 26
#include <vlc_vout_display.h>

27
#import "CompatibilityFixes.h"
28
#import "VLCVoutWindowController.h"
29
#import "intf.h"
30
#import "VLCMainWindow.h"
31
#import "VLCVoutView.h"
32

33
#import "VLCVideoEffectsWindowController.h"
34
#import "VLCAudioEffectsWindowController.h"
35
#import "VLCPlaylistInfo.h"
36
#import "VLCBookmarksWindowController.h"
37
#import "VLCTrackSynchronizationWindowController.h"
38
#import "VLCResumeDialogController.h"
39
#import "VLCPlaylist.h"
40

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
static atomic_bool b_intf_starting = ATOMIC_VAR_INIT(false);

static int WindowControl(vout_window_t *, int i_query, va_list);

int WindowOpen(vout_window_t *p_wnd, const vout_window_cfg_t *cfg)
{
    @autoreleasepool {
        if (cfg->type != VOUT_WINDOW_TYPE_INVALID
            && cfg->type != VOUT_WINDOW_TYPE_NSOBJECT)
            return VLC_EGENERIC;

        msg_Dbg(p_wnd, "Opening video window");

        if (!atomic_load(&b_intf_starting)) {
            msg_Err(p_wnd, "Cannot create vout as Mac OS X interface was not found");
            return VLC_EGENERIC;
        }

        NSRect proposedVideoViewPosition = NSMakeRect(cfg->x, cfg->y, cfg->width, cfg->height);

        VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
        if (!voutController) {
            return VLC_EGENERIC;
        }
        [voutController.lock lock];

        SEL sel = @selector(setupVoutForWindow:withProposedVideoViewPosition:);
        NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
        [inv setTarget:voutController];
        [inv setSelector:sel];
        [inv setArgument:&p_wnd atIndex:2]; // starting at 2!
        [inv setArgument:&proposedVideoViewPosition atIndex:3];

        [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
                           waitUntilDone:YES];

        VLCVoutView *videoView = nil;
        [inv getReturnValue:&videoView];

        // this method is not supposed to fail
        assert(videoView != nil);

83
        msg_Dbg(getIntf(), "returning videoview with proposed position x=%i, y=%i, width=%i, height=%i", cfg->x, cfg->y, cfg->width, cfg->height);
84 85 86 87 88 89 90
        p_wnd->handle.nsobject = (void *)CFBridgingRetain(videoView);

        [voutController.lock unlock];

        p_wnd->type = VOUT_WINDOW_TYPE_NSOBJECT;
        p_wnd->control = WindowControl;
    }
91 92
    vout_window_SetFullScreen(p_wnd, cfg->is_fullscreen);
    return VLC_SUCCESS;
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
}

static int WindowControl(vout_window_t *p_wnd, int i_query, va_list args)
{
    @autoreleasepool {
        VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
        if (!voutController) {
            return VLC_EGENERIC;
        }
        [voutController.lock lock];

        switch(i_query) {
            case VOUT_WINDOW_SET_STATE:
            {
                unsigned i_state = va_arg(args, unsigned);

                if (i_state & VOUT_WINDOW_STATE_BELOW)
                {
                    msg_Dbg(p_wnd, "Ignore change to VOUT_WINDOW_STATE_BELOW");
                    goto out;
                }

                NSInteger i_cooca_level = NSNormalWindowLevel;
                if (i_state & VOUT_WINDOW_STATE_ABOVE)
                    i_cooca_level = NSStatusWindowLevel;

                SEL sel = @selector(setWindowLevel:forWindow:);
                NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
                [inv setTarget:voutController];
                [inv setSelector:sel];
                [inv setArgument:&i_cooca_level atIndex:2]; // starting at 2!
                [inv setArgument:&p_wnd atIndex:3];
                [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
                                   waitUntilDone:NO];

                break;
            }
            case VOUT_WINDOW_SET_SIZE:
            {
                unsigned int i_width  = va_arg(args, unsigned int);
                unsigned int i_height = va_arg(args, unsigned int);

                NSSize newSize = NSMakeSize(i_width, i_height);
                SEL sel = @selector(setNativeVideoSize:forWindow:);
                NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
                [inv setTarget:voutController];
                [inv setSelector:sel];
                [inv setArgument:&newSize atIndex:2]; // starting at 2!
                [inv setArgument:&p_wnd atIndex:3];
                [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
                                   waitUntilDone:NO];

                break;
            }
            case VOUT_WINDOW_SET_FULLSCREEN:
            {
149
                if (var_InheritBool(getIntf(), "video-wallpaper")) {
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
                    msg_Dbg(p_wnd, "Ignore fullscreen event as video-wallpaper is on");
                    goto out;
                }

                int i_full = va_arg(args, int);
                BOOL b_animation = YES;

                SEL sel = @selector(setFullscreen:forWindow:withAnimation:);
                NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[voutController methodSignatureForSelector:sel]];
                [inv setTarget:voutController];
                [inv setSelector:sel];
                [inv setArgument:&i_full atIndex:2]; // starting at 2!
                [inv setArgument:&p_wnd atIndex:3];
                [inv setArgument:&b_animation atIndex:4];
                [inv performSelectorOnMainThread:@selector(invoke) withObject:nil
                                   waitUntilDone:NO];

                break;
            }
            default:
            {
                msg_Warn(p_wnd, "unsupported control query");
                [voutController.lock unlock];
                return VLC_EGENERIC;
            }
        }

        out:
        [voutController.lock unlock];
        return VLC_SUCCESS;
    }
}

void WindowClose(vout_window_t *p_wnd)
{
    @autoreleasepool {
        VLCVoutWindowController *voutController = [[VLCMain sharedInstance] voutController];
        if (!voutController) {
            return;
        }

        [voutController.lock lock];
        [voutController performSelectorOnMainThread:@selector(removeVoutforDisplay:) withObject:[NSValue valueWithPointer:p_wnd] waitUntilDone:NO];
        [voutController.lock unlock];
    }
}

197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
@interface VLCVoutWindowController ()
{
    NSMutableDictionary *o_vout_dict;
    KeyboardBacklight *o_keyboard_backlight;

    NSPoint top_left_point;

    // save the status level if at least one video window is on status level
    NSUInteger i_statusLevelWindowCounter;
    NSInteger i_currentWindowLevel;

    BOOL b_mainwindow_has_video;
}
@end

212 213 214 215 216
@implementation VLCVoutWindowController

- (id)init
{
    self = [super init];
217 218 219 220 221 222 223
    if (self) {
        atomic_store(&b_intf_starting, true);
        o_vout_dict = [[NSMutableDictionary alloc] init];
        o_keyboard_backlight = [[KeyboardBacklight alloc] init];
        i_currentWindowLevel = NSNormalWindowLevel;
        _currentStatusWindowLevel = NSFloatingWindowLevel;
    }
224 225 226 227 228
    return self;
}

- (void)dealloc
{
229 230 231 232
    NSArray *keys = [o_vout_dict allKeys];
    for (NSValue *key in keys)
        [self removeVoutforDisplay:key];

233
    if (var_InheritBool(getIntf(), "macosx-dim-keyboard")) {
234 235
        [o_keyboard_backlight switchLightsInstantly:YES];
    }
236 237
}

238 239
#pragma mark -
#pragma mark Methods for vout provider
240

241
- (VLCVoutView *)setupVoutForWindow:(vout_window_t *)p_wnd withProposedVideoViewPosition:(NSRect)videoViewPosition
242
{
243 244
    BOOL b_nonembedded = NO;
    BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
245 246
    BOOL b_video_deco = var_InheritBool(getIntf(), "video-deco");
    BOOL b_video_wallpaper = var_InheritBool(getIntf(), "video-wallpaper");
247
    BOOL b_multiple_vout_windows = [o_vout_dict count] > 0;
248 249 250
    VLCVoutView *o_vout_view;
    VLCVideoWindowCommon *o_new_video_window;

251
    // should be called before any window resizing occurs
252
    if (!b_multiple_vout_windows)
253
        [[[VLCMain sharedInstance] mainWindow] videoplayWillBeStarted];
254

255 256
    if (b_multiple_vout_windows && b_video_wallpaper)
        b_video_wallpaper = false;
257

258
    // TODO: make lion fullscreen compatible with video-wallpaper
259 260 261
    if ((b_video_wallpaper || !b_video_deco) && !b_nativeFullscreenMode) {
        // b_video_wallpaper is priorized over !b_video_deco

262 263
        msg_Dbg(getIntf(), "Creating background / blank window");
        NSScreen *screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_InheritInteger(getIntf(), "macosx-vdev")];
264
        if (!screen)
265
            screen = [[[VLCMain sharedInstance] mainWindow] screen];
266 267 268 269 270

        NSRect window_rect;
        if (b_video_wallpaper)
            window_rect = [screen frame];
        else
271
            window_rect = [[[VLCMain sharedInstance] mainWindow] frame];
272 273

        NSUInteger mask = NSBorderlessWindowMask;
274
        if (!b_video_deco)
275 276 277 278 279
            mask |= NSResizableWindowMask;

        BOOL b_no_video_deco_only = !b_video_wallpaper;
        o_new_video_window = [[VLCVideoWindowCommon alloc] initWithContentRect:window_rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
        [o_new_video_window setDelegate:o_new_video_window];
280
        [o_new_video_window setReleasedWhenClosed: NO];
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

        if (b_video_wallpaper)
            [o_new_video_window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey) + 1];

        [o_new_video_window setBackgroundColor: [NSColor blackColor]];
        [o_new_video_window setCanBecomeKeyWindow: !b_video_wallpaper];
        [o_new_video_window setCanBecomeMainWindow: !b_video_wallpaper];
        [o_new_video_window setAcceptsMouseMovedEvents: !b_video_wallpaper];
        [o_new_video_window setMovableByWindowBackground: !b_video_wallpaper];
        [o_new_video_window useOptimizedDrawing: YES];

        o_vout_view = [[VLCVoutView alloc] initWithFrame:[[o_new_video_window contentView] bounds]];
        [o_vout_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
        [[o_new_video_window contentView] addSubview:o_vout_view positioned:NSWindowAbove relativeTo:nil];
        [o_new_video_window setVideoView:o_vout_view];


        if (b_video_wallpaper)
            [o_new_video_window orderBack:nil];
        else {
301 302 303 304 305 306
            // no frame autosave for additional vout windows
            if (!b_multiple_vout_windows) {
                // initial window position
                [o_new_video_window center];
                [o_new_video_window setFrameAutosaveName:@"extra-videowindow"];
            }
307

308 309 310 311 312
            [o_new_video_window setContentMinSize: NSMakeSize(f_min_video_height, f_min_video_height)];
        }

        b_nonembedded = YES;
    } else {
313
        if ((var_InheritBool(getIntf(), "embedded-video") && !b_mainwindow_has_video)) {
314
            // setup embedded video
315
            o_new_video_window = [[VLCMain sharedInstance] mainWindow] ;
316
            o_vout_view = [o_new_video_window videoView];
317
            b_mainwindow_has_video = YES;
318 319
            b_nonembedded = NO;
        } else {
320
            // setup detached window with controls
321 322
            NSWindowController *o_controller = [[NSWindowController alloc] initWithWindowNibName:@"DetachedVideoWindow"];
            [o_controller loadWindow];
323
            o_new_video_window = (VLCDetachedVideoWindow *)[o_controller window];
324

325 326 327 328
            // no frame autosave for additional vout windows
            if (b_multiple_vout_windows)
                [o_new_video_window setFrameAutosaveName:@""];

329 330 331
            [o_new_video_window setDelegate: o_new_video_window];
            [o_new_video_window setLevel:NSNormalWindowLevel];
            [o_new_video_window useOptimizedDrawing: YES];
332
            o_vout_view = [o_new_video_window videoView];
333 334 335 336
            b_nonembedded = YES;
        }
    }

337 338
    NSSize videoViewSize = NSMakeSize(videoViewPosition.size.width, videoViewPosition.size.height);

339 340
    // Avoid flashes if video will directly start in fullscreen
    NSDisableScreenUpdates();
341

342
    if (!b_video_wallpaper) {
343
        // set (only!) window origin if specified
344
        if (b_nonembedded) {
345
            NSRect window_rect = [o_new_video_window frame];
346 347 348 349 350
            if (videoViewPosition.origin.x > 0.)
                window_rect.origin.x = videoViewPosition.origin.x;
            if (videoViewPosition.origin.y > 0.)
                window_rect.origin.y = videoViewPosition.origin.y;

351 352
            [o_new_video_window setFrame:window_rect display:YES];
        }
353 354 355 356

        // cascade windows if we have more than one vout
        if (b_multiple_vout_windows) {
            if ([o_vout_dict count] == 1) {
357
                NSWindow * o_first_window = [o_vout_dict objectForKey: [[o_vout_dict allKeys] firstObject]];
358

359 360
                NSRect topleftBaseRect = NSMakeRect(0, [o_first_window frame].size.height, 0, 0);
                top_left_point = [o_first_window convertRectToScreen: topleftBaseRect].origin;
361 362 363 364 365
            }

            top_left_point = [o_new_video_window cascadeTopLeftFromPoint: top_left_point];
            [o_new_video_window setFrameTopLeftPoint: top_left_point];
        }
366

367
        // resize window
368 369
        [o_new_video_window setNativeVideoSize:videoViewSize];

370 371
        [o_new_video_window makeKeyAndOrderFront: self];
    }
372

373
    [o_new_video_window setAlphaValue: config_GetFloat(getIntf(), "macosx-opaqueness")];
374

David Fuhrmann's avatar
David Fuhrmann committed
375
    [o_vout_view setVoutThread:(vout_thread_t *)p_wnd->obj.parent];
376
    [o_new_video_window setHasActiveVideo: YES];
377
    [o_vout_dict setObject:o_new_video_window forKey:[NSValue valueWithPointer:p_wnd]];
378

379
    [[VLCMain sharedInstance] setActiveVideoPlayback: YES];
380
    [[[VLCMain sharedInstance] mainWindow] setNonembedded:!b_mainwindow_has_video];
381 382 383

    // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
    if ([o_new_video_window class] == [VLCMainWindow class])
384
        [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
385

386
    if (b_nonembedded) {
387
        // events might be posted before window is created, so call them again
388 389
        [[[VLCMain sharedInstance] mainWindow] updateName];
        [[[VLCMain sharedInstance] mainWindow] updateWindow]; // update controls bar
390 391
    }

392 393
    // TODO: find a cleaner way for "start in fullscreen"
    // Start in fs, because either prefs settings, or fullscreen button was pressed before
394
    char *psz_splitter = var_GetString(pl_Get(getIntf()), "video-splitter");
395 396 397
    BOOL b_have_splitter = psz_splitter != NULL && *psz_splitter != '\0';
    free(psz_splitter);

398
    if (!b_video_wallpaper && !b_have_splitter && (var_InheritBool(getIntf(), "fullscreen") || var_GetBool(pl_Get(getIntf()), "fullscreen"))) {
399 400 401

        // this is not set when we start in fullscreen because of
        // fullscreen settings in video prefs the second time
David Fuhrmann's avatar
David Fuhrmann committed
402
        var_SetBool(p_wnd->obj.parent, "fullscreen", 1);
403 404 405 406 407 408

        [self setFullscreen:1 forWindow:p_wnd withAnimation:NO];
    }

    NSEnableScreenUpdates();

409
    return o_vout_view;
410 411 412 413 414
}

- (void)removeVoutforDisplay:(NSValue *)o_key
{
    VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:o_key];
415
    if (!o_window) {
416
        msg_Err(getIntf(), "Cannot close nonexisting window");
417 418
        return;
    }
419

420 421 422 423 424 425
    [[o_window videoView] releaseVoutThread];

    // set active video to no BEFORE closing the window and exiting fullscreen
    // (avoid stopping playback due to NSWindowWillCloseNotification, preserving fullscreen state)
    [o_window setHasActiveVideo: NO];

426 427
    // prevent visible extra window if in fullscreen
    NSDisableScreenUpdates();
428
    BOOL b_native = [[[VLCMain sharedInstance] mainWindow] nativeFullscreenMode];
429 430 431 432 433 434 435 436 437 438

    // close fullscreen, without changing fullscreen vars
    if (!b_native && ([o_window fullscreen] || [o_window inFullscreenTransition]))
        [o_window leaveFullscreenWithAnimation:NO];

    // native fullscreen window will not be closed if
    // fullscreen was triggered without video
    if ((b_native && [o_window class] == [VLCMainWindow class] && [o_window fullscreen] && [o_window windowShouldExitFullscreenWhenFinished])) {
        [o_window toggleFullScreen:self];
    }
439

440
    if ([o_window class] != [VLCMainWindow class]) {
441
        [o_window close];
442
    }
443
    NSEnableScreenUpdates();
444

445
    [o_vout_dict removeObjectForKey:o_key];
446
    if ([o_vout_dict count] == 0) {
447
        [[VLCMain sharedInstance] setActiveVideoPlayback:NO];
448 449
        i_statusLevelWindowCounter = 0;
    }
450 451 452 453 454 455

    if ([o_window class] == [VLCMainWindow class]) {
        b_mainwindow_has_video = NO;

        // video in main window might get stopped while another vout is open
        if ([o_vout_dict count] > 0)
456
            [[[VLCMain sharedInstance] mainWindow] setNonembedded:YES];
457 458

        // beware of order, setActiveVideoPlayback:, setHasActiveVideo: and setNonembedded: must be called before
459
        [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psVideoStartedOrStoppedEvent];
460
    }
461 462 463
}


464 465 466
- (void)setNativeVideoSize:(NSSize)size forWindow:(vout_window_t *)p_wnd
{
    VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
467
    if (!o_window) {
468
        msg_Err(getIntf(), "Cannot set size for nonexisting window");
469 470 471 472 473 474
        return;
    }

    [o_window setNativeVideoSize:size];
}

475 476
- (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd
{
477 478
    VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
    if (!o_window) {
479
        msg_Err(getIntf(), "Cannot set level for nonexisting window");
480 481 482
        return;
    }

483 484 485
    // only set level for helper windows to normal if no status vout window exist anymore
    if(i_level == NSStatusWindowLevel) {
        i_statusLevelWindowCounter++;
486
        // window level need to stay on normal in fullscreen mode
487
        if (![o_window fullscreen] && ![o_window inFullscreenTransition])
488
            [self updateWindowLevelForHelperWindows:i_level];
489
    } else {
490 491 492
        if (i_statusLevelWindowCounter > 0)
            i_statusLevelWindowCounter--;

493 494 495 496 497 498 499 500
        if (i_statusLevelWindowCounter == 0) {
            [self updateWindowLevelForHelperWindows:i_level];
        }
    }

    [o_window setWindowLevel:i_level];
}

501
- (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd withAnimation:(BOOL)b_animation
502
{
503
    intf_thread_t *p_intf = getIntf();
504
    BOOL b_nativeFullscreenMode = [[VLCMain sharedInstance] nativeFullscreenMode];
505

506 507 508
    if (!p_intf || (!b_nativeFullscreenMode && !p_wnd))
        return;
    playlist_t *p_playlist = pl_Get(p_intf);
509
    BOOL b_fullscreen = i_full != 0;
510 511 512 513 514 515 516 517

    if (!var_GetBool(p_playlist, "fullscreen") != !b_fullscreen)
        var_SetBool(p_playlist, "fullscreen", b_fullscreen);

    VLCVideoWindowCommon *o_current_window = nil;
    if(p_wnd)
        o_current_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];

518 519 520 521
    if (var_InheritBool(p_intf, "macosx-dim-keyboard")) {
        [o_keyboard_backlight switchLightsAsync:!b_fullscreen];
    }

522 523
    if (b_nativeFullscreenMode) {
        if(!o_current_window)
524
            o_current_window = [[VLCMain sharedInstance] mainWindow] ;
525 526 527 528
        assert(o_current_window);

        // fullscreen might be triggered twice (vout event)
        // so ignore duplicate events here
529
        if((b_fullscreen && !([o_current_window fullscreen] || [o_current_window inFullscreenTransition])) ||
530 531 532 533 534 535 536 537 538 539 540 541
           (!b_fullscreen && [o_current_window fullscreen])) {

            [o_current_window toggleFullScreen:self];
        }
    } else {
        assert(o_current_window);

        if (b_fullscreen) {
            input_thread_t * p_input = pl_CurrentInput(p_intf);
            if (p_input != NULL && [[VLCMain sharedInstance] activeVideoPlayback]) {
                // activate app, as method can also be triggered from outside the app (prevents nasty window layout)
                [NSApp activateIgnoringOtherApps:YES];
542
                [o_current_window enterFullscreenWithAnimation:b_animation];
543 544 545 546 547 548

            }
            if (p_input)
                vlc_object_release(p_input);
        } else {
            // leaving fullscreen is always allowed
549
            [o_current_window leaveFullscreenWithAnimation:YES];
550 551 552 553 554 555 556
        }
    }
}

#pragma mark -
#pragma mark Misc methods

557
- (void)updateControlsBarsUsingBlock:(void (^)(VLCControlsBarCommon *controlsBar))block
558 559
{
    [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
560

561
        if ([obj respondsToSelector:@selector(controlsBar)]) {
562 563 564
            VLCControlsBarCommon *o_controlsBar = [obj controlsBar];
            if (o_controlsBar && block)
                block(o_controlsBar);
565 566 567 568 569 570 571 572 573 574 575 576
        }
    }];
}

- (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
{
    [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        if ([obj isKindOfClass: [NSWindow class]])
            windowUpdater(obj);
    }];
}

577 578
- (void)updateWindowLevelForHelperWindows:(NSInteger)i_level
{
579
    if (var_InheritBool(getIntf(), "video-wallpaper"))
580 581 582
        return;

    i_currentWindowLevel = i_level;
583
    if (i_level == NSNormalWindowLevel) {
584
        _currentStatusWindowLevel = NSFloatingWindowLevel;
585
    } else {
586
        _currentStatusWindowLevel = i_level + 1;
587
    }
588

589
    NSInteger currentStatusWindowLevel = self.currentStatusWindowLevel;
590

591
    VLCMain *main = [VLCMain sharedInstance];
592
    [[[VLCMain sharedInstance] mainWindow] setWindowLevel:i_level];
593
    [[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
594
    [[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
595
    [[main currentMediaInfoPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
596
    [[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
597
    [[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
598
    [[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel];
599 600
}

601
@end