From 14c018a80f4908a6540e76e08047dcbf6d9dc059 Mon Sep 17 00:00:00 2001 From: reimar Date: Sun, 25 Apr 2010 16:13:57 +0000 Subject: Avoid duplicating mouse-movement command-generation code. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31091 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libvo/video_out.c | 15 +++++++++++++++ libvo/video_out.h | 1 + libvo/vo_corevideo.m | 7 ++----- libvo/w32_common.c | 7 +------ libvo/x11_common.c | 7 +------ 5 files changed, 20 insertions(+), 17 deletions(-) (limited to 'libvo') diff --git a/libvo/video_out.c b/libvo/video_out.c index c1786d27ba..fdb75ba8fb 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -446,6 +446,21 @@ void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, stru dst->height = dst->bottom - dst->top; } +/** + * Generates a mouse movement message if those are enable and sends it + * to the "main" MPlayer. + * + * \param posx new x position of mouse + * \param posy new y position of mouse + */ +void vo_mouse_movement(int posx, int posy) { + char cmd_str[40]; + if (!enable_mouse_movements) + return; + snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); + mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); +} + #if defined(CONFIG_FBDEV) || defined(CONFIG_VESA) /* Borrowed from vo_fbdev.c Monitor ranges related functions*/ diff --git a/libvo/video_out.h b/libvo/video_out.h index cdff7630a5..63f27ba0fb 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -281,6 +281,7 @@ struct vo_rect { }; void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop); +void vo_mouse_movement(int posx, int posy); static inline int aspect_scaling(void) { diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m index d6bb83e9ec..568fd7b802 100644 --- a/libvo/vo_corevideo.m +++ b/libvo/vo_corevideo.m @@ -953,11 +953,8 @@ static int control(uint32_t request, void *data, ...) if (enable_mouse_movements && !isRootwin) { NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil]; if ([self mouse:p inRect:textureFrame]) { - char cmdstr[40]; - snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i", - (int)(vo_fs ? p.x : (p.x - textureFrame.origin.x)), - (int)(vo_fs ? [self frame].size.height - p.y: (NSMaxY(textureFrame) - p.y))); - mp_input_queue_cmd(mp_input_parse_cmd(cmdstr)); + vo_mouse_movement(vo_fs ? p.x : p.x - textureFrame.origin.x, + vo_fs ? [self frame].size.height - p.y : NSMaxY(textureFrame) - p.y); } } } diff --git a/libvo/w32_common.c b/libvo/w32_common.c index 651386dbd8..bb420d87c9 100644 --- a/libvo/w32_common.c +++ b/libvo/w32_common.c @@ -159,12 +159,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l mplayer_put_key(MOUSE_BTN2); break; case WM_MOUSEMOVE: - if (enable_mouse_movements) { - char cmd_str[40]; - snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", - GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); - mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); - } + vo_mouse_movement(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); break; case WM_MOUSEWHEEL: if (!vo_nomouse_input) { diff --git a/libvo/x11_common.c b/libvo/x11_common.c index ff5b84f998..525772ace1 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -873,12 +873,7 @@ int vo_x11_check_events(Display * mydisplay) } break; case MotionNotify: - if(enable_mouse_movements) - { - char cmd_str[40]; - sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y); - mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); - } + vo_mouse_movement(Event.xmotion.x, Event.xmotion.y); if (vo_mouse_autohide) { -- cgit v1.2.3