{"id":26228045,"url":"https://github.com/stehfyn/imgui-borderless-win32","last_synced_at":"2025-04-19T16:43:09.464Z","repository":{"id":157685705,"uuid":"633600669","full_name":"Stehfyn/imgui-borderless-win32","owner":"Stehfyn","description":"Combines win32 BorderlessWindows with a transparent opengl rendering context to demonstrate advanced Windows DWM behavior for ImGui viewports","archived":false,"fork":false,"pushed_at":"2024-12-06T05:20:05.000Z","size":133418,"stargazers_count":36,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-06T06:22:04.909Z","etag":null,"topics":["aero","composition","desktop-window-manager","dwm","gui","gui-application","imgui","imgui-win32","mica","opengl","win32","windows","windows-desktop","windows-desktop-application","windows-gui"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Stehfyn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-27T21:42:21.000Z","updated_at":"2024-12-06T05:20:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"275e1ba4-5421-4aca-9470-477e22a2c349","html_url":"https://github.com/Stehfyn/imgui-borderless-win32","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stehfyn%2Fimgui-borderless-win32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stehfyn%2Fimgui-borderless-win32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stehfyn%2Fimgui-borderless-win32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stehfyn%2Fimgui-borderless-win32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stehfyn","download_url":"https://codeload.github.com/Stehfyn/imgui-borderless-win32/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243293353,"owners_count":20268136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aero","composition","desktop-window-manager","dwm","gui","gui-application","imgui","imgui-win32","mica","opengl","win32","windows","windows-desktop","windows-desktop-application","windows-gui"],"created_at":"2025-03-12T20:36:59.911Z","updated_at":"2025-03-12T20:37:00.377Z","avatar_url":"https://github.com/Stehfyn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imgui-borderless-win32\nCombines win32 [BorderlessWindows](https://github.com/melak47/BorderlessWindow) with a [transparent opengl rendering context](https://stackoverflow.com/questions/4052940/how-to-make-an-opengl-rendering-context-with-transparent-background) to achieve advanced Windows DWM behavior for ImGui viewports.\n\n| DWM Snapping | DWM Composition | DWM Accent Policy | Continuous Draw |\n| :---: | :---: | :---: | :---: |\n| ![](res/dwm_drag_snap.gif)  | ![](res/dwm_composition_attributes.gif)  | ![](res/dwm_accent_policy.gif) | ![](res/continuous_draw.gif) |\n| drag-snap from client area | alpha separate from glClearColor | aero, mica, acrylic | drag, resize, hold |\n\n## Demo\nTo try out the example you can clone the repository and its submodule:\n```bash\ngit clone --recursive https://github.com/Stehfyn/imgui-borderless-win32\n```\nOr do the following if you cloned the repo non-recursively already:\n```bash\ncd imgui-borderless-win32\ngit submodule update --init --recursive\n```\nThen open `imgui-borderless-win32.sln` with `Visual Studio` and build, or with the `Developer Command Prompt for VS` just do\n```bash\ncd imgui-borderless-win32\nmsbuild /m /p:Configuration=Release .\n```\n## Concept\nTo enable dragging from some custom client area, our `WndProc` needs to return `HTCAPTION` when we know we're not over an imgui window. Therefore our `WndProc` needs to do those hittests with knowledge of those window rects:\n```cpp\n// ...\n// (In Render Loop) Update imgui window rects for hit testing\n{\n    ImVec2 origin = { 0, 0 };\n    if (!(io.ConfigFlags \u0026 ImGuiConfigFlags_ViewportsEnable)) // Only apply offset if Multi-viewports are not enabled\n    {\n        RECT r;\n        GetWindowRect(hWnd, \u0026r); // Get ScreenPos offset\n        origin = { (float)r.left, (float)r.top };\n    }\n\n    // EXAMPLE:\n    // Add imgui windows that aren't default rects/dockspaces/windows over viewports,\n    // etc. to client area whitelist, but explicitly include imgui demo\n    std::vector\u003cRECT\u003e WindowRects;\n    for (ImGuiWindow* window : ImGui::GetCurrentContext()-\u003eWindows)\n    {\n        if(window-\u003eActive)\n        { \n            if ((!(std::string(window-\u003eName).find(\"Default\") != std::string::npos)  \u0026\u0026\n                (!(std::string(window-\u003eName).find(\"Dock\")    != std::string::npos)) \u0026\u0026\n                (!(std::string(window-\u003eName).find(\"Menu\")    != std::string::npos)) \u0026\u0026\n                (!(std::string(window-\u003eName).find(\"WindowOverViewport\") != std::string::npos))) ||\n                (std::string(window-\u003eName).find(\"Dear ImGui Demo\") != std::string::npos))\n            {\n                ImVec2 pos  = window-\u003ePos;\n                ImVec2 size = window-\u003eSize;\n                RECT   rect = { (LONG)(origin.x + pos.x),\n                                (LONG)(origin.y + pos.y),\n                                (LONG)(origin.x + (pos.x + size.x)),\n                                (LONG)(origin.y + (pos.y + size.y)) };\n\n                WindowRects.push_back(rect);\n            }\n        }\n    }\n    g_ClientCustomClientArea = std::move(WindowRects);\n}\n\n// ... (In the WndProc) Update imgui window rects for hit testing\ncase WM_NCHITTEST: {\n    switch (result) {\n    case left:           return HTLEFT;\n    case right:          return HTRIGHT;\n    case top:            return HTTOP;\n    case bottom:         return HTBOTTOM;\n    case top | left:     return HTTOPLEFT;\n    case top | right:    return HTTOPRIGHT;\n    case bottom | left:  return HTBOTTOMLEFT;\n    case bottom | right: return HTBOTTOMRIGHT;\n    case client: {\n        for (RECT rect : g_ClientCustomClientArea)\n            if (PtInRect(\u0026rect, cursor)) return HTCLIENT;\n        return HTCAPTION;\n    }\n    default: return HTNOWHERE;\n    }\n}\n```\n\n## Notes on SetWindowCompositionAttribute API\nIt's undocumented, and has varying behavior and performance bugs across different Windows 10 Builds and Windows 11. This demo has default flag values that work great for **Windows 10 Build 19044**, but some research and testing is required for feature parity across different versions. The following links may be helpful in understanding more about the `SetWindowCompositionAttribute` API:\n\n- https://github.com/sylveon/windows-swca\n- https://github.com/Maplespe/ExplorerBlurMica\n- https://github.com/TranslucentTB/TranslucentTB\n- https://gist.github.com/sylveon/9c199bb6684fe7dffcba1e3d383fb609\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstehfyn%2Fimgui-borderless-win32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstehfyn%2Fimgui-borderless-win32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstehfyn%2Fimgui-borderless-win32/lists"}