]> git.sesse.net Git - vlc/commitdiff
minimal_macosx: Fix the minimal window.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 30 Aug 2007 13:12:47 +0000 (13:12 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 30 Aug 2007 13:12:47 +0000 (13:12 +0000)
modules/gui/minimal_macosx/VLCMinimalVoutWindow.h
modules/gui/minimal_macosx/VLCMinimalVoutWindow.m
modules/gui/minimal_macosx/VLCOpenGLVoutView.m
modules/gui/minimal_macosx/intf.h
modules/gui/minimal_macosx/intf.m
modules/gui/minimal_macosx/macosx.c

index 4d889d28794cfde352478dd19dc83105ae939d15..1ce8e273907cfe3c2d1b5f8c1fdf24f1668af3ee 100644 (file)
 
 @interface VLCMinimalVoutWindow : NSWindow
 {
-    NSRect rect;
+    NSRect initialFrame;
+    NSPoint initialLocation, initialLocationOnScreen;
+    BOOL fullscreen;
+    BOOL mouseDraggedShouldResize;
 }
 
 - (id)initWithContentRect:(NSRect)contentRect;
index 8a69fdc298ef27c37a4cdb605b3d8b0cd3bb8c03..5025b36e6df71a3163612ddc3645a039c0361600 100644 (file)
 {
     if( self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
     {
-        rect = contentRect;
+        initialFrame = contentRect;
+        fullscreen = NO;
         [self setBackgroundColor:[NSColor blackColor]];
+        [self setHasShadow:YES];
         [self setMovableByWindowBackground: YES];
+        [self center];
     }
     return self;
 }
+
+/* @protocol VLCOpenGLVoutEmbedding */
 - (void)addVoutSubview:(NSView *)view
 {
+    [view setAutoresizingMask:NSViewHeightSizable|NSViewWidthSizable];
     [[self contentView] addSubview:view];
     [view setFrame:[[self contentView] bounds]];
 }
 
 - (void)enterFullscreen
 {
+    fullscreen = YES;
+    initialFrame = [self frame];
     SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
-    [self setFrame:[[self screen] frame] display: YES];
+    [self setFrame:[[self screen] frame] display:YES animate:YES];
 }
 
 - (void)leaveFullscreen
 {
+    fullscreen = NO;
     SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
-    [self setFrame:rect display: YES];
+    [self setFrame:initialFrame display:YES animate:YES];
 }
 
 - (BOOL)stretchesVideo
index aa7fe067586617c77213718e1eeaee7c01ad5e87..0b6601ca8174eda7c843fbe97a3d4028f3e51358 100644 (file)
@@ -52,16 +52,16 @@ int cocoaglvoutviewInit( vout_thread_t * p_vout )
     var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
     var_Get( p_vout, "drawable", &value_drawable );
 
+    p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
+
     o_cocoaglview_container = (id) value_drawable.i_int;
     if (!o_cocoaglview_container)
     {
         msg_Warn( p_vout, "No drawable!, spawing a window" );
-        o_cocoaglview_container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, 200, 200 )];
     }
 
     p_vout->p_sys->b_embedded = VLC_FALSE;
 
-    p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
 
     /* Create the GL view */
     struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } args = { p_vout, o_cocoaglview_container };
@@ -95,6 +95,8 @@ void cocoaglvoutviewEnd( vout_thread_t * p_vout )
     if( [(id)o_cocoaglview_container respondsToSelector:@selector(removeVoutSubview:)] )
         [o_cocoaglview_container removeVoutSubview: p_vout->p_sys->o_glview];
 
+    [p_vout->p_sys->o_glview release];
+
     [p_vout->p_sys->o_pool release];
     
 }
