mirror of https://github.com/mpv-player/mpv
Move vo_ontop to options struct
Add a 'struct vo *vo' argument to the x11_common.c functions that access the variable so it's available as vo->opts->vo_ontop. To keep VOs using the old API working create a global vo variable that is set to the currently used old vo. "vo_ontop" will be #defined to "global_vo->opts->vo_ontop", and x11_common.h will add defines like the following when it is included by old VOs: #define vo_x11_ontop() vo_x11_ontop(global_vo) so that they will call the function according to the new declaration.
This commit is contained in:
parent
6c9d09170d
commit
bfe569b76e
|
@ -101,8 +101,8 @@ const m_option_t mplayer_opts[]={
|
||||||
STRINGLIST("ao", audio_driver_list, 0),
|
STRINGLIST("ao", audio_driver_list, 0),
|
||||||
FLAG_ON("fixed-vo", fixed_vo, CONF_GLOBAL),
|
FLAG_ON("fixed-vo", fixed_vo, CONF_GLOBAL),
|
||||||
FLAG_OFF("nofixed-vo", fixed_vo, CONF_GLOBAL),
|
FLAG_OFF("nofixed-vo", fixed_vo, CONF_GLOBAL),
|
||||||
{"ontop", &vo_ontop, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
FLAG_ON("ontop", vo_ontop, 0),
|
||||||
{"noontop", &vo_ontop, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
FLAG_OFF("noontop", vo_ontop, 0),
|
||||||
{"rootwin", &vo_rootwin, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{"rootwin", &vo_rootwin, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
{"border", &vo_border, CONF_TYPE_FLAG, 0, 0, 1, NULL},
|
||||||
{"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
{"noborder", &vo_border, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
||||||
|
|
|
@ -1076,8 +1076,8 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg,
|
||||||
static int mp_property_ontop(m_option_t * prop, int action, void *arg,
|
static int mp_property_ontop(m_option_t * prop, int action, void *arg,
|
||||||
MPContext * mpctx)
|
MPContext * mpctx)
|
||||||
{
|
{
|
||||||
return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop,
|
return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP,
|
||||||
mpctx);
|
&mpctx->opts.vo_ontop, mpctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display in the root window (RW)
|
/// Display in the root window (RW)
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef MPLAYER_OLD_VO_DEFINES_H
|
||||||
|
#define MPLAYER_OLD_VO_DEFINES_H
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
#include "video_out.h"
|
||||||
|
#include "old_vo_wrapper.h"
|
||||||
|
|
||||||
|
// Triggers more defines in x11_common.h
|
||||||
|
#define IS_OLD_VO 1
|
||||||
|
|
||||||
|
#define vo_ontop global_vo->opts->vo_ontop
|
||||||
|
|
||||||
|
#endif
|
|
@ -22,8 +22,11 @@
|
||||||
#include "video_out.h"
|
#include "video_out.h"
|
||||||
#include "sub.h"
|
#include "sub.h"
|
||||||
|
|
||||||
|
struct vo *global_vo;
|
||||||
|
|
||||||
int old_vo_preinit(struct vo *vo, const char *arg)
|
int old_vo_preinit(struct vo *vo, const char *arg)
|
||||||
{
|
{
|
||||||
|
global_vo = vo;
|
||||||
return vo->driver->old_functions->preinit(arg);
|
return vo->driver->old_functions->preinit(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "video_out.h"
|
#include "video_out.h"
|
||||||
|
|
||||||
|
extern struct vo *global_vo;
|
||||||
|
|
||||||
int old_vo_preinit(struct vo *vo, const char *);
|
int old_vo_preinit(struct vo *vo, const char *);
|
||||||
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
uint32_t d_width, uint32_t d_height,
|
uint32_t d_width, uint32_t d_height,
|
||||||
|
|
|
@ -47,7 +47,6 @@ int vo_vsync = 0;
|
||||||
int vo_fs = 0;
|
int vo_fs = 0;
|
||||||
int vo_fsmode = 0;
|
int vo_fsmode = 0;
|
||||||
float vo_panscan = 0.0f;
|
float vo_panscan = 0.0f;
|
||||||
int vo_ontop = 0;
|
|
||||||
int vo_adapter_num=0;
|
int vo_adapter_num=0;
|
||||||
int vo_refresh_rate=0;
|
int vo_refresh_rate=0;
|
||||||
int vo_keepaspect=1;
|
int vo_keepaspect=1;
|
||||||
|
|
|
@ -261,7 +261,6 @@ extern int vo_adapter_num;
|
||||||
extern int vo_refresh_rate;
|
extern int vo_refresh_rate;
|
||||||
extern int vo_keepaspect;
|
extern int vo_keepaspect;
|
||||||
extern int vo_rootwin;
|
extern int vo_rootwin;
|
||||||
extern int vo_ontop;
|
|
||||||
extern int vo_border;
|
extern int vo_border;
|
||||||
|
|
||||||
extern int vo_gamma_gamma;
|
extern int vo_gamma_gamma;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "libmpcodecs/mp_image.h"
|
#include "libmpcodecs/mp_image.h"
|
||||||
#include "geometry.h"
|
#include "geometry.h"
|
||||||
#include "old_vo_wrapper.h"
|
#include "old_vo_wrapper.h"
|
||||||
|
#include "old_vo_defines.h"
|
||||||
|
|
||||||
static int control(uint32_t request, void *data);
|
static int control(uint32_t request, void *data);
|
||||||
static int config(uint32_t width, uint32_t height, uint32_t d_width,
|
static int config(uint32_t width, uint32_t height, uint32_t d_width,
|
||||||
|
|
|
@ -22,6 +22,7 @@ Buffer allocation:
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "options.h"
|
||||||
#include "mp_msg.h"
|
#include "mp_msg.h"
|
||||||
#include "help_mp.h"
|
#include "help_mp.h"
|
||||||
#include "video_out.h"
|
#include "video_out.h"
|
||||||
|
@ -173,6 +174,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
||||||
char *title, uint32_t format)
|
char *title, uint32_t format)
|
||||||
{
|
{
|
||||||
|
struct MPOpts *opts = vo->opts;
|
||||||
XSizeHints hint;
|
XSizeHints hint;
|
||||||
XVisualInfo vinfo;
|
XVisualInfo vinfo;
|
||||||
XGCValues xgcv;
|
XGCValues xgcv;
|
||||||
|
@ -296,7 +298,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height,
|
vo_x11_create_vo_window(vo, &vinfo, vo_dx, vo_dy, d_width, d_height,
|
||||||
flags, CopyFromParent, "xv", title);
|
flags, CopyFromParent, "xv", title);
|
||||||
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
|
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
|
||||||
}
|
}
|
||||||
|
@ -370,8 +372,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
|
||||||
mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX,
|
mp_msg(MSGT_VO, MSGL_V, "[xv] dx: %d dy: %d dw: %d dh: %d\n", ctx->drwX,
|
||||||
ctx->drwY, vo_dwidth, vo_dheight);
|
ctx->drwY, vo_dwidth, vo_dheight);
|
||||||
|
|
||||||
if (vo_ontop)
|
if (opts->vo_ontop)
|
||||||
vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
|
vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -866,7 +868,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||||
return VO_FALSE;
|
return VO_FALSE;
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
case VOCTRL_FULLSCREEN:
|
case VOCTRL_FULLSCREEN:
|
||||||
vo_x11_fullscreen();
|
vo_x11_fullscreen(vo);
|
||||||
/* indended, fallthrough to update panscan on fullscreen/windowed switch */
|
/* indended, fallthrough to update panscan on fullscreen/windowed switch */
|
||||||
case VOCTRL_SET_PANSCAN:
|
case VOCTRL_SET_PANSCAN:
|
||||||
if ((vo_fs && (vo_panscan != vo_panscan_amount))
|
if ((vo_fs && (vo_panscan != vo_panscan_amount))
|
||||||
|
@ -901,7 +903,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
|
||||||
return vo_xv_get_eq(xv_port, args->name, args->valueptr);
|
return vo_xv_get_eq(xv_port, args->name, args->valueptr);
|
||||||
}
|
}
|
||||||
case VOCTRL_ONTOP:
|
case VOCTRL_ONTOP:
|
||||||
vo_x11_ontop();
|
vo_x11_ontop(vo);
|
||||||
return VO_TRUE;
|
return VO_TRUE;
|
||||||
case VOCTRL_UPDATE_SCREENINFO:
|
case VOCTRL_UPDATE_SCREENINFO:
|
||||||
update_xinerama_info();
|
update_xinerama_info();
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "aspect.h"
|
#include "aspect.h"
|
||||||
#include "w32_common.h"
|
#include "w32_common.h"
|
||||||
#include "mp_fifo.h"
|
#include "mp_fifo.h"
|
||||||
|
// To get "#define vo_ontop global_vo->opts->vo_ontop" etc
|
||||||
|
#include "old_vo_defines.h"
|
||||||
|
|
||||||
extern int enable_mouse_movements;
|
extern int enable_mouse_movements;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "options.h"
|
||||||
#include "mp_msg.h"
|
#include "mp_msg.h"
|
||||||
#include "mp_fifo.h"
|
#include "mp_fifo.h"
|
||||||
#include "x11_common.h"
|
#include "x11_common.h"
|
||||||
|
@ -1291,11 +1292,12 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
|
||||||
* This also does the grunt-work like setting Window Manager hints etc.
|
* This also does the grunt-work like setting Window Manager hints etc.
|
||||||
* If vo_window is already set it just moves and resizes it.
|
* If vo_window is already set it just moves and resizes it.
|
||||||
*/
|
*/
|
||||||
void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
|
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
|
||||||
unsigned int width, unsigned int height, int flags,
|
unsigned int width, unsigned int height, int flags,
|
||||||
Colormap col_map,
|
Colormap col_map,
|
||||||
const char *classname, const char *title)
|
const char *classname, const char *title)
|
||||||
{
|
{
|
||||||
|
struct MPOpts *opts = vo->opts;
|
||||||
if (vo_window == None) {
|
if (vo_window == None) {
|
||||||
XSizeHints hint;
|
XSizeHints hint;
|
||||||
XEvent xev;
|
XEvent xev;
|
||||||
|
@ -1326,10 +1328,10 @@ void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
|
||||||
StructureNotifyMask | KeyPressMask | PointerMotionMask |
|
StructureNotifyMask | KeyPressMask | PointerMotionMask |
|
||||||
ButtonPressMask | ButtonReleaseMask | ExposureMask);
|
ButtonPressMask | ButtonReleaseMask | ExposureMask);
|
||||||
}
|
}
|
||||||
if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
|
if (opts->vo_ontop) vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
|
||||||
vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
|
vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
|
||||||
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
|
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
|
||||||
vo_x11_fullscreen();
|
vo_x11_fullscreen(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
|
void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
|
||||||
|
@ -1505,8 +1507,9 @@ static int vo_x11_get_fs_type(int supported)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vo_x11_fullscreen(void)
|
void vo_x11_fullscreen(struct vo *vo)
|
||||||
{
|
{
|
||||||
|
struct MPOpts *opts = vo->opts;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
|
|
||||||
if (WinID >= 0 || vo_fs_flip)
|
if (WinID >= 0 || vo_fs_flip)
|
||||||
|
@ -1570,8 +1573,8 @@ void vo_x11_fullscreen(void)
|
||||||
XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
|
XMoveResizeWindow(mDisplay, vo_window, x, y, w, h);
|
||||||
}
|
}
|
||||||
/* some WMs lose ontop after fullscreen */
|
/* some WMs lose ontop after fullscreen */
|
||||||
if ((!(vo_fs)) & vo_ontop)
|
if ((!(vo_fs)) & opts->vo_ontop)
|
||||||
vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
|
vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
|
||||||
|
|
||||||
XMapRaised(mDisplay, vo_window);
|
XMapRaised(mDisplay, vo_window);
|
||||||
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
|
if ( ! (vo_fs_type & vo_wm_FULLSCREEN) ) // some WMs change window pos on map
|
||||||
|
@ -1580,11 +1583,12 @@ void vo_x11_fullscreen(void)
|
||||||
XFlush(mDisplay);
|
XFlush(mDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vo_x11_ontop(void)
|
void vo_x11_ontop(struct vo *vo)
|
||||||
{
|
{
|
||||||
vo_ontop = (!(vo_ontop));
|
struct MPOpts *opts = vo->opts;
|
||||||
|
opts->vo_ontop = !opts->vo_ontop;
|
||||||
|
|
||||||
vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
|
vo_x11_setlayer(mDisplay, vo_window, opts->vo_ontop);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
struct vo;
|
||||||
|
|
||||||
#ifdef X11_FULLSCREEN
|
#ifdef X11_FULLSCREEN
|
||||||
|
|
||||||
#define vo_wm_LAYER 1
|
#define vo_wm_LAYER 1
|
||||||
|
@ -44,7 +46,7 @@ extern void vo_x11_nofs_sizepos(int x, int y, int width, int height);
|
||||||
extern void vo_x11_sizehint( int x, int y, int width, int height, int max );
|
extern void vo_x11_sizehint( int x, int y, int width, int height, int max );
|
||||||
extern int vo_x11_check_events(Display *mydisplay);
|
extern int vo_x11_check_events(Display *mydisplay);
|
||||||
extern void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
|
extern void vo_x11_selectinput_witherr(Display *display, Window w, long event_mask);
|
||||||
extern void vo_x11_fullscreen( void );
|
void vo_x11_fullscreen(struct vo *vo);
|
||||||
extern void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
|
extern void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer );
|
||||||
extern void vo_x11_uninit(void);
|
extern void vo_x11_uninit(void);
|
||||||
extern Colormap vo_x11_create_colormap(XVisualInfo *vinfo);
|
extern Colormap vo_x11_create_colormap(XVisualInfo *vinfo);
|
||||||
|
@ -54,13 +56,13 @@ extern void fstype_help(void);
|
||||||
extern Window vo_x11_create_smooth_window( Display *mDisplay, Window mRoot,
|
extern Window vo_x11_create_smooth_window( Display *mDisplay, Window mRoot,
|
||||||
Visual *vis, int x, int y, unsigned int width, unsigned int height,
|
Visual *vis, int x, int y, unsigned int width, unsigned int height,
|
||||||
int depth, Colormap col_map);
|
int depth, Colormap col_map);
|
||||||
extern void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
|
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
|
||||||
unsigned int width, unsigned int height, int flags,
|
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, const char *title);
|
||||||
extern void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
|
extern void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
|
||||||
int img_width, int img_height, int use_fs);
|
int img_width, int img_height, int use_fs);
|
||||||
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
|
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
|
||||||
extern void vo_x11_ontop(void);
|
void vo_x11_ontop(struct vo *vo);
|
||||||
extern void vo_x11_ewmh_fullscreen( int action );
|
extern void vo_x11_ewmh_fullscreen( int action );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,4 +124,12 @@ void update_xinerama_info(void);
|
||||||
|
|
||||||
int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);
|
int vo_find_depth_from_visuals(Display *dpy, int screen, Visual **visual_return);
|
||||||
|
|
||||||
|
// 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_fullscreen() vo_x11_fullscreen(global_vo)
|
||||||
|
#define vo_x11_ontop() vo_x11_ontop(global_vo)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* MPLAYER_X11_COMMON_H */
|
#endif /* MPLAYER_X11_COMMON_H */
|
||||||
|
|
|
@ -5,6 +5,7 @@ typedef struct MPOpts {
|
||||||
char **video_driver_list;
|
char **video_driver_list;
|
||||||
char **audio_driver_list;
|
char **audio_driver_list;
|
||||||
int fixed_vo;
|
int fixed_vo;
|
||||||
|
int vo_ontop;
|
||||||
int correct_pts;
|
int correct_pts;
|
||||||
int user_correct_pts;
|
int user_correct_pts;
|
||||||
} MPOpts;
|
} MPOpts;
|
||||||
|
|
Loading…
Reference in New Issue