mirror of https://github.com/mpv-player/mpv
libvo: remove title argument from struct vo_driver.config
This affects only the "new" VO API. The config() title argument was barely used, and it's hardcoded to "MPlayer" in vf_vo.c. The X11 and the Cocoa GUI backends, which are the only ones properly supporting window titles, ignored this argument. Remove the title argument. Add the vo_get_window_title function. All GUI VOs are supposed to use it for the window title.
This commit is contained in:
parent
421c840b3c
commit
d4de92e808
|
@ -321,9 +321,8 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h,
|
|||
|
||||
// Time to config libvo!
|
||||
mp_msg(MSGT_CPLAYER, MSGL_V,
|
||||
"VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", sh->disp_w,
|
||||
sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, "MPlayer",
|
||||
out_fmt);
|
||||
"VO Config (%dx%d->%dx%d,flags=%d,0x%X)\n", sh->disp_w,
|
||||
sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, out_fmt);
|
||||
|
||||
vf->w = sh->disp_w;
|
||||
vf->h = sh->disp_h;
|
||||
|
|
|
@ -79,7 +79,7 @@ static int config(struct vf_instance *vf,
|
|||
vf->default_caps=query_format(vf,outfmt);
|
||||
vf->draw_slice = (vf->default_caps & VOCAP_NOSLICES) ? NULL : draw_slice;
|
||||
|
||||
if (vo_config(video_out, width, height, d_width, d_height, flags, "MPlayer", outfmt))
|
||||
if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt))
|
||||
return 0;
|
||||
|
||||
#ifdef CONFIG_ASS
|
||||
|
|
|
@ -10,8 +10,7 @@ void vo_cocoa_update_xinerama_info(struct vo *vo);
|
|||
|
||||
int vo_cocoa_change_attributes(struct MPGLContext *ctx);
|
||||
int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags,
|
||||
const char *title);
|
||||
uint32_t d_height, uint32_t flags);
|
||||
|
||||
void vo_cocoa_swap_buffers(void);
|
||||
int vo_cocoa_check_events(struct vo *vo);
|
||||
|
|
|
@ -64,7 +64,6 @@ struct vo *l_vo;
|
|||
// local function definitions
|
||||
struct vo_cocoa_state *vo_cocoa_init_state(void);
|
||||
void update_screen_info(void);
|
||||
const char *title_from_vo_and_title(struct vo *vo, const char *title);
|
||||
void resize_window(struct vo *vo);
|
||||
void create_menu(void);
|
||||
|
||||
|
@ -136,19 +135,6 @@ int vo_cocoa_change_attributes(struct MPGLContext *ctx)
|
|||
return SET_WINDOW_OK;
|
||||
}
|
||||
|
||||
// this function exists because vf_vo.c calls config with title = "MPlayer"
|
||||
// and from the vo it will come down to the backend (ignoring --use-filename-title)
|
||||
const char *title_from_vo_and_title(struct vo *vo, const char *title)
|
||||
{
|
||||
if (vo->opts->vo_wintitle) {
|
||||
return vo->opts->vo_wintitle;
|
||||
} else if (title) {
|
||||
return title;
|
||||
} else {
|
||||
return "mplayer2";
|
||||
}
|
||||
}
|
||||
|
||||
void resize_window(struct vo *vo)
|
||||
{
|
||||
vo->dwidth = [[s->window contentView] frame].size.width;
|
||||
|
@ -157,7 +143,7 @@ void resize_window(struct vo *vo)
|
|||
}
|
||||
|
||||
int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags, const char *title)
|
||||
uint32_t d_height, uint32_t flags)
|
||||
{
|
||||
if (s->current_video_size.width > 0 || s->current_video_size.height > 0)
|
||||
s->previous_video_size = s->current_video_size;
|
||||
|
@ -222,7 +208,7 @@ int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
|
|||
if (s->window_title)
|
||||
[s->window_title release];
|
||||
|
||||
s->window_title = [[NSString alloc] initWithUTF8String:title_from_vo_and_title(ctx->vo,title)];
|
||||
s->window_title = [[NSString alloc] initWithUTF8String:vo_get_window_title(ctx->vo)];
|
||||
[s->window setTitle: s->window_title];
|
||||
|
||||
return SET_WINDOW_OK;
|
||||
|
|
|
@ -1613,10 +1613,9 @@ void glDrawTex(GL *gl, GLfloat x, GLfloat y, GLfloat w, GLfloat h,
|
|||
#ifdef CONFIG_GL_COCOA
|
||||
#include "cocoa_common.h"
|
||||
static int create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags,
|
||||
const char *title)
|
||||
uint32_t d_height, uint32_t flags)
|
||||
{
|
||||
return vo_cocoa_create_window(ctx, d_width, d_height, flags, title);
|
||||
return vo_cocoa_create_window(ctx, d_width, d_height, flags);
|
||||
}
|
||||
static int setGlWindow_cocoa(MPGLContext *ctx)
|
||||
{
|
||||
|
@ -1654,8 +1653,7 @@ static void cocoa_fullscreen(struct vo *vo)
|
|||
#include "w32_common.h"
|
||||
|
||||
static int create_window_w32(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags,
|
||||
const char *title)
|
||||
uint32_t d_height, uint32_t flags)
|
||||
{
|
||||
if (!vo_w32_config(d_width, d_height, flags))
|
||||
return -1;
|
||||
|
@ -1771,8 +1769,7 @@ static void new_w32_update_xinerama_info(struct vo *vo) { w32_update_xinerama_in
|
|||
#include "x11_common.h"
|
||||
|
||||
static int create_window_x11(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags,
|
||||
const char *title)
|
||||
uint32_t d_height, uint32_t flags)
|
||||
{
|
||||
struct vo *vo = ctx->vo;
|
||||
|
||||
|
@ -1805,7 +1802,7 @@ static int create_window_x11(struct MPGLContext *ctx, uint32_t d_width,
|
|||
Colormap colormap = XCreateColormap(vo->x11->display, vo->x11->rootwin,
|
||||
vinfo->visual, AllocNone);
|
||||
vo_x11_create_vo_window(vo, vinfo, vo->dx, vo->dy, d_width, d_height,
|
||||
flags, colormap, "gl", title);
|
||||
flags, colormap, "gl");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1968,10 +1965,9 @@ static void swapGlBuffers_x11(MPGLContext *ctx)
|
|||
#include "sdl_common.h"
|
||||
|
||||
static int create_window_sdl(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags,
|
||||
const char *title)
|
||||
uint32_t d_height, uint32_t flags)
|
||||
{
|
||||
SDL_WM_SetCaption(title, NULL);
|
||||
SDL_WM_SetCaption(vo_get_window_title(ctx->vo), NULL);
|
||||
ctx->vo->dwidth = d_width;
|
||||
ctx->vo->dheight = d_height;
|
||||
return 0;
|
||||
|
|
|
@ -387,7 +387,7 @@ typedef struct MPGLContext {
|
|||
#endif
|
||||
} context;
|
||||
int (*create_window)(struct MPGLContext *ctx, uint32_t d_width,
|
||||
uint32_t d_height, uint32_t flags, const char *title);
|
||||
uint32_t d_height, uint32_t flags);
|
||||
int (*setGlWindow)(struct MPGLContext *);
|
||||
void (*releaseGlContext)(struct MPGLContext *);
|
||||
void (*swapGlBuffers)(struct MPGLContext *);
|
||||
|
|
|
@ -34,10 +34,11 @@ int old_vo_preinit(struct vo *vo, const char *arg)
|
|||
|
||||
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height,
|
||||
uint32_t flags, char *title, uint32_t format)
|
||||
uint32_t flags, uint32_t format)
|
||||
{
|
||||
return vo->driver->old_functions->config(width, height, d_width,
|
||||
d_height, flags, title, format);
|
||||
d_height, flags, "MPlayer",
|
||||
format);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ extern struct osd_state *global_osd;
|
|||
int old_vo_preinit(struct vo *vo, const char *);
|
||||
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height,
|
||||
uint32_t flags, char *title, uint32_t format);
|
||||
uint32_t flags, uint32_t format);
|
||||
int old_vo_control(struct vo *vo, uint32_t request, void *data);
|
||||
int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
|
||||
int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
|
||||
|
|
|
@ -437,7 +437,7 @@ static int event_fd_callback(void *ctx, int fd)
|
|||
|
||||
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format)
|
||||
uint32_t format)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
panscan_init(vo);
|
||||
|
@ -458,7 +458,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
|||
}
|
||||
|
||||
int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
|
||||
title, format);
|
||||
format);
|
||||
vo->config_ok = (ret == 0);
|
||||
vo->config_count += vo->config_ok;
|
||||
if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
|
||||
|
@ -552,6 +552,18 @@ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
|
|||
dst->height = dst->bottom - dst->top;
|
||||
}
|
||||
|
||||
// Return the window title the VO should set. Always returns a null terminated
|
||||
// string. The string is valid until frontend code is invoked again. Copy it if
|
||||
// you need to keep the string for an extended period of time.
|
||||
const char *vo_get_window_title(struct vo *vo)
|
||||
{
|
||||
if (vo->opts->vo_wintitle) {
|
||||
return vo->opts->vo_wintitle;
|
||||
} else {
|
||||
return "MPlayer";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a mouse movement message if those are enable and sends it
|
||||
* to the "main" MPlayer.
|
||||
|
|
|
@ -188,7 +188,7 @@ struct vo_driver {
|
|||
*/
|
||||
int (*config)(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
|
||||
char *title, uint32_t format);
|
||||
uint32_t format);
|
||||
|
||||
/*
|
||||
* Control interface
|
||||
|
@ -298,7 +298,7 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
|
|||
struct input_ctx *input_ctx);
|
||||
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format);
|
||||
uint32_t format);
|
||||
void list_video_out(void);
|
||||
|
||||
int vo_control(struct vo *vo, uint32_t request, void *data);
|
||||
|
@ -313,6 +313,7 @@ void vo_check_events(struct vo *vo);
|
|||
void vo_seek_reset(struct vo *vo);
|
||||
void vo_destroy(struct vo *vo);
|
||||
|
||||
const char *vo_get_window_title(struct vo *vo);
|
||||
|
||||
// NULL terminated array of all drivers
|
||||
extern const struct vo_driver *video_out_drivers[];
|
||||
|
|
|
@ -647,19 +647,19 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
|
|||
}
|
||||
|
||||
static int create_window(struct vo *vo, uint32_t d_width, uint32_t d_height,
|
||||
uint32_t flags, const char *title)
|
||||
uint32_t flags)
|
||||
{
|
||||
struct gl_priv *p = vo->priv;
|
||||
|
||||
if (p->stereo_mode == GL_3D_QUADBUFFER)
|
||||
flags |= VOFLAG_STEREO;
|
||||
|
||||
return p->glctx->create_window(p->glctx, d_width, d_height, flags, title);
|
||||
return p->glctx->create_window(p->glctx, d_width, d_height, flags);
|
||||
}
|
||||
|
||||
static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format)
|
||||
uint32_t format)
|
||||
{
|
||||
struct gl_priv *p = vo->priv;
|
||||
|
||||
|
@ -676,7 +676,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
|||
|
||||
p->vo_flipped = !!(flags & VOFLAG_FLIPPING);
|
||||
|
||||
if (create_window(vo, d_width, d_height, flags, title) < 0)
|
||||
if (create_window(vo, d_width, d_height, flags) < 0)
|
||||
return -1;
|
||||
|
||||
if (vo->config_count)
|
||||
|
@ -1384,7 +1384,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
|
|||
}
|
||||
|
||||
if (p->use_yuv == -1 || !allow_sw) {
|
||||
if (create_window(vo, 320, 200, VOFLAG_HIDDEN, NULL) < 0)
|
||||
if (create_window(vo, 320, 200, VOFLAG_HIDDEN) < 0)
|
||||
goto err_out;
|
||||
if (p->glctx->setGlWindow(p->glctx) == SET_WINDOW_FAILED)
|
||||
goto err_out;
|
||||
|
|
|
@ -864,7 +864,7 @@ static int handle_preemption(struct vo *vo)
|
|||
*/
|
||||
static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format)
|
||||
uint32_t format)
|
||||
{
|
||||
struct vdpctx *vc = vo->priv;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
|
@ -912,7 +912,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
|||
xswamask = CWBorderPixel;
|
||||
|
||||
vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, d_width, d_height,
|
||||
flags, CopyFromParent, "vdpau", title);
|
||||
flags, CopyFromParent, "vdpau");
|
||||
XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
|
||||
|
||||
#ifdef CONFIG_XF86VM
|
||||
|
|
|
@ -200,7 +200,7 @@ static void resize(struct vo *vo)
|
|||
*/
|
||||
static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||
char *title, uint32_t format)
|
||||
uint32_t format)
|
||||
{
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
XVisualInfo vinfo;
|
||||
|
@ -265,8 +265,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
|||
}
|
||||
|
||||
vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, vo->dwidth,
|
||||
vo->dheight, flags, CopyFromParent, "xv",
|
||||
title);
|
||||
vo->dheight, flags, CopyFromParent, "xv");
|
||||
XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
|
||||
|
||||
#ifdef CONFIG_XF86VM
|
||||
|
|
|
@ -1032,15 +1032,13 @@ static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot
|
|||
* Only VOFLAG_FULLSCREEN is supported so far.
|
||||
* \param col_map Colourmap for window or CopyFromParent if a specific colormap isn't needed
|
||||
* \param classname name to use for the classhint
|
||||
* \param title title for the window
|
||||
*
|
||||
* This also does the grunt-work like setting Window Manager hints etc.
|
||||
* If vo_window is already set it just moves and resizes it.
|
||||
*/
|
||||
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
||||
unsigned int width, unsigned int height, int flags,
|
||||
Colormap col_map,
|
||||
const char *classname, const char *title)
|
||||
Colormap col_map, const char *classname)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
|
@ -1083,7 +1081,6 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
|||
XSizeHints hint;
|
||||
x11->window_state &= ~VOFLAG_HIDDEN;
|
||||
vo_x11_classhint(vo, x11->window, classname);
|
||||
XStoreName(mDisplay, x11->window, title);
|
||||
vo_hidecursor(mDisplay, x11->window);
|
||||
XSelectInput(mDisplay, x11->window, StructureNotifyMask);
|
||||
hint.x = x; hint.y = y;
|
||||
|
@ -1091,6 +1088,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
|||
hint.flags = PSize;
|
||||
if (geometry_xy_changed)
|
||||
hint.flags |= PPosition;
|
||||
const char *title = "MPlayer";
|
||||
XSetStandardProperties(mDisplay, x11->window, title, title, None, NULL, 0, &hint);
|
||||
if (!vo_border) vo_x11_decoration(vo, 0);
|
||||
// map window
|
||||
|
@ -1305,7 +1303,6 @@ static int vo_x11_get_fs_type(int supported)
|
|||
*/
|
||||
int vo_x11_update_geometry(struct vo *vo, bool update_pos)
|
||||
{
|
||||
struct MPOpts *opts = vo->opts;
|
||||
struct vo_x11_state *x11 = vo->x11;
|
||||
unsigned depth, w, h;
|
||||
int dummy_int;
|
||||
|
@ -1319,8 +1316,7 @@ int vo_x11_update_geometry(struct vo *vo, bool update_pos)
|
|||
if (update_pos)
|
||||
XTranslateCoordinates(x11->display, x11->window, x11->rootwin, 0, 0,
|
||||
&vo->dx, &vo->dy, &dummy_win);
|
||||
if (opts->vo_wintitle)
|
||||
XStoreName(x11->display, x11->window, opts->vo_wintitle);
|
||||
XStoreName(x11->display, x11->window, vo_get_window_title(vo));
|
||||
|
||||
return depth <= INT_MAX ? depth : 0;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ uint32_t vo_x11_get_equalizer(const char *name, int *value);
|
|||
void fstype_help(void);
|
||||
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
|
||||
int x, int y, unsigned int width, unsigned int height, int flags,
|
||||
Colormap col_map, const char *classname, const char *title);
|
||||
Colormap col_map, const char *classname);
|
||||
void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
|
||||
int img_width, int img_height);
|
||||
void vo_x11_clearwindow(struct vo *vo, Window vo_window);
|
||||
|
@ -184,7 +184,8 @@ void xscreensaver_heartbeat(struct vo_x11_state *x11);
|
|||
// Old VOs use incompatible function calls, translate them to new
|
||||
// prototypes
|
||||
#ifdef IS_OLD_VO
|
||||
#define vo_x11_create_vo_window(...) vo_x11_create_vo_window(global_vo, __VA_ARGS__)
|
||||
#define vo_x11_create_vo_window(vis, x, y, width, height, flags, col_map, classname, title) \
|
||||
vo_x11_create_vo_window(global_vo, vis, x, y, width, height, flags, col_map, classname)
|
||||
#define vo_x11_fullscreen() vo_x11_fullscreen(global_vo)
|
||||
#define vo_x11_update_geometry() vo_x11_update_geometry(global_vo, 1)
|
||||
#define vo_x11_ontop() vo_x11_ontop(global_vo)
|
||||
|
|
Loading…
Reference in New Issue