osxvideo: fix build on Mac OSX Mavericks and put new window in front
[platform/upstream/gst-plugins-good.git] / sys / osxvideo / cocoawindow.m
1 /* GStreamer
2  * Copyright (C) 2004 Zaheer Abbas Merali <zaheerabbas at merali dot org>
3  * Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * The development of this code was made possible due to the involvement of Pioneers
21  * of the Inevitable, the creators of the Songbird Music player
22  *
23  */
24
25 /* inspiration gained from looking at source of osx video out of xine and vlc
26  * and is reflected in the code
27  */
28
29
30 #include <Cocoa/Cocoa.h>
31 #include <gst/gst.h>
32 #import "cocoawindow.h"
33 #import "osxvideosink.h"
34
35 #include <OpenGL/OpenGL.h>
36 #include <OpenGL/gl.h>
37 #include <OpenGL/glext.h>
38
39 #include <Carbon/Carbon.h>
40
41 /* Debugging category */
42 #include <gst/gstinfo.h>
43
44 static
45 const gchar* gst_keycode_to_keyname(gint16 keycode)
46 {
47     switch (keycode)
48     {
49       case kVK_ANSI_A:
50         return "a";
51       case kVK_ANSI_S:
52         return "s";
53       case kVK_ANSI_D:
54         return "d";
55       case kVK_ANSI_F:
56         return "f";
57       case kVK_ANSI_H:
58         return "h";
59       case kVK_ANSI_G:
60         return "g";
61       case kVK_ANSI_Z:
62         return "z";
63       case kVK_ANSI_X:
64         return "x";
65       case kVK_ANSI_C:
66         return "c";
67       case kVK_ANSI_V:
68         return "v";
69       case kVK_ANSI_B:
70         return "b";
71       case kVK_ANSI_Q:
72         return "q";
73       case kVK_ANSI_W:
74         return "w";
75       case kVK_ANSI_E:
76         return "e";
77       case kVK_ANSI_R:
78         return "r";
79       case kVK_ANSI_Y:
80         return "y";
81       case kVK_ANSI_T:
82         return "t";
83       case kVK_ANSI_1:
84         return "1";
85       case kVK_ANSI_2:
86         return "2";
87       case kVK_ANSI_3:
88         return "3";
89       case kVK_ANSI_4:
90         return "4";
91       case kVK_ANSI_6:
92         return "6";
93       case kVK_ANSI_5:
94         return "5";
95       case kVK_ANSI_Equal:
96         return "equal";
97       case kVK_ANSI_9:
98         return "9";
99       case kVK_ANSI_7:
100         return "7";
101       case kVK_ANSI_Minus:
102         return "minus";
103       case kVK_ANSI_8:
104         return "8";
105       case kVK_ANSI_0:
106         return "0";
107       case kVK_ANSI_RightBracket:
108         return "bracketright";
109       case kVK_ANSI_O:
110         return "0";
111       case kVK_ANSI_U:
112         return "u";
113       case kVK_ANSI_LeftBracket:
114         return "bracketleft";
115       case kVK_ANSI_I:
116         return "i";
117       case kVK_ANSI_P:
118         return "p";
119       case kVK_ANSI_L:
120         return "l";
121       case kVK_ANSI_J:
122         return "j";
123       case kVK_ANSI_Quote:
124         return "apostrophe";
125       case kVK_ANSI_K:
126         return "k";
127       case kVK_ANSI_Semicolon:
128         return "semicolon";
129       case kVK_ANSI_Backslash:
130         return "backslash";
131       case kVK_ANSI_Comma:
132         return "comma";
133       case kVK_ANSI_Slash:
134         return "slash";
135       case kVK_ANSI_N:
136         return "n";
137       case kVK_ANSI_M:
138         return "m";
139       case kVK_ANSI_Period:
140         return "period";
141       case kVK_ANSI_Grave:
142         return "grave";
143       case kVK_ANSI_KeypadDecimal:
144         return "KP_Delete";
145       case kVK_ANSI_KeypadMultiply:
146         return "KP_Multiply";
147       case kVK_ANSI_KeypadPlus:
148         return "KP_Add";
149       case kVK_ANSI_KeypadClear:
150         return "KP_Clear";
151       case kVK_ANSI_KeypadDivide:
152         return "KP_Divide";
153       case kVK_ANSI_KeypadEnter:
154         return "KP_Enter";
155       case kVK_ANSI_KeypadMinus:
156         return "KP_Subtract";
157       case kVK_ANSI_KeypadEquals:
158         return "KP_Equals";
159       case kVK_ANSI_Keypad0:
160         return "KP_Insert";
161       case kVK_ANSI_Keypad1:
162         return "KP_End";
163       case kVK_ANSI_Keypad2:
164         return "KP_Down";
165       case kVK_ANSI_Keypad3:
166         return "KP_Next";
167       case kVK_ANSI_Keypad4:
168         return "KP_Left";
169       case kVK_ANSI_Keypad5:
170         return "KP_Begin";
171       case kVK_ANSI_Keypad6:
172         return "KP_Right";
173       case kVK_ANSI_Keypad7:
174         return "KP_Home";
175       case kVK_ANSI_Keypad8:
176         return "KP_Up";
177       case kVK_ANSI_Keypad9:
178         return "KP_Prior";
179
180     /* keycodes for keys that are independent of keyboard layout*/
181
182       case kVK_Return:
183         return "Return";
184       case kVK_Tab:
185         return "Tab";
186       case kVK_Space:
187         return "space";
188       case kVK_Delete:
189         return "Backspace";
190       case kVK_Escape:
191         return "Escape";
192       case kVK_Command:
193         return "Command";
194       case kVK_Shift:
195         return "Shift_L";
196       case kVK_CapsLock:
197         return "Caps_Lock";
198       case kVK_Option:
199         return "Option_L";
200       case kVK_Control:
201         return "Control_L";
202       case kVK_RightShift:
203         return "Shift_R";
204       case kVK_RightOption:
205         return "Option_R";
206       case kVK_RightControl:
207         return "Control_R";
208       case kVK_Function:
209         return "Function";
210       case kVK_F17:
211         return "F17";
212       case kVK_VolumeUp:
213         return "VolumeUp";
214       case kVK_VolumeDown:
215         return "VolumeDown";
216       case kVK_Mute:
217         return "Mute";
218       case kVK_F18:
219         return "F18";
220       case kVK_F19:
221         return "F19";
222       case kVK_F20:
223         return "F20";
224       case kVK_F5:
225         return "F5";
226       case kVK_F6:
227         return "F6";
228       case kVK_F7:
229         return "F7";
230       case kVK_F3:
231         return "F3";
232       case kVK_F8:
233         return "F8";
234       case kVK_F9:
235         return "F9";
236       case kVK_F11:
237         return "F11";
238       case kVK_F13:
239         return "F13";
240       case kVK_F16:
241         return "F16";
242       case kVK_F14:
243         return "F14";
244       case kVK_F10:
245         return "F10";
246       case kVK_F12:
247         return "F12";
248       case kVK_F15:
249         return "F15";
250       case kVK_Help:
251         return "Help";
252       case kVK_Home:
253         return "Home";
254       case kVK_PageUp:
255         return "Prior";
256       case kVK_ForwardDelete:
257         return "Delete";
258       case kVK_F4:
259         return "F4";
260       case kVK_End:
261         return "End";
262       case kVK_F2:
263         return "F2";
264       case kVK_PageDown:
265         return "Next";
266       case kVK_F1:
267         return "F1";
268       case kVK_LeftArrow:
269         return "Left";
270       case kVK_RightArrow:
271         return "Right";
272       case kVK_DownArrow:
273         return "Down";
274       case kVK_UpArrow:
275         return "Up";
276     default:
277         return "";
278   };
279 }
280
281 @ implementation GstOSXVideoSinkWindow
282
283 /* The object has to be released */
284 - (id) initWithContentNSRect: (NSRect) rect
285                  styleMask: (unsigned int) styleMask
286                    backing: (NSBackingStoreType) bufferingType
287                      defer: (BOOL) flag
288                     screen:(NSScreen *) aScreen
289 {
290   self = [super initWithContentRect: rect
291                 styleMask: styleMask
292                 backing: bufferingType
293                 defer: flag
294                 screen:aScreen];
295
296   GST_DEBUG ("Initializing GstOSXvideoSinkWindow");
297
298   gstview = [[GstGLView alloc] initWithFrame:rect];
299
300   if (gstview)
301     [self setContentView:gstview];
302   [self setTitle:@"GStreamer Video Output"];
303
304   return self;
305 }
306
307 - (void) setContentSize:(NSSize) size {
308   width = size.width;
309   height = size.height;
310
311   [super setContentSize:size];
312 }
313
314 - (GstGLView *) gstView {
315   return gstview;
316 }
317
318 - (void) awakeFromNib {
319   [self setAcceptsMouseMovedEvents:YES];
320 }
321
322 @end
323
324
325 //
326 // OpenGL implementation
327 //
328
329 @ implementation GstGLView
330
331 - (id) initWithFrame:(NSRect) frame {
332   NSOpenGLPixelFormat *fmt;
333   NSOpenGLPixelFormatAttribute attribs[] = {
334     NSOpenGLPFANoRecovery,
335     NSOpenGLPFADoubleBuffer,
336     NSOpenGLPFAColorSize, 24,
337     NSOpenGLPFAAlphaSize, 8,
338     NSOpenGLPFADepthSize, 24,
339     NSOpenGLPFAWindow,
340     0
341   };
342
343   fmt = [[NSOpenGLPixelFormat alloc]
344           initWithAttributes:attribs];
345
346   if (!fmt) {
347     GST_WARNING ("Cannot create NSOpenGLPixelFormat");
348     return nil;
349   }
350
351   self = [super initWithFrame: frame pixelFormat:fmt];
352   [fmt release];
353
354    actualContext = [self openGLContext];
355    [actualContext makeCurrentContext];
356    [actualContext update];
357
358   /* Black background */
359   glClearColor (0.0, 0.0, 0.0, 0.0);
360
361   pi_texture = 0;
362   data = nil;
363   width = frame.size.width;
364   height = frame.size.height;
365   drawingBounds = NSMakeRect(0, 0, width, height);
366
367   GST_LOG ("Width: %d Height: %d", width, height);
368
369   trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
370       options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow)
371       owner:self
372       userInfo:nil];
373
374   [self addTrackingArea:trackingArea];
375   mainThread = [NSThread mainThread];
376
377   [self initTextures];
378   return self;
379 }
380
381 - (NSRect) getDrawingBounds {
382   return drawingBounds;
383 }
384
385 - (void) reshape {
386   NSRect bounds;
387   gdouble frame_par, view_par;
388   gint view_height, view_width, c_height, c_width, c_x, c_y;
389
390
391   GST_LOG ("reshaping");
392
393   if (!initDone) {
394     return;
395   }
396
397   [actualContext makeCurrentContext];
398
399   bounds = [self bounds];
400   view_width = bounds.size.width;
401   view_height = bounds.size.height;
402
403   frame_par = (gdouble) width / height;
404   view_par = (gdouble) view_width / view_height;
405   if (!keepAspectRatio)
406     view_par = frame_par;
407
408   if (frame_par == view_par) {
409     c_height = view_height;
410     c_width = view_width;
411     c_x = 0;
412     c_y = 0;
413   } else if (frame_par < view_par) {
414     c_height = view_height;
415     c_width = c_height * frame_par;
416     c_x = (view_width - c_width) / 2;
417     c_y = 0;
418   } else {
419     c_width = view_width;
420     c_height = c_width / frame_par;
421     c_x = 0;
422     c_y = (view_height - c_height) / 2;
423   }
424
425   drawingBounds = NSMakeRect(c_x, c_y, c_width, c_height);
426   glViewport (c_x, c_y, (GLint) c_width, (GLint) c_height);
427 }
428
429 - (void) initTextures {
430
431   [actualContext makeCurrentContext];
432
433   /* Free previous texture if any */
434   if (pi_texture) {
435     glDeleteTextures (1, (GLuint *)&pi_texture);
436   }
437
438   if (data) {
439     data = g_realloc (data, width * height * sizeof(short)); // short or 3byte?
440   } else {
441     data = g_malloc0(width * height * sizeof(short));
442   }
443   /* Create textures */
444   glGenTextures (1, (GLuint *)&pi_texture);
445
446   glEnable (GL_TEXTURE_RECTANGLE_EXT);
447   glEnable (GL_UNPACK_CLIENT_STORAGE_APPLE);
448
449   glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
450   glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
451
452   glBindTexture (GL_TEXTURE_RECTANGLE_EXT, pi_texture);
453
454   /* Use VRAM texturing */
455   glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
456                    GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE);
457
458   /* Tell the driver not to make a copy of the texture but to use
459      our buffer */
460   glPixelStorei (GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
461
462   /* Linear interpolation */
463   glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
464   glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
465
466   /* I have no idea what this exactly does, but it seems to be
467      necessary for scaling */
468   glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
469                    GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
470   glTexParameteri (GL_TEXTURE_RECTANGLE_EXT,
471                    GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
472   // glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); WHY ??
473
474   glTexImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGBA,
475                 width, height, 0,
476                 GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, data);
477
478
479   initDone = 1;
480 }
481
482 - (void) reloadTexture {
483   if (!initDone) {
484     return;
485   }
486
487   GST_LOG ("Reloading Texture");
488
489   [actualContext makeCurrentContext];
490
491   glBindTexture (GL_TEXTURE_RECTANGLE_EXT, pi_texture);
492   glPixelStorei (GL_UNPACK_ROW_LENGTH, width);
493
494   /* glTexSubImage2D is faster than glTexImage2D
495      http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/
496      TextureRange/MainOpenGLView.m.htm */
497   glTexSubImage2D (GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0,
498                    width, height,
499                    GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, data);    //FIXME
500 }
501
502 - (void) cleanUp {
503   initDone = 0;
504 }
505
506 - (void) drawQuad {
507   f_x = 1.0;
508   f_y = 1.0;
509
510   glBegin (GL_QUADS);
511   /* Top left */
512   glTexCoord2f (0.0, 0.0);
513   glVertex2f (-f_x, f_y);
514   /* Bottom left */
515   glTexCoord2f (0.0, (float) height);
516   glVertex2f (-f_x, -f_y);
517   /* Bottom right */
518   glTexCoord2f ((float) width, (float) height);
519   glVertex2f (f_x, -f_y);
520   /* Top right */
521   glTexCoord2f ((float) width, 0.0);
522   glVertex2f (f_x, f_y);
523   glEnd ();
524 }
525
526 - (void) drawRect:(NSRect) rect {
527   GLint params[] = { 1 };
528
529   [actualContext makeCurrentContext];
530
531   CGLSetParameter (CGLGetCurrentContext (), kCGLCPSwapInterval, params);
532
533   /* Black background */
534   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
535
536   if (!initDone) {
537     [actualContext flushBuffer];
538     return;
539   }
540
541   /* Draw */
542   glBindTexture (GL_TEXTURE_RECTANGLE_EXT, pi_texture); // FIXME
543   [self drawQuad];
544   /* Draw */
545   [actualContext flushBuffer];
546 }
547
548 - (void) displayTexture {
549   if ([self lockFocusIfCanDraw]) {
550
551     [self drawRect:[self bounds]];
552     [self reloadTexture];
553
554     [self unlockFocus];
555
556   }
557
558 }
559
560 - (char *) getTextureBuffer {
561   return data;
562 }
563
564 - (void) setFullScreen:(BOOL) flag {
565   if (!fullscreen && flag) {
566     // go to full screen
567     /* Create the new pixel format */
568     NSOpenGLPixelFormat *fmt;
569     NSOpenGLPixelFormatAttribute attribs[] = {
570       NSOpenGLPFAAccelerated,
571       NSOpenGLPFANoRecovery,
572       NSOpenGLPFADoubleBuffer,
573       NSOpenGLPFAColorSize, 24,
574       NSOpenGLPFAAlphaSize, 8,
575       NSOpenGLPFADepthSize, 24,
576       NSOpenGLPFAFullScreen,
577       NSOpenGLPFAScreenMask,
578       CGDisplayIDToOpenGLDisplayMask (kCGDirectMainDisplay),
579       0
580     };
581
582     fmt = [[NSOpenGLPixelFormat alloc]
583             initWithAttributes:attribs];
584
585     if (!fmt) {
586       GST_WARNING ("Cannot create NSOpenGLPixelFormat");
587       return;
588     }
589
590     /* Create the new OpenGL context */
591     fullScreenContext = [[NSOpenGLContext alloc]
592                           initWithFormat: fmt shareContext:nil];
593     if (!fullScreenContext) {
594       GST_WARNING ("Failed to create new NSOpenGLContext");
595       return;
596     }
597
598     actualContext = fullScreenContext;
599
600     /* Capture display, switch to fullscreen */
601     if (CGCaptureAllDisplays () != CGDisplayNoErr) {
602       GST_WARNING ("CGCaptureAllDisplays() failed");
603       return;
604     }
605     [fullScreenContext setFullScreen];
606     [fullScreenContext makeCurrentContext];
607
608     fullscreen = YES;
609
610     [self initTextures];
611     [self setNeedsDisplay:YES];
612
613   } else if (fullscreen && !flag) {
614     // fullscreen now and needs to go back to normal
615     initDone = NO;
616
617     actualContext = [self openGLContext];
618
619     [NSOpenGLContext clearCurrentContext];
620     [fullScreenContext clearDrawable];
621     [fullScreenContext release];
622     fullScreenContext = nil;
623
624     CGReleaseAllDisplays ();
625
626     [self reshape];
627     [self initTextures];
628
629     [self setNeedsDisplay:YES];
630
631     fullscreen = NO;
632     initDone = YES;
633   }
634 }
635
636 - (void) setVideoSize: (int)w : (int)h {
637   GST_LOG ("width:%d, height:%d", w, h);
638
639   width = w;
640   height = h;
641
642   [self initTextures];
643   [self reshape];
644 }
645
646 - (void) setKeepAspectRatio: (BOOL) flag {
647   keepAspectRatio = flag;
648   [self reshape];
649 }
650
651 - (void) setMainThread: (NSThread *) thread {
652   mainThread = thread;
653 }
654
655 - (void) haveSuperviewReal:(NSMutableArray *)closure {
656         BOOL haveSuperview = [self superview] != nil;
657         [closure addObject:[NSNumber numberWithBool:haveSuperview]];
658 }
659
660 - (BOOL) haveSuperview {
661         NSMutableArray *closure = [NSMutableArray arrayWithCapacity:1];
662         [self performSelector:@selector(haveSuperviewReal:)
663                 onThread:mainThread
664                 withObject:(id)closure waitUntilDone:YES];
665
666         return [[closure objectAtIndex:0] boolValue];
667 }
668
669 - (void) addToSuperviewReal:(NSView *)superview {
670         NSRect bounds;
671         [superview addSubview:self];
672         bounds = [superview bounds];
673         [self setFrame:bounds];
674         [self setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
675 }
676
677 - (void) addToSuperview: (NSView *)superview {
678         [self performSelector:@selector(addToSuperviewReal:)
679                 onThread:mainThread
680                 withObject:superview waitUntilDone:YES];
681 }
682
683 - (void) removeFromSuperview: (id)unused
684 {
685         [self removeFromSuperview];
686 }
687
688 - (void) dealloc {
689   GST_LOG ("dealloc called");
690   if (data) g_free(data);
691
692   if (fullScreenContext) {
693     [NSOpenGLContext clearCurrentContext];
694     [fullScreenContext clearDrawable];
695     [fullScreenContext release];
696     if (actualContext == fullScreenContext) actualContext = nil;
697     fullScreenContext = nil;
698   }
699
700   [super dealloc];
701 }
702
703 - (void)updateTrackingAreas {
704   [self removeTrackingArea:trackingArea];
705   [trackingArea release];
706   trackingArea = [[NSTrackingArea alloc] initWithRect: [self bounds]
707       options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow)
708       owner:self userInfo:nil];
709   [self addTrackingArea:trackingArea];
710 }
711
712 - (BOOL)acceptsFirstResponder {
713     return YES;
714 }
715
716 - (void) setNavigation:(GstNavigation *)nav
717 {
718   navigation = nav;
719 }
720
721 - (void)sendMouseEvent:(NSEvent *)event : (const char *)event_name
722 {
723   NSPoint location;
724   gint button;
725   gdouble x, y;
726
727   if (!navigation)
728     return;
729
730   switch ([event type]) {
731     case NSMouseMoved:
732       button = 0;
733       break;
734     case NSLeftMouseDown:
735     case NSLeftMouseUp:
736       button = 1;
737       break;
738     case NSRightMouseDown:
739     case NSRightMouseUp:
740       button = 2;
741       break;
742     default:
743       button = 3;
744       break;
745   }
746
747   location = [self convertPoint:[event locationInWindow] fromView:nil];
748
749   x = location.x;
750   y = location.y;
751   /* invert Y */
752
753   y = (1 - ((gdouble) y) / [self bounds].size.height) * [self bounds].size.height;
754
755   gst_navigation_send_mouse_event (navigation, event_name, button, x, y);
756 }
757
758 - (void)sendKeyEvent:(NSEvent *)event : (const char *)event_name
759 {
760   if (!navigation)
761     return;
762
763   gst_navigation_send_key_event(navigation, event_name, gst_keycode_to_keyname([event keyCode]));
764 }
765
766 - (void)sendModifierKeyEvent:(NSEvent *)event
767 {
768   NSUInteger flags = [event modifierFlags];
769   const gchar* event_name = flags > savedModifierFlags ? "key-press" : "key-release";
770   savedModifierFlags = flags;
771   [self sendKeyEvent: event: event_name];
772 }
773
774 - (void)keyDown:(NSEvent *) event;
775 {
776   [self sendKeyEvent: event: "key-press"];
777   [super keyDown: event];
778 }
779
780 - (void)keyUp:(NSEvent *) event;
781 {
782   [self sendKeyEvent: event: "key-release"];
783   [super keyUp: event];
784 }
785
786 - (void)flagsChanged:(NSEvent *) event;
787 {
788   [self sendModifierKeyEvent: event];
789   [super flagsChanged: event];
790 }
791
792 - (void)mouseDown:(NSEvent *) event;
793 {
794   [self sendMouseEvent:event: "mouse-button-press"];
795   [super mouseDown: event];
796 }
797
798 - (void)mouseUp:(NSEvent *) event;
799 {
800   [self sendMouseEvent:event: "mouse-button-release"];
801   [super mouseUp: event];
802 }
803
804 - (void)mouseMoved:(NSEvent *)event;
805 {
806   [self sendMouseEvent:event: "mouse-move"];
807   [super mouseMoved: event];
808 }
809
810 - (void)mouseEntered:(NSEvent *)event;
811 {
812   [super mouseEntered: event];
813 }
814
815 - (void)mouseExited:(NSEvent *)event;
816 {
817   [super mouseExited: event];
818 }
819
820 @end