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);
|
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;
|
// Get the device name of the monitor containing the window
|
||||||
dm.dmSize = sizeof(DEVMODE);
|
HMONITOR mon = MonitorFromWindow(w32->window, MONITOR_DEFAULTTOPRIMARY);
|
||||||
dm.dmDriverExtra = 0;
|
MONITORINFOEXW mi = { .cbSize = sizeof mi };
|
||||||
if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
|
GetMonitorInfoW(mon, (MONITORINFO*)&mi);
|
||||||
|
|
||||||
|
DEVMODE dm = { .dmSize = sizeof dm };
|
||||||
|
if (!EnumDisplaySettingsW(mi.szDevice, ENUM_CURRENT_SETTINGS, &dm))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// May return 0 or 1 which "represent the display hardware's default refresh rate"
|
// 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;
|
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(w32);
|
||||||
|
|
||||||
double fps = vo_w32_get_display_fps();
|
|
||||||
if (fps != w32->display_fps) {
|
if (fps != w32->display_fps) {
|
||||||
w32->display_fps = fps;
|
w32->display_fps = fps;
|
||||||
signal_events(w32, VO_EVENT_WIN_STATE);
|
signal_events(w32, VO_EVENT_WIN_STATE);
|
||||||
|
|
Loading…
Reference in New Issue