Fix capturing Maximised windows.

This commit is contained in:
Robin Krom 2022-06-28 22:17:56 +02:00
parent f50f205b70
commit 36a285ebd4
No known key found for this signature in database
GPG key ID: BCC01364F1371490

View file

@ -550,8 +550,8 @@ namespace Greenshot.Base.Core
{
// Try to return a cached value
long now = DateTime.Now.Ticks;
if (_previousWindowRectangle.IsEmpty || !_frozen)
{
if (!_previousWindowRectangle.IsEmpty && _frozen) return _previousWindowRectangle;
if (!_previousWindowRectangle.IsEmpty && now - _lastWindowRectangleRetrieveTime <= CacheTime)
{
return _previousWindowRectangle;
@ -590,17 +590,6 @@ namespace Greenshot.Base.Core
}
}
// Correction for maximized windows
if (!HasParent && Maximised)
{
// Only if the border size can be retrieved
if (GetBorderSize(out var size))
{
windowRect = new NativeRect(windowRect.X + size.Width, windowRect.Y + size.Height, windowRect.Width - (2 * size.Width),
windowRect.Height - (2 * size.Height));
}
}
_lastWindowRectangleRetrieveTime = now;
// Try to return something valid, by getting returning the previous size if the window doesn't have a NativeRect anymore
if (windowRect.IsEmpty)
@ -610,9 +599,7 @@ namespace Greenshot.Base.Core
_previousWindowRectangle = windowRect;
return windowRect;
}
return _previousWindowRectangle;
}
}