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