MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / on_current_desktop

Method on_current_desktop

TranslucentTB/windows/window.cpp:157–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157std::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
188bool Window::is_user_window() const
189{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected