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