summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorgpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-11-24 14:29:32 +0000
committergpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-11-24 14:29:32 +0000
commit76797a077c20618a864967cab394046882193fc0 (patch)
tree1db54da5a9f3f249e4606d7c622f8457d09a621a /libvo
parent20011636d27b8592d78dd5f82bdb95f0a6c256a4 (diff)
downloadmpv-76797a077c20618a864967cab394046882193fc0.tar.bz2
mpv-76797a077c20618a864967cab394046882193fc0.tar.xz
cosmetics (svn diff --diff-cmd diff -x '-duwbBE' gives no differences)
replace tabs by 4 spaces. prettier intentation. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28026 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_quartz.c2375
1 files changed, 1189 insertions, 1186 deletions
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index 05e2ba9fc9..8fde1d0378 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -38,10 +38,10 @@
static const vo_info_t info =
{
- "Mac OSX (Quartz)",
- "quartz",
- "Nicolas Plourde <nicolasplourde@hotmail.com>, Romain Dolbeau <romain@dolbeau.org>",
- ""
+ "Mac OSX (Quartz)",
+ "quartz",
+ "Nicolas Plourde <nicolasplourde@hotmail.com>, Romain Dolbeau <romain@dolbeau.org>",
+ ""
};
const LIBVO_EXTERN(quartz)
@@ -57,11 +57,11 @@ static CodecType image_qtcodec;
static PlanarPixmapInfoYUV420 *P = NULL;
static struct
{
- ImageDescriptionHandle desc;
- Handle extension_colr;
- Handle extension_fiel;
- Handle extension_clap;
- Handle extension_pasp;
+ ImageDescriptionHandle desc;
+ Handle extension_colr;
+ Handle extension_fiel;
+ Handle extension_clap;
+ Handle extension_pasp;
} yuv_qt_stuff;
static MatrixRecord matrix;
static int EnterMoviesDone = 0;
@@ -86,8 +86,8 @@ static int mouseHide = FALSE;
static int device_id = 0;
-static short fs_res_x=0;
-static short fs_res_y=0;
+static short fs_res_x = 0;
+static short fs_res_y = 0;
static WindowRef theWindow = NULL;
static WindowGroupRef winGroup = NULL;
@@ -98,11 +98,11 @@ static CFDictionaryRef originalMode = NULL;
static CGDataProviderRef dataProviderRef = NULL;
static CGImageRef image = NULL;
-static Rect imgRect; // size of the original image (unscaled)
-static Rect dstRect; // size of the displayed image (after scaling)
-static Rect winRect; // size of the window containg the displayed image (include padding)
-static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode
-static CGRect displayRect; // size of the display device
+static Rect imgRect; // size of the original image (unscaled)
+static Rect dstRect; // size of the displayed image (after scaling)
+static Rect winRect; // size of the window containg the displayed image (include padding)
+static Rect oldWinRect; // size of the window containg the displayed image (include padding) when NOT in FS mode
+static CGRect displayRect; // size of the display device
static Rect oldWinBounds;
static MenuRef windMenu;
@@ -114,21 +114,21 @@ static int lastMouseHide = 0;
enum
{
- kQuitCmd = 1,
- kHalfScreenCmd = 2,
- kNormalScreenCmd = 3,
- kDoubleScreenCmd = 4,
- kFullScreenCmd = 5,
- kKeepAspectCmd = 6,
- kAspectOrgCmd = 7,
- kAspectFullCmd = 8,
- kAspectWideCmd = 9,
- kPanScanCmd = 10
+ kQuitCmd = 1,
+ kHalfScreenCmd = 2,
+ kNormalScreenCmd = 3,
+ kDoubleScreenCmd = 4,
+ kFullScreenCmd = 5,
+ kKeepAspectCmd = 6,
+ kAspectOrgCmd = 7,
+ kAspectFullCmd = 8,
+ kAspectWideCmd = 9,
+ kPanScanCmd = 10
};
#include "osdep/keycodes.h"
-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));
+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));
//PROTOTYPE/////////////////////////////////////////////////////////////////
static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
@@ -141,118 +141,119 @@ void window_panscan();
static inline int convert_key(UInt32 key, UInt32 charcode)
{
- switch(key)
+ switch (key)
{
- case QZ_IBOOK_ENTER:
- case QZ_RETURN: return KEY_ENTER;
- case QZ_ESCAPE: return KEY_ESC;
- case QZ_BACKSPACE: return KEY_BACKSPACE;
- case QZ_LALT: return KEY_BACKSPACE;
- case QZ_LCTRL: return KEY_BACKSPACE;
- case QZ_LSHIFT: return KEY_BACKSPACE;
- case QZ_F1: return KEY_F+1;
- case QZ_F2: return KEY_F+2;
- case QZ_F3: return KEY_F+3;
- case QZ_F4: return KEY_F+4;
- case QZ_F5: return KEY_F+5;
- case QZ_F6: return KEY_F+6;
- case QZ_F7: return KEY_F+7;
- case QZ_F8: return KEY_F+8;
- case QZ_F9: return KEY_F+9;
- case QZ_F10: return KEY_F+10;
- case QZ_F11: return KEY_F+11;
- case QZ_F12: return KEY_F+12;
- case QZ_INSERT: return KEY_INSERT;
- case QZ_DELETE: return KEY_DELETE;
- case QZ_HOME: return KEY_HOME;
- case QZ_END: return KEY_END;
- case QZ_KP_PLUS: return '+';
- case QZ_KP_MINUS: return '-';
- case QZ_TAB: return KEY_TAB;
- case QZ_PAGEUP: return KEY_PAGE_UP;
- case QZ_PAGEDOWN: return KEY_PAGE_DOWN;
- case QZ_UP: return KEY_UP;
- case QZ_DOWN: return KEY_DOWN;
- case QZ_LEFT: return KEY_LEFT;
- case QZ_RIGHT: return KEY_RIGHT;
- case QZ_KP_MULTIPLY: return '*';
- case QZ_KP_DIVIDE: return '/';
- case QZ_KP_ENTER: return KEY_KPENTER;
- case QZ_KP_PERIOD: return KEY_KPDEC;
- case QZ_KP0: return KEY_KP0;
- case QZ_KP1: return KEY_KP1;
- case QZ_KP2: return KEY_KP2;
- case QZ_KP3: return KEY_KP3;
- case QZ_KP4: return KEY_KP4;
- case QZ_KP5: return KEY_KP5;
- case QZ_KP6: return KEY_KP6;
- case QZ_KP7: return KEY_KP7;
- case QZ_KP8: return KEY_KP8;
- case QZ_KP9: return KEY_KP9;
- default: return charcode;
+ case QZ_IBOOK_ENTER:
+ case QZ_RETURN: return KEY_ENTER;
+ case QZ_ESCAPE: return KEY_ESC;
+ case QZ_BACKSPACE: return KEY_BACKSPACE;
+ case QZ_LALT: return KEY_BACKSPACE;
+ case QZ_LCTRL: return KEY_BACKSPACE;
+ case QZ_LSHIFT: return KEY_BACKSPACE;
+ case QZ_F1: return KEY_F + 1;
+ case QZ_F2: return KEY_F + 2;
+ case QZ_F3: return KEY_F + 3;
+ case QZ_F4: return KEY_F + 4;
+ case QZ_F5: return KEY_F + 5;
+ case QZ_F6: return KEY_F + 6;
+ case QZ_F7: return KEY_F + 7;
+ case QZ_F8: return KEY_F + 8;
+ case QZ_F9: return KEY_F + 9;
+ case QZ_F10: return KEY_F + 10;
+ case QZ_F11: return KEY_F + 11;
+ case QZ_F12: return KEY_F + 12;
+ case QZ_INSERT: return KEY_INSERT;
+ case QZ_DELETE: return KEY_DELETE;
+ case QZ_HOME: return KEY_HOME;
+ case QZ_END: return KEY_END;
+ case QZ_KP_PLUS: return '+';
+ case QZ_KP_MINUS: return '-';
+ case QZ_TAB: return KEY_TAB;
+ case QZ_PAGEUP: return KEY_PAGE_UP;
+ case QZ_PAGEDOWN: return KEY_PAGE_DOWN;
+ case QZ_UP: return KEY_UP;
+ case QZ_DOWN: return KEY_DOWN;
+ case QZ_LEFT: return KEY_LEFT;
+ case QZ_RIGHT: return KEY_RIGHT;
+ case QZ_KP_MULTIPLY: return '*';
+ case QZ_KP_DIVIDE: return '/';
+ case QZ_KP_ENTER: return KEY_KPENTER;
+ case QZ_KP_PERIOD: return KEY_KPDEC;
+ case QZ_KP0: return KEY_KP0;
+ case QZ_KP1: return KEY_KP1;
+ case QZ_KP2: return KEY_KP2;
+ case QZ_KP3: return KEY_KP3;
+ case QZ_KP4: return KEY_KP4;
+ case QZ_KP5: return KEY_KP5;
+ case QZ_KP6: return KEY_KP6;
+ case QZ_KP7: return KEY_KP7;
+ case QZ_KP8: return KEY_KP8;
+ case QZ_KP9: return KEY_KP9;
+ default: return charcode;
}
}
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
{
- switch (image_format)
- {
- case IMGFMT_RGB32:
- vo_draw_alpha_rgb32(w,h,src,srca,stride,image_data+4*(y0*imgRect.right+x0),4*imgRect.right);
- break;
- case IMGFMT_YV12:
- case IMGFMT_IYUV:
- case IMGFMT_I420:
- vo_draw_alpha_yv12(w,h,src,srca,stride, ((char*)P) + be2me_32(P->componentInfoY.offset) + x0 + y0 * imgRect.right, imgRect.right);
- break;
- case IMGFMT_UYVY:
- vo_draw_alpha_uyvy(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2);
- break;
- case IMGFMT_YUY2:
- vo_draw_alpha_yuy2(w,h,src,srca,stride,((char*)P) + (x0 + y0 * imgRect.right) * 2,imgRect.right*2);
- break;
- }
+ switch (image_format)
+ {
+ case IMGFMT_RGB32:
+ vo_draw_alpha_rgb32(w, h, src, srca, stride, image_data + 4 * (y0 * imgRect.right + x0), 4 * imgRect.right);
+ break;
+ case IMGFMT_YV12:
+ case IMGFMT_IYUV:
+ case IMGFMT_I420:
+ vo_draw_alpha_yv12(w, h, src, srca, stride, ((char *)P) + be2me_32(P->componentInfoY.offset) + x0 + y0 * imgRect.right, imgRect.right);
+ break;
+ case IMGFMT_UYVY:
+ vo_draw_alpha_uyvy(w, h, src, srca, stride, ((char *)P) + (x0 + y0 * imgRect.right) * 2, imgRect.right * 2);
+ break;
+ case IMGFMT_YUY2:
+ vo_draw_alpha_yuy2(w, h, src, srca, stride, ((char *)P) + (x0 + y0 * imgRect.right) * 2, imgRect.right * 2);
+ break;
+ }
}
//default keyboard event handler
static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
OSStatus result = noErr;
- UInt32 class = GetEventClass (event);
- UInt32 kind = GetEventKind (event);
-
- result = CallNextEventHandler(nextHandler, event);
-
- if(class == kEventClassKeyboard)
- {
- char macCharCodes;
- UInt32 macKeyCode;
- UInt32 macKeyModifiers;
-
- GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes);
- GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode);
- GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers);
-
- if(macKeyModifiers != 256)
- {
- if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown)
- {
- int key = convert_key(macKeyCode, macCharCodes);
- if(key != -1)
- mplayer_put_key(key);
- }
- }
- else if(macKeyModifiers == 256)
- {
- switch(macCharCodes)
- {
- case '[': SetWindowAlpha(theWindow, winAlpha-=0.05); break;
- case ']': SetWindowAlpha(theWindow, winAlpha+=0.05); break;
- }
- }
- else
- result = eventNotHandledErr;
- }
+ UInt32 class = GetEventClass(event);
+ UInt32 kind = GetEventKind(event);
+
+ result = CallNextEventHandler(nextHandler, event);
+
+ if (class == kEventClassKeyboard)
+ {
+ char macCharCodes;
+ UInt32 macKeyCode;
+ UInt32 macKeyModifiers;
+
+ GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(macCharCodes), NULL, &macCharCodes);
+ GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(macKeyCode), NULL, &macKeyCode);
+ GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macKeyModifiers), NULL, &macKeyModifiers);
+
+ if (macKeyModifiers != 256)
+ {
+ if (kind == kEventRawKeyRepeat || kind == kEventRawKeyDown)
+ {
+ int key = convert_key(macKeyCode, macCharCodes);
+
+ if (key != -1)
+ mplayer_put_key(key);
+ }
+ }
+ else if (macKeyModifiers == 256)
+ {
+ switch (macCharCodes)
+ {
+ case '[': SetWindowAlpha(theWindow, winAlpha -= 0.05); break;
+ case ']': SetWindowAlpha(theWindow, winAlpha += 0.05); break;
+ }
+ }
+ else
+ result = eventNotHandledErr;
+ }
return result;
}
@@ -261,127 +262,128 @@ static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event,
static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
OSStatus result = noErr;
- UInt32 class = GetEventClass (event);
- UInt32 kind = GetEventKind (event);
-
- result = CallNextEventHandler(nextHandler, event);
-
- if(class == kEventClassMouse)
- {
- WindowPtr tmpWin;
- Point mousePos;
- Point winMousePos;
-
- GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos);
- GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos);
-
- switch (kind)
- {
- case kEventMouseMoved:
- {
- if(vo_quartz_fs)
- {
- CGDisplayShowCursor(displayId);
- mouseHide = FALSE;
- }
- }
- break;
-
- case kEventMouseWheelMoved:
- {
- int wheel;
- short part;
-
- GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel);
-
- part = FindWindow(mousePos,&tmpWin);
-
- if(part == inContent)
- {
- if(wheel > 0)
- mplayer_put_key(MOUSE_BTN3);
- else
- mplayer_put_key(MOUSE_BTN4);
- }
- }
- break;
-
- case kEventMouseDown:
- case kEventMouseUp:
- {
- EventMouseButton button;
- short part;
- Rect bounds;
-
- GetWindowPortBounds(theWindow, &bounds);
- GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button);
-
- part = FindWindow(mousePos,&tmpWin);
- if(kind == kEventMouseUp)
- {
- if (part != inContent)
- break;
- switch(button)
- {
- case kEventMouseButtonPrimary:
- mplayer_put_key(MOUSE_BTN0);
- break;
- case kEventMouseButtonSecondary:
- mplayer_put_key(MOUSE_BTN2);
- break;
- case kEventMouseButtonTertiary:
- mplayer_put_key(MOUSE_BTN1);
- break;
+ UInt32 class = GetEventClass(event);
+ UInt32 kind = GetEventKind(event);
+
+ result = CallNextEventHandler(nextHandler, event);
+
+ if (class == kEventClassMouse)
+ {
+ WindowPtr tmpWin;
+ Point mousePos;
+ Point winMousePos;
+
+ GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &mousePos);
+ GetEventParameter(event, kEventParamWindowMouseLocation, typeQDPoint, 0, sizeof(Point), 0, &winMousePos);
+
+ switch (kind)
+ {
+ case kEventMouseMoved:
+ {
+ if (vo_quartz_fs)
+ {
+ CGDisplayShowCursor(displayId);
+ mouseHide = FALSE;
+ }
+ }
+ break;
+
+ case kEventMouseWheelMoved:
+ {
+ int wheel;
+ short part;
+
+ GetEventParameter(event, kEventParamMouseWheelDelta, typeSInt32, 0, sizeof(int), 0, &wheel);
+
+ part = FindWindow(mousePos, &tmpWin);
+
+ if (part == inContent)
+ {
+ if (wheel > 0)
+ mplayer_put_key(MOUSE_BTN3);
+ else
+ mplayer_put_key(MOUSE_BTN4);
+ }
+ }
+ break;
+
+ case kEventMouseDown:
+ case kEventMouseUp:
+ {
+ EventMouseButton button;
+ short part;
+ Rect bounds;
+
+ GetWindowPortBounds(theWindow, &bounds);
+ GetEventParameter(event, kEventParamMouseButton, typeMouseButton, 0, sizeof(EventMouseButton), 0, &button);
+
+ part = FindWindow(mousePos, &tmpWin);
+ if (kind == kEventMouseUp)
+ {
+ if (part != inContent)
+ break;
+ switch (button)
+ {
+ case kEventMouseButtonPrimary:
+ mplayer_put_key(MOUSE_BTN0);
+ break;
+ case kEventMouseButtonSecondary:
+ mplayer_put_key(MOUSE_BTN2);
+ break;
+ case kEventMouseButtonTertiary:
+ mplayer_put_key(MOUSE_BTN1);
+ break;
default:
result = eventNotHandledErr;
break;
- }
- break;
- }
- if( (winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)) )
- {
- if(!vo_quartz_fs)
- {
- Rect newSize;
- ResizeWindow(theWindow, mousePos, NULL, &newSize);
- }
- }
- else if(part == inMenuBar)
- {
- MenuSelect(mousePos);
- HiliteMenu(0);
- }
- else if(part == inContent)
- {
- switch(button)
- {
- case kEventMouseButtonPrimary:
- mplayer_put_key(MOUSE_BTN0 | MP_KEY_DOWN);
- break;
- case kEventMouseButtonSecondary:
- mplayer_put_key(MOUSE_BTN2 | MP_KEY_DOWN);
- break;
- case kEventMouseButtonTertiary:
- mplayer_put_key(MOUSE_BTN1 | MP_KEY_DOWN);
- break;
+ }
+ break;
+ }
+ if ((winMousePos.h > (bounds.right - 15)) && (winMousePos.v > (bounds.bottom)))
+ {
+ if (!vo_quartz_fs)
+ {
+ Rect newSize;
+
+ ResizeWindow(theWindow, mousePos, NULL, &newSize);
+ }
+ }
+ else if (part == inMenuBar)
+ {
+ MenuSelect(mousePos);
+ HiliteMenu(0);
+ }
+ else if (part == inContent)
+ {
+ switch (button)
+ {
+ case kEventMouseButtonPrimary:
+ mplayer_put_key(MOUSE_BTN0 | MP_KEY_DOWN);
+ break;
+ case kEventMouseButtonSecondary:
+ mplayer_put_key(MOUSE_BTN2 | MP_KEY_DOWN);
+ break;
+ case kEventMouseButtonTertiary:
+ mplayer_put_key(MOUSE_BTN1 | MP_KEY_DOWN);
+ break;
default:
result = eventNotHandledErr;
break;
- }
- }
- }
- break;
+ }
+ }
+ }
+ break;
- case kEventMouseDragged:
- break;
+ case kEventMouseDragged:
+ break;
default:
result = eventNotHandledErr;
break;
- }
- }
+ }
+ }
return result;
}
@@ -390,768 +392,771 @@ static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef even
static OSStatus WindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
OSStatus result = noErr;
- uint32_t d_width;
- uint32_t d_height;
- UInt32 class = GetEventClass (event);
- UInt32 kind = GetEventKind (event);
+ uint32_t d_width;
+ uint32_t d_height;
+ UInt32 class = GetEventClass(event);
+ UInt32 kind = GetEventKind(event);
- result = CallNextEventHandler(nextHandler, event);
+ result = CallNextEventHandler(nextHandler, event);
- aspect(&d_width,&d_height,A_NOZOOM);
+ aspect(&d_width, &d_height, A_NOZOOM);
+
+ if (class == kEventClassCommand)
+ {
+ HICommand theHICommand;
- if(class == kEventClassCommand)
- {
- HICommand theHICommand;
- GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
+ GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &theHICommand);
- switch ( theHICommand.commandID )
- {
- case kHICommandQuit:
- mplayer_put_key(KEY_CLOSE_WIN);
- break;
+ switch (theHICommand.commandID)
+ {
+ case kHICommandQuit:
+ mplayer_put_key(KEY_CLOSE_WIN);
+ break;
- case kHalfScreenCmd:
- if(vo_quartz_fs)
- {
+ case kHalfScreenCmd:
+ if (vo_quartz_fs)
+ {
vo_fs = (!(vo_fs));
window_fullscreen();
- }
+ }
- SizeWindow(theWindow, (d_width/2), ((d_width/movie_aspect)/2), 1);
- window_resized();
- break;
+ SizeWindow(theWindow, (d_width / 2), ((d_width / movie_aspect) / 2), 1);
+ window_resized();
+ break;
- case kNormalScreenCmd:
- if(vo_quartz_fs)
- {
+ case kNormalScreenCmd:
+ if (vo_quartz_fs)
+ {
vo_fs = (!(vo_fs));
window_fullscreen();
- }
+ }
- SizeWindow(theWindow, d_width, (d_width/movie_aspect), 1);
- window_resized();
- break;
+ SizeWindow(theWindow, d_width, (d_width / movie_aspect), 1);
+ window_resized();
+ break;
- case kDoubleScreenCmd:
- if(vo_quartz_fs)
- {
+ case kDoubleScreenCmd:
+ if (vo_quartz_fs)
+ {
vo_fs = (!(vo_fs));
window_fullscreen();
- }
+ }
- SizeWindow(theWindow, (d_width*2), ((d_width/movie_aspect)*2), 1);
- window_resized();
- break;
+ SizeWindow(theWindow, (d_width * 2), ((d_width / movie_aspect) * 2), 1);
+ window_resized();
+ break;
- case kFullScreenCmd:
+ case kFullScreenCmd:
vo_fs = (!(vo_fs));
window_fullscreen();
- break;
-
- case kKeepAspectCmd:
- vo_keepaspect = (!(vo_keepaspect));
- CheckMenuItem (aspectMenu, 1, vo_keepaspect);
- window_resized();
- break;
-
- case kAspectOrgCmd:
- movie_aspect = old_movie_aspect;
- if(!vo_quartz_fs)
- {
- SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
- }
- window_resized();
- break;
-
- case kAspectFullCmd:
- movie_aspect = 4.0f/3.0f;
- if(!vo_quartz_fs)
- {
- SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
- }
- window_resized();
- break;
-
- case kAspectWideCmd:
- movie_aspect = 16.0f/9.0f;
- if(!vo_quartz_fs)
- {
- SizeWindow(theWindow, dstRect.right, (dstRect.right/movie_aspect),1);
- }
- window_resized();
- break;
-
- case kPanScanCmd:
- vo_panscan = (!(vo_panscan));
- CheckMenuItem (aspectMenu, 2, vo_panscan);
- window_panscan();
- window_resized();
- break;
-
- default:
- result = eventNotHandledErr;
- break;
- }
- }
- else if(class == kEventClassWindow)
- {
- WindowRef window;
- Rect rectWindow = {0,0,0,0};
-
- GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
-
- if(window)
- {
- GetWindowBounds(window, kWindowGlobalPortRgn, &rectWindow);
- }
-
- switch (kind)
- {
- case kEventWindowClosed:
- theWindow = NULL;
- mplayer_put_key(KEY_CLOSE_WIN);
- break;
-
- //resize window
- case kEventWindowZoomed:
- case kEventWindowBoundsChanged:
- window_resized();
- flip_page();
- window_resized();
- break;
-
- default:
- result = eventNotHandledErr;
- break;
- }
- }
+ break;
+
+ case kKeepAspectCmd:
+ vo_keepaspect = (!(vo_keepaspect));
+ CheckMenuItem(aspectMenu, 1, vo_keepaspect);
+ window_resized();
+ break;
+
+ case kAspectOrgCmd:
+ movie_aspect = old_movie_aspect;
+ if (!vo_quartz_fs)
+ {
+ SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
+ }
+ window_resized();
+ break;
+
+ case kAspectFullCmd:
+ movie_aspect = 4.0f / 3.0f;
+ if (!vo_quartz_fs)
+ {
+ SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
+ }
+ window_resized();
+ break;
+
+ case kAspectWideCmd:
+ movie_aspect = 16.0f / 9.0f;
+ if (!vo_quartz_fs)
+ {
+ SizeWindow(theWindow, dstRect.right, (dstRect.right / movie_aspect), 1);
+ }
+ window_resized();
+ break;
+
+ case kPanScanCmd:
+ vo_panscan = (!(vo_panscan));
+ CheckMenuItem(aspectMenu, 2, vo_panscan);
+ window_panscan();
+ window_resized();
+ break;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
+ else if (class == kEventClassWindow)
+ {
+ WindowRef window;
+ Rect rectWindow = { 0, 0, 0, 0 };
+
+ GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
+
+ if (window)
+ {
+ GetWindowBounds(window, kWindowGlobalPortRgn, &rectWindow);
+ }
+
+ switch (kind)
+ {
+ case kEventWindowClosed:
+ theWindow = NULL;
+ mplayer_put_key(KEY_CLOSE_WIN);
+ break;
+
+ // resize window
+ case kEventWindowZoomed:
+ case kEventWindowBoundsChanged:
+ window_resized();
+ flip_page();
+ window_resized();
+ break;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
return result;
}
static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs)
{
- CFStringRef titleKey;
- CFStringRef windowTitle;
- OSStatus result;
+ CFStringRef titleKey;
+ CFStringRef windowTitle;
+ OSStatus result;
- MenuItemIndex index;
- CFStringRef movMenuTitle;
- CFStringRef aspMenuTitle;
+ MenuItemIndex index;
+ CFStringRef movMenuTitle;
+ CFStringRef aspMenuTitle;
const EventTypeSpec win_events[] = {
- { kEventClassWindow, kEventWindowClosed },
- { kEventClassWindow, kEventWindowBoundsChanged },
- { kEventClassCommand, kEventCommandProcess }
+ {kEventClassWindow, kEventWindowClosed},
+ {kEventClassWindow, kEventWindowBoundsChanged},
+ {kEventClassCommand, kEventCommandProcess}
};
const EventTypeSpec key_events[] = {
- { kEventClassKeyboard, kEventRawKeyDown },
- { kEventClassKeyboard, kEventRawKeyRepeat }
+ {kEventClassKeyboard, kEventRawKeyDown},
+ {kEventClassKeyboard, kEventRawKeyRepeat}
};
- const EventTypeSpec mouse_events[] = {
- { kEventClassMouse, kEventMouseMoved },
- { kEventClassMouse, kEventMouseWheelMoved },
- { kEventClassMouse, kEventMouseDown },
- { kEventClassMouse, kEventMouseUp },
- { kEventClassMouse, kEventMouseDragged }
- };
+ const EventTypeSpec mouse_events[] = {
+ {kEventClassMouse, kEventMouseMoved},
+ {kEventClassMouse, kEventMouseWheelMoved},
+ {kEventClassMouse, kEventMouseDown},
+ {kEventClassMouse, kEventMouseUp},
+ {kEventClassMouse, kEventMouseDragged}
+ };
- SetRect(&winRect, 0, 0, d_width, d_height);
- SetRect(&oldWinRect, 0, 0, d_width, d_height);
- SetRect(&dstRect, 0, 0, d_width, d_height);
+ SetRect(&winRect, 0, 0, d_width, d_height);
+ SetRect(&oldWinRect, 0, 0, d_width, d_height);
+ SetRect(&dstRect, 0, 0, d_width, d_height);
- //Clear Menu Bar
- ClearMenuBar();
+ // Clear Menu Bar
+ ClearMenuBar();
- //Create Window Menu
- CreateStandardWindowMenu(0, &windMenu);
- InsertMenu(windMenu, 0);
+ // Create Window Menu
+ CreateStandardWindowMenu(0, &windMenu);
+ InsertMenu(windMenu, 0);
- //Create Movie Menu
- CreateNewMenu (1004, 0, &movMenu);
- movMenuTitle = CFSTR("Movie");
- SetMenuTitleWithCFString(movMenu, movMenuTitle);
+ // Create Movie Menu
+ CreateNewMenu(1004, 0, &movMenu);
+ movMenuTitle = CFSTR("Movie");
+ SetMenuTitleWithCFString(movMenu, movMenuTitle);
- AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index);
- SetMenuItemCommandKey(movMenu, index, 0, '0');
+ AppendMenuItemTextWithCFString(movMenu, CFSTR("Half Size"), 0, kHalfScreenCmd, &index);
+ SetMenuItemCommandKey(movMenu, index, 0, '0');
- AppendMenuItemTextWithCFString(movMenu, CFSTR("Normal Size"), 0, kNormalScreenCmd, &index);
- SetMenuItemCommandKey(movMenu, index, 0, '1');
+ AppendMenuItemTextWithCFString(movMenu, CFSTR("Normal Size"), 0, kNormalScreenCmd, &index);
+ SetMenuItemCommandKey(movMenu, index, 0, '1');
- AppendMenuItemTextWithCFString(movMenu, CFSTR("Double Size"), 0, kDoubleScreenCmd, &index);
- SetMenuItemCommandKey(movMenu, index, 0, '2');
+ AppendMenuItemTextWithCFString(movMenu, CFSTR("Double Size"), 0, kDoubleScreenCmd, &index);
+ SetMenuItemCommandKey(movMenu, index, 0, '2');
- AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index);
- SetMenuItemCommandKey(movMenu, index, 0, 'F');
+ AppendMenuItemTextWithCFString(movMenu, CFSTR("Full Size"), 0, kFullScreenCmd, &index);
+ SetMenuItemCommandKey(movMenu, index, 0, 'F');
- AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, 0, &index);
+ AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, 0, &index);
- AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, 0, &index);
+ AppendMenuItemTextWithCFString(movMenu, CFSTR("Aspect Ratio"), 0, 0, &index);
- ////Create Aspect Ratio Sub Menu
- CreateNewMenu (0, 0, &aspectMenu);
- aspMenuTitle = CFSTR("Aspect Ratio");
- SetMenuTitleWithCFString(aspectMenu, aspMenuTitle);
- SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu);
+ //// Create Aspect Ratio Sub Menu
+ CreateNewMenu(0, 0, &aspectMenu);
+ aspMenuTitle = CFSTR("Aspect Ratio");
+ SetMenuTitleWithCFString(aspectMenu, aspMenuTitle);
+ SetMenuItemHierarchicalMenu(movMenu, 6, aspectMenu);
- AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index);
- CheckMenuItem (aspectMenu, 1, vo_keepaspect);
- AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Pan-Scan"), 0, kPanScanCmd, &index);
- CheckMenuItem (aspectMenu, 2, vo_panscan);
- AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, 0, &index);
- AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index);
- AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index);
- AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index);
+ AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Keep"), 0, kKeepAspectCmd, &index);
+ CheckMenuItem(aspectMenu, 1, vo_keepaspect);
+ AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Pan-Scan"), 0, kPanScanCmd, &index);
+ CheckMenuItem(aspectMenu, 2, vo_panscan);
+ AppendMenuItemTextWithCFString(aspectMenu, NULL, kMenuItemAttrSeparator, 0, &index);
+ AppendMenuItemTextWithCFString(aspectMenu, CFSTR("Original"), 0, kAspectOrgCmd, &index);
+ AppendMenuItemTextWithCFString(aspectMenu, CFSTR("4:3"), 0, kAspectFullCmd, &index);
+ AppendMenuItemTextWithCFString(aspectMenu, CFSTR("16:9"), 0, kAspectWideCmd, &index);
- InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu
+ InsertMenu(movMenu, GetMenuID(windMenu)); //insert before Window menu
- DrawMenuBar();
+ DrawMenuBar();
- //create window
- CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow);
+ // create window
+ CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow);
- CreateWindowGroup(0, &winGroup);
- SetWindowGroup(theWindow, winGroup);
+ CreateWindowGroup(0, &winGroup);
+ SetWindowGroup(theWindow, winGroup);
- //Set window title
- titleKey = CFSTR("MPlayer - The Movie Player");
- windowTitle = CFCopyLocalizedString(titleKey, NULL);
- result = SetWindowTitleWithCFString(theWindow, windowTitle);
- CFRelease(titleKey);
- CFRelease(windowTitle);
+ // Set window title
+ titleKey = CFSTR("MPlayer - The Movie Player");
+ windowTitle = CFCopyLocalizedString(titleKey, NULL);
+ result = SetWindowTitleWithCFString(theWindow, windowTitle);
+ CFRelease(titleKey);
+ CFRelease(windowTitle);
- //Install event handler
- InstallApplicationEventHandler (NewEventHandlerUPP (KeyEventHandler), GetEventTypeCount(key_events), key_events, NULL, NULL);
- InstallApplicationEventHandler (NewEventHandlerUPP (MouseEventHandler), GetEventTypeCount(mouse_events), mouse_events, NULL, NULL);
- InstallWindowEventHandler (theWindow, NewEventHandlerUPP (WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL);
+ // Install event handler
+ InstallApplicationEventHandler(NewEventHandlerUPP(KeyEventHandler), GetEventTypeCount(key_events), key_events, NULL, NULL);
+ InstallApplicationEventHandler(NewEventHandlerUPP(MouseEventHandler), GetEventTypeCount(mouse_events), mouse_events, NULL, NULL);
+ InstallWindowEventHandler(theWindow, NewEventHandlerUPP(WindowEventHandler), GetEventTypeCount(win_events), win_events, theWindow, NULL);
}
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
- WindowAttributes windowAttrs;
- OSErr qterr;
- CGRect tmpBounds;
- CGDisplayCount displayCount;
- CGDirectDisplayID *displays;
-
- //Get Main device info///////////////////////////////////////////////////
-
- //Display IDs might not be consecutive, get the list of all devices up to # device_id
- displayCount = device_id + 1;
- displays = malloc(sizeof(CGDirectDisplayID) * displayCount);
- if (kCGErrorSuccess != CGGetActiveDisplayList(displayCount, displays, &displayCount) || displayCount < device_id + 1) {
- mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id);
- displayId = kCGDirectMainDisplay;
- device_id = 0;
- }
- else
- {
- displayId = displays[device_id];
- }
- free(displays);
-
- displayRect = CGDisplayBounds(displayId);
-
- monitor_aspect = (float)displayRect.size.width/(float)displayRect.size.height;
-
- //misc mplayer setup/////////////////////////////////////////////////////
- SetRect(&imgRect, 0, 0, width, height);
- switch (image_format)
- {
- case IMGFMT_RGB32:
- image_depth = 32;
- break;
- case IMGFMT_YV12:
- case IMGFMT_IYUV:
+ WindowAttributes windowAttrs;
+ OSErr qterr;
+ CGRect tmpBounds;
+ CGDisplayCount displayCount;
+ CGDirectDisplayID *displays;
+
+ // Get Main device info///////////////////////////////////////////////////
+
+ // Display IDs might not be consecutive, get the list of all devices up to # device_id
+ displayCount = device_id + 1;
+ displays = malloc(sizeof(CGDirectDisplayID) * displayCount);
+ if (kCGErrorSuccess != CGGetActiveDisplayList(displayCount, displays, &displayCount) || displayCount < device_id + 1) {
+ mp_msg(MSGT_VO, MSGL_FATAL, "Quartz error: Device ID %d do not exist, falling back to main device.\n", device_id);