annotate libvo/vo_quartz.c @ 20565:7732bd30bb6c

encoding is now UTF-8
author diego
date Wed, 01 Nov 2006 14:50:36 +0000
parents 0e7291ee4b6b
children 856d660a1ebd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1 /*
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
2 vo_quartz.c
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
3
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
4 by Nicolas Plourde <nicolasplourde@gmail.com>
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
5
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
6 Copyright (c) Nicolas Plourde - April 2004
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
7
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
8 YUV support Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
9
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
10 MPlayer Mac OSX Quartz video out module.
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
11
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
12 todo: -screen overlay output
13818
9f707a805967 window now save is old position when going in fullscreen or while using resize preset
nplourde
parents: 13796
diff changeset
13 -fit osd in black bar when available
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
14 -fix RGB32
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
15 -(add sugestion here)
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
16 */
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
17
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
18 //SYS
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
19 #include <stdio.h>
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
20
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
21 //OSX
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
22 #include <Carbon/Carbon.h>
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
23 #include <QuickTime/QuickTime.h>
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
24
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
25 //MPLAYER
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
26 #include "config.h"
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
27 #include "fastmemcpy.h"
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
28 #include "video_out.h"
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
29 #include "video_out_internal.h"
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
30 #include "aspect.h"
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
31 #include "mp_msg.h"
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
32 #include "m_option.h"
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
33
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13779
diff changeset
34 #include "input/input.h"
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13779
diff changeset
35 #include "input/mouse.h"
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
36
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
37 #include "vo_quartz.h"
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
38
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
39 static vo_info_t info =
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
40 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
41 "Mac OSX (Quartz)",
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
42 "quartz",
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
43 "Nicolas Plourde <nicolasplourde@hotmail.com>, Romain Dolbeau <romain@dolbeau.org>",
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
44 ""
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
45 };
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
46
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
47 LIBVO_EXTERN(quartz)
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
48
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
49 static uint32_t image_depth;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
50 static uint32_t image_format;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
51 static uint32_t image_size;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
52 static uint32_t image_buffer_size;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
53 static char *image_data;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
54
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
55 static ImageSequence seqId;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
56 static CodecType image_qtcodec;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
57 static PlanarPixmapInfoYUV420 *P = NULL;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
58 static struct
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
59 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
60 ImageDescriptionHandle desc;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
61 Handle extension_colr;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
62 Handle extension_fiel;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
63 Handle extension_clap;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
64 Handle extension_pasp;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
65 } yuv_qt_stuff;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
66 static MatrixRecord matrix;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
67 static int EnterMoviesDone = 0;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
68 static int get_image_done = 0;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
69
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
70 static int vo_quartz_fs; // we are in fullscreen
13791
4f08a94405ad autodetect proper monitor aspect
nplourde
parents: 13788
diff changeset
71 extern float monitor_aspect;
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
72 extern float movie_aspect;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
73 static float old_movie_aspect;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
74
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
75 static int winLevel = 1;
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
76 int levelList[] =
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
77 {
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
78 kCGDesktopWindowLevelKey,
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
79 kCGNormalWindowLevelKey,
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
80 kCGScreenSaverWindowLevelKey
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
81 };
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
82
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
83 static int int_pause = 0;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
84 static float winAlpha = 1;
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
85 static int mouseHide = FALSE;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
86
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
87 static int device_width;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
88 static int device_height;
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
89 static int device_id;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
90
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
91 static short fs_res_x=0;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
92 static short fs_res_y=0;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
93
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
94 static WindowRef theWindow = NULL;
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
95 static WindowGroupRef winGroup = NULL;
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
96 static CGContextRef context;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
97 static CGRect bounds;
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
98 static GDHandle deviceHdl;
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
99
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
100 static CGDataProviderRef dataProviderRef;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
101 static CGImageAlphaInfo alphaInfo;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
102 static CGImageRef image;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
103
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
104 static Rect imgRect; // size of the original image (unscaled)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
105 static Rect dstRect; // size of the displayed image (after scaling)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
106 static Rect winRect; // size of the window containg the displayed image (include padding)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
107 static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
108 static Rect deviceRect; // size of the display device
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
109 static Rect oldWinBounds;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
110
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
111 static MenuRef windMenu;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
112 static MenuRef movMenu;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
113 static MenuRef aspectMenu;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
114
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
115 enum
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
116 {
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
117 kQuitCmd = 1,
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
118 kHalfScreenCmd = 2,
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
119 kNormalScreenCmd = 3,
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
120 kDoubleScreenCmd = 4,
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
121 kFullScreenCmd = 5,
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
122 kKeepAspectCmd = 6,
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
123 kAspectOrgCmd = 7,
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
124 kAspectFullCmd = 8,
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
125 kAspectWideCmd = 9,
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
126 kPanScanCmd = 10
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
127 };
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
128
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13779
diff changeset
129 #include "osdep/keycodes.h"
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
130
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
131 extern void mplayer_put_key(int code);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
132 extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
133
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
134 //PROTOTYPE/////////////////////////////////////////////////////////////////
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
135 static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
136 static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
137 static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
138 void window_resized();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
139 void window_ontop();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
140 void window_fullscreen();
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
141 void window_panscan();
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
142
12886
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
143 static inline int convert_key(UInt32 key, UInt32 charcode)
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
144 {
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
145 switch(key)
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
146 {
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
147 case QZ_IBOOK_ENTER:
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
148 case QZ_RETURN: return KEY_ENTER;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
149 case QZ_ESCAPE: return KEY_ESC;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
150 case QZ_BACKSPACE: return KEY_BACKSPACE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
151 case QZ_LALT: return KEY_BACKSPACE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
152 case QZ_LCTRL: return KEY_BACKSPACE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
153 case QZ_LSHIFT: return KEY_BACKSPACE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
154 case QZ_F1: return KEY_F+1;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
155 case QZ_F2: return KEY_F+2;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
156 case QZ_F3: return KEY_F+3;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
157 case QZ_F4: return KEY_F+4;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
158 case QZ_F5: return KEY_F+5;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
159 case QZ_F6: return KEY_F+6;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
160 case QZ_F7: return KEY_F+7;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
161 case QZ_F8: return KEY_F+8;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
162 case QZ_F9: return KEY_F+9;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
163 case QZ_F10: return KEY_F+10;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
164 case QZ_F11: return KEY_F+11;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
165 case QZ_F12: return KEY_F+12;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
166 case QZ_INSERT: return KEY_INSERT;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
167 case QZ_DELETE: return KEY_DELETE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
168 case QZ_HOME: return KEY_HOME;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
169 case QZ_END: return KEY_END;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
170 case QZ_KP_PLUS: return '+';
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
171 case QZ_KP_MINUS: return '-';
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
172 case QZ_TAB: return KEY_TAB;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
173 case QZ_PAGEUP: return KEY_PAGE_UP;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
174 case QZ_PAGEDOWN: return KEY_PAGE_DOWN;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
175 case QZ_UP: return KEY_UP;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
176 case QZ_DOWN: return KEY_DOWN;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
177 case QZ_LEFT: return KEY_LEFT;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
178 case QZ_RIGHT: return KEY_RIGHT;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
179 case QZ_KP_MULTIPLY: return '*';
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
180 case QZ_KP_DIVIDE: return '/';
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
181 case QZ_KP_ENTER: return KEY_BACKSPACE;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
182 case QZ_KP_PERIOD: return KEY_KPDEC;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
183 case QZ_KP0: return KEY_KP0;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
184 case QZ_KP1: return KEY_KP1;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
185 case QZ_KP2: return KEY_KP2;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
186 case QZ_KP3: return KEY_KP3;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
187 case QZ_KP4: return KEY_KP4;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
188 case QZ_KP5: return KEY_KP5;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
189 case QZ_KP6: return KEY_KP6;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
190 case QZ_KP7: return KEY_KP7;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
191 case QZ_KP8: return KEY_KP8;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
192 case QZ_KP9: return KEY_KP9;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
193 default: return charcode;
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
194 }
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
195 }
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
196
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
197 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
198 {
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
199 switch (image_format)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
200 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
201 case IMGFMT_RGB32:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
202 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*imgRect.right+x0),4*imgRect.right);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
203 break;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
204 case IMGFMT_YV12:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
205 case IMGFMT_IYUV:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
206 case IMGFMT_I420:
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
207 vo_draw_alpha_yv12(w,h,src,srca,stride, ((char*)P) + P->componentInfoY.offset + x0 + y0 * imgRect.right, imgRect.right);
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
208 break;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
209 case IMGFMT_UYVY:
12517
4c42b1fb183f uyvy osd support
nplourde
parents: 12487
diff changeset
210 vo_draw_alpha_uyvy(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2);
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
211 break;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
212 case IMGFMT_YUY2:
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
213 vo_draw_alpha_yuy2(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2);
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
214 break;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
215 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
216 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
217
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
218 //default keyboard event handler
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
219 static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
220 {
12624
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
221 OSStatus result = noErr;
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
222 UInt32 class = GetEventClass (event);
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
223 UInt32 kind = GetEventKind (event);
12624
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
224
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
225 result = CallNextEventHandler(nextHandler, event);
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
226
13712
f6ef5a0ad7e4 removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents: 13707
diff changeset
227 if(class == kEventClassKeyboard)
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
228 {
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
229 char macCharCodes;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
230 UInt32 macKeyCode;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
231 UInt32 macKeyModifiers;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
232
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
233 GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes);
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
234 GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode);
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
235 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers);
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
236
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
237 if(macKeyModifiers != 256)
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
238 {
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
239 if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown)
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
240 {
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
241 int key = convert_key(macKeyCode, macCharCodes);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
242 if(key != -1)
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
243 mplayer_put_key(key);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
244 }
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
245 }
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
246 else if(macKeyModifiers == 256)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
247 {
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
248 switch(macCharCodes)
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
249 {
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
250 case '[': SetWindowAlpha(theWindow, winAlpha-=0.05); break;
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
251 case ']': SetWindowAlpha(theWindow, winAlpha+=0.05); break;
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
252 }
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
253 }
12886
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
254 else
9b95958f4eb0 listen for key repeats, patch by Dan Christiansen
nplourde
parents: 12830
diff changeset
255 result = eventNotHandledErr;
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
256 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
257
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
258 return result;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
259 }
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
260
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
261 //default mouse event handler
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
262 static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
263 {
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
264 OSStatus result = noErr;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
265 UInt32 class = GetEventClass (event);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
266 UInt32 kind = GetEventKind (event);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
267
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
268 result = CallNextEventHandler(nextHandler, event);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
269
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
270 if(class == kEventClassMouse)
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
271 {
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
272 WindowPtr tmpWin;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
273 Point mousePos;
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
274 Point winMousePos;
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
275
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
276 GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos);
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
277 GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos);
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
278
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
279 switch (kind)
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
280 {
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
281 case kEventMouseMoved:
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
282 {
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
283 if(vo_quartz_fs)
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
284 {
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
285 CGDisplayShowCursor(kCGDirectMainDisplay);
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
286 mouseHide = FALSE;
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
287 }
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
288 }
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
289 break;
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
290
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
291 case kEventMouseWheelMoved:
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
292 {
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
293 int wheel;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
294 short part;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
295
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
296 GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
297
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
298 part = FindWindow(mousePos,&tmpWin);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
299
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
300 if(part == inContent)
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
301 {
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
302 if(wheel > 0)
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
303 mplayer_put_key(MOUSE_BTN3);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
304 else
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
305 mplayer_put_key(MOUSE_BTN4);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
306 }
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
307 }
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
308 break;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
309
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
310 case kEventMouseDown:
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
311 {
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
312 EventMouseButton button;
13719
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
313 short part;
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
314 Rect bounds;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
315
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
316 GetWindowPortBounds(theWindow, &bounds);
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
317 GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button);
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
318
13719
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
319 part = FindWindow(mousePos,&tmpWin);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
320
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
321 if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) )
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
322 {
15723
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
323 if(!vo_quartz_fs)
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
324 {
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
325 GrowWindow(theWindow, mousePos, NULL);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
326 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
327 }
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
328 else if(part == inMenuBar)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
329 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
330 MenuSelect(mousePos);
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
331 HiliteMenu(0);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
332 }
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
333 else if(part == inContent)
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
334 {
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
335 switch(button)
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
336 {
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
337 case 1: mplayer_put_key(MOUSE_BTN0);break;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
338 case 2: mplayer_put_key(MOUSE_BTN2);break;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
339 case 3: mplayer_put_key(MOUSE_BTN1);break;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
340
12624
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
341 default:result = eventNotHandledErr;break;
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
342 }
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
343 }
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
344 }
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
345 break;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
346
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
347 case kEventMouseUp:
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
348 break;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
349
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
350 case kEventMouseDragged:
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
351 break;
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
352
12624
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
353 default:result = eventNotHandledErr;break;
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
354 }
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
355 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
356
12624
730fc470a30c added more key to keyboard event
nplourde
parents: 12623
diff changeset
357 return result;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
358 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
359
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
360 //default window event handler
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
361 static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
362 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
363 OSStatus result = noErr;
13722
1bd6bd13193d fixed typo
nplourde
parents: 13719
diff changeset
364 uint32_t d_width;
1bd6bd13193d fixed typo
nplourde
parents: 13719
diff changeset
365 uint32_t d_height;
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
366 UInt32 class = GetEventClass (event);
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
367 UInt32 kind = GetEventKind (event);
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
368
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
369 result = CallNextEventHandler(nextHandler, event);
13712
f6ef5a0ad7e4 removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents: 13707
diff changeset
370
f6ef5a0ad7e4 removed duplicate case and fixed aspect ratio for window zoom feature
nplourde
parents: 13707
diff changeset
371 aspect(&d_width,&d_height,A_NOZOOM);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
372
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
373 if(class == kEventClassCommand)
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
374 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
375 HICommand theHICommand;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
376 GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
377
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
378 switch ( theHICommand.commandID )
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
379 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
380 case kHICommandQuit:
16892
3470c810527b libvo input cleanup: remove the dependency on libinput,
albeu
parents: 16280
diff changeset
381 mplayer_put_key(KEY_CLOSE_WIN);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
382 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
383
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
384 case kHalfScreenCmd:
13734
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
385 if(vo_quartz_fs)
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
386 {
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
387 vo_fs = (!(vo_fs)); window_fullscreen();
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
388 }
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
389
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
390 SizeWindow(theWindow, (d_width/2), ((d_width/movie_aspect)/2), 1);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
391 window_resized();
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
392 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
393
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
394 case kNormalScreenCmd:
13734
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
395 if(vo_quartz_fs)
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
396 {
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
397 vo_fs = (!(vo_fs)); window_fullscreen();
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
398 }
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
399
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
400 SizeWindow(theWindow, d_width, (d_width/movie_aspect), 1);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
401 window_resized();
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
402 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
403
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
404 case kDoubleScreenCmd:
13734
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
405 if(vo_quartz_fs)
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
406 {
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
407 vo_fs = (!(vo_fs)); window_fullscreen();
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
408 }
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
409
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
410 SizeWindow(theWindow, (d_width*2), ((d_width/movie_aspect)*2), 1);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
411 window_resized();
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
412 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
413
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
414 case kFullScreenCmd:
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
415 vo_fs = (!(vo_fs)); window_fullscreen();
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
416 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
417
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
418 case kKeepAspectCmd:
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
419 vo_keepaspect = (!(vo_keepaspect));
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
420 CheckMenuItem (aspectMenu, 1, vo_keepaspect);
15909
b1bc923b38fe resize video after keep aspect menu item toggle
nplourde
parents: 15902
diff changeset
421 window_resized();
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
422 break;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
423
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
424 case kAspectOrgCmd:
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
425 movie_aspect = old_movie_aspect;
15902
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
426 if(!vo_quartz_fs)
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
427 {
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
428 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
429 }
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
430 window_resized();
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
431 break;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
432
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
433 case kAspectFullCmd:
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
434 movie_aspect = 4.0f/3.0f;
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
435 if(!vo_quartz_fs)
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
436 {
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
437 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
438 }
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
439 window_resized();
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
440 break;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
441
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
442 case kAspectWideCmd:
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
443 movie_aspect = 16.0f/9.0f;
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
444 if(!vo_quartz_fs)
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
445 {
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
446 SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
447 }
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
448 window_resized();
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
449 break;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
450
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
451 case kPanScanCmd:
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
452 vo_panscan = (!(vo_panscan));
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
453 CheckMenuItem (aspectMenu, 2, vo_panscan);
15902
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
454 window_panscan();
16534910f0fb fix various window resizing bug with menu option
nplourde
parents: 15892
diff changeset
455 window_resized();
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
456 break;
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
457
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
458 default:
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
459 result = eventNotHandledErr;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
460 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
461 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
462 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
463 else if(class == kEventClassWindow)
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
464 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
465 WindowRef window;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
466 Rect rectPort = {0,0,0,0};
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
467
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
468 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
469
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
470 if(window)
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
471 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
472 GetPortBounds(GetWindowPort(window), &rectPort);
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
473 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
474
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
475 switch (kind)
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
476 {
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
477 case kEventWindowClosed:
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
478 theWindow = NULL;
16892
3470c810527b libvo input cleanup: remove the dependency on libinput,
albeu
parents: 16280
diff changeset
479 mplayer_put_key(KEY_CLOSE_WIN);
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
480 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
481
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
482 //resize window
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
483 case kEventWindowZoomed:
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
484 case kEventWindowBoundsChanged:
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
485 window_resized();
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
486 flip_page();
15885
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
487 window_resized();
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
488 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
489
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
490 default:
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
491 result = eventNotHandledErr;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
492 break;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
493 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
494 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
495
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
496 return result;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
497 }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
498
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
499 static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
500 {
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
501 CFStringRef titleKey;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
502 CFStringRef windowTitle;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
503 OSStatus result;
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
504
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
505 MenuItemIndex index;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
506 CFStringRef movMenuTitle;
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
507 CFStringRef aspMenuTitle;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
508
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
509 SetRect(&winRect, 0, 0, d_width, d_height);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
510 SetRect(&oldWinRect, 0, 0, d_width, d_height);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
511 SetRect(&dstRect, 0, 0, d_width, d_height);
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
512
14081
866623c7ec87 clear menubar before adding new menu
nplourde
parents: 13909
diff changeset
513 //Clear Menu Bar
866623c7ec87 clear menubar before adding new menu
nplourde
parents: 13909
diff changeset
514 ClearMenuBar();
866623c7ec87 clear menubar before adding new menu
nplourde
parents: 13909
diff changeset
515
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
516 //Create Window Menu
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
517 CreateStandardWindowMenu(0, &windMenu);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
518 InsertMenu(windMenu, 0);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
519
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
520 //Create Movie Menu
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
521 CreateNewMenu (1004, 0, &movMenu);
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
522 movMenuTitle = CFSTR("Movie");
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
523 SetMenuTitleWithCFString(movMenu, movMenuTitle);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
524
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
525 AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
526 SetMenuItemCommandKey(movMenu, index, 0, '0');
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
527
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
528 AppendMenuItemTextWithCFString(movMenu, CFSTR("Normal Size"), 0, kNormalScreenCmd, &index);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
529 SetMenuItemCommandKey(movMenu, index, 0, '1');
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
530
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
531 AppendMenuItemTextWithCFString(movMenu, CFSTR("Double Size"), 0, kDoubleScreenCmd, &index);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
532 SetMenuItemCommandKey(movMenu, index, 0, '2');
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
533
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
534 AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index);
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
535 SetMenuItemCommandKey(movMenu, index, 0, 'F');
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
536
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
537 AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, NULL, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
538
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
539 AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, NULL, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
540
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
541 ////Create Aspect Ratio Sub Menu
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
542 CreateNewMenu (0, 0, &aspectMenu);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
543 aspMenuTitle = CFSTR("Aspect Ratio");
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
544 SetMenuTitleWithCFString(aspectMenu, aspMenuTitle);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
545 SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
546
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
547 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
548 CheckMenuItem (aspectMenu, 1, vo_keepaspect);
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
549 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Pan-Scan"), 0, kPanScanCmd, &index);
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
550 CheckMenuItem (aspectMenu, 2, vo_panscan);
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
551 AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, NULL, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
552 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
553 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
554 AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index);
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
555
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
556 InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
557
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
558 DrawMenuBar();
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
559
13693
abba514689a1 fix menu bar support and add new movie zoom option menu a la quicktime
nplourde
parents: 13124
diff changeset
560 //create window
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
561 CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow);
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
562
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
563 CreateWindowGroup(0, &winGroup);
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
564 SetWindowGroup(theWindow, winGroup);
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
565
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
566 //Set window title
12785
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
567 titleKey = CFSTR("MPlayer - The Movie Player");
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
568 windowTitle = CFCopyLocalizedString(titleKey, NULL);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
569 result = SetWindowTitleWithCFString(theWindow, windowTitle);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
570 CFRelease(titleKey);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
571 CFRelease(windowTitle);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
572
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
573 //Install event handler
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
574 const EventTypeSpec win_events[] = {
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
575 { kEventClassWindow, kEventWindowClosed },
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
576 { kEventClassWindow, kEventWindowBoundsChanged },
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
577 { kEventClassCommand, kEventCommandProcess }
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
578 };
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
579
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
580 const EventTypeSpec key_events[] = {
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
581 { kEventClassKeyboard, kEventRawKeyDown },
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
582 { kEventClassKeyboard, kEventRawKeyRepeat }
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
583 };
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
584
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
585 const EventTypeSpec mouse_events[] = {
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
586 { kEventClassMouse, kEventMouseMoved },
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
587 { kEventClassMouse, kEventMouseWheelMoved },
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
588 { kEventClassMouse, kEventMouseDown },
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
589 { kEventClassMouse, kEventMouseUp },
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
590 { kEventClassMouse, kEventMouseDragged }
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
591 };
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
592
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
593 InstallApplicationEventHandler (NewEventHandlerUPP (KeyEventHandler), GetEventTypeCount(key_events), key_events, NULL, NULL);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
594 InstallApplicationEventHandler (NewEventHandlerUPP (MouseEventHandler), GetEventTypeCount(mouse_events), mouse_events, NULL, NULL);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
595 InstallWindowEventHandler (theWindow, NewEventHandlerUPP (WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
596 }
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
597
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
598 static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
599 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
600 WindowAttributes windowAttrs;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
601 OSErr qterr;
13719
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
602 int i;
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
603 CGRect tmpBounds;
13719
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
604
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
605 //Get Main device info///////////////////////////////////////////////////
13719
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
606
43ecd6a73ec0 move variable declaration at beginning of block
nplourde
parents: 13712
diff changeset
607
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
608 deviceHdl = GetMainDevice();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
609
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
610 for(i=0; i<device_id; i++)
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
611 {
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
612 deviceHdl = GetNextDevice(deviceHdl);
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
613
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
614 if(deviceHdl == NULL)
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
615 {
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
616 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id);
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
617 deviceHdl = GetMainDevice();
14699
779230cb313d set device id to 0 if the device selected on startup do not exist
nplourde
parents: 14082
diff changeset
618 device_id = 0;
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
619 break;
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
620 }
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
621 }
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
622
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
623 deviceRect = (*deviceHdl)->gdRect;
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
624 device_width = deviceRect.right-deviceRect.left;
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
625 device_height = deviceRect.bottom-deviceRect.top;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
626
13791
4f08a94405ad autodetect proper monitor aspect
nplourde
parents: 13788
diff changeset
627 monitor_aspect = (float)device_width/(float)device_height;
4f08a94405ad autodetect proper monitor aspect
nplourde
parents: 13788
diff changeset
628
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
629 //misc mplayer setup/////////////////////////////////////////////////////
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
630 SetRect(&imgRect, 0, 0, width, height);
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
631 switch (image_format)
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
632 {
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
633 case IMGFMT_RGB32:
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
634 image_depth = 32;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
635 break;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
636 case IMGFMT_YV12:
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
637 case IMGFMT_IYUV:
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
638 case IMGFMT_I420:
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
639 case IMGFMT_UYVY:
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
640 case IMGFMT_YUY2:
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
641 image_depth = 16;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
642 break;
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
643 }
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
644 image_size = ((imgRect.right*imgRect.bottom*image_depth)+7)/8;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
645
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
646 vo_fs = flags & VOFLAG_FULLSCREEN;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
647
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
648 //get movie aspect
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
649 panscan_init();
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
650 aspect_save_orig(width,height);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
651 aspect_save_prescale(d_width,d_height);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
652 aspect_save_screenres(device_width, device_height);
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
653
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
654 aspect(&d_width,&d_height,A_NOZOOM);
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
655
13793
631b0b664ece get proper movie aspect
nplourde
parents: 13792
diff changeset
656 movie_aspect = (float)d_width/(float)d_height;
631b0b664ece get proper movie aspect
nplourde
parents: 13792
diff changeset
657 old_movie_aspect = movie_aspect;
631b0b664ece get proper movie aspect
nplourde
parents: 13792
diff changeset
658
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
659 if(image_data)
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
660 free(image_data);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
661
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
662 image_data = malloc(image_size);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
663
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
664 //Create player window//////////////////////////////////////////////////
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
665 windowAttrs = kWindowStandardDocumentAttributes
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
666 | kWindowStandardHandlerAttribute
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
667 | kWindowLiveResizeAttribute;
12425
049136c501b2 Disable live resize for yuv - HW accel bug
nplourde
parents: 12424
diff changeset
668
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
669 windowAttrs &= (~kWindowResizableAttribute);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
670
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
671 if (theWindow == NULL)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
672 {
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
673 quartz_CreateWindow(d_width, d_height, windowAttrs);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
674
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
675 if (theWindow == NULL)
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
676 {
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
677 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Couldn't create window !!!!!\n");
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
678 return -1;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
679 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
680 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
681 CreateCGContextForPort(GetWindowPort(theWindow),&context);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
682 CGContextFillRect(context, tmpBounds);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
683 }
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
684 else
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
685 {
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
686 HideWindow(theWindow);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
687 ChangeWindowAttributes(theWindow, ~windowAttrs, windowAttrs);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
688 SetRect(&winRect, 0, 0, d_width, d_height);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
689 SetRect(&oldWinRect, 0, 0, d_width, d_height);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
690 SizeWindow (theWindow, d_width, d_height, 1);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
691 }
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
692
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
693 switch (image_format)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
694 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
695 case IMGFMT_RGB32:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
696 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
697 CreateCGContextForPort (GetWindowPort (theWindow), &context);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
698
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
699 dataProviderRef = CGDataProviderCreateWithData (0, image_data, imgRect.right * imgRect.bottom * 4, 0);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
700
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
701 image = CGImageCreate (imgRect.right,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
702 imgRect.bottom,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
703 8,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
704 image_depth,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
705 ((imgRect.right*32)+7)/8,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
706 CGColorSpaceCreateDeviceRGB(),
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
707 kCGImageAlphaNoneSkipFirst,
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
708 dataProviderRef, 0, 1, kCGRenderingIntentDefault);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
709 break;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
710 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
711
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
712 case IMGFMT_YV12:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
713 case IMGFMT_IYUV:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
714 case IMGFMT_I420:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
715 case IMGFMT_UYVY:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
716 case IMGFMT_YUY2:
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
717 {
12623
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
718 get_image_done = 0;
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
719
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
720 if (!EnterMoviesDone)
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
721 {
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
722 qterr = EnterMovies();
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
723 EnterMoviesDone = 1;
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
724 }
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
725 else
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
726 qterr = 0;
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
727
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
728 if (qterr)
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
729 {
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
730 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: EnterMovies (%d)\n", qterr);
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
731 return -1;
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
732 }
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
733
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
734
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
735 SetIdentityMatrix(&matrix);
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
736
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
737 if ((d_width != width) || (d_height != height))
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
738 {
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
739 ScaleMatrix(&matrix, FixDiv(Long2Fix(d_width),Long2Fix(width)), FixDiv(Long2Fix(d_height),Long2Fix(height)), 0, 0);
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
740 }
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
741
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
742 yuv_qt_stuff.desc = (ImageDescriptionHandle)NewHandleClear( sizeof(ImageDescription) );
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
743
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
744 yuv_qt_stuff.extension_colr = NewHandleClear(sizeof(NCLCColorInfoImageDescriptionExtension));
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
745 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->colorParamType = kVideoColorInfoImageDescriptionExtensionType;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
746 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->primaries = 2;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
747 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->transferFunction = 2;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
748 ((NCLCColorInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_colr))->matrix = 2;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
749
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
750 yuv_qt_stuff.extension_fiel = NewHandleClear(sizeof(FieldInfoImageDescriptionExtension));
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
751 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldCount = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
752 ((FieldInfoImageDescriptionExtension*)(*yuv_qt_stuff.extension_fiel))->fieldOrderings = 0;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
753
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
754 yuv_qt_stuff.extension_clap = NewHandleClear(sizeof(CleanApertureImageDescriptionExtension));
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
755 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthN = imgRect.right;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
756 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureWidthD = 1;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
757 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightN = imgRect.bottom;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
758 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->cleanApertureHeightD = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
759 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffN = 0;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
760 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->horizOffD = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
761 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffN = 0;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
762 ((CleanApertureImageDescriptionExtension*)(*yuv_qt_stuff.extension_clap))->vertOffD = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
763
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
764 yuv_qt_stuff.extension_pasp = NewHandleClear(sizeof(PixelAspectRatioImageDescriptionExtension));
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
765 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->hSpacing = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
766 ((PixelAspectRatioImageDescriptionExtension*)(*yuv_qt_stuff.extension_pasp))->vSpacing = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
767
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
768 (*yuv_qt_stuff.desc)->idSize = sizeof(ImageDescription);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
769 (*yuv_qt_stuff.desc)->cType = image_qtcodec;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
770 (*yuv_qt_stuff.desc)->version = 2;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
771 (*yuv_qt_stuff.desc)->revisionLevel = 0;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
772 (*yuv_qt_stuff.desc)->vendor = 'mpla';
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
773 (*yuv_qt_stuff.desc)->width = imgRect.right;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
774 (*yuv_qt_stuff.desc)->height = imgRect.bottom;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
775 (*yuv_qt_stuff.desc)->hRes = Long2Fix(72);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
776 (*yuv_qt_stuff.desc)->vRes = Long2Fix(72);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
777 (*yuv_qt_stuff.desc)->temporalQuality = 0;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
778 (*yuv_qt_stuff.desc)->spatialQuality = codecLosslessQuality;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
779 (*yuv_qt_stuff.desc)->frameCount = 1;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
780 (*yuv_qt_stuff.desc)->dataSize = 0;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
781 (*yuv_qt_stuff.desc)->depth = 24;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
782 (*yuv_qt_stuff.desc)->clutID = -1;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
783
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
784 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_colr, kColorInfoImageDescriptionExtension);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
785 if (qterr)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
786 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
787 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [colr] (%d)\n", qterr);
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
788 }
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
789
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
790 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_fiel, kFieldInfoImageDescriptionExtension);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
791 if (qterr)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
792 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
793 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [fiel] (%d)\n", qterr);
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
794 }
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
795
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
796 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_clap, kCleanApertureImageDescriptionExtension);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
797 if (qterr)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
798 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
799 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [clap] (%d)\n", qterr);
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
800 }
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
801
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
802 qterr = AddImageDescriptionExtension(yuv_qt_stuff.desc, yuv_qt_stuff.extension_pasp, kCleanApertureImageDescriptionExtension);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
803 if (qterr)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
804 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
805 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: AddImageDescriptionExtension [pasp] (%d)\n", qterr);
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
806 }
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
807 if (P != NULL) { // second or subsequent movie
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
808 free(P);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
809 }
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
810 P = calloc(sizeof(PlanarPixmapInfoYUV420) + image_size, 1);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
811 switch (image_format)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
812 {
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
813 case IMGFMT_YV12:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
814 case IMGFMT_IYUV:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
815 case IMGFMT_I420:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
816 P->componentInfoY.offset = sizeof(PlanarPixmapInfoYUV420);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
817 P->componentInfoCb.offset = P->componentInfoY.offset + image_size / 2;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
818 P->componentInfoCr.offset = P->componentInfoCb.offset + image_size / 4;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
819 P->componentInfoY.rowBytes = imgRect.right;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
820 P->componentInfoCb.rowBytes = imgRect.right / 2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
821 P->componentInfoCr.rowBytes = imgRect.right / 2;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
822 image_buffer_size = image_size + sizeof(PlanarPixmapInfoYUV420);
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
823 break;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
824 case IMGFMT_UYVY:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
825 case IMGFMT_YUY2:
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
826 image_buffer_size = image_size;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
827 break;
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
828 }
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
829
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
830 qterr = DecompressSequenceBeginS(&seqId,
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
831 yuv_qt_stuff.desc,
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
832 (char *)P,
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
833 image_buffer_size,
12623
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
834 GetWindowPort(theWindow),
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
835 NULL,
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
836 NULL,
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
837 ((d_width != width) || (d_height != height)) ?
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
838 &matrix : NULL,
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
839 srcCopy,
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
840 NULL,
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
841 0,
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
842 codecLosslessQuality,
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
843 bestSpeedCodec);
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
844
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
845 if (qterr)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
846 {
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
847 mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: DecompressSequenceBeginS (%d)\n", qterr);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
848 return -1;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
849 }
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
850 }
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
851 break;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
852 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
853
15885
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
854 //Show window
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
855 RepositionWindow(theWindow, NULL, kWindowCenterOnMainScreen);
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
856 ShowWindow (theWindow);
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
857
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
858 if(vo_fs)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
859 window_fullscreen();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
860
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
861 if(vo_ontop)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
862 window_ontop();
12888
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
863
12912
1f6bb2356d18 add var vo_rootwin and -rootwin switch for mac osx
nplourde
parents: 12889
diff changeset
864 if(vo_rootwin)
12888
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
865 {
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
866 vo_fs = TRUE;
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
867 winLevel = 0;
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
868 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel]));
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
869 window_fullscreen();
3a58fa9639d4 add support for -rootwin command
nplourde
parents: 12886
diff changeset
870 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
871
15885
b2f434649dec properly redraw fullscreen window with -fs and zoom
nplourde
parents: 15881
diff changeset
872 window_resized();
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
873
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
874 return 0;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
875 }
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
876
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
877 static void check_events(void)
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
878 {
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
879 EventRef theEvent;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
880 EventTargetRef theTarget;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
881 OSStatus theErr;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
882
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
883 //Get event
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
884 theTarget = GetEventDispatcherTarget();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
885 theErr = ReceiveNextEvent(0, 0, kEventDurationNoWait,true, &theEvent);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
886 if(theErr == noErr && theEvent != NULL)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
887 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
888 SendEventToEventTarget (theEvent, theTarget);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
889 ReleaseEvent(theEvent);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
890 }
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
891 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
892
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
893 static void draw_osd(void)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
894 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
895 vo_draw_text(imgRect.right,imgRect.bottom,draw_alpha);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
896 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
897
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
898 static void flip_page(void)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
899 {
13707
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
900 if(theWindow == NULL)
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
901 return;
3fff37ed4fe7 Fixed event handling for menubar and window close button.
nplourde
parents: 13693
diff changeset
902
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
903 switch (image_format)
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
904 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
905 case IMGFMT_RGB32:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
906 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
907 CGContextDrawImage (context, bounds, image);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
908 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
909 break;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
910
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
911 case IMGFMT_YV12:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
912 case IMGFMT_IYUV:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
913 case IMGFMT_I420:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
914 case IMGFMT_UYVY:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
915 case IMGFMT_YUY2:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
916 if (EnterMoviesDone)
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
917 {
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
918 OSErr qterr;
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
919 CodecFlags flags = 0;
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
920 qterr = DecompressSequenceFrameWhen(seqId,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
921 (char *)P,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
922 image_buffer_size,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
923 0, //codecFlagUseImageBuffer,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
924 &flags,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
925 NULL,
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
926 NULL);
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
927 if (qterr)
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
928 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
929 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: DecompressSequenceFrameWhen in flip_page (%d) flags:0x%08x\n", qterr, flags);
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
930 }
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
931 }
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
932 break;
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
933 }
15723
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
934
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
935 if(!vo_quartz_fs)
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
936 {
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
937 //render resize box
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
938 CGContextBeginPath(context);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
939 CGContextSetAllowsAntialiasing(context, false);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
940 //CGContextSaveGState(context);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
941
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
942 //line white
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
943 CGContextSetRGBStrokeColor (context, 0.2, 0.2, 0.2, 0.5);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
944 CGContextMoveToPoint( context, winRect.right-1, 1); CGContextAddLineToPoint( context, winRect.right-1, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
945 CGContextMoveToPoint( context, winRect.right-1, 5); CGContextAddLineToPoint( context, winRect.right-5, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
946 CGContextMoveToPoint( context, winRect.right-1, 9); CGContextAddLineToPoint( context, winRect.right-9, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
947 CGContextStrokePath( context );
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
948
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
949 //line gray
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
950 CGContextSetRGBStrokeColor (context, 0.4, 0.4, 0.4, 0.5);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
951 CGContextMoveToPoint( context, winRect.right-1, 2); CGContextAddLineToPoint( context, winRect.right-2, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
952 CGContextMoveToPoint( context, winRect.right-1, 6); CGContextAddLineToPoint( context, winRect.right-6, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
953 CGContextMoveToPoint( context, winRect.right-1, 10); CGContextAddLineToPoint( context, winRect.right-10, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
954 CGContextStrokePath( context );
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
955
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
956 //line black
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
957 CGContextSetRGBStrokeColor (context, 0.6, 0.6, 0.6, 0.5);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
958 CGContextMoveToPoint( context, winRect.right-1, 3); CGContextAddLineToPoint( context, winRect.right-3, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
959 CGContextMoveToPoint( context, winRect.right-1, 7); CGContextAddLineToPoint( context, winRect.right-7, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
960 CGContextMoveToPoint( context, winRect.right-1, 11); CGContextAddLineToPoint( context, winRect.right-11, 1);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
961 CGContextStrokePath( context );
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
962
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
963 //CGContextRestoreGState( context );
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
964 CGContextFlush (context);
ac7dcf4a1f8a draw resize box
nplourde
parents: 15702
diff changeset
965 }
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
966
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
967 //auto hide mouse cursor and futur on-screen control?
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
968 if(vo_quartz_fs && !mouseHide)
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
969 {
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
970 int curTime = TickCount()/60;
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
971 static int lastTime = 0;
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
972
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
973 if( ((curTime - lastTime) >= 5) || (lastTime == 0) )
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
974 {
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
975 CGDisplayHideCursor(kCGDirectMainDisplay);
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
976 mouseHide = TRUE;
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
977 lastTime = curTime;
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
978 }
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
979 }
17546
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
980
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
981 //update activity every 30 seconds to prevent
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
982 //screensaver from starting up.
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
983 int curTime = TickCount()/60;
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
984 static int lastTime = 0;
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
985
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
986 if( ((curTime/ - lastTime) >= 5) || (lastTime == 0) )
17546
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
987 {
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
988 UpdateSystemActivity(UsrActivity);
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
989 lastTime = curTime;
d878e3e313eb let osx sleep if video is paused
nplourde
parents: 16892
diff changeset
990 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
991 }
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
992
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
993 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
994 {
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
995 switch (image_format)
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
996 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
997 case IMGFMT_YV12:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
998 case IMGFMT_I420:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
999 memcpy_pic(((char*)P) + P->componentInfoY.offset + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1000 x=x/2;y=y/2;w=w/2;h=h/2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1001
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1002 memcpy_pic(((char*)P) + P->componentInfoCb.offset + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1003 memcpy_pic(((char*)P) + P->componentInfoCr.offset + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1004 return 0;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1005
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1006 case IMGFMT_IYUV:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1007 memcpy_pic(((char*)P) + P->componentInfoY.offset + x + imgRect.right * y, src[0], w, h, imgRect.right, stride[0]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1008 x=x/2;y=y/2;w=w/2;h=h/2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1009
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1010 memcpy_pic(((char*)P) + P->componentInfoCr.offset + x + imgRect.right / 2 * y, src[1], w, h, imgRect.right / 2, stride[1]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1011 memcpy_pic(((char*)P) + P->componentInfoCb.offset + x + imgRect.right / 2 * y, src[2], w, h, imgRect.right / 2, stride[2]);
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1012 return 0;
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1013 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1014 return -1;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1015 }
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1016
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
1017 static int draw_frame(uint8_t *src[])
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1018 {
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1019 switch (image_format)
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1020 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1021 case IMGFMT_RGB32:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1022 memcpy(image_data,src[0],image_size);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1023 return 0;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1024
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1025 case IMGFMT_UYVY:
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1026 case IMGFMT_YUY2:
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1027 memcpy_pic(((char*)P), src[0], imgRect.right * 2, imgRect.bottom, imgRect.right * 2, imgRect.right * 2);
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1028 return 0;
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1029 }
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1030 return -1;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1031 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1032
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
1033 static int query_format(uint32_t format)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1034 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1035 image_format = format;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1036 image_qtcodec = 0;
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1037
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1038 if (format == IMGFMT_RGB32)
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1039 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1040 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1041 }
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1042
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1043 if ((format == IMGFMT_YV12) || (format == IMGFMT_IYUV) || (format == IMGFMT_I420))
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1044 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1045 image_qtcodec = kMpegYUV420CodecType; //kYUV420CodecType ?;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1046 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_ACCEPT_STRIDE;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1047 }
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1048
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1049 if (format == IMGFMT_YUY2)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1050 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1051 image_qtcodec = kComponentVideoUnsigned;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1052 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1053 }
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1054
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1055 if (format == IMGFMT_UYVY)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1056 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1057 image_qtcodec = k422YpCbCr8CodecType;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1058 return VFCAP_CSP_SUPPORTED | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1059 }
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1060
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1061 return 0;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1062 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1063
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1064 static void uninit(void)
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1065 {
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1066 OSErr qterr;
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1067
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1068 switch (image_format)
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1069 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1070 case IMGFMT_YV12:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1071 case IMGFMT_IYUV:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1072 case IMGFMT_I420:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1073 case IMGFMT_UYVY:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1074 case IMGFMT_YUY2:
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1075 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1076 if (EnterMoviesDone)
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1077 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1078 qterr = CDSequenceEnd(seqId);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1079 if (qterr)
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1080 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1081 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: CDSequenceEnd (%d)\n", qterr);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1082 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1083 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1084 break;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1085 }
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1086 default:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1087 break;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1088 }
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1089
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1090 ShowMenuBar();
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1091 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1092
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
1093 static int preinit(const char *arg)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1094 {
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1095 int parse_err = 0;
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1096
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1097 if(arg)
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1098 {
12623
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
1099 char *parse_pos = (char *)&arg[0];
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1100 while (parse_pos[0] && !parse_err)
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1101 {
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1102 if (strncmp (parse_pos, "device_id=", 10) == 0)
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1103 {
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1104 parse_pos = &parse_pos[10];
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1105 device_id = strtol(parse_pos, &parse_pos, 0);
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1106 }
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1107 if (strncmp (parse_pos, "fs_res=", 7) == 0)
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1108 {
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1109 parse_pos = &parse_pos[7];
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1110 fs_res_x = strtol(parse_pos, &parse_pos, 0);
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1111 parse_pos = &parse_pos[1];
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1112 fs_res_y = strtol(parse_pos, &parse_pos, 0);
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1113 }
12519
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1114 if (parse_pos[0] == ':') parse_pos = &parse_pos[1];
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1115 else if (parse_pos[0]) parse_err = 1;
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1116 }
12a87d539f6d choose fullscreen device with suboption device_id=#
nplourde
parents: 12517
diff changeset
1117 }
12785
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1118
14082
30db51086c84 do not bring process to front if HAVE_SDL
nplourde
parents: 14081
diff changeset
1119 #if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL)
12785
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1120 //this chunk of code is heavily based off SDL_macosx.m from SDL
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1121 //it uses an Apple private function to request foreground operation
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1122
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1123 void CPSEnableForegroundOperation(ProcessSerialNumber* psn);
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1124 ProcessSerialNumber myProc, frProc;
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1125 Boolean sameProc;
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1126
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1127 if (GetFrontProcess(&frProc) == noErr)
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1128 {
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1129 if (GetCurrentProcess(&myProc) == noErr)
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1130 {
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1131 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc)
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1132 {
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1133 CPSEnableForegroundOperation(&myProc);
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1134 }
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1135 SetFrontProcess(&myProc);
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1136 }
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1137 }
13909
07dadc3066f3 add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
nplourde
parents: 13856
diff changeset
1138 #endif
12785
33f58bfc8a1b make mplayer capable of being in the foreground by Dan Christiansen
nplourde
parents: 12624
diff changeset
1139
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1140 return 0;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1141 }
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1142
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1143 static uint32_t draw_yuv_image(mp_image_t *mpi)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1144 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1145 // ATM we're only called for planar IMGFMT
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1146 // drawing is done directly in P
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1147 // and displaying is in flip_page.
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1148 return get_image_done ? VO_TRUE : VO_FALSE;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1149 }
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1150
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1151 static uint32_t get_yuv_image(mp_image_t *mpi)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1152 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1153 if(mpi->type!=MP_IMGTYPE_EXPORT) return VO_FALSE;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1154
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1155 if(mpi->imgfmt!=image_format) return VO_FALSE;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1156
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1157 if(mpi->flags&MP_IMGFLAG_PLANAR)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1158 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1159 if (mpi->num_planes != 3)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1160 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1161 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 3 planes allowed in get_yuv_image for planar (%d) \n", mpi->num_planes);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1162 return VO_FALSE;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1163 }
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1164
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1165 mpi->planes[0]=((char*)P) + P->componentInfoY.offset;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1166 mpi->stride[0]=imgRect.right;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1167 mpi->width=imgRect.right;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1168
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1169 if(mpi->flags&MP_IMGFLAG_SWAPPED)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1170 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1171 // I420
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1172 mpi->planes[1]=((char*)P) + P->componentInfoCb.offset;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1173 mpi->planes[2]=((char*)P) + P->componentInfoCr.offset;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1174 mpi->stride[1]=imgRect.right/2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1175 mpi->stride[2]=imgRect.right/2;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1176 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1177 else
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1178 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1179 // YV12
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1180 mpi->planes[1]=((char*)P) + P->componentInfoCr.offset;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1181 mpi->planes[2]=((char*)P) + P->componentInfoCb.offset;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1182 mpi->stride[1]=imgRect.right/2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1183 mpi->stride[2]=imgRect.right/2;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1184 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1185
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1186 mpi->flags|=MP_IMGFLAG_DIRECT;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1187 get_image_done = 1;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1188 return VO_TRUE;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1189 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1190 else
12433
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1191 {
e7ed5efa4d10 More code cleanup
nplourde
parents: 12432
diff changeset
1192 // doesn't work yet
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1193 if (mpi->num_planes != 1)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1194 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1195 mp_msg(MSGT_VO, MSGL_ERR, "Quartz error: only 1 plane allowed in get_yuv_image for packed (%d) \n", mpi->num_planes);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1196 return VO_FALSE;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1197 }
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1198
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1199 mpi->planes[0] = (char*)P;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1200 mpi->stride[0] = imgRect.right * 2;
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1201 mpi->width=imgRect.right;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1202 mpi->flags|=MP_IMGFLAG_DIRECT;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1203 get_image_done = 1;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1204 return VO_TRUE;
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1205 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1206 return VO_FALSE;
12414
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1207 }
f1a9dcdfab5d Add yuv csp support
nplourde
parents: 12296
diff changeset
1208
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15909
diff changeset
1209 static int control(uint32_t request, void *data, ...)
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1210 {
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1211 switch (request)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1212 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1213 case VOCTRL_PAUSE: return (int_pause=1);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1214 case VOCTRL_RESUME: return (int_pause=0);
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
1215 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); window_fullscreen(); return VO_TRUE;
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
1216 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); window_ontop(); return VO_TRUE;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1217 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data));
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
1218 case VOCTRL_GET_PANSCAN: return VO_TRUE;
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1219 case VOCTRL_SET_PANSCAN: window_panscan(); return VO_TRUE;
13795
ac35862cbc16 enable pan-scan + menu option
nplourde
parents: 13793
diff changeset
1220
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1221 case VOCTRL_GET_IMAGE:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1222 switch (image_format)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1223 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1224 case IMGFMT_YV12:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1225 case IMGFMT_IYUV:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1226 case IMGFMT_I420:
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1227 case IMGFMT_UYVY:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1228 case IMGFMT_YUY2:
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1229 return get_yuv_image(data);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1230 break;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1231 default:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1232 break;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1233 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1234 case VOCTRL_DRAW_IMAGE:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1235 switch (image_format)
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1236 {
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1237 case IMGFMT_YV12:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1238 case IMGFMT_IYUV:
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1239 case IMGFMT_I420:
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1240 case IMGFMT_UYVY:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1241 case IMGFMT_YUY2:
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1242 return draw_yuv_image(data);
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1243 break;
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1244 default:
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1245 break;
12424
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1246 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1247 }
09f8724dd0b0 Cosmetic change std ident style
nplourde
parents: 12423
diff changeset
1248 return VO_NOTIMPL;
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1249 }
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1250
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1251 void window_resized()
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1252 {
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1253 float aspectX;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1254 float aspectY;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1255
13855
493a0dd78307 set aqua default theme
nplourde
parents: 13841
diff changeset
1256 int padding = 0;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1257
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1258 uint32_t d_width;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1259 uint32_t d_height;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1260
13779
a03e87034921 fix windows resizing ui glitch
nplourde
parents: 13734
diff changeset
1261 CGRect tmpBounds;
13734
efefaa53aaf9 Enable live resize
nplourde
parents: 13722
diff changeset
1262
12623
e64e106c8798 removed buggy rgb32 support
nplourde
parents: 12519
diff changeset
1263 GetPortBounds( GetWindowPort(theWindow), &winRect );
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1264
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1265 if(vo_keepaspect)
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1266 {
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1267 aspect( &d_width, &d_height, A_NOZOOM);
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1268 d_height = ((float)d_width/movie_aspect);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1269
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1270 aspectX = (float)((float)winRect.right/(float)d_width);
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1271 aspectY = (float)((float)(winRect.bottom)/(float)d_height);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1272
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1273 if((d_height*aspectX)>(winRect.bottom))
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1274 {
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1275 padding = (winRect.right - d_width*aspectY)/2;
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1276 SetRect(&dstRect, padding, 0, d_width*aspectY+padding, d_height*aspectY);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1277 }
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1278 else
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1279 {
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1280 padding = ((winRect.bottom) - d_height*aspectX)/2;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1281 SetRect(&dstRect, 0, padding, (d_width*aspectX), d_height*aspectX+padding);
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1282 }
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1283 }
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1284 else
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1285 {
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1286 SetRect(&dstRect, 0, 0, winRect.right, winRect.bottom);
13792
d603c33bb3d3 menu option to set desired movie aspect & keep aspect on window resize
nplourde
parents: 13791
diff changeset
1287 }
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1288
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1289 switch (image_format)
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1290 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1291 case IMGFMT_RGB32:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1292 {
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1293 bounds = CGRectMake(dstRect.left, dstRect.top, dstRect.right-dstRect.left, dstRect.bottom-dstRect.top);
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1294 CreateCGContextForPort (GetWindowPort (theWindow), &context);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1295 break;
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1296 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1297 case IMGFMT_YV12:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1298 case IMGFMT_IYUV:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1299 case IMGFMT_I420:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1300 case IMGFMT_UYVY:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1301 case IMGFMT_YUY2:
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1302 {
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1303 long scale_X = FixDiv(Long2Fix(dstRect.right - dstRect.left),Long2Fix(imgRect.right));
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1304 long scale_Y = FixDiv(Long2Fix(dstRect.bottom - dstRect.top),Long2Fix(imgRect.bottom));
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1305
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1306 SetIdentityMatrix(&matrix);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1307 if (((dstRect.right - dstRect.left) != imgRect.right) || ((dstRect.bottom - dstRect.right) != imgRect.bottom))
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1308 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1309 ScaleMatrix(&matrix, scale_X, scale_Y, 0, 0);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1310
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1311 if (padding > 0)
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1312 {
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1313 TranslateMatrix(&matrix, Long2Fix(dstRect.left), Long2Fix(dstRect.top));
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1314 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1315 }
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1316
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1317 SetDSequenceMatrix(seqId, &matrix);
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1318 break;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1319 }
13124
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1320 default:
d830a4d6ffa6 add rgb32 csp support
nplourde
parents: 13119
diff changeset
1321 break;
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1322 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1323
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1324 //Clear Background
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1325 tmpBounds = CGRectMake( 0, 0, winRect.right, winRect.bottom);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1326 CreateCGContextForPort(GetWindowPort(theWindow),&context);
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1327 CGContextFillRect(context, tmpBounds);
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1328 }
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1329
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1330 void window_ontop()
12460
77cca80b1f27 Event Handling Makeover
nplourde
parents: 12433
diff changeset
1331 {
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1332 if(!vo_quartz_fs)
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1333 {
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1334 //Cycle between level
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1335 winLevel++;
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1336 if(winLevel>2)
15524
21252725b639 Toggle only between ontop and normal.
nplourde
parents: 14699
diff changeset
1337 winLevel = 1;
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1338 }
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1339 SetWindowGroupLevel(winGroup, CGWindowLevelForKey(levelList[winLevel]));
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1340 }
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1341
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1342 void window_fullscreen()
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1343 {
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1344 static Ptr restoreState = NULL;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1345
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1346 //go fullscreen
12432
877d25c4b237 Switch rgb32 from QD to QT
nplourde
parents: 12425
diff changeset
1347 if(vo_fs)
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1348 {
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1349 if(winLevel != 0)
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1350 {
13841
394deaee5d21 do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents: 13840
diff changeset
1351 if(device_id == 0)
394deaee5d21 do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents: 13840
diff changeset
1352 {
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
1353 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
1354 CGDisplayHideCursor(kCGDirectMainDisplay);
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
1355 mouseHide = TRUE;
13841
394deaee5d21 do not hide mouse and menubar in fulscreen if not using main device
nplourde
parents: 13840
diff changeset
1356 }
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1357
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1358 if(fs_res_x != 0 || fs_res_y != 0)
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1359 {
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1360 BeginFullScreen( &restoreState, deviceHdl, &fs_res_x, &fs_res_y, NULL, NULL, NULL);
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1361
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1362 //Get Main device info///////////////////////////////////////////////////
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1363 deviceRect = (*deviceHdl)->gdRect;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1364
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1365 device_width = deviceRect.right;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1366 device_height = deviceRect.bottom;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1367 }
12826
fb55f94f3001 Add Window Level Key, Can switch mode with T key
nplourde
parents: 12785
diff changeset
1368 }
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1369
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1370 //save old window size
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1371 if (!vo_quartz_fs)
13818
9f707a805967 window now save is old position when going in fullscreen or while using resize preset
nplourde
parents: 13796
diff changeset
1372 {
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1373 GetWindowPortBounds(theWindow, &oldWinRect);
13818
9f707a805967 window now save is old position when going in fullscreen or while using resize preset
nplourde
parents: 13796
diff changeset
1374 GetWindowBounds(theWindow, kWindowContentRgn, &oldWinBounds);
9f707a805967 window now save is old position when going in fullscreen or while using resize preset
nplourde
parents: 13796
diff changeset
1375 }
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1376
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1377 //go fullscreen
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1378 panscan_calc();
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1379 ChangeWindowAttributes(theWindow, kWindowNoShadowAttribute, 0);
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1380 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1);
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1381 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1382
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1383 vo_quartz_fs = 1;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1384 }
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1385 else //go back to windowed mode
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1386 {
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
1387 vo_quartz_fs = 0;
13788
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1388 if(restoreState != NULL)
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1389 {
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1390 EndFullScreen(restoreState, NULL);
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1391
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1392 //Get Main device info///////////////////////////////////////////////////
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1393 deviceRect = (*deviceHdl)->gdRect;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1394
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1395 device_width = deviceRect.right;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1396 device_height = deviceRect.bottom;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1397 restoreState = NULL;
ced61fa921ca let you choose fullscreen resolution for slower system
nplourde
parents: 13787
diff changeset
1398 }
15881
ab6d02448e57 auto hide menubar and cursor in fullscreen
nplourde
parents: 15723
diff changeset
1399 SetSystemUIMode( kUIModeNormal, NULL);
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1400
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1401 //show mouse cursor
18057
0e7291ee4b6b Replace deprecated function
nplourde
parents: 17546
diff changeset
1402 CGDisplayShowCursor(kCGDirectMainDisplay);
15892
c8e414e49fef more fullscreen behaviour fix for mouse cursor
nplourde
parents: 15885
diff changeset
1403 mouseHide = FALSE;
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1404
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1405 //revert window to previous setting
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1406 ChangeWindowAttributes(theWindow, 0, kWindowNoShadowAttribute);
12487
deec5d737a61 re-use same window when playing multiple files
nplourde
parents: 12460
diff changeset
1407 SizeWindow(theWindow, oldWinRect.right, oldWinRect.bottom,1);
13818
9f707a805967 window now save is old position when going in fullscreen or while using resize preset
nplourde
parents: 13796
diff changeset
1408 MoveWindow(theWindow, oldWinBounds.left, oldWinBounds.top, 1);
12296
1da74cbaf324 Add Fullscreen, Ontop and OSD support
nplourde
parents: 12120
diff changeset
1409 }
15702
9dbea0b7f3ce Fix Live Resize to match vo_macosx behavior
nplourde
parents: 15524
diff changeset
1410 window_resized();
12120
56e4423f16be Quartz/MacOSX video output module by Nicolas Plourde
alex
parents:
diff changeset
1411 }
13840
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1412
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1413 void window_panscan()
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1414 {
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1415 panscan_calc();
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1416
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1417 if(vo_panscan > 0)
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1418 CheckMenuItem (aspectMenu, 2, 1);
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1419 else
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1420 CheckMenuItem (aspectMenu, 2, 0);
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1421
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1422 if(vo_quartz_fs)
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1423 {
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1424 MoveWindow(theWindow, deviceRect.left-(vo_panscan_x >> 1), deviceRect.top-(vo_panscan_y >> 1), 1);
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1425 SizeWindow(theWindow, device_width+vo_panscan_x, device_height+vo_panscan_y,1);
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1426 }
62af31e1bdc8 more panscan fix
nplourde
parents: 13818
diff changeset
1427 }