This commit is contained in:
bailey cosier 2017-09-21 09:16:18 +00:00 committed by GitHub
commit 230e699996
6 changed files with 21 additions and 1 deletions

View File

@ -289,7 +289,9 @@ constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@anchor GLFW_TRANSPARENT @anchor GLFW_TRANSPARENT
__GLFW_TRANSPARENT__ specifies whether the framebuffer will support transparency __GLFW_TRANSPARENT__ specifies whether the framebuffer will support transparency
in the background. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. in the background. If transparency is not provided by your driver, GLFW will
gracefully fallback to opaque. It is possible to check for this outcome
with `glfwGetWindowAttrib()`. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@subsubsection window_hints_mtr Monitor related hints @subsubsection window_hints_mtr Monitor related hints

View File

@ -322,6 +322,11 @@ int main(int argc, char *argv[])
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
if (!glfwGetWindowAttrib(window, GLFW_TRANSPARENT))
{
fprintf( stderr, "Failed to set GLFW_TRANSPARENT flag\n" );
}
// Set callback functions // Set callback functions
glfwSetFramebufferSizeCallback(window, reshape); glfwSetFramebufferSizeCallback(window, reshape);
glfwSetKeyCallback(window, key); glfwSetKeyCallback(window, key);

View File

@ -188,6 +188,9 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
if (closest) if (closest)
*result = (EGLConfig) closest->handle; *result = (EGLConfig) closest->handle;
if (desired->transparent && closest->transparent != GLFW_TRUE)
_glfw.hints.framebuffer.transparent = GLFW_FALSE;
free(nativeConfigs); free(nativeConfigs);
free(usableConfigs); free(usableConfigs);

View File

@ -141,6 +141,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
if (closest) if (closest)
*result = (GLXFBConfig) closest->handle; *result = (GLXFBConfig) closest->handle;
if (desired->transparent && closest->transparent != GLFW_TRUE)
_glfw.hints.framebuffer.transparent = GLFW_FALSE;
XFree(nativeConfigs); XFree(nativeConfigs);
free(usableConfigs); free(usableConfigs);

View File

@ -988,6 +988,7 @@ static int createNativeWindow(_GLFWwindow* window,
WCHAR* wideTitle; WCHAR* wideTitle;
DWORD style = getWindowStyle(window); DWORD style = getWindowStyle(window);
DWORD exStyle = getWindowExStyle(window); DWORD exStyle = getWindowExStyle(window);
GLFWbool transparent = GLFW_FALSE;
if (window->monitor) if (window->monitor)
{ {
@ -1061,6 +1062,7 @@ static int createNativeWindow(_GLFWwindow* window,
bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
bb.hRgnBlur = region; bb.hRgnBlur = region;
bb.fEnable = TRUE; bb.fEnable = TRUE;
transparent = GLFW_TRUE;
if (SUCCEEDED(DwmEnableBlurBehindWindow(window->win32.handle, &bb))) if (SUCCEEDED(DwmEnableBlurBehindWindow(window->win32.handle, &bb)))
{ {
@ -1090,6 +1092,9 @@ static int createNativeWindow(_GLFWwindow* window,
DeleteObject(region); DeleteObject(region);
} }
// Need to let the framebuffer hint aware of the composition results.
_glfw.hints.framebuffer.transparent = transparent;
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -732,6 +732,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->resizable; return window->resizable;
case GLFW_DECORATED: case GLFW_DECORATED:
return window->decorated; return window->decorated;
case GLFW_TRANSPARENT:
return _glfw.hints.framebuffer.transparent;
case GLFW_FLOATING: case GLFW_FLOATING:
return window->floating; return window->floating;
case GLFW_AUTO_ICONIFY: case GLFW_AUTO_ICONIFY: