Skip to content

Commit 3a30a3a

Browse files
committed
fix capture area of maximized window bug #16.
1 parent f3b42d8 commit 3a30a3a

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.

Plugins/uWindowCapture/uWindowCapture/WindowTexture.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,34 @@ bool WindowTexture::Capture()
179179
auto hMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
180180
MONITORINFO monitor = { sizeof(MONITORINFO) };
181181
::GetMonitorInfo(hMonitor, &monitor);
182-
offsetX_ = monitor.rcMonitor.left - windowRect.left;
183-
offsetY_ = monitor.rcMonitor.top - windowRect.top;
184-
textureWidth_ -= 2 * offsetX_;
185-
textureHeight_ -= 2 * offsetY_;
182+
const auto ml = monitor.rcMonitor.left;
183+
const auto mr = monitor.rcMonitor.right;
184+
const auto mt = monitor.rcMonitor.top;
185+
const auto mb = monitor.rcMonitor.bottom;
186+
const auto wl = dwmRect.left;
187+
const auto wr = dwmRect.right;
188+
const auto wt = dwmRect.top;
189+
const auto wb = dwmRect.bottom;
190+
if (wl < ml || wt < mt || wr > mr || wb > mb)
191+
{
192+
// Remote taskbar area and get pixels out of the monitor range
193+
const auto calcSize = [&](LONG size) -> LONG
194+
{
195+
constexpr LONG taskBarSizeThresh = 30;
196+
if (size > taskBarSizeThresh) return 0;
197+
return max(size, 0);
198+
};
199+
const auto offsetExLeft = max(calcSize(ml - wl), 0);
200+
const auto offsetExRight = max(calcSize(wr - mr), 0);
201+
const auto offsetExTop = max(calcSize(mt - wt), 0);
202+
const auto offsetExBottom = max(calcSize(wb - mb), 0);
203+
const auto offsetExX = max(offsetExLeft, offsetExRight);
204+
const auto offsetExY = max(offsetExTop, offsetExBottom);
205+
textureWidth_ -= offsetExX * 2;
206+
textureHeight_ -= offsetExY * 2;
207+
offsetX_ += offsetExX;
208+
offsetY_ += offsetExY;
209+
}
186210
}
187211
}
188212
else

0 commit comments

Comments
 (0)