| 175 | } |
| 176 | |
| 177 | std::unique_ptr<win::KernelWindow> Overlay::MakeWindow_(std::optional<Vec2I> pos_) |
| 178 | { |
| 179 | UpdateTargetFullscreenStatus(); |
| 180 | std::unique_ptr<win::KernelWindow> pWindow; |
| 181 | if (pSpec->independentKernelWindow) { |
| 182 | // try and get the position of the control (CEF) window for calculating independent metrics window pos |
| 183 | // TODO: connect this more assuredly to the cef control window |
| 184 | // tried CefBrowserHost::GetWindowHandle, but it causes crashes for some unknown reason |
| 185 | // should make this at least less brittle with respect to window classname / title |
| 186 | bool bringToFrontOnCreation = false; |
| 187 | if (!pos_) { |
| 188 | bringToFrontOnCreation = true; |
| 189 | pos_ = Vec2I{ CW_USEDEFAULT, CW_USEDEFAULT }; |
| 190 | if (auto hWndControl = FindWindowA("BrowserWindowClass", "Intel PresentMon")) { |
| 191 | RECT controlRect{}; |
| 192 | if (GetWindowRect(hWndControl, &controlRect)) { |
| 193 | pos_ = Vec2I{ controlRect.left + 25, controlRect.top + 25 }; |
| 194 | } |
| 195 | else { |
| 196 | pmlog_warn("failed to get rect of control window").hr(); |
| 197 | } |
| 198 | } |
| 199 | else { |
| 200 | pmlog_warn("failed to find control window"); |
| 201 | } |
| 202 | } |
| 203 | // make the metrics window |
| 204 | pWindow = std::make_unique<win::StandardWindow>( |
| 205 | pos_->x, pos_->y, |
| 206 | windowDimensions, |
| 207 | L"PresentMon Data Display", |
| 208 | bringToFrontOnCreation |
| 209 | ); |
| 210 | } |
| 211 | else { |
| 212 | const auto pos = CalculateOverlayPosition_(); |
| 213 | pWindow = std::make_unique<win::OverlayWindow>( |
| 214 | targetFullscreen, |
| 215 | pos.x, pos.y, |
| 216 | windowDimensions, |
| 217 | L"P2C#OVERLAY" |
| 218 | ); |
| 219 | // place overlay just above target in the z-order |
| 220 | pWindow->Reorder(proc.hWnd); |
| 221 | } |
| 222 | return pWindow; |
| 223 | } |
| 224 | |
| 225 | void Overlay::RebuildDocument(std::shared_ptr<OverlaySpec> pSpec_) |
| 226 | { |