mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
fix: handle better DwmEnableBlurBehindWindow
This commit is contained in:
parent
25313317f0
commit
fe81dd9899
@ -493,6 +493,28 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window->transparent) {
|
||||||
|
if (!isCompositionEnabled || !_glfw_DwmEnableBlurBehindWindow) {
|
||||||
|
window->transparent = GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
DWM_BLURBEHIND bb = { 0 };
|
||||||
|
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
|
||||||
|
bb.hRgnBlur = CreateRectRgn(0, 0, -1, -1); // makes the window transparent
|
||||||
|
bb.fEnable = TRUE;
|
||||||
|
hr = _glfw_DwmEnableBlurBehindWindow(window->win32.handle, &bb);
|
||||||
|
|
||||||
|
if (!SUCCEEDED(hr)) {
|
||||||
|
window->transparent = GLFW_FALSE;
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"WGL: Failed to enable blur behind window required for transparency");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,12 @@ typedef enum PROCESS_DPI_AWARENESS
|
|||||||
} PROCESS_DPI_AWARENESS;
|
} PROCESS_DPI_AWARENESS;
|
||||||
#endif /*DPI_ENUMS_DECLARED*/
|
#endif /*DPI_ENUMS_DECLARED*/
|
||||||
|
|
||||||
|
#if !defined(_DWMAPI_H_)
|
||||||
|
// Blur behind data structures
|
||||||
|
#define DWM_BB_ENABLE 0x00000001 // fEnable has been specified
|
||||||
|
#define DWM_BB_BLURREGION 0x00000002 // hRgnBlur has been specified
|
||||||
|
#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 // fTransitionOnMaximized has been specified
|
||||||
|
|
||||||
typedef struct _DWM_BLURBEHIND
|
typedef struct _DWM_BLURBEHIND
|
||||||
{
|
{
|
||||||
DWORD dwFlags;
|
DWORD dwFlags;
|
||||||
@ -127,31 +133,31 @@ typedef struct _DWM_BLURBEHIND
|
|||||||
HRGN hRgnBlur;
|
HRGN hRgnBlur;
|
||||||
BOOL fTransitionOnMaximized;
|
BOOL fTransitionOnMaximized;
|
||||||
} DWM_BLURBEHIND, *PDWM_BLURBEHIND;
|
} DWM_BLURBEHIND, *PDWM_BLURBEHIND;
|
||||||
|
#endif
|
||||||
|
|
||||||
// winmm.dll function pointer typedefs
|
// winmm.dll function pointer typedefs
|
||||||
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
|
||||||
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
|
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
|
||||||
typedef MMRESULT (WINAPI * JOYGETPOSEX_T)(UINT,LPJOYINFOEX);
|
typedef MMRESULT (WINAPI * JOYGETPOSEX_T)(UINT,LPJOYINFOEX);
|
||||||
typedef DWORD (WINAPI * TIMEGETTIME_T)(void);
|
typedef DWORD (WINAPI * TIMEGETTIME_T)(void);
|
||||||
typedef HRESULT(WINAPI * DWMENABLEBLURBEHINDWINDOW_T)(HWND, const DWM_BLURBEHIND*);
|
|
||||||
#define _glfw_joyGetDevCaps _glfw.win32.winmm.joyGetDevCaps
|
#define _glfw_joyGetDevCaps _glfw.win32.winmm.joyGetDevCaps
|
||||||
#define _glfw_joyGetPos _glfw.win32.winmm.joyGetPos
|
#define _glfw_joyGetPos _glfw.win32.winmm.joyGetPos
|
||||||
#define _glfw_joyGetPosEx _glfw.win32.winmm.joyGetPosEx
|
#define _glfw_joyGetPosEx _glfw.win32.winmm.joyGetPosEx
|
||||||
#define _glfw_timeGetTime _glfw.win32.winmm.timeGetTime
|
#define _glfw_timeGetTime _glfw.win32.winmm.timeGetTime
|
||||||
#define _glfw_DwmEnableBlurBehindWindow _glfw.win32.dwmapi.DwmEnableBlurBehindWindow
|
|
||||||
|
|
||||||
// user32.dll function pointer typedefs
|
// user32.dll function pointer typedefs
|
||||||
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
||||||
typedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
typedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
||||||
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
||||||
#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
|
#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
|
||||||
#define _glfw_DwmEnableBlurBehindWindow _glfw.win32.dwmapi.DwmEnableBlurBehindWindow
|
|
||||||
|
|
||||||
// dwmapi.dll function pointer typedefs
|
// dwmapi.dll function pointer typedefs
|
||||||
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
||||||
typedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);
|
typedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);
|
||||||
|
typedef HRESULT (WINAPI * DWMENABLEBLURBEHINDWINDOW_T)(HWND, const DWM_BLURBEHIND*);
|
||||||
#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled
|
#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled
|
||||||
#define _glfw_DwmFlush _glfw.win32.dwmapi.DwmFlush
|
#define _glfw_DwmFlush _glfw.win32.dwmapi.DwmFlush
|
||||||
|
#define _glfw_DwmEnableBlurBehindWindow _glfw.win32.dwmapi.DwmEnableBlurBehindWindow
|
||||||
|
|
||||||
// shcore.dll function pointer typedefs
|
// shcore.dll function pointer typedefs
|
||||||
typedef HRESULT (WINAPI * SETPROCESSDPIAWARENESS_T)(PROCESS_DPI_AWARENESS);
|
typedef HRESULT (WINAPI * SETPROCESSDPIAWARENESS_T)(PROCESS_DPI_AWARENESS);
|
||||||
|
@ -732,19 +732,6 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
|||||||
window->win32.numer = GLFW_DONT_CARE;
|
window->win32.numer = GLFW_DONT_CARE;
|
||||||
window->win32.denom = GLFW_DONT_CARE;
|
window->win32.denom = GLFW_DONT_CARE;
|
||||||
|
|
||||||
// Accelerated transparent windows
|
|
||||||
// It currently doesn't support decorated windows.
|
|
||||||
// If decorated is required we just return an opaque window.
|
|
||||||
// Since DwmEnableBlurBehindWindow is supported since Vista,
|
|
||||||
// previous versions will simply get an opaque window.
|
|
||||||
if (!window->decorated && _glfw_DwmEnableBlurBehindWindow && window->transparent) {
|
|
||||||
DWM_BLURBEHIND bb = { 0 };
|
|
||||||
bb.dwFlags = 3; // DWM_BB_ENABLE | DWM_BB_BLURREGION
|
|
||||||
bb.hRgnBlur = CreateRectRgn(0, 0, -1, -1); // an invalid hRgnBlur makes the the window transparent
|
|
||||||
bb.fEnable = TRUE;
|
|
||||||
_glfw_DwmEnableBlurBehindWindow(window->win32.handle, &bb);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user