From 168a595bfeb97be89da314dcc652b7c4782e43e5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 15 Jun 2013 19:04:20 +0200 Subject: video/out: introduce VOCTRL_UPDATE_WINDOW_TITLE Instead of implicitly changing the window title on config(), do it as part of the new VOCTRL. At first I wanted to make all VOs use the VOCTRL argument directly, but on a second thought it appears vo_get_window_title() is much more useful for some (namely, if the window is created lazily on first config()). Not all VOs are changed. Wayland and OSX have to follow. --- core/mplayer.c | 1 + video/out/vo.h | 1 + video/out/vo_sdl.c | 6 ++++++ video/out/w32_common.c | 10 ++++++---- video/out/x11_common.c | 9 ++++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/core/mplayer.c b/core/mplayer.c index 5e1d58835e..4d6afd656c 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2365,6 +2365,7 @@ static void vo_update_window_title(struct MPContext *mpctx) char *title = mp_property_expand_string(mpctx, mpctx->opts.wintitle); talloc_free(mpctx->video_out->window_title); mpctx->video_out->window_title = talloc_steal(mpctx, title); + vo_control(mpctx->video_out, VOCTRL_UPDATE_WINDOW_TITLE, title); } static void update_fps(struct MPContext *mpctx) diff --git a/video/out/vo.h b/video/out/vo.h index 2ac993923d..df16a01d0e 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -60,6 +60,7 @@ enum mp_voctrl { VOCTRL_ONTOP, VOCTRL_BORDER, + VOCTRL_UPDATE_WINDOW_TITLE, // char* VOCTRL_SET_CURSOR_VISIBILITY, // bool diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c index dd825c30d8..66013e01f2 100644 --- a/video/out/vo_sdl.c +++ b/video/out/vo_sdl.c @@ -939,6 +939,8 @@ static int get_eq(struct vo *vo, const char *name, int *value) static int control(struct vo *vo, uint32_t request, void *data) { + struct priv *vc = vo->priv; + switch (request) { case VOCTRL_CHECK_EVENTS: check_events(vo); @@ -976,6 +978,10 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_SET_CURSOR_VISIBILITY: SDL_ShowCursor(*(bool *)data); return true; + case VOCTRL_UPDATE_WINDOW_TITLE: + if (vc->window) + SDL_SetWindowTitle(vc->window, vo_get_window_title(vo)); + return true; } return VO_NOTIMPL; } diff --git a/video/out/w32_common.c b/video/out/w32_common.c index e97a9e2e85..7d60435c5b 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -407,10 +407,6 @@ static int reinit_window_state(struct vo *vo) if (vo->opts->WinID >= 0) return 1; - wchar_t *title = mp_from_utf8(NULL, vo_get_window_title(vo)); - SetWindowTextW(w32->window, title); - talloc_free(title); - bool toggle_fs = w32->current_fs != vo->opts->fs; w32->current_fs = vo->opts->fs; @@ -705,6 +701,12 @@ int vo_w32_control(struct vo *vo, int *events, int request, void *arg) case VOCTRL_RESTORE_SCREENSAVER: w32->disable_screensaver = false; return VO_TRUE; + case VOCTRL_UPDATE_WINDOW_TITLE: { + wchar_t *title = mp_from_utf8(NULL, (char *)arg); + SetWindowTextW(w32->window, title); + talloc_free(title); + return VO_TRUE; + } } return VO_NOTIMPL; } diff --git a/video/out/x11_common.c b/video/out/x11_common.c index ecafc4a324..9d2db30924 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -915,6 +915,9 @@ static void vo_x11_update_window_title(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; + if (!x11->window) + return; + const char *title = vo_get_window_title(vo); vo_x11_set_property_string(vo, XA_WM_NAME, title); vo_x11_set_property_string(vo, XA_WM_ICON_NAME, title); @@ -970,6 +973,8 @@ static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, int x, int y, XNClientWindow, x11->window, XNFocusWindow, x11->window, NULL); + + vo_x11_update_window_title(vo); } static void vo_x11_map_window(struct vo *vo, int x, int y, int w, int h) @@ -1022,7 +1027,6 @@ void vo_x11_config_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y, if (flags & VOFLAG_HIDDEN) return; - vo_x11_update_window_title(vo); if (opts->ontop) vo_x11_setlayer(vo, x11->window, opts->ontop); @@ -1396,6 +1400,9 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg) case VOCTRL_RESTORE_SCREENSAVER: saver_on(x11); return VO_TRUE; + case VOCTRL_UPDATE_WINDOW_TITLE: + vo_x11_update_window_title(vo); + return VO_TRUE; } return VO_NOTIMPL; } -- cgit v1.2.3