Skip to content

Commit

Permalink
Recalculate non-client area size after changing window size
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Feb 7, 2024
1 parent d8a5c69 commit 4d4ec68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CollapseLauncher/XAMLs/MainApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ private void ChangeTitleDragAreaInvoker_TitleBarEvent(object sender, ChangeTitle
MainWindow.SetDragArea(DragAreaMode_Normal);
break;
}

// Recalculate non-client area size
MainWindow.EnableNonClientArea();
}
#endregion

Expand Down
4 changes: 2 additions & 2 deletions CollapseLauncher/XAMLs/MainApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ public void InitializeWindowSettings()
m_oldWndProc = SetWindowLongPtr(m_windowHandle, GWLP_WNDPROC, pWndProc);
}

public void EnableNonClientArea()
public static void EnableNonClientArea()
{
var incps = InputNonClientPointerSource.GetForWindowId(m_windowID);
var safeArea = new RectInt32[] { new(m_appWindow.Size.Width - (int)((144 + 12) * m_appDPIScale), 0, (int)((144 + 12) * m_appDPIScale), (int)(48 * m_appDPIScale)) };
incps.SetRegionRects(NonClientRegionKind.Passthrough, safeArea);
}

public void DisableNonClientArea()
public static void DisableNonClientArea()
{
var incps = InputNonClientPointerSource.GetForWindowId(m_windowID);
var safeArea = new RectInt32[] { new(0, 0, m_appWindow.Size.Width, (int)(48 * m_appDPIScale)) };
Expand Down
4 changes: 2 additions & 2 deletions CollapseLauncher/XAMLs/StartUp/StartupLanguageSelect.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ private void SelectLang_OnDropDownOpened(object sender, object e)
{
// The dropdown panel collides with non-client area, making the first item not clickable.
// Use this to disable whole non-client area temporarily.
(m_window as MainWindow).DisableNonClientArea();
MainWindow.DisableNonClientArea();
}

private void SelectLang_OnDropDownClosed(object sender, object e)
{
// And restore the nc area to normal state.
(m_window as MainWindow).EnableNonClientArea();
MainWindow.EnableNonClientArea();
}

private IEnumerable<string> LangList
Expand Down

0 comments on commit 4d4ec68

Please sign in to comment.