Commit 92759c9e authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

gui/macosx: Make sure we treat screens as screen, instead of screen number.

parent e77da242
......@@ -34,7 +34,7 @@
BOOL b_nonActive;
BOOL b_displayed;
BOOL b_voutWasUpdated;
int i_device;
NSScreen * o_screen;
}
- (id)initWithContentRect: (NSRect)contentRect
styleMask: (unsigned int)aStyle
......@@ -70,7 +70,7 @@
- (void)mouseDragged:(NSEvent *)theEvent;
- (BOOL)isDisplayed;
- (void)setVoutWasUpdated: (int) i_screen;
- (void)setVoutWasUpdated: (NSScreen *) o_screen;
@end
@interface VLCFSPanelView : NSView
......
......@@ -50,7 +50,7 @@
/* let the window sit on top of everything else and start out completely transparent */
[win setLevel:NSFloatingWindowLevel];
[win setAlphaValue:0.0];
i_device = 0;
o_screen = nil;
[win center];
return win;
......@@ -109,13 +109,11 @@
NSRect theScreensFrame;
NSRect theWindowsFrame;
if( i_device < 0 || i_device >= (signed int)[[NSScreen screens] count] )
/* invalid preferences or none specified, using main screen */
theScreensFrame = [[NSScreen mainScreen] frame];
if( o_screen )
theScreensFrame = [o_screen frame];
else
/* user-defined screen */
theScreensFrame = [[[NSScreen screens] objectAtIndex: i_device] frame];
theScreensFrame = [[NSScreen mainScreen] frame];
theWindowsFrame = [self frame];
theCoordinate.x = (theScreensFrame.size.width - theWindowsFrame.size.width) / 2 + theScreensFrame.origin.x;
......@@ -343,12 +341,12 @@
return b_displayed;
}
- (void)setVoutWasUpdated: (int)i_newdevice;
- (void)setVoutWasUpdated: (NSScreen *)o_new_screen;
{
b_voutWasUpdated = YES;
if( i_newdevice != i_device )
if( ![o_new_screen isScreen: o_screen] )
{
i_device = i_newdevice;
o_screen = o_new_screen;
[self center];
}
}
......
......@@ -166,6 +166,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
int i_device;
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSArray *o_screens = [NSScreen screens];
NSArray *o_fullscreen_screen = nil;
p_vout = vout;
o_view = view;
......@@ -186,6 +187,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
i_device = var_GetInteger( p_real_vout->p_vlc, "video-device" );
}
o_fullscreen_screen = [NSScreen screenWithDisplayID:i_device];
if( !o_fullscreen_screen )
o_fullscreen_screen = [[self window] screen];
/* Setup the menuitem for the multiple displays. */
if( var_Type( p_real_vout, "video-device" ) == 0 )
{
......@@ -217,10 +222,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
(int)s_rect.size.width, (int)s_rect.size.height );
text.psz_string = psz_temp;
val2.i_int = i;
val2.i_int = [o_screen displayID];
var_Change( p_real_vout, "video-device",
VLC_VAR_ADDCHOICE, &val2, &text );
if( i == i_device )
if( [o_screen isScreen:o_fullscreen_screen] )
{
var_Set( p_real_vout, "video-device", val2 );
}
......@@ -1007,20 +1012,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
b_embedded = var_GetBool( p_vout, "macosx-embedded" );
/* Find out on which screen to open the window */
if( i_device <= 0 || i_device > (int)[o_screens count] )
{
/* No preference specified. Use the main screen */
o_screen = [NSScreen mainScreen];
i_device = [o_screens indexOfObject: o_screen];
if( o_screen == [o_screens objectAtIndex: 0] )
b_menubar_screen = VLC_TRUE;
}
else
{
i_device--;
o_screen = [o_screens objectAtIndex: i_device];
b_menubar_screen = ( i_device == 0 );
}
o_screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
if( !o_screen )
o_screen = [[self window] screen];
if( [o_screen isMainScreen] )
b_menubar_screen = VLC_TRUE;
if( p_vout->b_fullscreen )
{
......@@ -1034,7 +1030,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
/* tell the fspanel to move itself to front next time it's triggered */
[[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: o_screen];
/* Creates a window with size: screen_rect on o_screen */
[self initWithContentRect: screen_rect
......@@ -1060,7 +1056,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
CGDisplayCount dspyCnt;
CGPoint gPoint;
if( i == (unsigned int)i_device ) continue;
if( [[o_screens objectAtIndex:i] isScreen: o_screen] ) continue;
screen_rect = [[o_screens objectAtIndex: i] frame];
......@@ -1158,7 +1154,6 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
{
/* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
Command-Q */
[self setContentView: NULL];
[self performSelectorOnMainThread: @selector(closeReal:)
withObject: NULL waitUntilDone: NO];
}
......@@ -1169,10 +1164,17 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
{
CGDisplayFadeReservationToken token;
CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
CGDisplayFade( token, 2, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, false );
CGDisplayFade( token, 0.3 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
[self disableScreenUpdatesUntilFlush];
[self orderOut: self];
CGDisplayFade( token, 0.6 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, YES );
CGReleaseDisplayFadeReservation( token);
CGDisplayRestoreColorSyncSettings();
}
[NSScreen unblackoutScreens];
SetSystemUIMode( kUIModeNormal, 0);
[super close];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment