summaryrefslogtreecommitdiffstats
path: root/libvo/vo_quartz.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2008-11-25 21:12:01 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2008-11-25 21:12:01 +0200
commit835511ac394d5283c9c449e6154ccb0db1365321 (patch)
treec223ee6b82481a0030273cfae9e831dada249fd8 /libvo/vo_quartz.c
parent6c712271ce9e8d4eb9cd615e920139ebcb1d1d49 (diff)
parentcc5e0406412a5f8b4e6e7094f6ffa18a65decd74 (diff)
downloadmpv-835511ac394d5283c9c449e6154ccb0db1365321.tar.bz2
mpv-835511ac394d5283c9c449e6154ccb0db1365321.tar.xz
Merge svn changes up to r28038
Diffstat (limited to 'libvo/vo_quartz.c')
-rw-r--r--libvo/vo_quartz.c2512
1 files changed, 1276 insertions, 1236 deletions
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index 164d00b79d..cc7cdb922b 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -1,19 +1,17 @@
-/*
- vo_quartz.c
-
- by Nicolas Plourde <nicolasplourde@gmail.com>
-
- Copyright (c) Nicolas Plourde - April 2004
-
- YUV support Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
-
- MPlayer Mac OSX Quartz video out module.
-
- todo: -screen overlay output
- -fit osd in black bar when available
- -fix RGB32
- -(add sugestion here)
- */
+/**
+ \author Nicolas Plourde <nicolasplourde@gmail.com>
+
+ Copyright (c) Nicolas Plourde - April 2004
+
+ YUV support Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
+
+ \brief MPlayer Mac OSX Quartz video out module.
+
+ \todo: -screen overlay output
+ -fit osd in black bar when available
+ -fix RGB32
+ -(add sugestion here)
+*/
//SYS
#include <stdio.h>
@@ -38,12 +36,12 @@
#include "vo_quartz.h"
-static const vo_info_t info =
+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)
@@ -59,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;
@@ -84,45 +82,46 @@ static int int_pause = 0;
static float winAlpha = 1;
static int mouseHide = FALSE;
-static int device_width;
-static int device_height;
-static int device_id;
+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;
-static CGContextRef context;
static CGRect bounds;
-static GDHandle deviceHdl;
+static CGDirectDisplayID displayId = 0;
+static CFDictionaryRef originalMode = NULL;
-static CGDataProviderRef dataProviderRef;
-static CGImageRef image;
+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 Rect deviceRect; // 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;
static MenuRef movMenu;
static MenuRef aspectMenu;
+static int lastScreensaverUpdate = 0;
+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"
@@ -138,119 +137,120 @@ 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;
}
@@ -258,120 +258,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(kCGDirectMainDisplay);
- 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)
- {
- GrowWindow(theWindow, mousePos, NULL);
- }
- }
- 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;
-
- case kEventMouseDragged:
- break;
-
- default:result = eventNotHandledErr;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;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
+ }
+ break;
+
+ case kEventMouseDragged:
+ break;
+
+ default:
+ result = eventNotHandledErr;
+ break;
+ }
+ }
return result;
}
@@ -380,1070 +388,1102 @@ 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);
-
- result = CallNextEventHandler(nextHandler, event);
-
- aspect(&d_width,&d_height,A_NOZOOM);
-
- if(class == kEventClassCommand)
- {
- HICommand theHICommand;
- GetEventParameter( event, kEventParamDirectObject, typeHICommand, NULL, sizeof( HICommand ), NULL, &theHICommand );
-
- switch ( theHICommand.commandID )
- {
- case kHICommandQuit:
- mplayer_put_key(KEY_CLOSE_WIN);
- break;
-
- 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;
-
- case kNormalScreenCmd:
- if(vo_quartz_fs)
- {
- vo_fs = (!(vo_fs)); window_fullscreen();
- }
-
- SizeWindow(theWindow, d_width, (d_width/movie_aspect), 1);
- window_resized();
- break;
-
- 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;
-
- 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 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_CLOSE_WIN);
- break;
-
- //resize window
- case kEventWindowZoomed:
- case kEventWindowBoundsChanged:
- window_resized();
- flip_page();
- window_resized();
- break;
-
- default:
- result = eventNotHandledErr;
- break;
- }
- }
-
+ uint32_t d_width;
+ uint32_t d_height;
+ UInt32 class = GetEventClass(event);
+ UInt32 kind = GetEventKind(event);
+
+ result = CallNextEventHandler(nextHandler, event);
+
+ aspect(&d_width, &d_height, A_NOZOOM);
+
+ if (class == kEventClassCommand)
+ {
+ HICommand theHICommand;
+
+ GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &theHICommand);
+
+ switch (theHICommand.commandID)
+ {
+ case kHICommandQuit:
+ mplayer_put_key(KEY_CLOSE_WIN);
+ break;
+
+ 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;
+
+ case kNormalScreenCmd:
+ if (vo_quartz_fs)
+ {
+ vo_fs = (!(vo_fs));
+ window_fullscreen();
+ }
+
+ SizeWindow(theWindow, d_width, (d_width / movie_aspect), 1);
+ window_resized();
+ break;
+
+ 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;
+
+ 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;
+ }
+ }
+
return result;
}
-static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs)
+static void quartz_CreateWindow(uint32_t d_width, uint32_t d_height, WindowAttributes windowAttrs)
{
- CFStringRef titleKey;
- CFStringRef windowTitle;
- OSStatus result;
-
- MenuItemIndex index;
- CFStringRef movMenuTitle;
- CFStringRef aspMenuTitle;
-
+ CFStringRef titleKey;
+ CFStringRef windowTitle;
+ OSStatus result;
+
+ 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);
-
- //Clear Menu Bar
- ClearMenuBar();
-
- //Create Window Menu
- CreateStandardWindowMenu(0, &windMenu);
- InsertMenu(windMenu, 0);
-
- //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("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("Full Size"), 0, kFullScreenCmd, &index);
- SetMenuItemCommandKey(movMenu, index, 0, 'F');
-
- AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, 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);
-
- 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
-
- DrawMenuBar();
-
- //create window
- CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow);
-
- 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);
-
- //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);
+ 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();
+
+ // Create Window Menu
+ CreateStandardWindowMenu(0, &windMenu);
+ InsertMenu(windMenu, 0);
+
+ // 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("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("Full Size"), 0, kFullScreenCmd, &index);
+ SetMenuItemCommandKey(movMenu, index, 0, 'F');
+
+ AppendMenuItemTextWithCFString(movMenu, NULL, kMenuItemAttrSeparator, 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);
+
+ 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
+
+ DrawMenuBar();
+
+ // create window
+ CreateNewWindow(kDocumentWindowClass, windowAttrs, &winRect, &theWindow);
+
+ CreateWindowGroup(0, &winGroup);