mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Tray icon-click fix https://github.com/seerge/g-helper/pull/1407#issuecomment-1746823625
This commit is contained in:
@@ -213,13 +213,13 @@ namespace GHelper
|
|||||||
SetAutoModes(true);
|
SetAutoModes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SettingsToggle(string action = "", bool checkForFocus = true)
|
public static void SettingsToggle(string action = "", bool checkForFocus = true, bool trayClick = false)
|
||||||
{
|
{
|
||||||
if (settingsForm.Visible)
|
if (settingsForm.Visible)
|
||||||
{
|
{
|
||||||
// If helper window is not on top, this just focuses on the app again
|
// If helper window is not on top, this just focuses on the app again
|
||||||
// Pressing the ghelper button again will hide the app
|
// Pressing the ghelper button again will hide the app
|
||||||
if (checkForFocus && !settingsForm.HasAnyFocus())
|
if (checkForFocus && !settingsForm.HasAnyFocus(trayClick))
|
||||||
{
|
{
|
||||||
settingsForm.ShowAll();
|
settingsForm.ShowAll();
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ namespace GHelper
|
|||||||
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
|
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left)
|
if (e.Button == MouseButtons.Left)
|
||||||
SettingsToggle();
|
SettingsToggle(trayClick: true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -882,14 +882,14 @@ namespace GHelper
|
|||||||
/// Check if any of fans, keyboard, update, or itself has focus
|
/// Check if any of fans, keyboard, update, or itself has focus
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Focus state</returns>
|
/// <returns>Focus state</returns>
|
||||||
public bool HasAnyFocus()
|
public bool HasAnyFocus(bool lostFocusCheck = false)
|
||||||
{
|
{
|
||||||
return (fansForm != null && fansForm.ContainsFocus) ||
|
return (fansForm != null && fansForm.ContainsFocus) ||
|
||||||
(extraForm != null && extraForm.ContainsFocus) ||
|
(extraForm != null && extraForm.ContainsFocus) ||
|
||||||
(updatesForm != null && updatesForm.ContainsFocus) ||
|
(updatesForm != null && updatesForm.ContainsFocus) ||
|
||||||
(matrixForm != null && matrixForm.ContainsFocus) ||
|
(matrixForm != null && matrixForm.ContainsFocus) ||
|
||||||
this.ContainsFocus ||
|
this.ContainsFocus ||
|
||||||
Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastLostFocus) < 300;
|
(lostFocusCheck && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastLostFocus) < 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user