Always reset the thread desktop before calling DuplicateOutput()
Otherwise capture will fail if the thread desktop is different than the current input desktop (ex: UAC secure desktop is active)
This commit is contained in:
@@ -376,11 +376,15 @@ namespace platf::dxgi {
|
||||
// Check if we can use the Desktop Duplication API on this output
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
dup_t dup;
|
||||
|
||||
// Ensure we can duplicate the current display
|
||||
syncThreadDesktop();
|
||||
|
||||
status = output1->DuplicateOutput((IUnknown *) device.get(), &dup);
|
||||
if (SUCCEEDED(status)) {
|
||||
return true;
|
||||
}
|
||||
Sleep(200);
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
BOOST_LOG(error) << "DuplicateOutput() test failed [0x"sv << util::hex(status).to_string_view() << ']';
|
||||
@@ -405,9 +409,6 @@ namespace platf::dxgi {
|
||||
FreeLibrary(user32);
|
||||
});
|
||||
|
||||
// Ensure we can duplicate the current display
|
||||
syncThreadDesktop();
|
||||
|
||||
// Get rectangle of full desktop for absolute mouse coordinates
|
||||
env_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||
env_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||
@@ -679,6 +680,9 @@ namespace platf::dxgi {
|
||||
|
||||
// We try this twice, in case we still get an error on reinitialization
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
// Ensure we can duplicate the current display
|
||||
syncThreadDesktop();
|
||||
|
||||
status = output5->DuplicateOutput1((IUnknown *) device.get(), 0, supported_formats.size(), supported_formats.data(), &dup.dup);
|
||||
if (SUCCEEDED(status)) {
|
||||
break;
|
||||
@@ -705,6 +709,9 @@ namespace platf::dxgi {
|
||||
}
|
||||
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
// Ensure we can duplicate the current display
|
||||
syncThreadDesktop();
|
||||
|
||||
status = output1->DuplicateOutput((IUnknown *) device.get(), &dup.dup);
|
||||
if (SUCCEEDED(status)) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user