mirror of
https://github.com/kunkundi/crossdesk.git
synced 2026-03-25 01:27:25 +08:00
[fix] reset to initial monitor on connection close via ResetToInitialMonitor to fix black screen
This commit is contained in:
@@ -73,6 +73,7 @@ int ScreenCapturerGdi::Init(const int fps, cb_desktop_data cb) {
|
||||
return -2;
|
||||
}
|
||||
monitor_index_ = 0;
|
||||
initial_monitor_index_ = monitor_index_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -124,6 +125,16 @@ int ScreenCapturerGdi::SwitchTo(int monitor_index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ScreenCapturerGdi::ResetToInitialMonitor() {
|
||||
if (display_info_list_.empty()) return -1;
|
||||
int target = initial_monitor_index_;
|
||||
if (target < 0 || target >= (int)display_info_list_.size()) return -1;
|
||||
monitor_index_ = target;
|
||||
LOG_INFO("GDI: reset to initial monitor {}:{}", monitor_index_.load(),
|
||||
display_info_list_[monitor_index_].name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScreenCapturerGdi::CaptureLoop() {
|
||||
int interval_ms = fps_ > 0 ? (1000 / fps_) : 16;
|
||||
HDC screen_dc = GetDC(nullptr);
|
||||
|
||||
Reference in New Issue
Block a user