From acf319b3edea4d8dd0fe338778e08e0d99dc49bb Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 20 Apr 2008 07:36:34 +0300 Subject: Create a struct for X11 state Will be used for common data between X11 VOs. The main reasons for making it a separate struct rather than extra fields in the main VO struct are that some field definitions need X headers and that the code keeps basic X state such as the display connection over opening and closing of individual VOs. --- libvo/video_out.c | 9 ++++++--- libvo/video_out.h | 3 ++- libvo/x11_common.c | 4 ++++ libvo/x11_common.h | 5 +++++ mp_core.h | 1 + mplayer.c | 7 ++++++- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/libvo/video_out.c b/libvo/video_out.c index abbaaae7ef..3a6b57347a 100644 --- a/libvo/video_out.c +++ b/libvo/video_out.c @@ -20,6 +20,9 @@ #include "help_mp.h" #include "osdep/shmem.h" +#ifdef HAVE_X11 +#include "x11_common.h" +#endif //int vo_flags=0; @@ -298,7 +301,7 @@ void list_video_out(void) mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n"); } -struct vo *init_best_video_out(struct MPOpts *opts) +struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11) { char **vo_list = opts->video_driver_list; int i; @@ -321,7 +324,7 @@ struct vo *init_best_video_out(struct MPOpts *opts) const vo_info_t *info = video_driver->info; if (!strcmp(info->short_name, name)) { // name matches, try it - *vo = (struct vo){.opts = opts}; + *vo = (struct vo){.opts = opts, .x11 = x11}; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) { free(name); @@ -339,7 +342,7 @@ struct vo *init_best_video_out(struct MPOpts *opts) vo_subdevice = NULL; for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; - *vo = (struct vo){.opts = opts}; + *vo = (struct vo){.opts = opts, .x11 = x11}; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) return vo; // success! diff --git a/libvo/video_out.h b/libvo/video_out.h index 5e1e244e8c..c1ba46e59f 100644 --- a/libvo/video_out.h +++ b/libvo/video_out.h @@ -210,9 +210,10 @@ struct vo { const struct vo_driver *driver; void *priv; struct MPOpts *opts; + struct vo_x11_state *x11; }; -struct vo *init_best_video_out(struct MPOpts *opts); +struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11); 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); diff --git a/libvo/x11_common.c b/libvo/x11_common.c index 47758b0d08..e5dbee5734 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -122,6 +122,10 @@ static int vo_x11_get_fs_type(int supported); static void saver_off(Display *); static void saver_on(Display *); +void vo_x11_init_state(struct vo_x11_state *s) +{ + *s = (struct vo_x11_state){}; +} /* * Sends the EWMH fullscreen state event. diff --git a/libvo/x11_common.h b/libvo/x11_common.h index fa9d7d0444..4585bc6bd5 100644 --- a/libvo/x11_common.h +++ b/libvo/x11_common.h @@ -6,6 +6,10 @@ struct vo; +struct vo_x11_state { + int unused; // placeholder to avoid empty struct +}; + #ifdef X11_FULLSCREEN #define vo_wm_LAYER 1 @@ -36,6 +40,7 @@ extern int mLocalDisplay; extern int vo_mouse_autohide; +void vo_x11_init_state(struct vo_x11_state *s); extern int vo_init( void ); extern void vo_uninit( void ); extern void vo_x11_decoration( Display * vo_Display,Window w,int d ); diff --git a/mp_core.h b/mp_core.h index c40c948114..df9d3098e7 100644 --- a/mp_core.h +++ b/mp_core.h @@ -44,6 +44,7 @@ typedef struct MPContext { struct MPOpts opts; + struct vo_x11_state *x11_state; int osd_show_percentage; int osd_function; const ao_functions_t *audio_out; diff --git a/mplayer.c b/mplayer.c index 52a489b1f4..1b89105c07 100644 --- a/mplayer.c +++ b/mplayer.c @@ -5,6 +5,7 @@ #include #include #include "config.h" +#include "talloc.h" #ifdef WIN32 #define _UWIN 1 /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/ @@ -2143,7 +2144,7 @@ int reinit_video_chain(void) { //shouldn't we set dvideo->id=-2 when we fail? vo_config_count=0; //if((mpctx->video_out->preinit(vo_subdevice))!=0){ - if(!(mpctx->video_out=init_best_video_out(opts))){ + if(!(mpctx->video_out=init_best_video_out(opts, mpctx->x11_state))){ mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorInitializingVODevice); goto err_out; } @@ -2562,6 +2563,10 @@ int gui_no_filename=0; mp_msg_init(); +#ifdef HAVE_X11 + mpctx->x11_state = talloc_ptrtype(NULL, mpctx->x11_state); + vo_x11_init_state(mpctx->x11_state); +#endif struct MPOpts *opts = &mpctx->opts; set_default_mplayer_options(opts); // Create the config context and register the options -- cgit v1.2.3