mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Merge pull request #842 from IceStormNG/clamshell-mode-fixes
Clamshell mode fixes
This commit is contained in:
1
app/Extra.Designer.cs
generated
1
app/Extra.Designer.cs
generated
@@ -1031,7 +1031,6 @@ namespace GHelper
|
||||
checkAutoToggleClamshellMode.TabIndex = 58;
|
||||
checkAutoToggleClamshellMode.Text = "Auto Toggle Clamshell Mode";
|
||||
checkAutoToggleClamshellMode.UseVisualStyleBackColor = true;
|
||||
checkAutoToggleClamshellMode.CheckedChanged += checkAutoToggleClamshellMode_CheckedChanged;
|
||||
//
|
||||
// checkAutoApplyWindowsPowerMode
|
||||
//
|
||||
|
||||
16
app/Extra.cs
16
app/Extra.cs
@@ -213,6 +213,7 @@ namespace GHelper
|
||||
|
||||
|
||||
checkAutoToggleClamshellMode.Checked = AppConfig.Is("toggle_clamshell_mode");
|
||||
checkAutoToggleClamshellMode.CheckedChanged += checkAutoToggleClamshellMode_CheckedChanged;
|
||||
|
||||
checkTopmost.Checked = AppConfig.Is("topmost");
|
||||
checkTopmost.CheckedChanged += CheckTopmost_CheckedChanged; ;
|
||||
@@ -471,11 +472,20 @@ namespace GHelper
|
||||
AppConfig.Set("auto_apply_power_plan", checkAutoApplyWindowsPowerMode.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
private void checkAutoToggleClamshellMode_CheckedChanged(object sender, EventArgs e)
|
||||
private void checkAutoToggleClamshellMode_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
AppConfig.Set("toggle_clamshell_mode", checkAutoToggleClamshellMode.Checked ? 1 : 0);
|
||||
ClamshellModeControl ctrl = new ClamshellModeControl();
|
||||
ctrl.ToggleLidAction();
|
||||
|
||||
if (checkAutoToggleClamshellMode.Checked)
|
||||
{
|
||||
ClamshellModeControl ctrl = new ClamshellModeControl();
|
||||
ctrl.ToggleLidAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClamshellModeControl.DisableClamshellMode();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,24 +39,38 @@ namespace GHelper.Helpers
|
||||
return SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online;
|
||||
}
|
||||
|
||||
public bool IsInClamshellMode()
|
||||
public bool IsClamshellReady()
|
||||
{
|
||||
return IsExternalDisplayConnected() && IsChargerConnected();
|
||||
}
|
||||
|
||||
public void ToggleLidAction()
|
||||
{
|
||||
if (IsInClamshellMode() && IsClamshellEnabled())
|
||||
if (!IsClamshellEnabled())
|
||||
{
|
||||
PowerNative.SetLidAction(0, true);
|
||||
Logger.WriteLine("Engaging Clamshell Mode");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsClamshellReady())
|
||||
{
|
||||
EnableClamshellMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerNative.SetLidAction(1, true);
|
||||
Logger.WriteLine("Disengaging Clamshell Mode");
|
||||
DisableClamshellMode();
|
||||
}
|
||||
}
|
||||
public static void DisableClamshellMode()
|
||||
{
|
||||
PowerNative.SetLidAction(1, true);
|
||||
Logger.WriteLine("Disengaging Clamshell Mode");
|
||||
}
|
||||
|
||||
public static void EnableClamshellMode()
|
||||
{
|
||||
PowerNative.SetLidAction(0, true);
|
||||
Logger.WriteLine("Engaging Clamshell Mode");
|
||||
}
|
||||
|
||||
public void UnregisterDisplayEvents()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user