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