@@ -195,15 +197,22 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
  * vout_thread_t. Must be called from main thread. */
 + (void) autoinitOpenGLVoutViewIntVoutWithContainer: (NSData *) argsAsData
 {
+    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
     struct args { vout_thread_t * p_vout; id <VLCOpenGLVoutEmbedding> container; } *
         args = (struct args *)[argsAsData bytes];
     VLCOpenGLVoutView * oglview;
 
+    if( !args->container )
+    {
+        args->container = [[VLCMinimalVoutWindow alloc] initWithContentRect: NSMakeRect( 0, 0, args->p_vout->i_window_width, args->p_vout->i_window_height )];
+        [(VLCMinimalVoutWindow *)args->container makeKeyAndOrderFront: nil];
+    }
     oglview = [[VLCOpenGLVoutView alloc] initWithVout: args->p_vout container: args->container];
 
-    args->p_vout->p_sys->o_glview = [oglview autorelease];
-
+    args->p_vout->p_sys->o_glview = oglview;
     [args->container addVoutSubview: oglview];
+
+    [pool release];
 }
 
 - (void)dealloc
@@ -365,5 +374,9 @@ void cocoaglvoutviewUnlock( vout_thread_t * p_vout )
     CGLUnlockContext([[p_vout->p_sys->o_glview openGLContext] CGLContextObj]);
 }
 
+- (BOOL)mouseDownCanMoveWindow
+{
+    return YES;
+}
 @end
 
index a43b902f022ec1c3e84331a5a68439ca8e6cc9e9..0876f4d215c3dde5ac09b5e7e013e9fdf2f43e2f 100644 (file)
@@ -45,6 +45,6 @@
  *****************************************************************************/
 struct intf_sys_t
 {
-    NSAutoreleasePool * o_pool;
+    int nothing_for_now;
 };
 
index 62638e7f2950f3d36194497cbeace83468f48a80..340f1955f851f39b20490140b4f6a94012dafea0 100644 (file)
@@ -58,12 +58,9 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
 
     memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
 
-    p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
-
-    p_intf->b_play = VLC_TRUE;
     p_intf->pf_run = Run;
 
-    return( 0 );
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
@@ -76,6 +73,17 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
     free( p_intf->p_sys );
 }
 
+/* Dock Connection */
+typedef struct CPSProcessSerNum
+{
+        UInt32                lo;
+        UInt32                hi;
+} CPSProcessSerNum;
+
+extern OSErr    CPSGetCurrentProcess( CPSProcessSerNum *psn);
+extern OSErr    CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
+extern OSErr    CPSSetFrontProcess( CPSProcessSerNum *psn);
+
 /*****************************************************************************
  * Run: main loop
  *****************************************************************************/
@@ -95,7 +103,14 @@ static void Run( intf_thread_t *p_intf )
     sigemptyset( &set );
     sigaddset( &set, SIGTERM );
     pthread_sigmask( SIG_UNBLOCK, &set, NULL );
-
+    CPSProcessSerNum PSN;
+    NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
+    [NSApplication sharedApplication];
+    if (!CPSGetCurrentProcess(&PSN))
+        if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
+            if (!CPSSetFrontProcess(&PSN))
+                [NSApplication sharedApplication];
     [NSApp run];
+    [pool release];
 }
 
index 5a664ba1c8da152a7fc885c42e8e9bd4099b1780..ae9e6a6c6161b23dcc5289a1d2d5a1612bf94ce8 100644 (file)
@@ -47,8 +47,9 @@ void E_(CloseVideoGL) ( vlc_object_t * );
 
 vlc_module_begin();
     /* Minimal interface. see intf.m */
+    set_shortname( _( "minimal_macosx" ));
     set_description( _("Mac OS X minimal interface") );
-    set_capability( "interface", 50 );
+    set_capability( "interface", 110 );
     set_callbacks( E_(OpenIntf), E_(CloseIntf) );
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_MAIN );
@@ -56,7 +57,7 @@ vlc_module_begin();
     add_submodule();
         /* Will be loaded even without interface module. see voutgl.m */
         set_description( "Mac OS X minimal OpenGL video output (opens a borderless window)" );
-        set_capability( "opengl provider", 50 );
+        set_capability( "opengl provider", 110 );
         set_category( CAT_VIDEO);
         set_subcategory( SUBCAT_VIDEO_VOUT );
         set_callbacks( E_(OpenVideoGL), E_(CloseVideoGL) );