Merge pull request #6665 from alphanu1/master

Windows hz bug fix
This commit is contained in:
Twinaphex 2018-04-30 19:27:49 +02:00 committed by GitHub
commit 97ccfdf020
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 28 deletions

View File

@ -106,7 +106,7 @@ static void win32_display_server_destroy(void *data)
if (win32_orig_width > 0 && win32_orig_height > 0 )
video_display_server_switch_resolution(win32_orig_width, win32_orig_height,
0, 60);
60, 60);
#ifdef HAS_TASKBAR_EXT
if (g_taskbarList && win32_taskbar_is_created())
@ -200,14 +200,14 @@ static bool win32_set_window_decorations(void *data, bool on)
}
static bool win32_display_server_set_resolution(void *data,
unsigned width, unsigned height, int f_restore, float hz)
unsigned width, unsigned height, int int_hz, float hz)
{
LONG res;
DEVMODE curDevmode;
DEVMODE devmode;
int iModeNum;
int freq = 0;
int freq = win_hz;
DWORD flags = 0;
int depth = 0;
dispserv_win32_t *serv = (dispserv_win32_t*)data;
@ -220,20 +220,6 @@ static bool win32_display_server_set_resolution(void *data,
if (win32_orig_height == 0)
win32_orig_height = GetSystemMetrics(SM_CYSCREEN);
/* set hz float to an int for windows switching */
if (hz < 53)
hz = 50;
if (hz >= 53 && hz < 57)
hz = 55;
if (hz >= 57)
hz = 60;
video_monitor_set_refresh_rate(hz);
if (f_restore == 0)
freq = hz;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode);
/* Used to stop super resolution bug */

View File

@ -82,7 +82,7 @@ static bool x11_set_window_decorations(void *data, bool on)
}
static bool x11_set_resolution(void *data,
unsigned width, unsigned height, int f_restore, float hz)
unsigned width, unsigned height, int int_hz, float hz)
{
int i = 0;
int hfp = 0;
@ -113,13 +113,13 @@ static bool x11_set_resolution(void *data,
if (width > 599 && width < 1919)
{
hfp = width+16;
hbp = width*1.10-8;
hbp = width*1.18;
}
if (width > 1919 && width < 2559)
{
hfp = width+32;
hbp = width*1.10;
hbp = width*1.20;
}
if (width > 2559)

View File

@ -48,6 +48,24 @@ static void crt_check_first_run(void)
first_run = false;
}
static void switch_crt_hz(void)
{
if (ra_core_hz == ra_tmp_core_hz)
return;
/* set hz float to an int for windows switching */
if (ra_core_hz < 53)
ra_set_core_hz = 50;
if (ra_core_hz >= 53 && ra_core_hz < 57)
ra_set_core_hz = 55;
if (ra_core_hz >= 57)
ra_set_core_hz = 60;
video_monitor_set_refresh_rate(ra_set_core_hz);
ra_tmp_core_hz = ra_core_hz;
}
static void crt_aspect_ratio_switch(unsigned width, unsigned height)
{
/* send aspect float to videeo_driver */
@ -60,7 +78,7 @@ static void switch_res_crt(unsigned width, unsigned height)
if (height > 100)
{
video_display_server_switch_resolution(width, height,
0, ra_core_hz);
ra_set_core_hz, ra_core_hz);
video_driver_apply_state_changes();
}
}
@ -69,6 +87,7 @@ static void switch_res_crt(unsigned width, unsigned height)
static void crt_screen_setup_aspect(unsigned width, unsigned height)
{
switch_crt_hz();
/* get original resolution of core */
if (height == 4)
{

View File

@ -84,9 +84,9 @@ bool video_display_server_set_window_decorations(bool on)
bool video_display_server_switch_resolution(unsigned width, unsigned height,
int f_restore, float hz)
int int_hz, float hz)
{
if (current_display_server && current_display_server->switch_resolution)
return current_display_server->switch_resolution(current_display_server_data, width, height, f_restore, hz);
return current_display_server->switch_resolution(current_display_server_data, width, height, int_hz, hz);
return false;
}

View File

@ -31,7 +31,7 @@ typedef struct video_display_server
bool (*set_window_progress)(void *data, int progress, bool finished);
bool (*set_window_decorations)(void *data, bool on);
bool (*switch_resolution)(void *data, unsigned width,
unsigned height, int f_restore, float hz);
unsigned height, int int_hz, float hz);
const char *ident;
} video_display_server_t;
@ -47,7 +47,7 @@ bool video_display_server_set_window_decorations(bool on);
bool video_display_server_switch_resolution(
unsigned width, unsigned height,
int f_restore, float hz);
int int_hz, float hz);
extern const video_display_server_t dispserv_win32;
extern const video_display_server_t dispserv_x11;