Screen index and offset support

This commit is contained in:
Vo1 2021-09-14 20:36:06 +02:00
parent f59db2c01e
commit 7a8ae1a795
2 changed files with 17 additions and 2 deletions

View file

@ -67,6 +67,9 @@ namespace OnTopReplica.StartupOptions {
private static void ParseCommandLine(string[] args, Options options) {
var cmdOptions = new NDesk.Options.OptionSet()
.Add<int>("screen=", "ScreenIndex to display on.", id => {
options.ScreenIndex = id;
})
.Add<long>("windowId=", "Window handle ({HWND}) to be cloned.", id => {
options.WindowId = new IntPtr(id);
options.WindowTitle = null;

View file

@ -5,7 +5,8 @@ using System.Text;
using System.Drawing;
using System.IO;
using OnTopReplica.WindowSeekers;
using System.Windows.Forms;
namespace OnTopReplica.StartupOptions {
/// <summary>
@ -19,7 +20,9 @@ namespace OnTopReplica.StartupOptions {
DisableChrome = false;
MustBeVisible = false;
Fullscreen = false;
}
}
public int ScreenIndex = 0;
#region Position and size
@ -97,6 +100,12 @@ namespace OnTopReplica.StartupOptions {
#region Application
private void setFormLocation(Form form, Screen screen) {
Point start = StartLocation ?? default(Point);
Point loc = new Point(start.X + screen.WorkingArea.Location.X, start.Y + screen.WorkingArea.Location.Y);
form.Location = loc;
}
public void Apply(MainForm form) {
Log.Write("Applying command line launch parameters");
@ -160,6 +169,9 @@ namespace OnTopReplica.StartupOptions {
form.ClientSize = StartSize.Value;
}
if (ScreenIndex != 0) {
setFormLocation(form, Screen.AllScreens[ScreenIndex]);
}
//Other features
if (EnableClickForwarding) {
form.ClickForwardingEnabled = true;