@@ -2243,8 +2243,23 @@ struct disp_names_data {
2243
2243
HMONITOR assoc ;
2244
2244
int count ;
2245
2245
char * * names ;
2246
+ bool friendly ;
2246
2247
};
2247
2248
2249
+ static void disp_names_append (HMONITOR mon , struct disp_names_data * data )
2250
+ {
2251
+ MONITORINFOEXW mi = { .cbSize = sizeof mi };
2252
+ if (GetMonitorInfoW (mon , (MONITORINFO * )& mi )) {
2253
+ wchar_t * friendly_name = NULL ;
2254
+ if (data -> friendly ) {
2255
+ friendly_name = mp_w32_displayconfig_get_friendly_name_from_device (mi .szDevice );
2256
+ }
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 );
2260
+ }
2261
+ }
2262
+
2248
2263
static BOOL CALLBACK disp_names_proc (HMONITOR mon , HDC dc , LPRECT r , LPARAM p )
2249
2264
{
2250
2265
struct disp_names_data * data = (struct disp_names_data * )p ;
@@ -2253,30 +2268,25 @@ static BOOL CALLBACK disp_names_proc(HMONITOR mon, HDC dc, LPRECT r, LPARAM p)
2253
2268
if (mon == data -> assoc )
2254
2269
return TRUE;
2255
2270
2256
- MONITORINFOEXW mi = { .cbSize = sizeof mi };
2257
- if (GetMonitorInfoW (mon , (MONITORINFO * )& mi )) {
2258
- MP_TARRAY_APPEND (NULL , data -> names , data -> count ,
2259
- mp_to_utf8 (NULL , mi .szDevice ));
2260
- }
2271
+ disp_names_append (mon , data );
2261
2272
return TRUE;
2262
2273
}
2263
2274
2264
- static char * * get_disp_names (struct vo_w32_state * w32 )
2275
+ static char * * get_disp_names (struct vo_w32_state * w32 , bool friendly )
2265
2276
{
2266
2277
// Get the client area of the window in screen space
2267
2278
RECT rect = { 0 };
2268
2279
GetClientRect (w32 -> window , & rect );
2269
2280
MapWindowPoints (w32 -> window , NULL , (POINT * )& rect , 2 );
2270
2281
2271
- struct disp_names_data data = { .assoc = w32 -> monitor };
2282
+ struct disp_names_data data = {
2283
+ .assoc = w32 -> monitor ,
2284
+ .friendly = friendly ,
2285
+ };
2272
2286
2273
2287
// Make sure the monitor that Windows considers to be associated with the
2274
2288
// window is first in the list
2275
- MONITORINFOEXW mi = { .cbSize = sizeof mi };
2276
- if (GetMonitorInfoW (data .assoc , (MONITORINFO * )& mi )) {
2277
- MP_TARRAY_APPEND (NULL , data .names , data .count ,
2278
- mp_to_utf8 (NULL , mi .szDevice ));
2279
- }
2289
+ disp_names_append (data .assoc , & data );
2280
2290
2281
2291
// Get the names of the other monitors that intersect the client rect
2282
2292
EnumDisplayMonitors (NULL , & rect , disp_names_proc , (LPARAM )& data );
@@ -2300,6 +2310,7 @@ static bool gui_thread_control_supports(int request)
2300
2310
case VOCTRL_GET_DISPLAY_FPS :
2301
2311
case VOCTRL_GET_DISPLAY_RES :
2302
2312
case VOCTRL_GET_DISPLAY_NAMES :
2313
+ case VOCTRL_GET_DISPLAY_NAMES_FRIENDLY :
2303
2314
case VOCTRL_GET_ICC_PROFILE :
2304
2315
case VOCTRL_GET_FOCUSED :
2305
2316
case VOCTRL_BEGIN_DRAGGING :
@@ -2447,7 +2458,10 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
2447
2458
((int * )arg )[1 ] = monrc .bottom - monrc .top ;
2448
2459
return VO_TRUE ;
2449
2460
case VOCTRL_GET_DISPLAY_NAMES :
2450
- * (char * * * )arg = get_disp_names (w32 );
2461
+ * (char * * * )arg = get_disp_names (w32 , false);
2462
+ return VO_TRUE ;
2463
+ case VOCTRL_GET_DISPLAY_NAMES_FRIENDLY :
2464
+ * (char * * * )arg = get_disp_names (w32 , true);
2451
2465
return VO_TRUE ;
2452
2466
case VOCTRL_GET_ICC_PROFILE :
2453
2467
update_display_info (w32 );
0 commit comments