~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/gui/macosx/voutgl.m

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * voutgl.m: MacOS X OpenGL provider
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2001-2004, 2007-2009 the VideoLAN team
5
 
 * $Id: a6e751d8bd07c838a11aaeab5f3c294951657261 $
 
5
 * $Id: 9276f4526abf89cf97d33eb8531da20762e98746 $
6
6
 *
7
7
 * Authors: Colin Delacroix <colin@zoy.org>
8
8
 *          Florian G. Pflug <fgp@phlo.org>
30
30
/*****************************************************************************
31
31
 * Preamble
32
32
 *****************************************************************************/
33
 
#include <errno.h>                                                 /* ENOMEM */
34
33
#include <stdlib.h>                                                /* free() */
35
34
#include <string.h>
36
35
 
 
36
#include <vlc_common.h>
37
37
#include <vlc_keys.h>
38
38
 
39
39
#include "intf.h"
103
103
int OpenVideoGL  ( vlc_object_t * p_this )
104
104
{
105
105
    vout_thread_t * p_vout = (vout_thread_t *) p_this;
106
 
    vlc_value_t value_drawable;
107
106
 
108
107
    if( !CGDisplayUsesOpenGLAcceleration( kCGDirectMainDisplay ) )
109
108
    {
119
118
    memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
120
119
 
121
120
#ifndef __x86_64__
122
 
    var_Get( p_vout->p_libvlc, "drawable-agl", &value_drawable );
123
 
    if( value_drawable.i_int != 0 )
 
121
    int i_drawable_agl;
 
122
    i_drawable_agl = var_GetInteger( p_vout->p_libvlc, "drawable-agl" );
 
123
    if( i_drawable_agl > 0 )
124
124
    {
125
125
        static const GLint ATTRIBUTES[] = {
126
126
            AGL_WINDOW,
146
146
            free( p_vout->p_sys );
147
147
            return VLC_EGENERIC;
148
148
        }
149
 
 
 
149
 
150
150
        p_vout->p_sys->agl_ctx = aglCreateContext(pixFormat, NULL);
151
151
        aglDestroyPixelFormat(pixFormat);
152
152
        if( NULL == p_vout->p_sys->agl_ctx )
208
208
{
209
209
    vout_thread_t * p_vout = (vout_thread_t *) p_this;
210
210
 
211
 
    msg_Dbg( p_this, "Closing" );
212
211
 
213
212
#ifndef __x86_64__
214
213
    if( p_vout->p_sys->b_embedded )
364
363
#define o_glview p_vout->p_sys->o_glview
365
364
    o_glview = [[VLCGLView alloc] initWithVout: p_vout];
366
365
    [o_glview autorelease];
367
 
 
 
366
 
368
367
    if( p_vout->p_sys->b_saved_frame )
369
368
    {
370
369
        id old_vout = p_vout->p_sys->o_vout_view;
503
502
    Unlock( p_vout );
504
503
}
505
504
 
 
505
- (void) renewGState
 
506
{
 
507
    NSWindow *window = [self window];
 
508
 
 
509
        if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
 
510
        {
 
511
                [window disableScreenUpdatesUntilFlush];
 
512
        }
 
513
 
 
514
    [super renewGState];
 
515
}
 
516
 
506
517
@end
507
518
 
508
519
/*****************************************************************************
519
530
{
520
531
    Rect viewBounds;
521
532
    Rect clipBounds;
522
 
 
 
533
 
523
534
    p_vout->p_sys->agl_drawable = (AGLDrawable)
524
535
            var_GetInteger( p_vout->p_libvlc, "drawable-agl" );
525
536
    aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
664
675
        {
665
676
            /* Go into fullscreen */
666
677
            Rect deviceRect;
667
 
 
 
678
 
668
679
            GDHandle deviceHdl = GetMainDevice();
669
680
            deviceRect = (*deviceHdl)->gdRect;
670
 
 
 
681
 
671
682
            if( !p_vout->p_sys->theWindow )
672
683
            {
673
684
                /* Create a window */
677
688
                            | kWindowStandardHandlerAttribute
678
689
                            | kWindowLiveResizeAttribute
679
690
                            | kWindowNoShadowAttribute;
680
 
 
 
691
 
681
692
                windowAttrs &= (~kWindowResizableAttribute);
682
693
 
683
694
                CreateNewWindow(kDocumentWindowClass, windowAttrs, &deviceRect, &p_vout->p_sys->theWindow);
687
698
                    SetWindowGroup(p_vout->p_sys->theWindow, p_vout->p_sys->winGroup);
688
699
                    SetWindowGroupParent( p_vout->p_sys->winGroup, GetWindowGroupOfClass(kDocumentWindowClass) ) ;
689
700
                }
690
 
 
 
701
 
691
702
                // Window title
692
703
                CFStringRef titleKey    = CFSTR("Fullscreen VLC media plugin");
693
704
                CFStringRef windowTitle = CFCopyLocalizedString(titleKey, NULL);
694
705
                SetWindowTitleWithCFString(p_vout->p_sys->theWindow, windowTitle);
695
706
                CFRelease(titleKey);
696
707
                CFRelease(windowTitle);
697
 
 
 
708
 
698
709
                //Install event handler
699
710
                static const EventTypeSpec win_events[] = {
700
711
                    { kEventClassMouse, kEventMouseDown },
751
762
            clipBounds.left = va_arg( args, int);
752
763
            clipBounds.bottom = va_arg( args, int);
753
764
            clipBounds.right = va_arg( args, int);
754
 
 
 
765
 
755
766
            if( !p_vout->b_fullscreen )
756
767
            {
757
768
                /*
870
881
    {
871
882
        HICommand theHICommand;
872
883
        GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
873
 
 
 
884
 
874
885
        switch ( theHICommand.commandID )
875
886
        {
876
887
            default:
881
892
    {
882
893
        WindowRef     window;
883
894
        Rect          rectPort = {0,0,0,0};
884
 
 
 
895
 
885
896
        GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
886
897
 
887
898
        if(window)
895
906
            case kEventWindowZoomed:
896
907
            case kEventWindowBoundsChanged:
897
908
                break;
898
 
 
 
909
 
899
910
            default:
900
911
                result = eventNotHandledErr;
901
912
        }
907
918
            case kEventMouseDown:
908
919
            {
909
920
                UInt16     button;
910
 
 
 
921
 
911
922
                GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
912
923
                switch (button)
913
924
                {
947
958
            case kEventMouseUp:
948
959
            {
949
960
                UInt16     button;
950
 
 
 
961
 
951
962
                GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
952
963
                switch (button)
953
964
                {
965
976
                        else
966
977
                        {
967
978
                            vlc_value_t val;
 
979
                            int x, y;
968
980
 
969
 
                            var_SetBool( p_vout, "mouse-clicked", true );
 
981
                            var_GetCoords( p_vout, "mouse-moved", &x, &y );
 
982
                            var_SetCoords( p_vout, "mouse-clicked", x, y );
970
983
 
971
984
                            var_Get( p_vout, "mouse-button-down", &val );
972
985
                            val.i_int &= ~1;
1006
1019
                unsigned int i_x, i_y;
1007
1020
                unsigned int i_height = p_vout->p_sys->i_height;
1008
1021
                unsigned int i_width  = p_vout->p_sys->i_width;
 
1022
                int x, y;
1009
1023
 
1010
1024
                vout_PlacePicture(p_vout, i_width, i_height, &i_x, &i_y, &i_width, &i_height);
1011
1025
 
1012
1026
                GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &ml);
1013
 
 
1014
 
                val.i_int = ( ((int)ml.h) - i_x ) *
1015
 
                            p_vout->render.i_width / i_width;
1016
 
                var_Set( p_vout, "mouse-x", val );
1017
 
 
1018
 
                val.i_int = ( ((int)ml.v) - i_y ) *
1019
 
                            p_vout->render.i_height / i_height;
1020
 
 
1021
 
                var_Set( p_vout, "mouse-y", val );
1022
 
 
1023
 
                val.b_bool = true;
1024
 
                var_Set( p_vout, "mouse-moved", val );
1025
 
 
 
1027
 
 
1028
                x = (((int)ml.h) - i_x) * p_vout->render.i_width / i_width;
 
1029
                y = (((int)ml.v) - i_y) * p_vout->render.i_height / i_height;
 
1030
                var_SetCoords( p_vout, "mouse-moved", x, y );
1026
1031
                break;
1027
1032
            }
1028
 
 
 
1033
 
1029
1034
            default:
1030
1035
                result = eventNotHandledErr;
1031
1036
        }