Added automatic toggle for "Lid Action" when external display and power is connected to keep the laptop awake when lid is closed (known as Clamshell Mode).

This commit is contained in:
Carsten Braun
2023-07-19 11:54:51 +02:00
parent 2b8d82b58f
commit 595336288a
7 changed files with 158 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ namespace GHelper
public static ModeControl modeControl = new ModeControl();
static GPUModeControl gpuControl = new GPUModeControl(settingsForm);
static ScreenControl screenControl = new ScreenControl();
static ClamshellModeControl clamshellControl = new ClamshellModeControl();
public static ToastForm toast = new ToastForm();
@@ -99,6 +100,8 @@ namespace GHelper
// Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
clamshellControl.RegisterDisplayEvents();
clamshellControl.ToggleLidAction();
// Subscribing for monitor power on events
PowerSettingGuid settingGuid = new NativeMethods.PowerSettingGuid();
@@ -238,6 +241,7 @@ namespace GHelper
static void OnExit(object sender, EventArgs e)
{
trayIcon.Visible = false;
clamshellControl.UnregisterDisplayEvents();
NativeMethods.UnregisterPowerSettingNotification(unRegPowerNotify);
Application.Exit();
}