This commit is contained in:
twinaphex 2018-01-08 23:30:07 +01:00
parent 7fdb621481
commit aa641325cb

View File

@ -816,7 +816,8 @@ bool win32_window_create(void *data, unsigned style,
SetWindowLongPtr(main_window.hwnd, SetWindowLongPtr(main_window.hwnd,
GWL_EXSTYLE, GWL_EXSTYLE,
GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(main_window.hwnd, 0, (255 * settings->uints.video_window_opacity) / 100, LWA_ALPHA); SetLayeredWindowAttributes(main_window.hwnd, 0, (255 *
settings->uints.video_window_opacity) / 100, LWA_ALPHA);
#endif #endif
#endif #endif
return true; return true;
@ -944,7 +945,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
if (frontend->get_os) if (frontend->get_os)
frontend->get_os(tmp, sizeof(tmp), &major, &minor); frontend->get_os(tmp, sizeof(tmp), &major, &minor);
if (major*100+minor >= 601) if (major * 100 + minor >= 601)
{ {
#if _WIN32_WINNT >= 0x0601 #if _WIN32_WINNT >= 0x0601
/* Windows 7, 8, 10 codepath */ /* Windows 7, 8, 10 codepath */
@ -973,7 +974,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
} }
#endif #endif
} }
else if (major*100+minor >= 410) else if (major * 100 + minor >= 410)
{ {
#if _WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0410 #if _WIN32_WINDOWS >= 0x0410 || _WIN32_WINNT >= 0x0410
/* 98 / 2K / XP / Vista codepath */ /* 98 / 2K / XP / Vista codepath */
@ -981,12 +982,12 @@ bool win32_suppress_screensaver(void *data, bool enable)
return true; return true;
#endif #endif
} }
else else
{ {
/* 95 / NT codepath */ /* 95 / NT codepath */
/* No way to block the screensaver. */ /* No way to block the screensaver. */
return true; return true;
} }
} }
#endif #endif
@ -998,18 +999,17 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
RECT *rect, RECT *mon_rect, DWORD *style) RECT *rect, RECT *mon_rect, DWORD *style)
{ {
#ifndef _XBOX #ifndef _XBOX
settings_t *settings = config_get_ptr();
/* Windows only reports the refresh rates for modelines as
* an integer, so video_refresh_rate needs to be rounded. Also, account
* for black frame insertion using video_refresh_rate set to half
* of the display refresh rate, as well as higher vsync swap intervals. */
float refresh_mod = settings->bools.video_black_frame_insertion ? 2.0f : 1.0f;
unsigned refresh = roundf(settings->floats.video_refresh_rate
* refresh_mod * settings->uints.video_swap_interval);
if (fullscreen) if (fullscreen)
{ {
settings_t *settings = config_get_ptr();
/* Windows only reports the refresh rates for modelines as
* an integer, so video_refresh_rate needs to be rounded. Also, account
* for black frame insertion using video_refresh_rate set to half
* of the display refresh rate, as well as higher vsync swap intervals. */
float refresh_mod = settings->bools.video_black_frame_insertion ? 2.0f : 1.0f;
unsigned refresh = roundf(settings->floats.video_refresh_rate
* refresh_mod * settings->uints.video_swap_interval);
if (windowed_full) if (windowed_full)
{ {
*style = WS_EX_TOPMOST | WS_POPUP; *style = WS_EX_TOPMOST | WS_POPUP;
@ -1022,7 +1022,7 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
if (!win32_monitor_set_fullscreen(*width, *height, if (!win32_monitor_set_fullscreen(*width, *height,
refresh, current_mon->szDevice)) refresh, current_mon->szDevice))
{} {}
/* Display settings might have changed, get new coordinates. */ /* Display settings might have changed, get new coordinates. */
GetMonitorInfo(*hm_to_use, (LPMONITORINFO)current_mon); GetMonitorInfo(*hm_to_use, (LPMONITORINFO)current_mon);
@ -1031,10 +1031,12 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
} }
else else
{ {
*style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; *style = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
rect->right = *width; rect->right = *width;
rect->bottom = *height; rect->bottom = *height;
AdjustWindowRect(rect, *style, FALSE); AdjustWindowRect(rect, *style, FALSE);
g_resize_width = *width = rect->right - rect->left; g_resize_width = *width = rect->right - rect->left;
g_resize_height = *height = rect->bottom - rect->top; g_resize_height = *height = rect->bottom - rect->top;
} }
@ -1207,7 +1209,7 @@ void win32_get_video_output_prev(
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
DEVMODE dm; DEVMODE dm;
int iModeNum; unsigned i;
bool found = false; bool found = false;
unsigned prev_width = 0; unsigned prev_width = 0;
unsigned prev_height = 0; unsigned prev_height = 0;
@ -1220,9 +1222,9 @@ void win32_get_video_output_prev(
win32_get_video_output_size(&curr_width, &curr_height); win32_get_video_output_size(&curr_width, &curr_height);
for (iModeNum = 0; for (i = 0;
EnumDisplaySettings(NULL, iModeNum, &dm) != 0; EnumDisplaySettings(NULL, i, &dm) != 0;
iModeNum++) i++)
{ {
if ( dm.dmPelsWidth == curr_width if ( dm.dmPelsWidth == curr_width
&& dm.dmPelsHeight == curr_height) && dm.dmPelsHeight == curr_height)
@ -1250,7 +1252,7 @@ void win32_get_video_output_next(
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
DEVMODE dm; DEVMODE dm;
int iModeNum; int i;
bool found = false; bool found = false;
unsigned curr_width = 0; unsigned curr_width = 0;
unsigned curr_height = 0; unsigned curr_height = 0;
@ -1260,9 +1262,9 @@ void win32_get_video_output_next(
win32_get_video_output_size(&curr_width, &curr_height); win32_get_video_output_size(&curr_width, &curr_height);
for (iModeNum = 0; for (i = 0;
EnumDisplaySettings(NULL, iModeNum, &dm) != 0; EnumDisplaySettings(NULL, i, &dm) != 0;
iModeNum++) i++)
{ {
if (found) if (found)
{ {