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