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