mirror of https://github.com/mpv-player/mpv
w32_common: use the current monitor's refresh rate
This commit is contained in:
parent
e2326bda82
commit
138c4e50df
|
@ -565,12 +565,15 @@ static void wakeup_gui_thread(void *ctx)
|
|||
PostMessage(w32->window, WM_USER, 0, 0);
|
||||
}
|
||||
|
||||
static double vo_w32_get_display_fps(void)
|
||||
static double vo_w32_get_display_fps(struct vo_w32_state *w32)
|
||||
{
|
||||
DEVMODE dm;
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
dm.dmDriverExtra = 0;
|
||||
if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
|
||||
// Get the device name of the monitor containing the window
|
||||
HMONITOR mon = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY);
|
||||
MONITORINFOEXW mi = { .cbSize = sizeof mi };
|
||||
GetMonitorInfoW(mon, (MONITORINFO*)&mi);
|
||||
|
||||
DEVMODE dm = { .dmSize = sizeof dm };
|
||||
if (!EnumDisplaySettingsW(mi.szDevice, ENUM_CURRENT_SETTINGS, &dm))
|
||||
return -1;
|
||||
|
||||
// May return 0 or 1 which "represent the display hardware's default refresh rate"
|
||||
|
@ -595,11 +598,9 @@ static double vo_w32_get_display_fps(void)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static void update_display_fps(void *ctx)
|
||||
static void update_display_fps(struct vo_w32_state *w32)
|
||||
{
|
||||
struct vo_w32_state *w32 = ctx;
|
||||
|
||||
double fps = vo_w32_get_display_fps();
|
||||
double fps = vo_w32_get_display_fps(w32);
|
||||
if (fps != w32->display_fps) {
|
||||
w32->display_fps = fps;
|
||||
signal_events(w32, VO_EVENT_WIN_STATE);
|
||||
|
|
Loading…
Reference in New Issue