summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r--video/out/cocoa_common.m29
1 files changed, 18 insertions, 11 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 022520665a..2cb365cc1f 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,18 +506,21 @@ 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));
- NSString *nstitle = [NSString stringWithUTF8String:btitle.start];
- if (nstitle) {
- [s->window setTitle: nstitle];
- [s->window displayIfNeeded];
+ struct bstr btitle =
+ bstr_sanitize_utf8_latin1(talloc_ctx, bstr0(s->window_title));
+ if (btitle.start) {
+ NSString *nstitle = [NSString stringWithUTF8String:btitle.start];
+ if (nstitle) {
+ [s->window setTitle: nstitle];
+ [s->window displayIfNeeded];
+ }
}
talloc_free(talloc_ctx);
return VO_TRUE;
@@ -584,7 +589,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 +768,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;
@@ -796,8 +805,6 @@ static int vo_cocoa_control_async(struct vo *vo, int *events, int request, void
case VOCTRL_CHECK_EVENTS:
*events |= vo_cocoa_check_events(vo);
return VO_TRUE;
- case VOCTRL_GET_RECENT_FLIP_TIME:
- return VO_FALSE; // unsupported, but avoid syncing with main thread
}
return VO_NOTIMPL;
}