Skip to content

fix(windows): unify standard window title bar theming#87

Merged
debugtheworldbot merged 1 commit intomainfrom
feat/window-theme-unify
Mar 30, 2026
Merged

fix(windows): unify standard window title bar theming#87
debugtheworldbot merged 1 commit intomainfrom
feat/window-theme-unify

Conversation

@debugtheworldbot
Copy link
Copy Markdown
Owner

Summary

  • apply the existing immersive dark title bar behavior to Settings, Notification Settings, and Mouse Calibration so standard windows follow the same theme treatment
  • keep the main stats window aligned with the standard window path and fix its windowed-mode top corner artifact by removing the popup corner radius in that mode
  • leave the custom transparent dialogs unchanged so only standard windows are normalized in this pass

@debugtheworldbot
Copy link
Copy Markdown
Owner Author

image

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces window title bar theme synchronization across multiple windows and adds dynamic corner radius adjustments for the StatsPopupWindow. The review identifies opportunities to reduce code duplication by extracting theme logic into a base class and recommends direct access to named XAML elements instead of using FindName.

Comment on lines +36 to 60
Loaded += OnLoaded;
Closed += OnClosed;
ThemeManager.Instance.ThemeChanged += OnThemeChanged;
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
ApplyWindowTitleBarTheme();
}

private void OnClosed(object? sender, EventArgs e)
{
ThemeManager.Instance.ThemeChanged -= OnThemeChanged;
}

private void OnThemeChanged()
{
Dispatcher.BeginInvoke(new Action(ApplyWindowTitleBarTheme));
}

private void ApplyWindowTitleBarTheme()
{
var handle = new WindowInteropHelper(this).Handle;
NativeInterop.TrySetImmersiveDarkMode(handle, ThemeManager.Instance.IsDarkTheme);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code for handling title bar theming is duplicated across MouseCalibrationWindow, NotificationSettingsWindow, and SettingsWindow. To improve maintainability and reduce code duplication, consider extracting this logic into a common base class.

For example, you could create a ThemedWindow base class that inherits from Window and contains this logic:

// In a new file, e.g., Views/ThemedWindow.cs
public class ThemedWindow : Window
{
    public ThemedWindow()
    {
        Loaded += OnLoaded;
        Closed += OnClosed;
        ThemeManager.Instance.ThemeChanged += OnThemeChanged;
    }

    private void OnLoaded(object sender, RoutedEventArgs e)
    {
        ApplyWindowTitleBarTheme();
    }

    private void OnClosed(object? sender, EventArgs e)
    {
        ThemeManager.Instance.ThemeChanged -= OnThemeChanged;
    }

    private void OnThemeChanged()
    {
        Dispatcher.BeginInvoke(new Action(ApplyWindowTitleBarTheme));
    }

    private void ApplyWindowTitleBarTheme()
    {
        var handle = new WindowInteropHelper(this).Handle;
        NativeInterop.TrySetImmersiveDarkMode(handle, ThemeManager.Instance.IsDarkTheme);
    }
}

Then, you could change MouseCalibrationWindow, NotificationSettingsWindow, and SettingsWindow to inherit from ThemedWindow instead of Window. This would also require updating the root element in their respective XAML files (e.g., <local:ThemedWindow ...>). This would centralize the theme handling logic, making it easier to maintain.

Comment on lines +444 to +447
if (FindName("RootBorder") is System.Windows.Controls.Border rootBorder)
{
rootBorder.CornerRadius = _isWindowMode ? new CornerRadius(0) : new CornerRadius(8);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since RootBorder is defined with x:Name in the corresponding XAML file, the XAML compiler will generate a field for it in this partial class. You can access it directly instead of using FindName(), which is more efficient and results in cleaner code.

        RootBorder.CornerRadius = _isWindowMode ? new CornerRadius(0) : new CornerRadius(8);

@debugtheworldbot debugtheworldbot merged commit 81e2d5d into main Mar 30, 2026
@debugtheworldbot debugtheworldbot deleted the feat/window-theme-unify branch March 30, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant