Mercurial > mplayer.hg
annotate libvo/vo_macosx.m @ 24434:8b5437063481
Fix 10l typo in syncword
author | reimar |
---|---|
date | Fri, 14 Sep 2007 12:39:02 +0000 |
parents | d4adc8503dd5 |
children | 6f56399be56c |
rev | line source |
---|---|
15289 | 1 /* |
2 vo_macosx.m | |
3 by Nicolas Plourde <nicolasplourde@gmail.com> | |
4 | |
5 MPlayer Mac OSX video out module. | |
6 Copyright (c) Nicolas Plourde - 2005 | |
7 */ | |
8 | |
9 #import "vo_macosx.h" | |
16385 | 10 #include <sys/types.h> |
11 #include <sys/ipc.h> | |
12 #include <sys/shm.h> | |
15289 | 13 |
14 //MPLAYER | |
15 #include "config.h" | |
16 #include "fastmemcpy.h" | |
17 #include "video_out.h" | |
18 #include "video_out_internal.h" | |
19 #include "aspect.h" | |
20 #include "mp_msg.h" | |
21 #include "m_option.h" | |
22 | |
23 #include "input/input.h" | |
24 #include "input/mouse.h" | |
25 | |
26 #include "osdep/keycodes.h" | |
27 | |
28 //Cocoa | |
16385 | 29 NSProxy *mplayerosxProxy; |
15611 | 30 MPlayerOpenGLView *mpGLView; |
15289 | 31 NSAutoreleasePool *autoreleasepool; |
32 OSType pixelFormat; | |
33 | |
16385 | 34 //shared memory |
35 int shm_id; | |
36 struct shmid_ds shm_desc; | |
37 BOOL shared_buffer = false; | |
38 | |
15728 | 39 //Screen |
40 int screen_id; | |
41 BOOL screen_force; | |
42 NSRect screen_frame; | |
43 NSScreen *screen_handle; | |
44 NSArray *screen_array; | |
15289 | 45 |
46 //image | |
47 unsigned char *image_data; | |
48 static uint32_t image_width; | |
49 static uint32_t image_height; | |
50 static uint32_t image_depth; | |
51 static uint32_t image_bytes; | |
52 static uint32_t image_format; | |
53 | |
54 //vo | |
55 static int isFullscreen; | |
15320 | 56 static int isOntop; |
15327 | 57 static int isRootwin; |
15289 | 58 extern float monitor_aspect; |
59 extern float movie_aspect; | |
60 static float old_movie_aspect; | |
61 | |
15731 | 62 static float winAlpha = 1; |
15289 | 63 static int int_pause = 0; |
64 | |
65 static vo_info_t info = | |
66 { | |
67 "Mac OSX Core Video", | |
68 "macosx", | |
69 "Nicolas Plourde <nicolas.plourde@gmail.com>", | |
70 "" | |
71 }; | |
72 | |
73 LIBVO_EXTERN(macosx) | |
74 | |
75 extern void mplayer_put_key(int code); | |
76 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)); | |
77 | |
78 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) | |
79 { | |
80 switch (image_format) | |
81 { | |
82 case IMGFMT_RGB32: | |
83 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width); | |
84 break; | |
85 case IMGFMT_YUY2: | |
86 vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2); | |
87 break; | |
88 } | |
89 } | |
90 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
91 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) |
15289 | 92 { |
16385 | 93 |
15728 | 94 //init screen |
95 screen_array = [NSScreen screens]; | |
96 if(screen_id < [screen_array count]) | |
15289 | 97 { |
15728 | 98 screen_handle = [screen_array objectAtIndex:screen_id]; |
15289 | 99 } |
15728 | 100 else |
101 { | |
102 mp_msg(MSGT_VO, MSGL_FATAL, "Get device error: Device ID %d do not exist, falling back to main device.\n", screen_id); | |
103 screen_handle = [screen_array objectAtIndex:0]; | |
104 screen_id = 0; | |
105 } | |
106 screen_frame = [screen_handle frame]; | |
16385 | 107 |
15289 | 108 //misc mplayer setup |
109 image_width = width; | |
110 image_height = height; | |
111 switch (image_format) | |
112 { | |
113 case IMGFMT_BGR32: | |
114 case IMGFMT_RGB32: | |
115 image_depth = 32; | |
116 break; | |
16385 | 117 case IMGFMT_YUY2: |
15289 | 118 image_depth = 16; |
119 break; | |
120 } | |
121 image_bytes = (image_depth + 7) / 8; | |
18878 | 122 image_data = malloc(image_width*image_height*image_bytes); |
16385 | 123 |
124 if(!shared_buffer) | |
125 { | |
126 monitor_aspect = (float)screen_frame.size.width/(float)screen_frame.size.height; | |
127 | |
128 //set aspect | |
129 panscan_init(); | |
130 aspect_save_orig(width,height); | |
131 aspect_save_prescale(d_width,d_height); | |
132 aspect_save_screenres(screen_frame.size.width, screen_frame.size.height); | |
133 aspect((int *)&d_width,(int *)&d_height,A_NOZOOM); | |
134 | |
135 movie_aspect = (float)d_width/(float)d_height; | |
136 old_movie_aspect = movie_aspect; | |
15726 | 137 |
16385 | 138 vo_fs = flags & VOFLAG_FULLSCREEN; |
139 | |
140 //config OpenGL View | |
141 [mpGLView config]; | |
142 [mpGLView reshape]; | |
143 } | |
144 else | |
145 { | |
146 movie_aspect = (float)d_width/(float)d_height; | |
147 | |
148 shm_id = shmget(9849, image_width*image_height*image_bytes, IPC_CREAT | 0666); | |
149 if (shm_id == -1) | |
150 { | |
151 perror("vo_mplayer shmget: "); | |
152 return 1; | |
153 } | |
154 | |
155 image_data = shmat(shm_id, NULL, 0); | |
156 if (!image_data) | |
157 { | |
158 perror("vo_mplayer shmat: "); | |
159 return 1; | |
160 } | |
161 | |
162 //connnect to mplayerosx | |
163 mplayerosxProxy=[NSConnection rootProxyForConnectionWithRegisteredName:@"mplayerosx" host:nil]; | |
18057 | 164 [mplayerosxProxy startWithWidth: image_width withHeight: image_height withBytes: image_bytes withAspect:(int)(movie_aspect*100)]; |
16385 | 165 } |
15289 | 166 return 0; |
167 } | |
168 | |
169 static void check_events(void) | |
170 { | |
15611 | 171 [mpGLView check_events]; |
15289 | 172 } |
173 | |
174 static void draw_osd(void) | |
175 { | |
176 vo_draw_text(image_width, image_height, draw_alpha); | |
177 } | |
178 | |
179 static void flip_page(void) | |
180 { | |
16385 | 181 if(shared_buffer) |
182 [mplayerosxProxy render]; | |
183 else | |
184 [mpGLView render]; | |
15289 | 185 } |
186 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
187 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
15289 | 188 { |
15611 | 189 [mpGLView setCurrentTexture]; |
15289 | 190 return 0; |
191 } | |
192 | |
193 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
194 static int draw_frame(uint8_t *src[]) |
15289 | 195 { |
196 switch (image_format) | |
197 { | |
198 case IMGFMT_BGR32: | |
199 case IMGFMT_RGB32: | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23381
diff
changeset
|
200 fast_memcpy(image_data, src[0], image_width*image_height*image_bytes); |
15289 | 201 break; |
202 | |
203 case IMGFMT_YUY2: | |
204 memcpy_pic(image_data, src[0], image_width * 2, image_height, image_width * 2, image_width * 2); | |
205 break; | |
206 } | |
16385 | 207 |
208 if(!shared_buffer) | |
209 [mpGLView setCurrentTexture]; | |
210 | |
15289 | 211 return 0; |
212 } | |
213 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
214 static int query_format(uint32_t format) |
15289 | 215 { |
216 image_format = format; | |
217 | |
218 switch(format) | |
219 { | |
220 case IMGFMT_YUY2: | |
221 pixelFormat = kYUVSPixelFormat; | |
222 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; | |
223 | |
224 case IMGFMT_RGB32: | |
225 case IMGFMT_BGR32: | |
226 pixelFormat = k32ARGBPixelFormat; | |
227 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN; | |
228 } | |
229 return 0; | |
230 } | |
231 | |
232 static void uninit(void) | |
233 { | |
16385 | 234 if(shared_buffer) |
235 { | |
236 [mplayerosxProxy stop]; | |
237 | |
238 if (shmdt(image_data) == -1) | |
239 mp_msg(MSGT_VO, MSGL_FATAL, "uninit: shmdt failed\n"); | |
240 | |
241 if (shmctl(shm_id, IPC_RMID, &shm_desc) == -1) | |
242 mp_msg(MSGT_VO, MSGL_FATAL, "uninit: shmctl failed\n"); | |
243 } | |
244 | |
21551 | 245 SetSystemUIMode( kUIModeNormal, 0); |
246 CGDisplayShowCursor(kCGDirectMainDisplay); | |
247 | |
248 if(mpGLView) | |
249 { | |
250 [autoreleasepool release]; | |
251 } | |
15289 | 252 } |
253 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
254 static int preinit(const char *arg) |
15289 | 255 { |
256 int parse_err = 0; | |
257 | |
15728 | 258 if(arg) |
259 { | |
260 char *parse_pos = (char *)&arg[0]; | |
261 while (parse_pos[0] && !parse_err) | |
262 { | |
263 if (strncmp (parse_pos, "device_id=", 10) == 0) | |
264 { | |
265 parse_pos = &parse_pos[10]; | |
266 screen_id = strtol(parse_pos, &parse_pos, 0); | |
267 screen_force = YES; | |
268 } | |
16385 | 269 if (strncmp (parse_pos, "shared_buffer", 13) == 0) |
270 { | |
271 parse_pos = &parse_pos[13]; | |
272 shared_buffer = YES; | |
273 } | |
15728 | 274 if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; |
275 else if (parse_pos[0]) parse_err = 1; | |
276 } | |
277 } | |
278 | |
15737
0c3939433cef
set nsapp and setup cocoa with NSApplicationLoad
nplourde
parents:
15736
diff
changeset
|
279 NSApplicationLoad(); |
15289 | 280 autoreleasepool = [[NSAutoreleasePool alloc] init]; |
15737
0c3939433cef
set nsapp and setup cocoa with NSApplicationLoad
nplourde
parents:
15736
diff
changeset
|
281 NSApp = [NSApplication sharedApplication]; |
15726 | 282 |
16385 | 283 if(!shared_buffer) |
16144 | 284 { |
17358
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
285 #if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
286 //this chunk of code is heavily based off SDL_macosx.m from SDL |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
287 //it uses an Apple private function to request foreground operation |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
288 void CPSEnableForegroundOperation(ProcessSerialNumber* psn); |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
289 ProcessSerialNumber myProc, frProc; |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
290 Boolean sameProc; |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
291 |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
292 if (GetFrontProcess(&frProc) == noErr) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
293 { |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
294 if (GetCurrentProcess(&myProc) == noErr) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
295 { |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
296 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc) |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
297 { |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
298 CPSEnableForegroundOperation(&myProc); |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
299 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
300 SetFrontProcess(&myProc); |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
301 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
302 } |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
303 #endif |
22ec2e9cb530
do not give focus to vo_macosx in shared buffer mode. Patch by Hector Chu<hectorchu@gmail.com>
nplourde
parents:
16385
diff
changeset
|
304 |
16385 | 305 if(!mpGLView) |
306 { | |
307 mpGLView = [[MPlayerOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:[MPlayerOpenGLView defaultPixelFormat]]; | |
308 [mpGLView autorelease]; | |
309 } | |
310 | |
311 [mpGLView display]; | |
312 [mpGLView preinit]; | |
16144 | 313 } |
314 | |
15289 | 315 return 0; |
316 } | |
317 | |
16171
fd51fd1ff231
Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents:
16145
diff
changeset
|
318 static int control(uint32_t request, void *data, ...) |
15289 | 319 { |
320 switch (request) | |
321 { | |
322 case VOCTRL_PAUSE: return (int_pause=1); | |
323 case VOCTRL_RESUME: return (int_pause=0); | |
324 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); | |
15611 | 325 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); [mpGLView ontop]; return VO_TRUE; |
326 case VOCTRL_ROOTWIN: vo_rootwin = (!(vo_rootwin)); [mpGLView rootwin]; return VO_TRUE; | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
327 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); [mpGLView fullscreen: NO]; return VO_TRUE; |
15289 | 328 case VOCTRL_GET_PANSCAN: return VO_TRUE; |
15611 | 329 case VOCTRL_SET_PANSCAN: [mpGLView panscan]; return VO_TRUE; |
15289 | 330 } |
331 return VO_NOTIMPL; | |
332 } | |
333 | |
334 ////////////////////////////////////////////////////////////////////////// | |
335 // NSOpenGLView Subclass | |
336 ////////////////////////////////////////////////////////////////////////// | |
15611 | 337 @implementation MPlayerOpenGLView |
24076 | 338 - (void) preinit |
15289 | 339 { |
15726 | 340 //init menu |
341 [self initMenu]; | |
342 | |
343 //create window | |
15747
fbf14e1ab725
osx 10.3 dont like to have a window init with no size
nplourde
parents:
15737
diff
changeset
|
344 window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) |
15726 | 345 styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask |
346 backing:NSBackingStoreBuffered defer:NO]; | |
347 | |
16144 | 348 [window autorelease]; |
15726 | 349 [window setDelegate:mpGLView]; |
350 [window setContentView:mpGLView]; | |
351 [window setInitialFirstResponder:mpGLView]; | |
352 [window setAcceptsMouseMovedEvents:YES]; | |
353 [window setTitle:@"MPlayer - The Movie Player"]; | |
354 | |
355 isFullscreen = 0; | |
15855 | 356 winSizeMult = 1; |
15726 | 357 } |
358 | |
24076 | 359 - (void) config |
15726 | 360 { |
361 uint32_t d_width; | |
362 uint32_t d_height; | |
363 | |
15610 | 364 long swapInterval = 1; |
15726 | 365 |
366 NSRect frame; | |
15289 | 367 CVReturn error = kCVReturnSuccess; |
368 | |
15728 | 369 //config window |
15726 | 370 aspect((int *)&d_width, (int *)&d_height,A_NOZOOM); |
371 frame = NSMakeRect(0, 0, d_width, d_height); | |
372 [window setContentSize: frame.size]; | |
15570 | 373 |
15289 | 374 //create OpenGL Context |
375 glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil]; | |
15647 | 376 |
15289 | 377 [self setOpenGLContext:glContext]; |
15647 | 378 [glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; |
15289 | 379 [glContext setView:self]; |
380 [glContext makeCurrentContext]; | |
381 | |
15647 | 382 error = CVPixelBufferCreateWithBytes( NULL, image_width, image_height, pixelFormat, image_data, image_width*image_bytes, NULL, NULL, NULL, ¤tFrameBuffer); |
15289 | 383 if(error != kCVReturnSuccess) |
384 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create Pixel Buffer(%d)\n", error); | |
385 | |
386 error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache); | |
387 if(error != kCVReturnSuccess) | |
388 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture Cache(%d)\n", error); | |
389 | |
390 error = CVOpenGLTextureCacheCreateTextureFromImage( NULL, textureCache, currentFrameBuffer, 0, &texture); | |
391 if(error != kCVReturnSuccess) | |
392 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); | |
393 | |
15728 | 394 //show window |
395 [window center]; | |
396 [window makeKeyAndOrderFront:mpGLView]; | |
397 | |
15726 | 398 if(vo_rootwin) |
399 [mpGLView rootwin]; | |
400 | |
401 if(vo_fs) | |
402 [mpGLView fullscreen: NO]; | |
403 | |
404 if(vo_ontop) | |
405 [mpGLView ontop]; | |
15289 | 406 } |
407 | |
408 /* | |
15570 | 409 Init Menu |
410 */ | |
411 - (void)initMenu | |
412 { | |
21395 | 413 NSMenu *menu, *aspectMenu; |
15570 | 414 NSMenuItem *menuItem; |
415 | |
416 [NSApp setMainMenu:[[NSMenu alloc] init]]; | |
417 | |
418 //Create Movie Menu | |
419 menu = [[NSMenu alloc] initWithTitle:@"Movie"]; | |
420 menuItem = [[NSMenuItem alloc] initWithTitle:@"Half Size" action:@selector(menuAction:) keyEquivalent:@"0"]; [menu addItem:menuItem]; | |
421 kHalfScreenCmd = menuItem; | |
422 menuItem = [[NSMenuItem alloc] initWithTitle:@"Normal Size" action:@selector(menuAction:) keyEquivalent:@"1"]; [menu addItem:menuItem]; | |
423 kNormalScreenCmd = menuItem; | |
424 menuItem = [[NSMenuItem alloc] initWithTitle:@"Double Size" action:@selector(menuAction:) keyEquivalent:@"2"]; [menu addItem:menuItem]; | |
425 kDoubleScreenCmd = menuItem; | |
426 menuItem = [[NSMenuItem alloc] initWithTitle:@"Full Size" action:@selector(menuAction:) keyEquivalent:@"f"]; [menu addItem:menuItem]; | |
427 kFullScreenCmd = menuItem; | |
15909 | 428 menuItem = (NSMenuItem *)[NSMenuItem separatorItem]; [menu addItem:menuItem]; |
15570 | 429 |
430 aspectMenu = [[NSMenu alloc] initWithTitle:@"Aspect Ratio"]; | |
431 menuItem = [[NSMenuItem alloc] initWithTitle:@"Keep" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
432 if(vo_keepaspect) [menuItem setState:NSOnState]; | |
433 kKeepAspectCmd = menuItem; | |
434 menuItem = [[NSMenuItem alloc] initWithTitle:@"Pan-Scan" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
435 if(vo_panscan) [menuItem setState:NSOnState]; | |
436 kPanScanCmd = menuItem; | |
15909 | 437 menuItem = (NSMenuItem *)[NSMenuItem separatorItem]; [aspectMenu addItem:menuItem]; |
15570 | 438 menuItem = [[NSMenuItem alloc] initWithTitle:@"Original" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; |
439 kAspectOrgCmd = menuItem; | |
440 menuItem = [[NSMenuItem alloc] initWithTitle:@"4:3" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
441 kAspectFullCmd = menuItem; | |
442 menuItem = [[NSMenuItem alloc] initWithTitle:@"16:9" action:@selector(menuAction:) keyEquivalent:@""]; [aspectMenu addItem:menuItem]; | |
443 kAspectWideCmd = menuItem; | |
444 menuItem = [[NSMenuItem alloc] initWithTitle:@"Aspect Ratio" action:nil keyEquivalent:@""]; | |
445 [menuItem setSubmenu:aspectMenu]; | |
446 [menu addItem:menuItem]; | |
447 [aspectMenu release]; | |
448 | |
449 //Add to menubar | |
450 menuItem = [[NSMenuItem alloc] initWithTitle:@"Movie" action:nil keyEquivalent:@""]; | |
451 [menuItem setSubmenu:menu]; | |
452 [[NSApp mainMenu] addItem:menuItem]; | |
453 | |
454 //Create Window Menu | |
455 menu = [[NSMenu alloc] initWithTitle:@"Window"]; | |
456 | |
457 menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [menu addItem:menuItem]; | |
458 menuItem = [[NSMenuItem alloc] initWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; [menu addItem:menuItem]; | |
459 | |
460 //Add to menubar | |
461 menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; | |
462 [menuItem setSubmenu:menu]; | |
463 [[NSApp mainMenu] addItem:menuItem]; | |
464 [NSApp setWindowsMenu:menu]; | |
465 | |
466 [menu release]; | |
467 [menuItem release]; | |
468 } | |
469 | |
470 /* | |
471 Menu Action | |
472 */ | |
473 - (void)menuAction:(id)sender | |
474 { | |
475 uint32_t d_width; | |
476 uint32_t d_height; | |
477 NSRect frame; | |
478 | |
479 aspect((int *)&d_width, (int *)&d_height,A_NOZOOM); | |
15731 | 480 |
481 if(sender == kQuitCmd) | |
482 { | |
483 mplayer_put_key(KEY_ESC); | |
484 } | |
15570 | 485 |
486 if(sender == kHalfScreenCmd) | |
487 { | |
488 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
489 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 490 } |
491 | |
15855 | 492 winSizeMult = 0.5; |
493 frame.size.width = (d_width*winSizeMult); | |
494 frame.size.height = ((d_width/movie_aspect)*winSizeMult); | |
15570 | 495 [window setContentSize: frame.size]; |
496 [self reshape]; | |
497 } | |
498 if(sender == kNormalScreenCmd) | |
499 { | |
500 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
501 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 502 } |
503 | |
15855 | 504 winSizeMult = 1; |
15570 | 505 frame.size.width = d_width; |
506 frame.size.height = d_width/movie_aspect; | |
507 [window setContentSize: frame.size]; | |
508 [self reshape]; | |
509 } | |
510 if(sender == kDoubleScreenCmd) | |
511 { | |
512 if(isFullscreen) { | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
513 vo_fs = (!(vo_fs)); [self fullscreen:NO]; |
15570 | 514 } |
515 | |
15855 | 516 winSizeMult = 2; |
517 frame.size.width = d_width*winSizeMult; | |
518 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
15570 | 519 [window setContentSize: frame.size]; |
520 [self reshape]; | |
521 } | |
522 if(sender == kFullScreenCmd) | |
523 { | |
524 vo_fs = (!(vo_fs)); | |
21546
253a1e98bfe3
vo_macosx.m disable window animation when going to fullscreen
nplourde
parents:
21395
diff
changeset
|
525 [self fullscreen:NO]; |
15570 | 526 } |
527 | |
528 if(sender == kKeepAspectCmd) | |
529 { | |
530 vo_keepaspect = (!(vo_keepaspect)); | |
531 if(vo_keepaspect) | |
532 [kKeepAspectCmd setState:NSOnState]; | |
533 else | |
534 [kKeepAspectCmd setState:NSOffState]; | |
15909 | 535 |
536 [self reshape]; | |
15570 | 537 } |
538 | |
539 if(sender == kPanScanCmd) | |
540 { | |
541 vo_panscan = (!(vo_panscan)); | |
542 if(vo_panscan) | |
543 [kPanScanCmd setState:NSOnState]; | |
544 else | |
545 [kPanScanCmd setState:NSOffState]; | |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
546 |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
547 [self panscan]; |
15570 | 548 } |
549 | |
550 if(sender == kAspectOrgCmd) | |
551 { | |
552 movie_aspect = old_movie_aspect; | |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
553 |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
554 if(isFullscreen) |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
555 { |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
556 [self reshape]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
557 } |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
558 else |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
559 { |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
560 frame.size.width = d_width*winSizeMult; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
561 frame.size.height = (d_width/movie_aspect)*winSizeMult; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
562 [window setContentSize: frame.size]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
563 [self reshape]; |
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
564 } |
15570 | 565 } |
566 | |
567 if(sender == kAspectFullCmd) | |
568 { | |
569 movie_aspect = 4.0f/3.0f; | |
15882 | 570 |
571 if(isFullscreen) | |
572 { | |
573 [self reshape]; | |
574 } | |
575 else | |
576 { | |
577 frame.size.width = d_width*winSizeMult; | |
578 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
579 [window setContentSize: frame.size]; | |
580 [self reshape]; | |
581 } | |
15570 | 582 } |
583 | |
584 if(sender == kAspectWideCmd) | |
585 { | |
586 movie_aspect = 16.0f/9.0f; | |
15882 | 587 |
588 if(isFullscreen) | |
589 { | |
590 [self reshape]; | |
591 } | |
592 else | |
593 { | |
594 frame.size.width = d_width*winSizeMult; | |
595 frame.size.height = (d_width/movie_aspect)*winSizeMult; | |
596 [window setContentSize: frame.size]; | |
597 [self reshape]; | |
598 } | |
15570 | 599 } |
600 } | |
601 | |
602 /* | |
15289 | 603 Setup OpenGL |
604 */ | |
605 - (void)prepareOpenGL | |
606 { | |
15339 | 607 glEnable(GL_BLEND); |
15289 | 608 glDisable(GL_DEPTH_TEST); |
609 glDepthMask(GL_FALSE); | |
610 glDisable(GL_CULL_FACE); | |
611 [self reshape]; | |
612 } | |
613 | |
614 /* | |
615 reshape OpenGL viewport | |
616 */ | |
617 - (void)reshape | |
618 { | |
619 uint32_t d_width; | |
620 uint32_t d_height; | |
621 float aspectX; | |
622 float aspectY; | |
623 int padding = 0; | |
624 | |
625 NSRect frame = [self frame]; | |
626 | |
627 glViewport(0, 0, frame.size.width, frame.size.height); | |
628 glMatrixMode(GL_PROJECTION); | |
629 glLoadIdentity(); | |
630 glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0); | |
631 glMatrixMode(GL_MODELVIEW); | |
632 glLoadIdentity(); | |
633 | |
15729 | 634 //set texture frame |
15289 | 635 if(vo_keepaspect) |
636 { | |
15571 | 637 aspect( (int *)&d_width, (int *)&d_height, A_NOZOOM); |
15289 | 638 d_height = ((float)d_width/movie_aspect); |
639 | |
640 aspectX = (float)((float)frame.size.width/(float)d_width); | |
641 aspectY = (float)((float)(frame.size.height)/(float)d_height); | |
642 | |
643 if((d_height*aspectX)>(frame.size.height)) | |
644 { | |
645 padding = (frame.size.width - d_width*aspectY)/2; | |
15729 | 646 textureFrame = NSMakeRect(padding, 0, d_width*aspectY+padding, d_height*aspectY); |
15289 | 647 } |
648 else | |
649 { | |
650 padding = ((frame.size.height) - d_height*aspectX)/2; | |
15729 | 651 textureFrame = NSMakeRect(0, padding, d_width*aspectX, d_height*aspectX+padding); |
15289 | 652 } |
653 } | |
654 else | |
655 { | |
15729 | 656 textureFrame = frame; |
15289 | 657 } |
658 } | |
659 | |
660 /* | |
661 Render frame | |
662 */ | |
663 - (void) render | |
664 { | |
21395 | 665 int curTime; |
666 static int lastTime; | |
667 | |
15289 | 668 glClear(GL_COLOR_BUFFER_BIT); |
669 | |
670 glEnable(CVOpenGLTextureGetTarget(texture)); | |
671 glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture)); | |
672 | |
673 glColor3f(1,1,1); | |
674 glBegin(GL_QUADS); | |
15729 | 675 glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); |
676 glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i( textureFrame.origin.x-(vo_panscan_x >> 1), textureFrame.size.height+(vo_panscan_y >> 1)); | |
677 glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i( textureFrame.size.width+(vo_panscan_x >> 1), textureFrame.size.height+(vo_panscan_y >> 1)); | |
678 glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i( textureFrame.size.width+(vo_panscan_x >> 1), textureFrame.origin.y-(vo_panscan_y >> 1)); | |
15289 | 679 glEnd(); |
15339 | 680 glDisable(CVOpenGLTextureGetTarget(texture)); |
681 | |
682 //render resize box | |
683 if(!isFullscreen) | |
684 { | |
685 NSRect frame = [self frame]; | |
686 | |
687 glBegin(GL_LINES); | |
688 glColor4f(0.2, 0.2, 0.2, 0.5); | |
689 glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1); | |
690 glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1); | |
691 glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1); | |
692 | |
693 glColor4f(0.4, 0.4, 0.4, 0.5); | |
694 glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1); | |
695 glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1); | |
696 glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1); | |
697 | |
698 glColor4f(0.6, 0.6, 0.6, 0.5); | |
699 glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1); | |
700 glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1); | |
701 glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1); | |
702 glEnd(); | |
703 } | |
15289 | 704 |
705 glFlush(); | |
706 | |
707 //auto hide mouse cursor and futur on-screen control? | |
15327 | 708 if(isFullscreen && !mouseHide && !isRootwin) |
15289 | 709 { |
18057 | 710 int curTime = TickCount()/60; |
711 static int lastTime = 0; | |
15289 | 712 |
713 if( ((curTime - lastTime) >= 5) || (lastTime == 0) ) | |
714 { | |
18057 | 715 CGDisplayHideCursor(kCGDirectMainDisplay); |
15289 | 716 mouseHide = YES; |
717 lastTime = curTime; | |
718 } | |
719 } | |
17546 | 720 |
17725 | 721 //update activity every 30 seconds to prevent |
17546 | 722 //screensaver from starting up. |
21395 | 723 curTime = TickCount()/60; |
724 lastTime = 0; | |
18057 | 725 |
726 if( ((curTime - lastTime) >= 30) || (lastTime == 0) ) | |
17546 | 727 { |
728 UpdateSystemActivity(UsrActivity); | |
729 lastTime = curTime; | |
730 } | |
15289 | 731 } |
732 | |
733 /* | |
734 Create OpenGL texture from current frame & set texco | |
735 */ | |
736 - (void) setCurrentTexture | |
737 { | |
738 CVReturn error = kCVReturnSuccess; | |
739 | |
740 error = CVOpenGLTextureCacheCreateTextureFromImage (NULL, textureCache, currentFrameBuffer, 0, &texture); | |
741 if(error != kCVReturnSuccess) | |
742 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error); | |
743 | |
744 CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft); | |
745 } | |
746 | |
747 /* | |
748 redraw win rect | |
749 */ | |
750 - (void) drawRect: (NSRect *) bounds | |
751 { | |
752 [self render]; | |
753 } | |
754 | |
755 /* | |
756 Toggle Fullscreen | |
757 */ | |
758 - (void) fullscreen: (BOOL) animate | |
759 { | |
760 static NSRect old_frame; | |
761 static NSRect old_view_frame; | |
15728 | 762 |
763 if(screen_force) | |
764 screen_frame = [screen_handle frame]; | |
765 else | |
766 screen_frame = [[window screen] frame]; | |
15289 | 767 |
15573 | 768 panscan_calc(); |
769 | |
15289 | 770 //go fullscreen |
771 if(vo_fs) | |
772 { | |
15327 | 773 if(!isRootwin) |
774 { | |
15882 | 775 SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
18057 | 776 CGDisplayHideCursor(kCGDirectMainDisplay); |
15327 | 777 mouseHide = YES; |
778 } | |
15289 | 779 |
780 old_frame = [window frame]; //save main window size & position | |
15728 | 781 [window setFrame:screen_frame display:YES animate:animate]; //zoom-in window with nice useless sfx |
15289 | 782 old_view_frame = [self bounds]; |
783 | |
784 //fix origin for multi screen setup | |
15728 | 785 screen_frame.origin.x = 0; |
786 screen_frame.origin.y = 0; | |
787 [self setFrame:screen_frame]; | |
15289 | 788 [self setNeedsDisplay:YES]; |
789 [window setHasShadow:NO]; | |
790 isFullscreen = 1; | |
791 } | |
792 else | |
15882 | 793 { |
15902
16534910f0fb
fix various window resizing bug with menu option
nplourde
parents:
15882
diff
changeset
|
794 SetSystemUIMode( kUIModeNormal, 0); |
15882 | 795 |
15289 | 796 isFullscreen = 0; |
18057 | 797 CGDisplayShowCursor(kCGDirectMainDisplay); |
15289 | 798 mouseHide = NO; |
799 | |
800 //revert window to previous setting | |
801 [self setFrame:old_view_frame]; | |
802 [self setNeedsDisplay:YES]; | |
16081
72c352edce8f
restore window shadow when quitting fullscreen mode
nplourde
parents:
15909
diff
changeset
|
803 [window setHasShadow:YES]; |
15289 | 804 [window setFrame:old_frame display:YES animate:animate];//zoom-out window with nice useless sfx |
805 } | |
806 } | |
807 | |
808 /* | |
809 Toggle ontop | |
810 */ | |
811 - (void) ontop | |
812 { | |
15320 | 813 if(vo_ontop) |
814 { | |
815 [window setLevel:NSScreenSaverWindowLevel]; | |
816 isOntop = YES; | |
817 } | |
818 else | |
819 { | |
820 [window setLevel:NSNormalWindowLevel]; | |
821 isOntop = NO; | |
822 } | |
15289 | 823 } |
824 | |
825 /* | |
826 Toggle panscan | |
827 */ | |
828 - (void) panscan | |
829 { | |
15331 | 830 panscan_calc(); |
15289 | 831 } |
832 | |
833 /* | |
15327 | 834 Toggle rootwin |
835 */ | |
836 - (void) rootwin | |
837 { | |
838 if(vo_rootwin) | |
839 { | |
840 [window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey)]; | |
841 [window orderBack:self]; | |
842 isRootwin = YES; | |
843 } | |
844 else | |
845 { | |
846 [window setLevel:NSNormalWindowLevel]; | |
847 isRootwin = NO; | |
848 } | |
849 } | |
850 | |
851 /* | |
15289 | 852 Check event for new event |
853 */ | |
854 - (void) check_events | |
855 { | |
856 event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.0001] inMode:NSEventTrackingRunLoopMode dequeue:YES]; | |
857 [NSApp sendEvent:event]; | |
858 } | |
859 | |
860 /* | |
15731 | 861 From NSView, respond to key equivalents. |
862 */ | |
863 - (BOOL)performKeyEquivalent:(NSEvent *)theEvent | |
864 { | |
865 switch([theEvent keyCode]) | |
866 { | |
867 case 0x21: [window setAlphaValue: winAlpha-=0.05]; return YES; | |
868 case 0x1e: [window setAlphaValue: winAlpha+=0.05]; return YES; | |
869 } | |
870 return NO; | |
871 } | |
872 | |
873 /* | |
15289 | 874 Process key event |
875 */ | |
876 - (void) keyDown: (NSEvent *) theEvent | |
877 { | |
878 unsigned int key; | |
879 | |
880 switch([theEvent keyCode]) | |
881 { | |
882 case 0x34: | |
883 case 0x24: key = KEY_ENTER; break; | |
884 case 0x35: key = KEY_ESC; break; | |
885 case 0x33: key = KEY_BACKSPACE; break; | |
886 case 0x3A: key = KEY_BACKSPACE; break; | |
887 case 0x3B: key = KEY_BACKSPACE; break; | |
888 case 0x38: key = KEY_BACKSPACE; break; | |
889 case 0x7A: key = KEY_F+1; break; | |
890 case 0x78: key = KEY_F+2; break; | |
891 case 0x63: key = KEY_F+3; break; | |
892 case 0x76: key = KEY_F+4; break; | |
893 case 0x60: key = KEY_F+5; break; | |
894 case 0x61: key = KEY_F+6; break; | |
895 case 0x62: key = KEY_F+7; break; | |
896 case 0x64: key = KEY_F+8; break; | |
897 case 0x65: key = KEY_F+9; break; | |
898 case 0x6D: key = KEY_F+10; break; | |
899 case 0x67: key = KEY_F+11; break; | |
900 case 0x6F: key = KEY_F+12; break; | |
901 case 0x72: key = KEY_INSERT; break; | |
902 case 0x75: key = KEY_DELETE; break; | |
903 case 0x73: key = KEY_HOME; break; | |
904 case 0x77: key = KEY_END; break; | |
905 case 0x45: key = '+'; break; | |
906 case 0x4E: key = '-'; break; | |
907 case 0x30: key = KEY_TAB; break; | |
908 case 0x74: key = KEY_PAGE_UP; break; | |
909 case 0x79: key = KEY_PAGE_DOWN; break; | |
910 case 0x7B: key = KEY_LEFT; break; | |
911 case 0x7C: key = KEY_RIGHT; break; | |
912 case 0x7D: key = KEY_DOWN; break; | |
913 case 0x7E: key = KEY_UP; break; | |
914 case 0x43: key = '*'; break; | |
915 case 0x4B: key = '/'; break; | |
24107 | 916 case 0x4C: key = KEY_KPENTER; break; |
15289 | 917 case 0x41: key = KEY_KPDEC; break; |
918 case 0x52: key = KEY_KP0; break; | |
919 case 0x53: key = KEY_KP1; break; | |
920 case 0x54: key = KEY_KP2; break; | |
921 case 0x55: key = KEY_KP3; break; | |
922 case 0x56: key = KEY_KP4; break; | |
923 case 0x57: key = KEY_KP5; break; | |
924 case 0x58: key = KEY_KP6; break; | |
925 case 0x59: key = KEY_KP7; break; | |
926 case 0x5B: key = KEY_KP8; break; | |
927 case 0x5C: key = KEY_KP9; break; | |
928 default: key = *[[theEvent characters] UTF8String]; break; | |
929 } | |
930 mplayer_put_key(key); | |
931 } | |
932 | |
933 /* | |
934 Process mouse button event | |
935 */ | |
936 - (void) mouseMoved: (NSEvent *) theEvent | |
937 { | |
15327 | 938 if(isFullscreen && !isRootwin) |
15289 | 939 { |
18057 | 940 CGDisplayShowCursor(kCGDirectMainDisplay); |
15289 | 941 mouseHide = NO; |
942 } | |
943 } | |
944 | |
945 - (void) mouseDown: (NSEvent *) theEvent | |
946 { | |
947 [self mouseEvent: theEvent]; | |
948 } | |
949 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
950 - (void) mouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
951 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
952 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
953 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
954 |
15289 | 955 - (void) rightMouseDown: (NSEvent *) theEvent |
956 { | |
957 [self mouseEvent: theEvent]; | |
958 } | |
959 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
960 - (void) rightMouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
961 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
962 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
963 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
964 |
15289 | 965 - (void) otherMouseDown: (NSEvent *) theEvent |
966 { | |
967 [self mouseEvent: theEvent]; | |
968 } | |
969 | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
970 - (void) otherMouseUp: (NSEvent *) theEvent |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
971 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
972 [self mouseEvent: theEvent]; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
973 } |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
974 |
15289 | 975 - (void) scrollWheel: (NSEvent *) theEvent |
976 { | |
977 if([theEvent deltaY] > 0) | |
978 mplayer_put_key(MOUSE_BTN3); | |
979 else | |
980 mplayer_put_key(MOUSE_BTN4); | |
981 } | |
982 | |
983 - (void) mouseEvent: (NSEvent *) theEvent | |
984 { | |
24077
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
985 if ( [theEvent buttonNumber] >= 0 && [theEvent buttonNumber] <= 9 ) |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
986 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
987 switch([theEvent type]) |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
988 { |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
989 case NSLeftMouseDown: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
990 case NSRightMouseDown: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
991 case NSOtherMouseDown: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
992 mplayer_put_key((MOUSE_BTN0 + [theEvent buttonNumber]) | MP_KEY_DOWN); |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
993 break; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
994 case NSLeftMouseUp: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
995 case NSRightMouseUp: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
996 case NSOtherMouseUp: |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
997 mplayer_put_key(MOUSE_BTN0 + [theEvent buttonNumber]); |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
998 break; |
9ce03980ed0c
added double click support in vo_macosx. Patch by Ulion <ulion2002@gmail.com>
nplourde
parents:
24076
diff
changeset
|
999 } |
15289 | 1000 } |
1001 } | |
1002 | |
1003 /* | |
1004 NSResponder | |
1005 */ | |
1006 - (BOOL) acceptsFirstResponder | |
1007 { | |
1008 return YES; | |
1009 } | |
1010 | |
1011 - (BOOL) becomeFirstResponder | |
1012 { | |
1013 return YES; | |
1014 } | |
1015 | |
1016 - (BOOL) resignFirstResponder | |
1017 { | |
1018 return YES; | |
1019 } | |
15325 | 1020 |
1021 - (void)windowWillClose:(NSNotification *)aNotification | |
1022 { | |
21551 | 1023 mpGLView = NULL; |
15325 | 1024 mplayer_put_key(KEY_ESC); |
1025 } | |
1026 @end |