report to mplayer with a slave command the coordinates of the pointer reported by x11; rescale coordinates to [0,1]x[0,1] range - patch by Jonas Jermann and me

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19856 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nicodvb 2006-09-16 15:13:41 +00:00
parent 8bab2f0d70
commit 2003857aa2
5 changed files with 40 additions and 0 deletions

View File

@ -101,6 +101,7 @@ extern int sws_flags;
extern int readPPOpt(void *conf, char *arg);
extern void revertPPOpt(void *conf, char* opt);
extern char* pp_help;
extern int enable_mouse_movements;
m_option_t vd_conf[]={
{"help", "Use MPlayer with an appropriate video file instead of live partners to avoid vd.\n", CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
@ -366,6 +367,8 @@ m_option_t mplayer_opts[]={
{"key-fifo-size", &key_fifo_size, CONF_TYPE_INT, CONF_RANGE, 2, 65000, NULL},
{"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"consolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL},
{"mouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomouse-movements", &enable_mouse_movements, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 0, NULL},
#define MAIN_CONF
#include "cfg-common.h"

View File

@ -167,6 +167,7 @@ static mp_cmd_t mp_cmds[] = {
{ MP_CMD_GET_PROPERTY, "get_property", 1, { {MP_CMD_ARG_STRING, {0}}, {-1,{0}} } },
{ MP_CMD_SEEK_CHAPTER, "seek_chapter", 1, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
{ MP_CMD_SET_MOUSE_POS, "set_mouse_pos", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
{ 0, NULL, 0, {} }
};

View File

@ -89,6 +89,7 @@
#define MP_CMD_RADIO_STEP_CHANNEL 87
#define MP_CMD_RADIO_SET_CHANNEL 88
#define MP_CMD_RADIO_SET_FREQ 89
#define MP_CMD_SET_MOUSE_POS 90
#define MP_CMD_GUI_EVENTS 5000
#define MP_CMD_GUI_LOADFILE 5001

View File

@ -63,6 +63,7 @@
#define WIN_LAYER_ONTOP 6
#define WIN_LAYER_ABOVE_DOCK 10
extern int enable_mouse_movements;
int fs_layer = WIN_LAYER_ABOVE_DOCK;
static int orig_layer = 0;
static int old_gravity = NorthWestGravity;
@ -1084,6 +1085,13 @@ 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));
}
if (vo_mouse_autohide)
{
vo_showcursor(mydisplay, vo_window);

View File

@ -86,6 +86,7 @@ extern int mp_input_win32_slave_cmd_func(int fd,char* dest,int size);
int slave_mode=0;
int player_idle_mode=0;
int quiet=0;
int enable_mouse_movements=0;
#ifdef WIN32
char * proc_priority=NULL;
@ -2713,6 +2714,24 @@ static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video)
return 1;
}
static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) {
//remove the borders, if any, and rescale to the range [0,1],[0,1]
if(vo_fs) { //we are in full-screen mode
if(vo_screenwidth > vo_dwidth) //there are borders along the x axis
ix -= (vo_screenwidth - vo_dwidth) / 2;
if(vo_screenheight > vo_dheight) //there are borders along the y axis (usual way)
iy -= (vo_screenheight - vo_dheight) / 2;
if(ix < 0 || ix > vo_dwidth) {*dx = *dy = -1.0; return; } //we are on one of the borders
if(iy < 0 || iy > vo_dheight) {*dx = *dy = -1.0; return; } //we are on one of the borders
}
*dx = (double) ix / (double) vo_dwidth;
*dy = (double) iy / (double) vo_dheight;
mp_msg(MSGT_CPLAYER,MSGL_V, "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
*dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, vo_dheight, vo_fs);
}
int main(int argc,char* argv[]){
@ -5132,6 +5151,14 @@ if(step_sec>0) {
}
break;
} break;
case MP_CMD_SET_MOUSE_POS: {
int button = 0, pointer_x, pointer_y;
double dx, dy;
pointer_x = cmd->args[0].v.i;
pointer_y = cmd->args[1].v.i;
rescale_input_coordinates(pointer_x, pointer_y, &dx, &dy);
break;
}
#ifdef USE_DVDNAV
case MP_CMD_DVDNAV: {
int button = 0;