Skip to content

Commit 4d9b7eb

Browse files
committed
fixup display-names/friendly
fix formatting add interface-changes file
1 parent 3ada66e commit 4d9b7eb

File tree

5 files changed

+34
-48
lines changed

5 files changed

+34
-48
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add `display-name/friendly` property on Windows to obtain display names from EDID

player/command.c

+17-25
Original file line numberDiff line numberDiff line change
@@ -2827,46 +2827,38 @@ static int get_display_names_subkey(struct vo *vo, int action,
28272827
void *arg, enum mp_voctrl voctrl)
28282828
{
28292829
switch (action) {
2830-
case M_PROPERTY_GET_TYPE:
2831-
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
2832-
return M_PROPERTY_OK;
2833-
case M_PROPERTY_GET: {
2834-
char** display_names;
2835-
if (vo_control(vo, voctrl, &display_names) < 1)
2836-
return M_PROPERTY_UNAVAILABLE;
2830+
case M_PROPERTY_GET_TYPE:
2831+
*(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING_LIST};
2832+
return M_PROPERTY_OK;
2833+
case M_PROPERTY_GET: {
2834+
char **display_names;
2835+
if (vo_control(vo, voctrl, &display_names) < 1)
2836+
return M_PROPERTY_UNAVAILABLE;
28372837

2838-
*(char ***)arg = display_names;
2839-
return M_PROPERTY_OK;
2840-
}
2838+
*(char ***)arg = display_names;
2839+
return M_PROPERTY_OK;
2840+
}
28412841
}
28422842
return M_PROPERTY_NOT_IMPLEMENTED;
28432843
}
28442844

28452845
static int mp_property_display_names(void *ctx, struct m_property *prop,
28462846
int action, void *arg)
28472847
{
2848-
MPContext *const mpctx = ctx;
2849-
struct vo *const vo = mpctx->video_out;
2848+
MPContext *mpctx = ctx;
2849+
struct vo *vo = mpctx->video_out;
28502850
if (!vo)
28512851
return M_PROPERTY_UNAVAILABLE;
28522852

28532853
if (action == M_PROPERTY_KEY_ACTION) {
28542854
struct m_property_action_arg *const ka = arg;
2855-
if (!strcmp(ka->key, "friendly")) {
2856-
return get_display_names_subkey(
2857-
vo,
2858-
ka->action,
2859-
ka->arg,
2860-
VOCTRL_GET_DISPLAY_NAMES_FRIENDLY);
2861-
} else {
2855+
if (strcmp(ka->key, "friendly"))
28622856
return M_PROPERTY_UNKNOWN;
2863-
}
2857+
2858+
return get_display_names_subkey(vo, ka->action, ka->arg,
2859+
VOCTRL_GET_DISPLAY_NAMES_FRIENDLY);
28642860
}
2865-
return get_display_names_subkey(
2866-
vo,
2867-
action,
2868-
arg,
2869-
VOCTRL_GET_DISPLAY_NAMES);
2861+
return get_display_names_subkey(vo, action, arg, VOCTRL_GET_DISPLAY_NAMES);
28702862
}
28712863

28722864
static int mp_property_vo_configured(void *ctx, struct m_property *prop,

video/out/w32_common.c

+6-12
Original file line numberDiff line numberDiff line change
@@ -2246,23 +2246,17 @@ struct disp_names_data {
22462246
bool friendly;
22472247
};
22482248

2249-
static void disp_names_append(HMONITOR mon, struct disp_names_data* data)
2249+
static void disp_names_append(HMONITOR mon, struct disp_names_data *data)
22502250
{
22512251
MONITORINFOEXW mi = { .cbSize = sizeof mi };
22522252
if (GetMonitorInfoW(mon, (MONITORINFO*)&mi)) {
2253-
wchar_t* friendly_name = NULL;
2253+
wchar_t *friendly_name = NULL;
22542254
if (data->friendly) {
2255-
friendly_name =
2256-
mp_w32_displayconfig_get_friendly_name_from_device(mi.szDevice);
2257-
}
2258-
if (friendly_name) {
2259-
MP_TARRAY_APPEND(NULL, data->names, data->count,
2260-
mp_to_utf8(NULL, friendly_name));
2261-
talloc_free(friendly_name);
2262-
} else {
2263-
MP_TARRAY_APPEND(NULL, data->names, data->count,
2264-
mp_to_utf8(NULL, mi.szDevice));
2255+
friendly_name = mp_w32_displayconfig_get_friendly_name_from_device(mi.szDevice);
22652256
}
2257+
wchar_t *name = friendly_name ? friendly_name : mi.szDevice;
2258+
MP_TARRAY_APPEND(NULL, data->names, data->count, mp_to_utf8(NULL, name));
2259+
talloc_free(friendly_name);
22662260
}
22672261
}
22682262

video/out/win32/displayconfig.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -208,22 +208,22 @@ wchar_t *mp_w32_displayconfig_get_device_from_friendly_name(
208208
return gdi_device_name;
209209
}
210210

211-
wchar_t* mp_w32_displayconfig_get_friendly_name_from_device(
211+
wchar_t *mp_w32_displayconfig_get_friendly_name_from_device(
212212
const wchar_t *device)
213213
{
214214
void *ctx = talloc_new(NULL);
215-
wchar_t* monitor_friendly_device_name = NULL;
215+
wchar_t *monitor_friendly_device_name = NULL;
216216

217217
// Get the current display configuration
218218
UINT32 num_paths;
219-
DISPLAYCONFIG_PATH_INFO* paths;
219+
DISPLAYCONFIG_PATH_INFO *paths;
220220
UINT32 num_modes;
221-
DISPLAYCONFIG_MODE_INFO* modes;
221+
DISPLAYCONFIG_MODE_INFO *modes;
222222
if (get_config(ctx, &num_paths, &paths, &num_modes, &modes))
223223
goto end;
224224

225225
// Get the path for the specified monitor
226-
DISPLAYCONFIG_PATH_INFO* path;
226+
DISPLAYCONFIG_PATH_INFO *path;
227227
if (!(path = get_path(num_paths, paths, device)))
228228
goto end;
229229

@@ -242,10 +242,9 @@ wchar_t* mp_w32_displayconfig_get_friendly_name_from_device(
242242
if (!target.flags.friendlyNameFromEdid)
243243
goto end;
244244

245-
monitor_friendly_device_name = talloc_memdup(
246-
NULL,
247-
target.monitorFriendlyDeviceName,
248-
sizeof(target.monitorFriendlyDeviceName));
245+
monitor_friendly_device_name = talloc_memdup(NULL,
246+
target.monitorFriendlyDeviceName,
247+
sizeof(target.monitorFriendlyDeviceName));
249248

250249
end:
251250
talloc_free(ctx);

video/out/win32/displayconfig.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ wchar_t *mp_w32_displayconfig_get_device_from_friendly_name(
3131
const wchar_t *monitor_friendly_device_name);
3232

3333
// Given a GDI monitor device name, get a friendly monitor device name
34-
// using the Windows 7 DisplayConfig API. Returns NULL on failure.
34+
// using the DisplayConfig API. Returns NULL on failure.
3535
// The caller is responsible for releasing the result with talloc_free.
36-
wchar_t* mp_w32_displayconfig_get_friendly_name_from_device(
36+
wchar_t *mp_w32_displayconfig_get_friendly_name_from_device(
3737
const wchar_t *device);
3838

3939
#endif

0 commit comments

Comments
 (0)