Skip to content

Commit

Permalink
Merge pull request #38 from madpew/supersize
Browse files Browse the repository at this point in the history
added SuperSize mode, made borderless-windows topmost
  • Loading branch information
Andrew Sampson committed Feb 21, 2014
2 parents ccd322f + e02eb2c commit d4d592b
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 111 deletions.
38 changes: 36 additions & 2 deletions Forms/CompactWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ private bool RemoveBorderRect(IntPtr targetHandle, Rectangle targetFrame)
Native.SetWindowLong(targetHandle, WindowLongIndex.Style, newWindowStyle);
Native.SetWindowPos(
targetHandle,
0,
-1, //HWND_TOPMOST
targetFrame.X,
targetFrame.Y,
targetFrame.Width,
targetFrame.Height,
SetWindowPosFlags.NoZOrder | SetWindowPosFlags.ShowWindow);
SetWindowPosFlags.ShowWindow);
return true;
}

Expand Down Expand Up @@ -326,6 +326,26 @@ private void FavoriteContextOpening(object sender, CancelEventArgs e)
this.contextRemoveFromFavs.Enabled = Favorites.CanRemove(process);
}

/// <summary>
/// Gets the smallest containing Rectangle
/// </summary>
private Rectangle GetContainingRectangle(Rectangle a, Rectangle b)
{
var amin = new Point(a.X, a.Y);
var amax = new Point(a.X + a.Width, a.Y + a.Height);
var bmin = new Point(b.X, b.Y);
var bmax = new Point(b.X + b.Width, b.Y + b.Height);
var nmin = new Point(0, 0);
var nmax = new Point(0, 0);

nmin.X = (amin.X < bmin.X) ? amin.X : bmin.X;
nmin.Y = (amin.Y < bmin.Y) ? amin.Y : bmin.Y;
nmax.X = (amax.X > bmax.X) ? amax.X : bmax.X;
nmax.Y = (amax.Y > bmax.Y) ? amax.Y : bmax.Y;

return new Rectangle(nmin, new Size(nmax.X - nmin.X, nmax.Y - nmin.Y));
}

/// <summary>
/// Sets up the Process-ContextMenu according to the current state
/// </summary>
Expand Down Expand Up @@ -353,8 +373,12 @@ private void ProcessContextOpening(object sender, CancelEventArgs e)
this.contextBorderlessOn.DropDownItems.Clear();
}

var superSize = Screen.PrimaryScreen.Bounds;

foreach (var screen in Screen.AllScreens)
{
superSize = GetContainingRectangle(superSize, screen.Bounds);

// fix for a .net-bug on Windows XP
var idx = screen.DeviceName.IndexOf('\0');
var fixedDeviceName = idx > 0 ? screen.DeviceName.Substring(0,idx) : screen.DeviceName;
Expand All @@ -370,6 +394,16 @@ private void ProcessContextOpening(object sender, CancelEventArgs e)

this.contextBorderlessOn.DropDownItems.Add(tsi);
}

//add supersize Option
var superSizeItem = new ToolStripMenuItem("SuperSize!");
System.Diagnostics.Debug.WriteLine(superSize);
superSizeItem.Click += (s, ea) =>
{
this.RemoveBorderRect(process, superSize);
};

this.contextBorderlessOn.DropDownItems.Add(superSizeItem);
}
}

Expand Down
Loading

0 comments on commit d4d592b

Please sign in to comment.