Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit cfd9d91

Browse files
Mika MelikyanMika Melikyan
authored andcommitted
Partially fixed #3 and #6
1 parent 370d046 commit cfd9d91

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

SublimeOverlay/MainForm.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ public MainForm()
2828
Region = RoundRegion(Width, Height, radius);
2929
settingsWindow = new Settings(this);
3030
this.GotFocus += MainForm_GotFocus;
31+
32+
}
33+
private bool isWindowActive(IntPtr hWnd)
34+
{
35+
return NativeMethods.GetForegroundWindow() == hWnd;
3136
}
32-
3337
private void MainForm_GotFocus(object sender, EventArgs e)
3438
{
3539
if (!titleBar.Bounds.Contains(PointToClient(MousePosition)) &&
36-
!preventForceFocus)
40+
!preventForceFocus &&
41+
!isWindowActive(pDocked.MainWindowHandle))
3742
{
3843
NativeMethods.SetForegroundWindow(pDocked.MainWindowHandle);
3944
}
@@ -43,8 +48,12 @@ protected override CreateParams CreateParams
4348
get
4449
{
4550
const int CS_DROPSHADOW = 0x20000;
51+
const int WS_MINIMIZEBOX = 0x20000;
52+
const int CS_DBLCLKS = 0x8;
4653
CreateParams cp = base.CreateParams;
4754
cp.ClassStyle |= CS_DROPSHADOW;
55+
cp.Style |= WS_MINIMIZEBOX;
56+
cp.ClassStyle |= CS_DBLCLKS;
4857
return cp;
4958
}
5059
}

SublimeOverlay/MainForm.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@
182182
<metadata name="titleWatcher.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
183183
<value>17, 17</value>
184184
</metadata>
185+
<metadata name="titleTooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
186+
<value>104, 17</value>
187+
</metadata>
185188
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
186189
<value>
187190
AAABAAYAAAAAAAEAIAAoIAQAZgAAAICAAAABACAAKAgBAI4gBABAQAAAAQAgAChCAAC2KAUAMDAAAAEA

SublimeOverlay/WINAPI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class NativeMethods
1212

1313
public const int WM_NCLBUTTONDOWN = 0xA1;
1414
public const int HT_CAPTION = 0x2;
15+
[System.Runtime.InteropServices.DllImport("user32.dll")]
16+
public static extern IntPtr GetForegroundWindow();
1517
[DllImport("user32.dll")]
1618
[return: MarshalAs(UnmanagedType.Bool)]
1719
public static extern bool SetForegroundWindow(IntPtr hWnd);

0 commit comments

Comments
 (0)