Skip to content

Commit d05835b

Browse files
committed
Improvements to tray click behaviour
1 parent 1a2e516 commit d05835b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/UniGetUI/Interface/MainWindow.xaml.cs

+7
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@
2222
using UniGetUI.Core.SettingsEngine;
2323
using UniGetUI.PackageEngine.PackageClasses;
2424
using UniGetUI.Core.Tools;
25+
using System.Runtime.InteropServices;
26+
using System.Reflection.Metadata;
2527

2628

2729
namespace UniGetUI.Interface
2830
{
2931
public sealed partial class MainWindow : Window
3032
{
33+
[DllImport("user32.dll")]
34+
[return: MarshalAs(UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd);
35+
3136
[System.Runtime.InteropServices.ComImport]
3237
[System.Runtime.InteropServices.Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
3338
[System.Runtime.InteropServices.InterfaceType(
@@ -226,6 +231,7 @@ private void LoadTrayMenu()
226231
ShowHideCommand.ExecuteRequested += (s, e) =>
227232
{
228233
Activate();
234+
SetForegroundWindow(GetWindowHandle());
229235
};
230236

231237
TrayIcon.LeftClickCommand = ShowHideCommand;
@@ -235,6 +241,7 @@ private void LoadTrayMenu()
235241
UpdateSystemTrayStatus();
236242
}
237243

244+
238245
public void UpdateSystemTrayStatus()
239246
{
240247
string modifier = "_empty";

0 commit comments

Comments
 (0)