summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/out/cocoa_common.m17
-rw-r--r--video/out/vo.c17
-rw-r--r--video/out/vo.h2
-rw-r--r--video/out/vo_sdl.c12
-rw-r--r--video/out/x11_common.c13
-rw-r--r--video/out/x11_common.h1
6 files changed, 28 insertions, 34 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index c316a09a04..ab2f666c3e 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -106,6 +106,8 @@ struct vo_cocoa_state {
int frame_w, frame_h; // dimensions of the frame rendered
NSCursor *blankCursor;
+
+ char *window_title;
};
static void run_on_main_thread(struct vo *vo, void(^block)(void))
@@ -504,14 +506,15 @@ static void create_ui(struct vo *vo, struct mp_rect *win, int geo_flags)
}
}
-static int cocoa_set_window_title(struct vo *vo, const char *title)
+static int cocoa_set_window_title(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
if (s->embedded)
return VO_NOTIMPL;
void *talloc_ctx = talloc_new(NULL);
- struct bstr btitle = bstr_sanitize_utf8_latin1(talloc_ctx, bstr0(title));
+ struct bstr btitle =
+ bstr_sanitize_utf8_latin1(talloc_ctx, bstr0(s->window_title));
NSString *nstitle = [NSString stringWithUTF8String:btitle.start];
if (nstitle) {
[s->window setTitle: nstitle];
@@ -584,7 +587,7 @@ int vo_cocoa_config_window(struct vo *vo)
queue_new_video_size(vo, width, height);
vo_cocoa_fullscreen(vo);
cocoa_add_fs_screen_profile_observer(vo);
- cocoa_set_window_title(vo, vo_get_window_title(vo));
+ cocoa_set_window_title(vo);
vo_set_level(vo, vo->opts->ontop);
}
@@ -763,8 +766,12 @@ static int vo_cocoa_control_on_main_thread(struct vo *vo, int request, void *arg
}
case VOCTRL_SET_CURSOR_VISIBILITY:
return vo_cocoa_set_cursor_visibility(vo, arg);
- case VOCTRL_UPDATE_WINDOW_TITLE:
- return cocoa_set_window_title(vo, (const char *) arg);
+ case VOCTRL_UPDATE_WINDOW_TITLE: {
+ struct vo_cocoa_state *s = vo->cocoa;
+ talloc_free(s->window_title);
+ s->window_title = talloc_strdup(s, (char *) arg);
+ return cocoa_set_window_title(vo);
+ }
case VOCTRL_RESTORE_SCREENSAVER:
enable_power_management(vo->cocoa);
return VO_TRUE;
diff --git a/video/out/vo.c b/video/out/vo.c
index 4364b5d7f2..6318ac7dc5 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -166,9 +166,6 @@ struct vo_internal {
int req_frames; // VO's requested value of num_frames
double display_fps;
-
- // --- The following fields can be accessed from the VO thread only
- char *window_title;
};
static void forget_frames(struct vo *vo);
@@ -550,8 +547,6 @@ static void run_control(void *p)
struct vo *vo = pp[0];
uint32_t request = *(int *)pp[1];
void *data = pp[2];
- if (request == VOCTRL_UPDATE_WINDOW_TITLE) // legacy fallback
- vo->in->window_title = talloc_strdup(vo, data);
int ret = vo->driver->control(vo, request, data);
*(int *)pp[3] = ret;
}
@@ -1063,18 +1058,6 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src,
out_src, out_dst, out_osd);
}
-// 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.
-// Must be called from the VO thread only.
-// Don't use for new code.
-const char *vo_get_window_title(struct vo *vo)
-{
- if (!vo->in->window_title)
- vo->in->window_title = talloc_strdup(vo, "");
- return vo->in->window_title;
-}
-
// flip_page[_timed] will be called offset_us microseconds too early.
// (For vo_vdpau, which does its own timing.)
// num_req_frames set the requested number of requested vo_frame.frames.
diff --git a/video/out/vo.h b/video/out/vo.h
index 87fd741c98..49a7546462 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -357,8 +357,6 @@ double vo_get_delay(struct vo *vo);
void vo_wakeup(struct vo *vo);
-const char *vo_get_window_title(struct vo *vo);
-
struct mp_keymap {
int from;
int to;
diff --git a/video/out/vo_sdl.c b/video/out/vo_sdl.c
index d1bad6877b..5ee6cb273a 100644
--- a/video/out/vo_sdl.c
+++ b/video/out/vo_sdl.c
@@ -190,6 +190,7 @@ struct priv {
double osd_pts;
int mouse_hidden;
int brightness, contrast;
+ char *window_title;
Uint32 wakeup_event;
// options
@@ -353,6 +354,9 @@ static bool try_create_renderer(struct vo *vo, int i, const char *driver,
vc->renderer_index = i;
}
+ if (vc->window_title)
+ SDL_SetWindowTitle(vc->window, vc->window_title);
+
return true;
}
@@ -519,8 +523,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
set_fullscreen(vo);
- SDL_SetWindowTitle(vc->window, vo_get_window_title(vo));
-
SDL_ShowWindow(vc->window);
check_resize(vo);
@@ -1012,8 +1014,10 @@ static int control(struct vo *vo, uint32_t request, void *data)
SDL_ShowCursor(*(bool *)data);
return true;
case VOCTRL_UPDATE_WINDOW_TITLE:
- if (vc->window)
- SDL_SetWindowTitle(vc->window, vo_get_window_title(vo));
+ talloc_free(vc->window_title);
+ vc->window_title = talloc_strdup(vc, (char *)data);
+ if (vc->window && vc->window_title)
+ SDL_SetWindowTitle(vc->window, vc->window_title);
return true;
}
return VO_NOTIMPL;
diff --git a/video/out/x11_common.c b/video/out/x11_common.c
index 95308b9559..dd7565512e 100644
--- a/video/out/x11_common.c
+++ b/video/out/x11_common.c
@@ -1194,14 +1194,13 @@ static void vo_x11_update_window_title(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
- if (!x11->window)
+ if (!x11->window || !x11->window_title)
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);
- vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_NAME), title);
- vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_ICON_NAME), title);
+ vo_x11_set_property_string(vo, XA_WM_NAME, x11->window_title);
+ vo_x11_set_property_string(vo, XA_WM_ICON_NAME, x11->window_title);
+ vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_NAME), x11->window_title);
+ vo_x11_set_property_utf8(vo, XA(x11, _NET_WM_ICON_NAME), x11->window_title);
}
static void vo_x11_xembed_update(struct vo_x11_state *x11, int flags)
@@ -1804,6 +1803,8 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
set_screensaver(x11, true);
return VO_TRUE;
case VOCTRL_UPDATE_WINDOW_TITLE:
+ talloc_free(x11->window_title);
+ x11->window_title = talloc_strdup(x11, (char *)arg);
if (!x11->parent)
vo_x11_update_window_title(vo);
return VO_TRUE;
diff --git a/video/out/x11_common.h b/video/out/x11_common.h
index 7707c0a707..4b122e8535 100644
--- a/video/out/x11_common.h
+++ b/video/out/x11_common.h
@@ -52,6 +52,7 @@ struct vo_x11_state {
int ws_width;
int ws_height;
struct mp_rect screenrc;
+ char *window_title;
struct xrandr_display displays[MAX_DISPLAYS];
int num_displays;