annotate libvo/vo_macosx.m @ 15418:c2bbb228011c

v4l2 RGB15/16 is actually BGR
author henry
date Thu, 12 May 2005 15:30:39 +0000
parents 606d1aac2d85
children f197f4a60b20
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
1 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
2 vo_macosx.m
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
3 by Nicolas Plourde <nicolasplourde@gmail.com>
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
4
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
5 MPlayer Mac OSX video out module.
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
6 Copyright (c) Nicolas Plourde - 2005
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
7 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
8
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
9 #import "vo_macosx.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
10
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
11 //MPLAYER
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
12 #include "config.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
13 #include "fastmemcpy.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
14 #include "video_out.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
15 #include "video_out_internal.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
16 #include "aspect.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
17 #include "mp_msg.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
18 #include "m_option.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
19
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
20 #include "input/input.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
21 #include "input/mouse.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
22
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
23 #include "osdep/keycodes.h"
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
24
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
25 extern void mplayer_put_key(int code);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
26
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
27 //Cocoa
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
28 CustomOpenGLView *glView;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
29 NSAutoreleasePool *autoreleasepool;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
30 OSType pixelFormat;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
31
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
32 //Device
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
33 static int device_width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
34 static int device_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
35 static int device_id;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
36 static GDHandle device_handle;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
37
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
38 //image
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
39 unsigned char *image_data;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
40 static uint32_t image_width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
41 static uint32_t image_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
42 static uint32_t image_depth;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
43 static uint32_t image_bytes;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
44 static uint32_t image_format;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
45 static NSRect image_rec;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
46
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
47 //vo
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
48 extern int vo_rootwin;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
49 extern int vo_ontop;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
50 extern int vo_fs;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
51 static int isFullscreen;
15320
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
52 static int isOntop;
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
53 static int isRootwin;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
54 extern float monitor_aspect;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
55 extern int vo_keepaspect;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
56 extern float movie_aspect;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
57 static float old_movie_aspect;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
58 extern float vo_panscan;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
59
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
60 static int int_pause = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
61
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
62 static vo_info_t info =
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
63 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
64 "Mac OSX Core Video",
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
65 "macosx",
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
66 "Nicolas Plourde <nicolas.plourde@gmail.com>",
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
67 ""
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
68 };
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
69
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
70 LIBVO_EXTERN(macosx)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
71
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
72 extern void mplayer_put_key(int code);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
73 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));
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
74
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
75 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
76 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
77 switch (image_format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
78 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
79 case IMGFMT_RGB32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
80 vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*image_width+x0),4*image_width);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
81 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
82 case IMGFMT_YUY2:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
83 vo_draw_alpha_yuy2(w,h,src,srca,stride,image_data + (x0 + y0 * image_width) * 2,image_width*2);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
84 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
85 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
86 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
87
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
88 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
89 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
90 int i;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
91
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
92 //Get Main device info///////////////////////////////////////////////////
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
93 device_handle = GetMainDevice();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
94
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
95 for(i=0; i<device_id; i++)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
96 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
97 device_handle = GetNextDevice(device_handle);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
98
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
99 if(device_handle == NULL)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
100 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
101 mp_msg(MSGT_VO, MSGL_FATAL, "Get device error: Device ID %d do not exist, falling back to main device.\n", device_id);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
102 device_handle = GetMainDevice();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
103 device_id = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
104 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
105 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
106 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
107
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
108 NSRect device_rect = [[NSScreen mainScreen] frame];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
109 device_width = device_rect.size.width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
110 device_height = device_rect.size.height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
111 monitor_aspect = (float)device_width/(float)device_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
112
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
113 //misc mplayer setup
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
114 image_width = width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
115 image_height = height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
116 switch (image_format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
117 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
118 case IMGFMT_BGR32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
119 case IMGFMT_RGB32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
120 image_depth = 32;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
121 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
122 case IMGFMT_YUY2:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
123 image_depth = 16;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
124 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
125 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
126 image_bytes = (image_depth + 7) / 8;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
127 image_data = (unsigned char*)malloc(image_width*image_height*image_bytes);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
128
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
129 //set aspect
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
130 panscan_init();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
131 aspect_save_orig(width,height);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
132 aspect_save_prescale(d_width,d_height);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
133 aspect_save_screenres(device_width,device_height);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
134 aspect(&d_width,&d_height,A_NOZOOM);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
135
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
136 movie_aspect = (float)d_width/(float)d_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
137 old_movie_aspect = movie_aspect;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
138
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
139 //init OpenGL View
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
140 glView = [[CustomOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, d_width, d_height) pixelFormat:[CustomOpenGLView defaultPixelFormat]];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
141 [glView initOpenGLView];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
142
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
143 vo_fs = flags & VOFLAG_FULLSCREEN;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
144
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
145 if(vo_rootwin)
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
146 [glView rootwin];
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
147
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
148 if(vo_fs)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
149 [glView fullscreen: NO];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
150
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
151 if(vo_ontop)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
152 [glView ontop];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
153
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
154 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
155 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
156
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
157 static void check_events(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
158 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
159 [glView check_events];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
160
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
161 //update activity every 60 seconds to prevent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
162 //screensaver from starting up.
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
163 DateTimeRec d;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
164 unsigned long curTime;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
165 static unsigned long lastTime = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
166
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
167 GetTime(&d);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
168 DateToSeconds( &d, &curTime);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
169
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
170 if( ( (curTime - lastTime) >= 60) || (lastTime == 0))
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
171 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
172 UpdateSystemActivity(UsrActivity);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
173 lastTime = curTime;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
174 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
175 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
176
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
177 static void draw_osd(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
178 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
179 vo_draw_text(image_width, image_height, draw_alpha);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
180 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
181
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
182 static void flip_page(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
183 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
184 [glView render];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
185 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
186
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
187 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
188 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
189 [glView setCurrentTexture];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
190 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
191 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
192
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
193
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
194 static uint32_t draw_frame(uint8_t *src[])
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
195 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
196 switch (image_format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
197 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
198 case IMGFMT_BGR32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
199 case IMGFMT_RGB32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
200 memcpy(image_data, src[0], image_width*image_height*image_bytes);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
201 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
202
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
203 case IMGFMT_YUY2:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
204 memcpy_pic(image_data, src[0], image_width * 2, image_height, image_width * 2, image_width * 2);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
205 break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
206 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
207 [glView setCurrentTexture];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
208 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
209 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
210
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
211 static uint32_t query_format(uint32_t format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
212 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
213 image_format = format;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
214
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
215 switch(format)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
216 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
217 case IMGFMT_YUY2:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
218 pixelFormat = kYUVSPixelFormat;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
219 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
220
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
221 case IMGFMT_RGB32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
222 case IMGFMT_BGR32:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
223 pixelFormat = k32ARGBPixelFormat;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
224 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
225 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
226 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
227 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
228
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
229 static void uninit(void)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
230 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
231 [autoreleasepool release];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
232 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
233
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
234 static uint32_t preinit(const char *arg)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
235 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
236 int parse_err = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
237
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
238 if(arg)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
239 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
240 char *parse_pos = (char *)&arg[0];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
241 while (parse_pos[0] && !parse_err)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
242 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
243 if (strncmp (parse_pos, "device_id=", 10) == 0)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
244 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
245 parse_pos = &parse_pos[10];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
246 device_id = strtol(parse_pos, &parse_pos, 0);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
247 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
248 if (parse_pos[0] == ':') parse_pos = &parse_pos[1];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
249 else if (parse_pos[0]) parse_err = 1;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
250 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
251 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
252
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
253 #if !defined (MACOSX_FINDER_SUPPORT) || !defined (HAVE_SDL)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
254 //this chunk of code is heavily based off SDL_macosx.m from SDL
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
255 //it uses an Apple private function to request foreground operation
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
256 void CPSEnableForegroundOperation(ProcessSerialNumber* psn);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
257 ProcessSerialNumber myProc, frProc;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
258 Boolean sameProc;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
259
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
260 if (GetFrontProcess(&frProc) == noErr)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
261 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
262 if (GetCurrentProcess(&myProc) == noErr)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
263 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
264 if (SameProcess(&frProc, &myProc, &sameProc) == noErr && !sameProc)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
265 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
266 CPSEnableForegroundOperation(&myProc);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
267 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
268 SetFrontProcess(&myProc);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
269 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
270 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
271 #endif
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
272
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
273 NSApplicationLoad();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
274 autoreleasepool = [[NSAutoreleasePool alloc] init];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
275
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
276 return 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
277 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
278
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
279 static uint32_t control(uint32_t request, void *data, ...)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
280 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
281 switch (request)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
282 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
283 case VOCTRL_PAUSE: return (int_pause=1);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
284 case VOCTRL_RESUME: return (int_pause=0);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
285 case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data));
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
286 case VOCTRL_ONTOP: vo_ontop = (!(vo_ontop)); [glView ontop]; return VO_TRUE;
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
287 case VOCTRL_ROOTWIN: vo_rootwin = (!(vo_rootwin)); [glView rootwin]; return VO_TRUE;
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
288 case VOCTRL_FULLSCREEN: vo_fs = (!(vo_fs)); [glView fullscreen: YES]; return VO_TRUE;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
289 case VOCTRL_GET_PANSCAN: return VO_TRUE;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
290 case VOCTRL_SET_PANSCAN: [glView panscan]; return VO_TRUE;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
291 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
292 return VO_NOTIMPL;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
293 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
294
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
295 //////////////////////////////////////////////////////////////////////////
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
296 // NSOpenGLView Subclass
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
297 //////////////////////////////////////////////////////////////////////////
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
298 @implementation CustomOpenGLView
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
299 - (void) initOpenGLView
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
300 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
301 NSRect frame = [self frame];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
302 CVReturn error = kCVReturnSuccess;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
303
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
304 //create OpenGL Context
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
305 glContext = [[NSOpenGLContext alloc] initWithFormat:[NSOpenGLView defaultPixelFormat] shareContext:nil];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
306
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
307
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
308 //create window
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
309 window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, frame.size.width, frame.size.height)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
310 styleMask:NSTitledWindowMask|NSTexturedBackgroundWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
311 backing:NSBackingStoreBuffered
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
312 defer:NO];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
313
15325
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
314 [window setDelegate:self];
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
315 [window setContentView:self];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
316 [window setInitialFirstResponder:self];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
317 [window setAcceptsMouseMovedEvents:YES];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
318 [window setTitle:@"MPlayer - The Movie Player"];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
319 [window center];
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
320 [window makeKeyAndOrderFront:self];
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
321
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
322 [self setOpenGLContext:glContext];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
323 [glContext setView:self];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
324 [glContext makeCurrentContext];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
325
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
326 error = CVPixelBufferCreateWithBytes( NULL,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
327 image_width, image_height,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
328 pixelFormat,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
329 image_data,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
330 image_width*image_bytes,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
331 NULL, NULL, NULL,
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
332 &currentFrameBuffer);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
333 if(error != kCVReturnSuccess)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
334 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create Pixel Buffer(%d)\n", error);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
335
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
336 error = CVOpenGLTextureCacheCreate(NULL, 0, [glContext CGLContextObj], [[self pixelFormat] CGLPixelFormatObj], 0, &textureCache);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
337 if(error != kCVReturnSuccess)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
338 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture Cache(%d)\n", error);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
339
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
340 error = CVOpenGLTextureCacheCreateTextureFromImage( NULL, textureCache, currentFrameBuffer, 0, &texture);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
341 if(error != kCVReturnSuccess)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
342 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
343
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
344 isFullscreen = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
345 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
346
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
347 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
348 Setup OpenGL
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
349 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
350 - (void)prepareOpenGL
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
351 {
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
352 glEnable(GL_BLEND);
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
353 glDisable(GL_DEPTH_TEST);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
354 glDepthMask(GL_FALSE);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
355 glDisable(GL_CULL_FACE);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
356 [self reshape];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
357 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
358
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
359 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
360 reshape OpenGL viewport
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
361 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
362 - (void)reshape
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
363 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
364 uint32_t d_width;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
365 uint32_t d_height;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
366 float aspectX;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
367 float aspectY;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
368 int padding = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
369
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
370 NSRect frame = [self frame];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
371
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
372 glViewport(0, 0, frame.size.width, frame.size.height);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
373 glMatrixMode(GL_PROJECTION);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
374 glLoadIdentity();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
375 glOrtho(0, frame.size.width, frame.size.height, 0, -1.0, 1.0);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
376 glMatrixMode(GL_MODELVIEW);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
377 glLoadIdentity();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
378
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
379 //set image_rec
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
380 if(vo_keepaspect)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
381 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
382 aspect( &d_width, &d_height, A_NOZOOM);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
383 d_height = ((float)d_width/movie_aspect);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
384
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
385 aspectX = (float)((float)frame.size.width/(float)d_width);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
386 aspectY = (float)((float)(frame.size.height)/(float)d_height);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
387
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
388 if((d_height*aspectX)>(frame.size.height))
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
389 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
390 padding = (frame.size.width - d_width*aspectY)/2;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
391 image_rec.origin.x = padding;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
392 image_rec.origin.y = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
393 image_rec.size.width = d_width*aspectY+padding;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
394 image_rec.size.height = d_height*aspectY;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
395 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
396 else
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
397 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
398 padding = ((frame.size.height) - d_height*aspectX)/2;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
399 image_rec.origin.x = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
400 image_rec.origin.y = padding;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
401 image_rec.size.width = d_width*aspectX;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
402 image_rec.size.height = d_height*aspectX+padding;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
403 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
404 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
405 else
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
406 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
407 image_rec = frame;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
408 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
409 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
410
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
411 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
412 Render frame
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
413 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
414 - (void) render
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
415 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
416 glClear(GL_COLOR_BUFFER_BIT);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
417
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
418 glEnable(CVOpenGLTextureGetTarget(texture));
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
419 glBindTexture(CVOpenGLTextureGetTarget(texture), CVOpenGLTextureGetName(texture));
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
420
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
421 glColor3f(1,1,1);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
422 glBegin(GL_QUADS);
15331
7746903599b2 enable panscan
nplourde
parents: 15327
diff changeset
423 glTexCoord2f(upperLeft[0], upperLeft[1]); glVertex2i( image_rec.origin.x-(vo_panscan_x >> 1), image_rec.origin.y-(vo_panscan_y >> 1));
7746903599b2 enable panscan
nplourde
parents: 15327
diff changeset
424 glTexCoord2f(lowerLeft[0], lowerLeft[1]); glVertex2i( image_rec.origin.x-(vo_panscan_x >> 1), image_rec.size.height+(vo_panscan_y >> 1));
7746903599b2 enable panscan
nplourde
parents: 15327
diff changeset
425 glTexCoord2f(lowerRight[0], lowerRight[1]); glVertex2i( image_rec.size.width+(vo_panscan_x >> 1), image_rec.size.height+(vo_panscan_y >> 1));
7746903599b2 enable panscan
nplourde
parents: 15327
diff changeset
426 glTexCoord2f(upperRight[0], upperRight[1]); glVertex2i( image_rec.size.width+(vo_panscan_x >> 1), image_rec.origin.y-(vo_panscan_y >> 1));
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
427 glEnd();
15339
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
428 glDisable(CVOpenGLTextureGetTarget(texture));
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
429
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
430 //render resize box
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
431 if(!isFullscreen)
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
432 {
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
433 NSRect frame = [self frame];
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
434
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
435 glBegin(GL_LINES);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
436 glColor4f(0.2, 0.2, 0.2, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
437 glVertex2i(frame.size.width-1, frame.size.height-1); glVertex2i(frame.size.width-1, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
438 glVertex2i(frame.size.width-1, frame.size.height-5); glVertex2i(frame.size.width-5, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
439 glVertex2i(frame.size.width-1, frame.size.height-9); glVertex2i(frame.size.width-9, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
440
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
441 glColor4f(0.4, 0.4, 0.4, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
442 glVertex2i(frame.size.width-1, frame.size.height-2); glVertex2i(frame.size.width-2, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
443 glVertex2i(frame.size.width-1, frame.size.height-6); glVertex2i(frame.size.width-6, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
444 glVertex2i(frame.size.width-1, frame.size.height-10); glVertex2i(frame.size.width-10, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
445
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
446 glColor4f(0.6, 0.6, 0.6, 0.5);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
447 glVertex2i(frame.size.width-1, frame.size.height-3); glVertex2i(frame.size.width-3, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
448 glVertex2i(frame.size.width-1, frame.size.height-7); glVertex2i(frame.size.width-7, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
449 glVertex2i(frame.size.width-1, frame.size.height-11); glVertex2i(frame.size.width-11, frame.size.height-1);
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
450 glEnd();
606d1aac2d85 draw resize box
nplourde
parents: 15331
diff changeset
451 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
452
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
453 glFlush();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
454
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
455 //auto hide mouse cursor and futur on-screen control?
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
456 if(isFullscreen && !mouseHide && !isRootwin)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
457 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
458 DateTimeRec d;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
459 unsigned long curTime;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
460 static unsigned long lastTime = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
461
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
462 GetTime(&d);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
463 DateToSeconds( &d, &curTime);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
464
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
465 if( ((curTime - lastTime) >= 5) || (lastTime == 0) )
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
466 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
467 HideMenuBar();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
468 HideCursor();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
469 mouseHide = YES;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
470 lastTime = curTime;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
471 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
472 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
473 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
474
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
475 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
476 Create OpenGL texture from current frame & set texco
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
477 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
478 - (void) setCurrentTexture
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
479 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
480 CVReturn error = kCVReturnSuccess;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
481
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
482 error = CVOpenGLTextureCacheCreateTextureFromImage (NULL, textureCache, currentFrameBuffer, 0, &texture);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
483 if(error != kCVReturnSuccess)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
484 mp_msg(MSGT_VO, MSGL_ERR,"Failed to create OpenGL texture(%d)\n", error);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
485
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
486 CVOpenGLTextureGetCleanTexCoords(texture, lowerLeft, lowerRight, upperRight, upperLeft);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
487 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
488
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
489 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
490 redraw win rect
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
491 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
492 - (void) drawRect: (NSRect *) bounds
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
493 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
494 [self render];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
495 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
496
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
497 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
498 Toggle Fullscreen
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
499 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
500 - (void) fullscreen: (BOOL) animate
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
501 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
502 static NSRect old_frame;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
503 static NSRect old_view_frame;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
504 NSRect device_rect = [[window screen] frame];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
505
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
506 //go fullscreen
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
507 if(vo_fs)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
508 {
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
509 if(!isRootwin)
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
510 {
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
511 //hide menubar and mouse if fullscreen on main display
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
512 HideMenuBar();
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
513 HideCursor();
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
514 mouseHide = YES;
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
515 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
516
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
517 panscan_calc();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
518 old_frame = [window frame]; //save main window size & position
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
519 [window setFrame:device_rect display:YES animate:animate]; //zoom-in window with nice useless sfx
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
520 old_view_frame = [self bounds];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
521
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
522 //fix origin for multi screen setup
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
523 device_rect.origin.x = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
524 device_rect.origin.y = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
525 [self setFrame:device_rect];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
526 [self setNeedsDisplay:YES];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
527 [window setHasShadow:NO];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
528 isFullscreen = 1;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
529 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
530 else
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
531 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
532 isFullscreen = 0;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
533 ShowMenuBar();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
534 ShowCursor();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
535 mouseHide = NO;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
536
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
537 //revert window to previous setting
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
538 [self setFrame:old_view_frame];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
539 [self setNeedsDisplay:YES];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
540 [window setHasShadow:NO];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
541 [window setFrame:old_frame display:YES animate:animate];//zoom-out window with nice useless sfx
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
542 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
543 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
544
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
545 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
546 Toggle ontop
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
547 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
548 - (void) ontop
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
549 {
15320
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
550 if(vo_ontop)
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
551 {
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
552 [window setLevel:NSScreenSaverWindowLevel];
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
553 isOntop = YES;
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
554 }
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
555 else
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
556 {
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
557 [window setLevel:NSNormalWindowLevel];
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
558 isOntop = NO;
f743828642fd add ontop
nplourde
parents: 15289
diff changeset
559 }
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
560 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
561
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
562 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
563 Toggle panscan
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
564 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
565 - (void) panscan
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
566 {
15331
7746903599b2 enable panscan
nplourde
parents: 15327
diff changeset
567 panscan_calc();
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
568 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
569
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
570 /*
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
571 Toggle rootwin
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
572 */
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
573 - (void) rootwin
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
574 {
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
575 if(vo_rootwin)
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
576 {
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
577 [window setLevel:CGWindowLevelForKey(kCGDesktopWindowLevelKey)];
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
578 [window orderBack:self];
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
579 isRootwin = YES;
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
580 }
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
581 else
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
582 {
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
583 [window setLevel:NSNormalWindowLevel];
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
584 isRootwin = NO;
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
585 }
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
586 }
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
587
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
588 /*
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
589 Check event for new event
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
590 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
591 - (void) check_events
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
592 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
593 event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate dateWithTimeIntervalSinceNow:0.0001] inMode:NSEventTrackingRunLoopMode dequeue:YES];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
594 [NSApp sendEvent:event];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
595 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
596
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
597 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
598 Process key event
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
599 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
600 - (void) keyDown: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
601 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
602 unsigned int key;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
603
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
604 switch([theEvent keyCode])
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
605 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
606 case 0x34:
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
607 case 0x24: key = KEY_ENTER; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
608 case 0x35: key = KEY_ESC; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
609 case 0x33: key = KEY_BACKSPACE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
610 case 0x3A: key = KEY_BACKSPACE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
611 case 0x3B: key = KEY_BACKSPACE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
612 case 0x38: key = KEY_BACKSPACE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
613 case 0x7A: key = KEY_F+1; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
614 case 0x78: key = KEY_F+2; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
615 case 0x63: key = KEY_F+3; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
616 case 0x76: key = KEY_F+4; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
617 case 0x60: key = KEY_F+5; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
618 case 0x61: key = KEY_F+6; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
619 case 0x62: key = KEY_F+7; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
620 case 0x64: key = KEY_F+8; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
621 case 0x65: key = KEY_F+9; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
622 case 0x6D: key = KEY_F+10; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
623 case 0x67: key = KEY_F+11; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
624 case 0x6F: key = KEY_F+12; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
625 case 0x72: key = KEY_INSERT; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
626 case 0x75: key = KEY_DELETE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
627 case 0x73: key = KEY_HOME; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
628 case 0x77: key = KEY_END; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
629 case 0x45: key = '+'; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
630 case 0x4E: key = '-'; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
631 case 0x30: key = KEY_TAB; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
632 case 0x74: key = KEY_PAGE_UP; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
633 case 0x79: key = KEY_PAGE_DOWN; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
634 case 0x7B: key = KEY_LEFT; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
635 case 0x7C: key = KEY_RIGHT; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
636 case 0x7D: key = KEY_DOWN; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
637 case 0x7E: key = KEY_UP; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
638 case 0x43: key = '*'; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
639 case 0x4B: key = '/'; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
640 case 0x4C: key = KEY_BACKSPACE; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
641 case 0x41: key = KEY_KPDEC; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
642 case 0x52: key = KEY_KP0; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
643 case 0x53: key = KEY_KP1; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
644 case 0x54: key = KEY_KP2; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
645 case 0x55: key = KEY_KP3; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
646 case 0x56: key = KEY_KP4; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
647 case 0x57: key = KEY_KP5; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
648 case 0x58: key = KEY_KP6; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
649 case 0x59: key = KEY_KP7; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
650 case 0x5B: key = KEY_KP8; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
651 case 0x5C: key = KEY_KP9; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
652 default: key = *[[theEvent characters] UTF8String]; break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
653 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
654 mplayer_put_key(key);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
655 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
656
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
657 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
658 Process mouse button event
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
659 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
660 - (void) mouseMoved: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
661 {
15327
8e21844c8a4c enable rootwin
nplourde
parents: 15325
diff changeset
662 if(isFullscreen && !isRootwin)
15289
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
663 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
664 ShowMenuBar();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
665 ShowCursor();
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
666 mouseHide = NO;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
667 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
668 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
669
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
670 - (void) mouseDown: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
671 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
672 [self mouseEvent: theEvent];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
673 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
674
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
675 - (void) rightMouseDown: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
676 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
677 [self mouseEvent: theEvent];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
678 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
679
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
680 - (void) otherMouseDown: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
681 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
682 [self mouseEvent: theEvent];
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
683 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
684
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
685 - (void) scrollWheel: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
686 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
687 if([theEvent deltaY] > 0)
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
688 mplayer_put_key(MOUSE_BTN3);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
689 else
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
690 mplayer_put_key(MOUSE_BTN4);
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
691 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
692
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
693 - (void) mouseEvent: (NSEvent *) theEvent
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
694 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
695 switch( [theEvent buttonNumber] )
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
696 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
697 case 0: mplayer_put_key(MOUSE_BTN0);break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
698 case 1: mplayer_put_key(MOUSE_BTN1);break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
699 case 2: mplayer_put_key(MOUSE_BTN2);break;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
700 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
701 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
702
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
703 /*
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
704 NSResponder
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
705 */
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
706 - (BOOL) acceptsFirstResponder
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
707 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
708 return YES;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
709 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
710
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
711 - (BOOL) becomeFirstResponder
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
712 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
713 return YES;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
714 }
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
715
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
716 - (BOOL) resignFirstResponder
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
717 {
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
718 return YES;
e985d786c5f1 macosx core video module
nplourde
parents:
diff changeset
719 }
15325
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
720
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
721 - (void)windowWillClose:(NSNotification *)aNotification
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
722 {
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
723 mplayer_put_key(KEY_ESC);
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
724 }
5bd11a72dc58 close button exit mplayer with esc key
nplourde
parents: 15320
diff changeset
725 @end