Skip to content

Commit

Permalink
[MWB]Simulate input to gain focus when hiding mouse (#26524)
Browse files Browse the repository at this point in the history
* [MWB]Simulate input to gain focus when hiding mouse

* Little tooltip fix
  • Loading branch information
jaimecbernardo committed May 31, 2023
1 parent 0f04180 commit 88656a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/modules/MouseWithoutBorders/App/Helper/FormHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ protected override void WndProc(ref Message m)
Program.DotForm.TopMost = true;
Program.DotForm.Show();
Application.DoEvents();

// Simulate input to help bring to the foreground, as it doesn't seem to work in every case otherwise.
NativeMethods.INPUT input = new NativeMethods.INPUT { type = (int)NativeMethods.InputType.INPUT_MOUSE, mi = { } };
NativeMethods.INPUT[] inputs = new NativeMethods.INPUT[] { input };
_ = NativeMethods.SendInput(1, inputs, Marshal.SizeOf(typeof(NativeMethods.INPUT)));
m.Result = SetForeGround() ? new IntPtr(1) : IntPtr.Zero;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ internal struct MonitorInfoEx
CallingConvention = CallingConvention.StdCall)]
internal static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);

private enum InputType
internal enum InputType
{
INPUT_MOUSE = 0,
INPUT_KEYBOARD = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
Content=""
FontFamily="{StaticResource SymbolThemeFontFamily}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_CopyMachineName" />
<TextBlock x:Uid="MouseWithoutBorders_CopyMachineName" TextWrapping="Wrap" />
</ToolTipService.ToolTip>
</Button>
</StackPanel>
Expand Down Expand Up @@ -161,7 +161,7 @@
</ItemsControl>
<Button HorizontalAlignment="Right" Command="{x:Bind Mode=OneTime, Path=ReconnectCommand}">
<ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_ReconnectTooltip" />
<TextBlock x:Uid="MouseWithoutBorders_ReconnectTooltip" TextWrapping="Wrap"/>
</ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_ReconnectButton" />
</Button>
Expand Down

0 comments on commit 88656a9

Please sign in to comment.