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