mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Fixed a stacktrace overflow due recursive loop when processing Metro-Apps (Windows 8, which also run on 10)
This commit is contained in:
parent
1469f1fa41
commit
bd71f47e95
1 changed files with 22 additions and 5 deletions
|
@ -159,7 +159,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// enumeration
|
/// enumeration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WindowDetails : IEquatable<WindowDetails>{
|
public class WindowDetails : IEquatable<WindowDetails>{
|
||||||
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow";
|
private const string METRO_WINDOWS_CLASS = "Windows.UI.Core.CoreWindow"; // Windows 10 uses ApplicationFrameWindow
|
||||||
private const string METRO_APPLAUNCHER_CLASS = "ImmersiveLauncher";
|
private const string METRO_APPLAUNCHER_CLASS = "ImmersiveLauncher";
|
||||||
private const string METRO_GUTTER_CLASS = "ImmersiveGutter";
|
private const string METRO_GUTTER_CLASS = "ImmersiveGutter";
|
||||||
|
|
||||||
|
@ -193,6 +193,10 @@ namespace GreenshotPlugin.Core {
|
||||||
private WindowDetails _parent;
|
private WindowDetails _parent;
|
||||||
private bool _frozen;
|
private bool _frozen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This checks if the window is a Windows 8 App
|
||||||
|
/// For Windows 10 most normal code works, as it's hosted inside "ApplicationFrameWindow"
|
||||||
|
/// </summary>
|
||||||
public bool IsApp {
|
public bool IsApp {
|
||||||
get {
|
get {
|
||||||
return METRO_WINDOWS_CLASS.Equals(ClassName);
|
return METRO_WINDOWS_CLASS.Equals(ClassName);
|
||||||
|
@ -644,7 +648,8 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Maximised {
|
public bool Maximised {
|
||||||
get {
|
get {
|
||||||
if (IsApp) {
|
if (IsApp)
|
||||||
|
{
|
||||||
if (Visible) {
|
if (Visible) {
|
||||||
Rectangle windowRectangle = WindowRectangle;
|
Rectangle windowRectangle = WindowRectangle;
|
||||||
foreach (Screen screen in Screen.AllScreens) {
|
foreach (Screen screen in Screen.AllScreens) {
|
||||||
|
@ -758,6 +763,7 @@ namespace GreenshotPlugin.Core {
|
||||||
private Rectangle _previousWindowRectangle = Rectangle.Empty;
|
private Rectangle _previousWindowRectangle = Rectangle.Empty;
|
||||||
private long _lastWindowRectangleRetrieveTime;
|
private long _lastWindowRectangleRetrieveTime;
|
||||||
private const long CacheTime = TimeSpan.TicksPerSecond * 2;
|
private const long CacheTime = TimeSpan.TicksPerSecond * 2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the bounding rectangle of the window
|
/// Gets the bounding rectangle of the window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -768,14 +774,25 @@ namespace GreenshotPlugin.Core {
|
||||||
if (_previousWindowRectangle.IsEmpty || !_frozen) {
|
if (_previousWindowRectangle.IsEmpty || !_frozen) {
|
||||||
if (_previousWindowRectangle.IsEmpty || now - _lastWindowRectangleRetrieveTime > CacheTime) {
|
if (_previousWindowRectangle.IsEmpty || now - _lastWindowRectangleRetrieveTime > CacheTime) {
|
||||||
Rectangle windowRect = Rectangle.Empty;
|
Rectangle windowRect = Rectangle.Empty;
|
||||||
if (DWM.IsDwmEnabled() && !Maximised) {
|
if (DWM.IsDwmEnabled())
|
||||||
if (GetExtendedFrameBounds(out windowRect) && Environment.OSVersion.IsWindows10())
|
|
||||||
{
|
{
|
||||||
|
bool gotFrameBounds = GetExtendedFrameBounds(out windowRect);
|
||||||
|
if (IsApp)
|
||||||
|
{
|
||||||
|
// Pre-Cache for Maximised call, this is only on Windows 8 apps (full screen)
|
||||||
|
if (gotFrameBounds)
|
||||||
|
{
|
||||||
|
_previousWindowRectangle = windowRect;
|
||||||
_lastWindowRectangleRetrieveTime = now;
|
_lastWindowRectangleRetrieveTime = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gotFrameBounds && Environment.OSVersion.IsWindows10() && !Maximised)
|
||||||
|
{
|
||||||
// Somehow DWM doesn't calculate it corectly, there is a 1 pixel border around the capture
|
// Somehow DWM doesn't calculate it corectly, there is a 1 pixel border around the capture
|
||||||
// Remove this border, currently it's fixed but TODO: Make it depend on the OS?
|
// Remove this border, currently it's fixed but TODO: Make it depend on the OS?
|
||||||
windowRect.Inflate(-1, -1);
|
windowRect.Inflate(-1, -1);
|
||||||
_previousWindowRectangle = windowRect;
|
_previousWindowRectangle = windowRect;
|
||||||
|
_lastWindowRectangleRetrieveTime = now;
|
||||||
return windowRect;
|
return windowRect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue