Skip to content

Commit

Permalink
UI tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Serge committed May 22, 2023
1 parent 9e6ca7c commit 5b2a4cb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
10 changes: 9 additions & 1 deletion app/Extra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,15 @@ private void ComboKeyboardSpeed_SelectedValueChanged(object? sender, EventArgs e

private void Keyboard_Shown(object? sender, EventArgs e)
{
Top = Program.settingsForm.Top;
if (Height > Program.settingsForm.Height)
{
Top = Program.settingsForm.Top + Program.settingsForm.Height - Height;
}
else
{
Top = Program.settingsForm.Top;
}

Left = Program.settingsForm.Left - Width - 5;
}

Expand Down
9 changes: 9 additions & 0 deletions app/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,15 @@ public static int SetRefreshRate(int frequency = 120)
dm.dmDisplayFrequency = frequency;
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));

// Retry as refresh rate can fail sometimes
if (iRet == -1)
{
Thread.Sleep(500);
iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
}

return iRet;
}

Expand Down
26 changes: 17 additions & 9 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,13 @@ private void ButtonXGM_Click(object? sender, EventArgs e)

if (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1)
{
Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM");
await Task.Delay(TimeSpan.FromSeconds(15));
KillGPUApps();
DialogResult dialogResult = MessageBox.Show("Did you close all applications running on XG Mobile?", "Disabling XG Mobile", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Program.acpi.DeviceSet(AsusACPI.GPUXG, 0, "GPU XGM");
await Task.Delay(TimeSpan.FromSeconds(15));
}
}
else
{
Expand Down Expand Up @@ -516,7 +521,7 @@ protected override void WndProc(ref Message m)
}
m.Result = (IntPtr)1;
break;

case KeyHandler.WM_HOTKEY_MSG_ID:

Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
Expand Down Expand Up @@ -1491,6 +1496,14 @@ public void RestartGPU(bool confirm = true)

}

protected static void KillGPUApps()
{
string[] tokill = { "EADesktop", "RadeonSoftware", "epicgameslauncher" };
foreach (string kill in tokill)
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();

}

public void SetGPUEco(int eco, bool hardWay = false)
{

Expand All @@ -1507,12 +1520,7 @@ public void SetGPUEco(int eco, bool hardWay = false)

int status;

if (eco == 1)
{
string[] tokill = { "EADesktop", "RadeonSoftware" };
foreach (string kill in tokill)
foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
}
if (eco == 1) KillGPUApps();

//if (eco == 1) status = 0; else
status = Program.acpi.SetGPUEco(eco);
Expand Down

0 comments on commit 5b2a4cb

Please sign in to comment.