diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 3326f800c..2b11d5dde 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -92,6 +92,9 @@ Docking+Viewports Branch: viewports managed by the backend. (#4350) [@PathogenDavid] - Backends: Vulkan: Added ImGui_ImplVulkanH_GetWindowDataFromViewport() accessor/helper. (#8946, #8940) [@olivier-gerard] +- Examples: DX10, DX11: Disabled DXGI's Alt+Enter default behavior in examples. + Applications are free to leave this enabled, but it does not work properly with + multiple viewports. (#4350) [@PathogenDavid] ----------------------------------------------------------------------- diff --git a/examples/example_sdl2_directx11/main.cpp b/examples/example_sdl2_directx11/main.cpp index 298fcaaf7..c238c458b 100644 --- a/examples/example_sdl2_directx11/main.cpp +++ b/examples/example_sdl2_directx11/main.cpp @@ -256,6 +256,13 @@ bool CreateDeviceD3D(HWND hWnd) if (res != S_OK) return false; + // Disable DXGI's default Alt+Enter fullscreen behavior. + // - You are free to leave this enabled, but it will not work properly with multiple viewports. + // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates. + IDXGIFactory* pSwapChainFactory; + if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory)))) + pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); + CreateRenderTarget(); return true; } diff --git a/examples/example_sdl3_directx11/main.cpp b/examples/example_sdl3_directx11/main.cpp index 681c30dbc..e6f7515fd 100644 --- a/examples/example_sdl3_directx11/main.cpp +++ b/examples/example_sdl3_directx11/main.cpp @@ -251,6 +251,13 @@ bool CreateDeviceD3D(HWND hWnd) if (res != S_OK) return false; + // Disable DXGI's default Alt+Enter fullscreen behavior. + // - You are free to leave this enabled, but it will not work properly with multiple viewports. + // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates. + IDXGIFactory* pSwapChainFactory; + if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory)))) + pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); + CreateRenderTarget(); return true; } diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index f94440221..504502dac 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -241,6 +241,13 @@ bool CreateDeviceD3D(HWND hWnd) if (res != S_OK) return false; + // Disable DXGI's default Alt+Enter fullscreen behavior. + // - You are free to leave this enabled, but it will not work properly with multiple viewports. + // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates. + IDXGIFactory* pSwapChainFactory; + if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory)))) + pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); + CreateRenderTarget(); return true; } diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index e1ec03664..16b7e2cf2 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -245,6 +245,13 @@ bool CreateDeviceD3D(HWND hWnd) if (res != S_OK) return false; + // Disable DXGI's default Alt+Enter fullscreen behavior. + // - You are free to leave this enabled, but it will not work properly with multiple viewports. + // - This must be done for all windows associated to the device. Our DX11 backend does this automatically for secondary viewports that it creates. + IDXGIFactory* pSwapChainFactory; + if (SUCCEEDED(g_pSwapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory)))) + pSwapChainFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); + CreateRenderTarget(); return true; }