Add cocoa_update_title to cocoa_common.m

This commit is contained in:
twinaphex 2021-01-18 19:28:36 +01:00
parent 3d17cf1e38
commit a80a64f261
3 changed files with 21 additions and 18 deletions

View File

@ -238,23 +238,6 @@ static void cocoa_gl_gfx_ctx_destroy(void *data)
static enum gfx_ctx_api cocoa_gl_gfx_ctx_get_api(void *data) { return cocoagl_api; }
#ifdef OSX
static void cocoa_gl_gfx_ctx_update_title(void *data)
{
const ui_window_t *window = ui_companion_driver_get_window_ptr();
if (window)
{
char title[128];
title[0] = '\0';
video_driver_get_window_title(title, sizeof(title));
if (title[0])
window->set_title((void*)video_driver_display_userdata_get(), title);
}
}
static bool cocoa_gl_gfx_ctx_get_metrics(
void *data, enum display_metric_types type,
float *value)
@ -874,7 +857,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = {
cocoa_gl_gfx_ctx_get_metrics,
NULL, /* translate_aspect */
#ifdef OSX
cocoa_gl_gfx_ctx_update_title,
cocoa_update_title,
#else
NULL, /* update_title */
#endif

View File

@ -115,6 +115,7 @@ void *cocoa_screen_get_chosen(void);
#ifdef OSX
float cocoa_screen_get_backing_scale_factor(void);
void cocoa_update_title(void *data);
#else
float cocoa_screen_get_native_scale(void);
#endif

View File

@ -437,3 +437,22 @@ CocoaView *cocoaview_get(void)
return NULL;
#endif
}
#ifdef OSX
void cocoa_update_title(void *data)
{
const ui_window_t *window = ui_companion_driver_get_window_ptr();
if (window)
{
char title[128];
title[0] = '\0';
video_driver_get_window_title(title, sizeof(title));
if (title[0])
window->set_title((void*)video_driver_display_userdata_get(), title);
}
}
#endif