Skip to content

Fix/windows kps#98

Merged
debugtheworldbot merged 11 commits intomainfrom
fix/windows-kps
Apr 7, 2026
Merged

Fix/windows kps#98
debugtheworldbot merged 11 commits intomainfrom
fix/windows-kps

Conversation

@debugtheworldbot
Copy link
Copy Markdown
Owner

@debugtheworldbot debugtheworldbot commented Apr 6, 2026

This pull request introduces a new shared helper for applying modern DWM window backdrops, updates the theme resource structure for better consistency and translucency, and makes improvements to data handling in StatsManager. It also adds a detailed CLAUDE.md guide for AI contributors, and documents new window material rules in AGENTS.md. The most important changes are grouped below.

Window Backdrop and Theming Improvements:

  • Added WindowBackdropHelper to centralize and standardize the application of DWM system backdrops, rounded corners, border clearing, and frame extension for all windows. This ensures visual consistency and reduces per-window code duplication. (KeyStats/Helpers/WindowBackdropHelper.cs)
  • Extended NativeInterop with new DWM interop methods and types, including TrySetSystemBackdrop, TrySetRoundedCorners, TryClearWindowBorder, and TryExtendFrameIntoClientArea, as well as the MARGINS struct and DwmSystemBackdropType enum. (KeyStats/Helpers/NativeInterop.cs) [1] [2] [3]
  • Updated theme resources in both App.xaml and ThemeManager.cs to introduce WindowSurfaceColor/WindowSurfaceBrush, increase translucency of window and card backgrounds, and adjust subtle fill colors for improved backdrop visibility and light/dark theme consistency. (KeyStats/App.xaml, KeyStats/Helpers/ThemeManager.cs) [1] [2] [3] [4] [5] [6]

StatsManager Data Handling:

  • Ensured that every key and mouse event triggers a call to ScheduleSave, reducing the risk of unsaved stats in case of a crash. (KeyStats/Services/StatsManager.cs) [1] [2] [3] [4] [5] [6]
  • Added PeakKPS and PeakCPS to the data recorded in daily stats history, stats cloning, and normalization, ensuring these metrics are persisted and available for analysis. (KeyStats/Services/StatsManager.cs) [1] [2] [3]

Documentation and Contributor Guidance:

  • Added CLAUDE.md to provide a comprehensive project overview, architecture, constraints, and conventions for AI and code contributors. (KeyStats.Windows/CLAUDE.md)
  • Documented new window material rules in AGENTS.md to ensure consistent use of DWM backdrops, tint layers, and theme resources across all windows. (KeyStats.Windows/AGENTS.md)

debugtheworldbot and others added 8 commits April 6, 2026 22:44
Move peak KPS and CPS display from standalone card row into a
lightning bolt toggle button next to the "今日统计" title. Clicking
it opens a floating popup with both values.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CloneDailyStats, RecordCurrentStatsToHistory, NormalizeDailyStats,
and MergeDailyStats all omitted PeakKPS/PeakCPS when copying
DailyStats, causing the values to be lost on save and always read
back as 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously only mouse move and scroll triggered ScheduleSave(),
so key presses and clicks were only persisted on graceful exit
via FlushPendingSave(). Crash or power loss could lose all
keyboard/click data since last mouse activity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 6, 2026 15:39
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 a unified window backdrop system using DWM interop, featuring a new WindowBackdropHelper and updated theme resources to support transparency. It also refactors the StatsPopupWindow to include a peak statistics popup and ensures these metrics are persisted in StatsManager. Review feedback recommends refactoring the backdrop helper to return a success status, utilizing it in the tray popup logic to avoid duplication, and removing redundant UI thread dispatches and method calls. Additionally, the reviewer noted that hardcoded colors in the window logic should be moved to shared resources to comply with the project's Window Material Rules.

Comment thread KeyStats.Windows/KeyStats/Helpers/WindowBackdropHelper.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Windows UI to use a consistent DWM “system backdrop” (transient window material) across app windows/dialogs and improves peak KPS/CPS display + persistence, including a new compact peak popup in the tray stats UI.

