Skip to content

Commit f715c6c

Browse files
committed
Screen capture now detected increases in monitor size and rebuilds appropriately
1 parent 9365eb8 commit f715c6c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

include/Internal/ThreadManager.h

+15-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace SL
1919

2020
std::vector<std::thread> m_ThreadHandles;
2121
std::shared_ptr<std::atomic_bool> TerminateThreadsEvent;
22-
2322
public:
2423
ThreadManager();
2524
~ThreadManager();
@@ -65,10 +64,23 @@ namespace SL
6564
return true;
6665
}
6766

68-
67+
inline bool MonitorsChanged(const std::vector<Monitor>& startmonitors, const std::vector<Monitor>& nowmonitors) {
68+
if (startmonitors.size() != nowmonitors.size()) return true;
69+
for (size_t i = 0; i < startmonitors.size(); i++) {
70+
if (startmonitors[i].Height != nowmonitors[i].Height ||
71+
startmonitors[i].Id != nowmonitors[i].Id ||
72+
startmonitors[i].Index != nowmonitors[i].Index ||
73+
startmonitors[i].Name != nowmonitors[i].Name ||
74+
startmonitors[i].OffsetX != nowmonitors[i].OffsetX ||
75+
startmonitors[i].OffsetY != nowmonitors[i].OffsetY ||
76+
startmonitors[i].Width != nowmonitors[i].Width) return true;
77+
}
78+
return false;
79+
}
6980
template <class T, class F> bool TryCaptureMonitor(const F& data, Monitor& monitor)
7081
{
7182
T frameprocessor;
83+
auto startmonitors = GetMonitors();
7284
auto ret = frameprocessor.Init(data, monitor);
7385
if (ret != DUPL_RETURN_SUCCESS) {
7486
return false;
@@ -88,7 +100,7 @@ namespace SL
88100
auto timer = std::atomic_load(&data->Monitor_Capture_Timer);
89101
timer->start();
90102
auto monitors = GetMonitors();
91-
if (isMonitorInsideBounds(monitors, monitor)) {
103+
if (isMonitorInsideBounds(monitors, monitor) && !MonitorsChanged(startmonitors, monitors)) {
92104
ret = frameprocessor.ProcessFrame(monitors[Index(monitor)]);
93105
}
94106
else {

0 commit comments

Comments
 (0)