feat: improve adaptive theme detection, add seconds-level TimePicker and main-window occlusion auto-hide#56
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79880392d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var handle = Process.GetCurrentProcess().MainWindowHandle; | ||
| if (handle == IntPtr.Zero || !GetWindowRect(handle, out var rect)) | ||
| { |
There was a problem hiding this comment.
Preserve window handle so auto-hide can restore window
After ShowWindow(handle, SW_HIDE), subsequent ticks reacquire Process.GetCurrentProcess().MainWindowHandle; for hidden windows this value becomes IntPtr.Zero, so execution returns here and never reaches the SW_SHOWNA path. That means once the feature hides the main window, it can no longer automatically show it again when occlusion clears unless some external path reopens it. Keep a stable HWND (or resolve hidden-window HWND via a different API) before hiding so restore logic can still run.
Useful? React with 👍 / 👎.
Motivation
Description
Controls/InTimePeriodRuleSettingsControl.axamland updatedControls/InTimePeriodRuleSettingsControl.csto load the AXAML and wireTimePickerevents, enablingUseSeconds="True"and preservinghh:mm:sssettings sync.Services/AdaptiveThemeSyncService.csto sample the current screen area (top/bottom one-fifth) based on main-window vertical placement viaGetWindowRectandScreen.FromRectangle, compute average luminance on an 8x grid, and map luminance to ClassIsland-compatible theme modes (0=明亮, 1=黑暗) while only switching light/dark (callingIThemeService.SetTheme(mode, null)) so emphasis/primary colors are not altered.Services/MainWindowOcclusionAutoHideService.csthat runs every 2 seconds, captures the screen region beneath the main window, runs OCR using WindowsOcrEngineto measure recognized character length, and hides/shows the main window (ShowWindow) when character count > 4.AutoHideMainWindowWhenOccludedtoConfigHandlers/MainConfigData.csand new UI controls inSettingsPage/MoreFeaturesOptionsSettingsPage.axamlplus event handler in its.axaml.csto toggle andRefreshNow()the services.Plugin.csso it starts/stops with the plugin, and addedMicrosoft.Windows.SDK.ContractstoSystemTools.csprojto enable Windows OCR API usage.Testing
git diff --checkwhich reported no whitespace or index issues and succeeded.dotnet restorein this environment but it failed becausedotnetis not available here, so build and runtime validation were not executed.Codex Task