Changes:

  • Introduces WindowBackdropHelper and applies DWM backdrop styling broadly (also switching windows/dialogs away from AllowsTransparency="True").
  • Updates theming resources for translucent window surfaces/cards (WindowSurfaceBrush, adjusted CardBrush/SubtleFillBrush).
  • Enhances peak KPS/CPS behavior: new peak popup UI, integer formatting, persistence in history/merge paths, and more frequent save scheduling.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Applies new backdrop logic for windowed vs tray modes; adds tray popup tint/border behavior and theme refresh handling.
KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml Adds peak toggle + popup UI and disables window transparency.
KeyStats.Windows/KeyStats/Views/SettingsWindow.xaml.cs Switches to shared backdrop helper on load/theme change.
KeyStats.Windows/KeyStats/Views/SettingsWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/Views/NotificationSettingsWindow.xaml.cs Switches to shared backdrop helper on load/theme change.
KeyStats.Windows/KeyStats/Views/NotificationSettingsWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/Views/MouseCalibrationWindow.xaml.cs Switches to shared backdrop helper on load/theme change.
KeyStats.Windows/KeyStats/Views/MouseCalibrationWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/Views/KeyHistoryWindow.xaml.cs Switches to shared backdrop helper on load/theme change.
KeyStats.Windows/KeyStats/Views/KeyHistoryWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/Views/KeyboardHeatmapWindow.xaml.cs Switches to shared backdrop helper on load/theme updates.
KeyStats.Windows/KeyStats/Views/KeyboardHeatmapWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/Views/ImportModeDialog.xaml.cs Adds theme-aware backdrop application + lifecycle unsubscribe.
KeyStats.Windows/KeyStats/Views/ImportModeDialog.xaml Disables transparency and uses WindowSurfaceBrush.
KeyStats.Windows/KeyStats/Views/ConfirmDialog.xaml.cs Adds theme-aware backdrop application + lifecycle unsubscribe.
KeyStats.Windows/KeyStats/Views/ConfirmDialog.xaml Disables transparency and uses WindowSurfaceBrush.
KeyStats.Windows/KeyStats/Views/AppStatsWindow.xaml.cs Switches to shared backdrop helper on load/theme change.
KeyStats.Windows/KeyStats/Views/AppStatsWindow.xaml Uses WindowSurfaceBrush for top-level window background.
KeyStats.Windows/KeyStats/ViewModels/StatsPopupViewModel.cs Adds IsPeakPopupOpen; changes peak formatting to rounded integer strings.
KeyStats.Windows/KeyStats/Services/StatsManager.cs Schedules saves on more input events; persists peak fields into history/merge/normalize flows.
KeyStats.Windows/KeyStats/Helpers/WindowBackdropHelper.cs New shared helper to apply DWM backdrop + window chrome tweaks consistently.
KeyStats.Windows/KeyStats/Helpers/ThemeManager.cs Adds WindowSurface* resources and adjusts translucency-related colors/brushes.
KeyStats.Windows/KeyStats/Helpers/NativeInterop.cs Adds DWM backdrop/rounded-corner/border-clear/extend-frame interop helpers.
KeyStats.Windows/KeyStats/App.xaml Adds WindowSurfaceBrush resource and updates default translucency resources.
KeyStats.Windows/CLAUDE.md Adds repository guidance (architecture, build, constraints).
KeyStats.Windows/AGENTS.md Documents “Window Material Rules” and related validation guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Views/StatsPopupWindow.xaml.cs Outdated
Comment thread KeyStats.Windows/KeyStats/Services/StatsManager.cs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Comment thread KeyStats.Windows/KeyStats/Services/StatsManager.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@debugtheworldbot debugtheworldbot merged commit f0694cb into main Apr 7, 2026
@debugtheworldbot debugtheworldbot deleted the fix/windows-kps branch April 7, 2026 04:24
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.

2 participants