[Mplayer-cvslog] CVS: main/libvo vo_quartz.c,1.24,1.25
Nicolas Plourde CVS
syncmail at mplayerhq.hu
Wed Oct 20 18:38:36 CEST 2004
CVS change done by Nicolas Plourde CVS
Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv31786/libvo
Modified Files:
vo_quartz.c
Log Message:
Fixed event handling for menubar and window close button.
Index: vo_quartz.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_quartz.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- vo_quartz.c 19 Oct 2004 15:04:45 -0000 1.24
+++ vo_quartz.c 20 Oct 2004 16:38:33 -0000 1.25
@@ -9,11 +9,8 @@
MPlayer Mac OSX Quartz video out module.
- todo: -key binding to set zoom, a la quicktime
- -screen overlay output
- -while mouse button down event mplayer is locked, fix that
+ todo: -screen overlay output
-Enable live resize
- -fix menu
-RGB32 lost HW accel in fullscreen
-(add sugestion here)
*/
@@ -178,7 +175,8 @@
}
}
-static OSStatus MainEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
+static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
+static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
{
@@ -202,7 +200,7 @@
}
//default window event handler
-static OSStatus MainEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
+static OSStatus MainWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
OSStatus result = noErr;
UInt32 class = GetEventClass (event);
@@ -218,7 +216,6 @@
switch ( theHICommand.commandID )
{
case kHICommandQuit:
- uninit();
mplayer_put_key(KEY_ESC);
break;
@@ -250,38 +247,7 @@
vo_fs = (!(vo_fs)); window_fullscreen();
break;
- default:
- printf("\nHI Command ID Unknown: %d\n", theHICommand.commandID);
- break;
- }
- }
- else if(class == kEventClassWindow)
- {
- WindowRef window;
- Rect rectPort = {0,0,0,0};
-
- GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
-
- if(window)
- {
- GetPortBounds(GetWindowPort(window), &rectPort);
- }
-
- switch (kind)
- {
- //close window
- case kEventWindowClosed:
- uninit();
- mplayer_put_key(KEY_ESC);
- break;
-
- //resize window
- case kEventWindowBoundsChanged:
- window_resized();
- flip_page();
- break;
-
- default:result = eventNotHandledErr;break;
+ default:break;
}
}
else if(class == kEventClassKeyboard)
@@ -404,6 +370,93 @@
return result;
}
+//default window command handler
+static OSStatus MainWindowCommandHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
+{
+ OSStatus result = noErr;
+ UInt32 class = GetEventClass (event);
+ UInt32 kind = GetEventKind (event);
+
+ result = CallNextEventHandler(nextHandler, event);
+
+ if(class == kEventClassCommand)
+ {
+ HICommand theHICommand;
+ GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
+
+ switch ( theHICommand.commandID )
+ {
+ case kHICommandQuit:
+ mplayer_put_key(KEY_ESC);
+ break;
+
+ case kHalfScreenCmd:
+ ShowMenuBar();
+ ShowCursor();
+ SizeWindow(theWindow, (imgRect.right/2), (imgRect.bottom/2), 1);
+ RepositionWindow(theWindow, NULL, kWindowCascadeOnMainScreen);
+ window_resized();
+ break;
+
+ case kNormalScreenCmd:
+ ShowMenuBar();
+ ShowCursor();
+ SizeWindow(theWindow, imgRect.right, imgRect.bottom, 1);
+ RepositionWindow(theWindow, NULL, kWindowCascadeOnMainScreen);
+ window_resized();
+ break;
+
+ case kDoubleScreenCmd:
+ ShowMenuBar();
+ ShowCursor();
+ SizeWindow(theWindow, (imgRect.right*2), (imgRect.bottom*2), 1);
+ RepositionWindow(theWindow, NULL, kWindowCascadeOnMainScreen);
+ window_resized();
+ break;
+
+ case kFullScreenCmd:
+ vo_fs = (!(vo_fs)); window_fullscreen();
+ break;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
+ else if(class == kEventClassWindow)
+ {
+ WindowRef window;
+ Rect rectPort = {0,0,0,0};
+
+ GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
+
+ if(window)
+ {
+ GetPortBounds(GetWindowPort(window), &rectPort);
+ }
+
+ switch (kind)
+ {
+ case kEventWindowClosed:
+ theWindow = NULL;
+ mplayer_put_key(KEY_ESC);
+ break;
+
+ //resize window
+ case kEventWindowBoundsChanged:
+ window_resized();
+ flip_page();
+ break;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
+
+ return result;
+}
+
static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs)
{
CFStringRef titleKey;
@@ -455,15 +508,22 @@
CFRelease(windowTitle);
//Install event handler
- const EventTypeSpec winEvents[] = { { kEventClassKeyboard, kEventRawKeyDown },
- { kEventClassKeyboard, kEventRawKeyRepeat },
- { kEventClassMouse, kEventMouseDown },
- { kEventClassMouse, kEventMouseWheelMoved },
- { kEventClassWindow, kEventWindowClosed },
- { kEventClassWindow, kEventWindowBoundsChanged },
- { kEventClassCommand, kEventCommandProcess } };
-
- InstallApplicationEventHandler (NewEventHandlerUPP (MainEventHandler), GetEventTypeCount(winEvents), winEvents, NULL, NULL);
+ const EventTypeSpec commands[] = {
+ { kEventClassWindow, kEventWindowClosed },
+ { kEventClassWindow, kEventWindowBoundsChanged },
+ { kEventClassCommand, kEventCommandProcess }
+ };
+
+ const EventTypeSpec events[] = {
+ { kEventClassKeyboard, kEventRawKeyDown },
+ { kEventClassKeyboard, kEventRawKeyRepeat },
+ { kEventClassMouse, kEventMouseDown },
+ { kEventClassMouse, kEventMouseWheelMoved }
+ };
+
+
+ InstallApplicationEventHandler (NewEventHandlerUPP (MainWindowEventHandler), GetEventTypeCount(events), events, NULL, NULL);
+ InstallWindowEventHandler (theWindow, NewEventHandlerUPP (MainWindowCommandHandler), GetEventTypeCount(commands), commands, theWindow, NULL);
}
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)
@@ -772,6 +832,9 @@
static void flip_page(void)
{
+ if(theWindow == NULL)
+ return;
+
switch (image_format)
{
case IMGFMT_RGB32:
More information about the MPlayer-cvslog
mailing list