From ab4bdb64e1010be0b408012a79629d05a663b7a1 Mon Sep 17 00:00:00 2001 From: ptt Date: Thu, 12 Nov 2009 09:21:53 +0000 Subject: [PATCH] Added -name, -title and -use-filename-title options and implementation in X11 vos git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29904 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 14 ++++++++++++++ cfg-mplayer.h | 5 +++++ libvo/video_out.c | 5 +++++ libvo/video_out.h | 3 +++ libvo/x11_common.c | 5 ++++- mplayer.c | 6 +++++- 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index 5a6f039121..a2730fb05d 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -3204,6 +3204,10 @@ A value of 1 means square pixels (correct for (almost?) all LCDs). . .TP +.B \-name (X11 only) +Set the window class name. +. +.TP .B \-nodouble Disables double buffering, mostly for debugging purposes. Double buffering fixes flicker by storing two frames in memory, and @@ -3283,6 +3287,16 @@ If your screensaver supports neither the XSS nor XResetScreenSaver API please use \-heartbeat\-cmd instead. . .TP +.B \-title (also see \-use\-filename\-title) +Set the window title. +Supported by X11 based video output drivers. +. +.TP +.B \-use\-filename\-title (also see \-title) +Set the window title using the media file name, when not set with \-title. +Supported by X11 based video output drivers. +. +.TP .B "\-vm \ \ \ " Try to change to a different video mode. Supported by the dga, x11, xv, sdl and directx video output drivers. diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 5b297dd450..630d5e9d4a 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -170,6 +170,9 @@ const m_option_t mplayer_opts[]={ {"screenh", &vo_screenheight, CONF_TYPE_INT, CONF_RANGE|CONF_OLD, 0, 4096, NULL}, // Geometry string {"geometry", &vo_geometry, CONF_TYPE_STRING, 0, 0, 0, NULL}, + // vo name (X classname) and window title strings + {"name", &vo_winname, CONF_TYPE_STRING, 0, 0, 0, NULL}, + {"title", &vo_wintitle, CONF_TYPE_STRING, 0, 0, 0, NULL}, // set aspect ratio of monitor - useful for 16:9 TV-out {"monitoraspect", &force_monitor_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 9.0, NULL}, {"monitorpixelaspect", &monitor_pixel_aspect, CONF_TYPE_FLOAT, CONF_RANGE, 0.2, 9.0, NULL}, @@ -246,6 +249,8 @@ const m_option_t mplayer_opts[]={ {"use-filedir-conf", &use_filedir_conf, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"nouse-filedir-conf", &use_filedir_conf, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, + {"use-filename-title", &use_filename_title, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, + {"nouse-filename-title", &use_filename_title, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, #ifdef CONFIG_CRASH_DEBUG {"crash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL}, {"nocrash-debug", &crash_debug, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL}, diff --git a/libvo/video_out.c b/libvo/video_out.c index e636902d2e..ec4cd9c109 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -79,6 +79,11 @@ int vo_directrendering=0; int vo_colorkey = 0x0000ff00; // default colorkey is green // (0xff000000 means that colorkey has been disabled) +// name to be used instead of the vo's default +char *vo_winname; +// title to be applied to movie window +char *vo_wintitle; + // // Externally visible list of all vo drivers // diff --git a/libvo/video_out.h b/libvo/video_out.h index ae38970209..b143ff5554 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -250,6 +250,9 @@ extern char *vo_subdevice; extern int vo_colorkey; +extern char *vo_winname; +extern char *vo_wintitle; + extern int64_t WinID; typedef struct { diff --git a/libvo/x11_common.c b/libvo/x11_common.c index 1c8a2785c9..d1911401ce 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -738,7 +738,7 @@ void vo_x11_classhint(Display * display, Window window, char *name) XClassHint wmClass; pid_t pid = getpid(); - wmClass.res_name = name; + wmClass.res_name = vo_winname ? vo_winname : name; wmClass.res_class = "MPlayer"; XSetClassHint(display, window, &wmClass); XChangeProperty(display, window, XA_NET_WM_PID, XA_CARDINAL, 32, @@ -1335,6 +1335,9 @@ int vo_x11_update_geometry(void) { if (w <= INT_MAX && h <= INT_MAX) { vo_dwidth = w; vo_dheight = h; } XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy, &dummy_win); + if (vo_wintitle) + XStoreName(mDisplay, vo_window, vo_wintitle); + return depth <= INT_MAX ? depth : 0; } diff --git a/mplayer.c b/mplayer.c index 4ef2ac2df7..ee58b03660 100644 --- a/mplayer.c +++ b/mplayer.c @@ -349,6 +349,7 @@ edl_record_ptr next_edl_record = NULL; ///< only for traversing edl_records short edl_decision = 0; ///< 1 when an EDL operation has been made. FILE* edl_fd = NULL; ///< fd to write to when in -edlout mode. int use_filedir_conf; +int use_filename_title; static unsigned int initialized_flags=0; #include "mpcommon.h" @@ -3089,9 +3090,12 @@ while (player_idle_mode && !filename) { } //--------------------------------------------------------------------------- - if(filename) + if(filename) { mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename_recode(filename)); + if(use_filename_title && vo_wintitle == NULL) + vo_wintitle = strdup ( mp_basename2 (filename)); + } if (edl_filename) { if (edl_records) free_edl(edl_records);