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