Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent unnecessary redraws during window minimize/restore #3955

Merged
merged 4 commits into from
Dec 26, 2024

Conversation

562589540
Copy link
Contributor

@562589540 562589540 commented Dec 17, 2024

Description

This PR fixes the window flickering issue when minimizing/restoring windows applications.

The issue was caused by unnecessary redraws during the minimize/restore process. This fix:

  1. Adds isMinimizing flag to track window state
  2. Adds SetPadding filter to prevent redundant redraws during transitions
  3. Properly handles minimize/restore window states

Related Issue

Fixes #3951

Testing

Tested on Windows 10/11 with:

  • Normal window operations
  • Minimize/restore operations
  • Different window sizes
  • Applications with small windows

Additional Notes

The fix minimizes code changes while effectively preventing the flickering issue.

Summary by CodeRabbit

  • New Features

    • Introduced a mechanism to prevent flickering during window minimize and restore actions.
    • Added a new method to manage padding adjustments based on window state.
    • Users can now set the window class name on Windows.
  • Bug Fixes

    • Enhanced handling of window resizing events to improve visual performance during transitions.
    • Resolved cross-compilation issues and fixed memory issues on Darwin.
  • Documentation

    • Updated changelog to reflect various modifications and fixes.
    • Revised installation documentation for the latest Linux OS versions.

This fixes the window flickering issue when minimizing/restoring by:
1. Adding isMinimizing flag to track window state
2. Adding SetPadding filter to prevent redundant redraws
3. Properly handling minimize/restore window states

Fixes wailsapp#3951
Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Walkthrough

The changes focus on enhancing the handling of window resizing and minimizing behavior in the Windows frontend implementation. A new isMinimizing flag is introduced in the Window struct to manage the window's minimizing state and prevent unnecessary redraws during state transitions. Modifications include updates to the OnSize event handler and the creation of a new SetPadding method that avoids padding adjustments when the window is minimizing. These adjustments aim to improve visual performance and reduce flickering during window state changes.

Changes

File Change Summary
v2/internal/frontend/desktop/windows/frontend.go Added isMinimizing flag to manage window minimizing state and updated OnSize event handler.
v2/internal/frontend/desktop/windows/window.go - Added isMinimizing bool field to Window struct
- Implemented new SetPadding method with minimizing state check
- Updated WndProc to use new SetPadding method.
website/src/pages/changelog.mdx Updated changelog to reflect changes, including flickering fix and new feature for setting window class name.

Assessment against linked issues

Objective Addressed Explanation
Prevent unnecessary redraws during minimize/restore [#3951]
Stop flickering during window state transitions [#3951]
Avoid SetPadding during transitional window states [#3951]

Possibly related PRs

Suggested reviewers

  • leaanthony

Poem

🐰 In the world of windows, smooth and bright,
A rabbit hops with pure delight.
Minimizing with grace, no flicker in sight,
Code flows like magic, everything feels right.
With every resize, a dance so neat,
Our frameless dreams, a visual treat! 🪟✨

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3846824 and ec97d84.

📒 Files selected for processing (3)
  • v2/internal/frontend/desktop/windows/frontend.go (1 hunks)
  • v2/internal/frontend/desktop/windows/window.go (6 hunks)
  • website/src/pages/changelog.mdx (1 hunks)
👮 Files not reviewed due to content moderation or server errors (3)
  • v2/internal/frontend/desktop/windows/window.go
  • v2/internal/frontend/desktop/windows/frontend.go
  • website/src/pages/changelog.mdx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@leaanthony
Copy link
Member

Thanks so much for this🙏 Please could you add an entry to the changelog located at website/src/pages/changelog.mdx?

@leaanthony leaanthony added the awaiting feedback More information is required from the requestor label Dec 17, 2024
- Add detailed comments about frameless window fix
- Update changelog to clarify this is a frameless window issue
- Add bilingual comments for better understanding

Fixes wailsapp#3951
@562589540
Copy link
Contributor Author

I've updated the PR with:

  • Improved code comments to clarify this is a frameless window fix
  • Updated changelog entry to be more specific about frameless windows
  • Added bilingual comments for better understanding

@leaanthony leaanthony merged commit 461d34c into wailsapp:master Dec 26, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback More information is required from the requestor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

在解决 #1319 最小化/恢复闪烁问题时,发现了一个新的问题
2 participants