1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-22 19:34:14 +00:00

Avoid duplicating mouse-movement command-generation code.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31091 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-04-25 16:13:57 +00:00
parent 38505822c7
commit 14c018a80f
5 changed files with 20 additions and 17 deletions

View File

@ -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; 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) #if defined(CONFIG_FBDEV) || defined(CONFIG_VESA)
/* Borrowed from vo_fbdev.c /* Borrowed from vo_fbdev.c
Monitor ranges related functions*/ Monitor ranges related functions*/

View File

@ -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, 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); struct vo_rect *borders, const struct vo_rect *crop);
void vo_mouse_movement(int posx, int posy);
static inline int aspect_scaling(void) static inline int aspect_scaling(void)
{ {

View File

@ -953,11 +953,8 @@ static int control(uint32_t request, void *data, ...)
if (enable_mouse_movements && !isRootwin) { if (enable_mouse_movements && !isRootwin) {
NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil]; NSPoint p =[self convertPoint:[theEvent locationInWindow] fromView:nil];
if ([self mouse:p inRect:textureFrame]) { if ([self mouse:p inRect:textureFrame]) {
char cmdstr[40]; vo_mouse_movement(vo_fs ? p.x : p.x - textureFrame.origin.x,
snprintf(cmdstr, sizeof(cmdstr), "set_mouse_pos %i %i", vo_fs ? [self frame].size.height - p.y : NSMaxY(textureFrame) - p.y);
(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));
} }
} }
} }

View File

@ -159,12 +159,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
mplayer_put_key(MOUSE_BTN2); mplayer_put_key(MOUSE_BTN2);
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (enable_mouse_movements) { vo_mouse_movement(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
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));
}
break; break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
if (!vo_nomouse_input) { if (!vo_nomouse_input) {

View File

@ -873,12 +873,7 @@ int vo_x11_check_events(Display * mydisplay)
} }
break; break;
case MotionNotify: case MotionNotify:
if(enable_mouse_movements) vo_mouse_movement(Event.xmotion.x, Event.xmotion.y);
{
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));
}
if (vo_mouse_autohide) if (vo_mouse_autohide)
{ {