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