mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-10-18 09:53:05 +08:00
[fix] recover headless capture and use WGC for usbmmidd displays
This commit is contained in:
@@ -217,6 +217,22 @@ int CountUsbmmiddMonitors() {
|
||||
return count;
|
||||
}
|
||||
|
||||
std::wstring FindUsbmmiddDisplayDeviceName() {
|
||||
for (const auto& adapter : EnumerateUsbmmiddAdapters()) {
|
||||
if (adapter.attached_to_desktop) return adapter.device_name;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
bool IsUsbmmiddDisplayDevice(const std::wstring& device_name) {
|
||||
for (const auto& adapter : EnumerateUsbmmiddAdapters()) {
|
||||
if (adapter.attached_to_desktop &&
|
||||
_wcsicmp(adapter.device_name.c_str(), device_name.c_str()) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsUsbmmiddDriverInstalled() {
|
||||
const HDEVINFO device_info = SetupDiGetClassDevsW(
|
||||
&GUID_DEVCLASS_DISPLAY, nullptr, nullptr, DIGCF_PRESENT);
|
||||
|
||||
@@ -42,6 +42,9 @@ UsbmmiddStatus QueryUsbmmiddStatus();
|
||||
|
||||
// Adapters attached to the desktop, i.e. monitors currently plugged in.
|
||||
int CountUsbmmiddMonitors();
|
||||
// GDI device name of an attached usbmmidd output, or empty while settling.
|
||||
std::wstring FindUsbmmiddDisplayDeviceName();
|
||||
bool IsUsbmmiddDisplayDevice(const std::wstring& device_name);
|
||||
// Root-enumerated device node present, plugged or not.
|
||||
bool IsUsbmmiddDriverInstalled();
|
||||
|
||||
|
||||
@@ -190,7 +190,10 @@ bool VirtualDisplayProvisioner::Acquire(VirtualDisplayMode mode,
|
||||
std::string local_error;
|
||||
if (error == nullptr) error = &local_error;
|
||||
if (active_.load(std::memory_order_relaxed)) return true;
|
||||
cancel_.store(false, std::memory_order_relaxed);
|
||||
if (Cancelled()) {
|
||||
*error = "cancelled";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool helper_reachable = false;
|
||||
const ULONGLONG started = GetTickCount64();
|
||||
|
||||
@@ -29,6 +29,9 @@ class VirtualDisplayProvisioner {
|
||||
delete;
|
||||
|
||||
bool Acquire(VirtualDisplayMode mode, std::string* error);
|
||||
// Owner calls this before launching an Acquire worker. Clearing cancellation
|
||||
// inside the worker would lose a Stop() racing with thread startup.
|
||||
void PrepareAcquire() { cancel_.store(false, std::memory_order_relaxed); }
|
||||
void Release();
|
||||
bool active() const { return active_.load(std::memory_order_relaxed); }
|
||||
// True when Release() has something to undo. Read on the owner's thread
|
||||
@@ -37,7 +40,7 @@ class VirtualDisplayProvisioner {
|
||||
return active() || pending_helper_release_ || plugged_locally_ > 0;
|
||||
}
|
||||
// Makes a blocking Acquire() return early with "cancelled" at its next poll
|
||||
// (helper install/plug can take up to two minutes). Cleared by Acquire().
|
||||
// (helper install/plug can take up to two minutes).
|
||||
void RequestCancel() { cancel_.store(true, std::memory_order_relaxed); }
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user