Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen index and offset support for cmdline #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/OnTopReplica/StartupOptions/Factory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private static void LoadSettings(Options options) {

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;
Expand Down
16 changes: 14 additions & 2 deletions src/OnTopReplica/StartupOptions/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using System.Drawing;
using System.IO;
using OnTopReplica.WindowSeekers;

using System.Windows.Forms;

namespace OnTopReplica.StartupOptions {

/// <summary>
Expand All @@ -19,7 +20,9 @@ public Options() {
DisableChrome = false;
MustBeVisible = false;
Fullscreen = false;
}
}

public int ScreenIndex = 0;

#region Position and size

Expand Down Expand Up @@ -97,6 +100,12 @@ public string DebugMessage {

#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");

Expand Down Expand Up @@ -160,6 +169,9 @@ public void Apply(MainForm form) {
form.ClientSize = StartSize.Value;
}

if (ScreenIndex != 0) {
setFormLocation(form, Screen.AllScreens[ScreenIndex]);
}
//Other features
if (EnableClickForwarding) {
form.ClickForwardingEnabled = true;
Expand Down