summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-06 18:39:09 +0100
committerwm4 <wm4@nowhere>2015-12-06 18:41:31 +0100
commit9db50c6760758089a013983f0fbf93ebde53dbc7 (patch)
treeb37322cdb821fdfea5e3efe190fd25b593cfdbd1 /video/out/cocoa_common.m
parent970606e49198594c243edf4a85c426693676f6a3 (diff)
downloadmpv-9db50c6760758089a013983f0fbf93ebde53dbc7.tar.bz2
mpv-9db50c6760758089a013983f0fbf93ebde53dbc7.tar.xz
vo: get rid of vo_get_window_title()
It always was a weird artifact - VOCTRLs are meant _not_ to require special handling in the code that passes them through (like in vo.c). Removing it is also interesting to further reduce the dependency of backends on struct vo. Just get rid of it. Removing it is somewhat inconvenient, because in many situations the UI window is created after the first VOCTRL_UPDATE_WINDOW_TITLE. This means these backends have to store it in a new field in their own context.
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r--video/out/cocoa_common.m17
1 files changed, 12 insertions, 5 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;