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