Host: Add GetTopLevelWindowInfo()

And use it for screensaver inhibiting on Linux.
This commit is contained in:
Connor McLaughlin
2022-11-18 18:14:39 +10:00
parent 3d4d2336a9
commit 8d7aea5e19
25 changed files with 133 additions and 126 deletions

View File

@ -85,9 +85,15 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
// need to release the lock while we're enumerating, because we call winId().
settings_lock.unlock();
m_toplevel_window = static_cast<HWND>(Host::GetTopLevelWindowHandle());
const std::optional<WindowInfo> toplevel_wi(Host::GetTopLevelWindowInfo());
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfo::Type::Win32)
{
Log_ErrorPrintf("Missing top level window, cannot add DInput devices.");
return false;
}
settings_lock.lock();
m_toplevel_window = static_cast<HWND>(toplevel_wi->window_handle);
ReloadDevices();
return true;
}