Merge pull request #6094 from aliaspider/master

(win32)  disable WS_EX_LAYERED when opacity == 100.
This commit is contained in:
Twinaphex 2018-01-13 14:53:43 +01:00 committed by GitHub
commit b2ec210fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -813,11 +813,14 @@ bool win32_window_create(void *data, unsigned style,
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 /* 2K */
/* Windows 2000 and above use layered windows to enable transparency */
SetWindowLongPtr(main_window.hwnd,
GWL_EXSTYLE,
GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(main_window.hwnd, 0, (255 *
settings->uints.video_window_opacity) / 100, LWA_ALPHA);
if(settings->uints.video_window_opacity < 100)
{
SetWindowLongPtr(main_window.hwnd,
GWL_EXSTYLE,
GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(main_window.hwnd, 0, (255 *
settings->uints.video_window_opacity) / 100, LWA_ALPHA);
}
#endif
#endif
return true;

View File

@ -113,8 +113,20 @@ static bool win32_set_window_opacity(void *data, unsigned opacity)
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500
/* Set window transparency on Windows 2000 and above */
if (SetLayeredWindowAttributes(hwnd, 0, (255 * opacity) / 100, LWA_ALPHA))
if(opacity < 100)
{
SetWindowLongPtr(hwnd,
GWL_EXSTYLE,
GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
return SetLayeredWindowAttributes(hwnd, 0, (255 * opacity) / 100, LWA_ALPHA);
}
else
{
SetWindowLongPtr(hwnd,
GWL_EXSTYLE,
GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
return true;
}
#endif
return false;
}