summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-16 15:13:41 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-16 15:13:41 +0000
commit2003857aa2bb32f24f72561374569dd2a2132cc2 (patch)
tree6f1d8d1bc45e988f9a904f871a6e7ca5fa597541
parent8bab2f0d70e1e1d3c368618c5b5a9c98925217b4 (diff)
downloadmpv-2003857aa2bb32f24f72561374569dd2a2132cc2.tar.bz2
mpv-2003857aa2bb32f24f72561374569dd2a2132cc2.tar.xz
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
-rw-r--r--cfg-mplayer.h3
-rw-r--r--input/input.c1
-rw-r--r--input/input.h1
-rw-r--r--libvo/x11_common.c8
-rw-r--r--mplayer.c27
5 files changed, 40 insertions, 0 deletions
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index bd6a2faedc..5bca0469cc 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -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"
diff --git a/input/input.c b/input/input.c
index 5fe3c96eb0..528c50445a 100644
--- a/input/input.c
+++ b/input/input.c
@@ -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, {} }
};
diff --git a/input/input.h b/input/input.h
index dc4da8899d..bdb385c5e4 100644
--- a/input/input.h
+++ b/input/input.h
@@ -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
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 9149192c40..d2607b7455 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -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);
diff --git a/mplayer.c b/mplayer.c
index b6df2324c0..2e906cfbb5 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -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;