| 155 | } |
| 156 | |
| 157 | std::optional<bool> Window::on_current_desktop() const |
| 158 | { |
| 159 | static const auto desktop_manager = []() -> wil::com_ptr<IVirtualDesktopManager> |
| 160 | { |
| 161 | try |
| 162 | { |
| 163 | return wil::CoCreateInstance<IVirtualDesktopManager>(CLSID_VirtualDesktopManager); |
| 164 | } |
| 165 | catch (const wil::ResultException &err) |
| 166 | { |
| 167 | ResultExceptionHandle(err, spdlog::level::warn, L"Failed to create virtual desktop manager"); |
| 168 | return nullptr; |
| 169 | } |
| 170 | }(); |
| 171 | |
| 172 | if (desktop_manager) |
| 173 | { |
| 174 | BOOL on_current_desktop; |
| 175 | if (const HRESULT hr = desktop_manager->IsWindowOnCurrentVirtualDesktop(m_WindowHandle, &on_current_desktop); SUCCEEDED(hr)) |
| 176 | { |
| 177 | return on_current_desktop; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | HresultHandle(hr, spdlog::level::info, L"Verifying if a window is on the current virtual desktop failed."); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | return std::nullopt; |
| 186 | } |
| 187 | |
| 188 | bool Window::is_user_window() const |
| 189 | { |
nothing calls this directly
no outgoing calls
no test coverage detected