Skip to content

[V3/Linux] Fix Min/Max window options#3979

Merged
leaanthony merged 2 commits into
wailsapp:v3-alphafrom
atterpac:v3-linux/fix-min-max-window
Jan 10, 2025
Merged

[V3/Linux] Fix Min/Max window options#3979
leaanthony merged 2 commits into
wailsapp:v3-alphafrom
atterpac:v3-linux/fix-min-max-window

Conversation

@atterpac

@atterpac atterpac commented Jan 2, 2025

Copy link
Copy Markdown
Member

There were a few reasons that were causing the MinWidth MinHeight MaxWidth and MaxHeight options for the webview windows in linux

  1. It was only being set If ALL options were defined
if w.parent.options.MinWidth != 0 &&
               w.parent.options.MinHeight != 0 &&
               w.parent.options.MaxWidth != 0 &&
               w.parent.options.MaxHeight != 0 { 
               // Set the size
  1. The window geometry to allow for MaxWidth/Height to fill the entire monitor checks what screen the widget is on before it is rendered at the first start, Added a backup check for the primary monitor resolution to use as Max dimensions if no dimensions were found (otherwise max sizes were -1)

  2. If for whatever reason the 2 doesnt return a monitor dimensions we default to 1920x1080 as a sane default. If this is an issue setting maximums in the options will override this default.

┌──────────────────────────────────────────────────────────────────────────────────────────┐
| Name         | Ubuntu                                                                    |
| Version      | 24.04                                                                     |
| ID           | ubuntu                                                                    |
| Branding     | 24.04.1 LTS (Noble Numbat)                                                |
| Platform     | linux                                                                     |
| Architecture | amd64                                                                     |
| CPU          | 12th Gen Intel(R) Core(TM) i5-1235U                                       |
| GPU 1        | Alder Lake-UP3 GT2 [Iris Xe Graphics] (Intel Corporation) - Driver: i915  |
| Memory       | 7GB                                                                       |
└──────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3 dev                                   |
| Go Version   | go1.22.4                                 |
| Revision     | 91a99299b1639fbea7ae2f936ad827c11e6626db |
| Modified     | false                                    |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | linux                                    |
| vcs          | git                                      |
| vcs.modified | false                                    |
| vcs.revision | 91a99299b1639fbea7ae2f936ad827c11e6626db |
| vcs.time     | 2025-01-02T09:47:37Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies

┌──────────────────────────────────────┐
| npm        | 10.5.1                  |
| pkg-config | 1.8.1-2build1           |
| webkit2gtk | 2.46.4-0ubuntu0.24.04.1 |
| gcc        | 12.10ubuntu1            |
| gtk3       | 3.24.41-4ubuntu1.2      |
└────── * - Optional Dependency ───────┘

Summary by CodeRabbit

Release Notes

  • New Features

    • Added OpenFileManager method to open system file manager
    • Introduced Single Instance feature
    • New CLI commands: wails3 generate webview2bootstrapper, wails3 generate template, wails3 releasenotes, wails3 update cli
    • Added runtime init() method for manual initialization
  • Improvements

    • Enhanced window handling and positioning
    • Added WindowDidMoveDebounceMS option in Window settings
    • Improved monitor resolution detection on Linux
    • Simplified logic for setting window size constraints with default values
  • Bug Fixes

    • Adjusted min/max width options for Linux
    • Fixed window position logic with system tray
    • Ensured key callbacks execute on main thread
  • Changes

    • Renamed WindowClose events to WindowClosing
    • Removed ShouldClose option and Window.Destroy method

@coderabbitai

coderabbitai Bot commented Jan 2, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates the changelog to reflect several new features, fixes, and changes across the Wails framework. Key additions include a method for opening the system file manager, new CLI commands, and enhancements to window management. The changes improve the handling of monitor resolutions and window sizing, particularly for Linux. Additionally, the build process has been refined, and various internal methods have been updated or deprecated, contributing to a more robust and flexible framework.

Changes

File Change Summary
docs/src/content/docs/changelog.mdx Updated with new features: app.OpenFileManager(), -git flag for wails3 init, new CLI commands, runtime init() method, and WindowDidMoveDebounceMS option
v3/pkg/application/linux_cgo.go Enhanced getCurrentMonitorGeometry to provide fallback monitor resolution when current monitor cannot be determined
v3/pkg/application/webview_window_linux.go Improved setMinMaxSize method with default monitor dimensions and more robust window sizing logic

Possibly related PRs

  • [v3] allow build with garble #3192: This PR adds new commands and methods related to the application package, which aligns with the main PR's updates to the changelog that includes new commands like wails3 generate webview2bootstrapper and wails3 update cli.
  • [V3] setURL bug fix #3533: The modifications to the SetURL method in this PR involve changes to the webview window, which relates to the main PR's updates on window handling and improvements noted in the changelog.

Suggested labels

TODO

Suggested reviewers

  • atterpac

Poem

🐰 Wails of wonder, code so bright,
Monitors dance in Linux light,
File managers swing, CLI takes flight,
Windows resize with rabbit might,
Coding magic at peak height! 🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fbba46 and 135283b.

📒 Files selected for processing (1)
  • docs/src/content/docs/changelog.mdx (1 hunks)

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.

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.

@atterpac atterpac force-pushed the v3-linux/fix-min-max-window branch from 2e0c129 to 5fbba46 Compare January 2, 2025 18:10
@atterpac atterpac marked this pull request as ready for review January 2, 2025 18:11

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
v3/pkg/application/webview_window_linux.go (1)

286-300: Ensure minimum size doesn't conflict with user-specified values.

The logic sets a default minimum size of 1×1 if the user supplies 0. As a safeguard, validate if the user-supplied values are negative, which could cause unintended window sizing behavior.

v3/pkg/application/linux_cgo.go (1)

924-929: Provide more detailed logging for monitor fallback.

When the current monitor is nil, fallback to the primary monitor is a good practice. Consider logging a warning if both the current and primary monitors are nil, to simplify troubleshooting.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91a9929 and 5fbba46.

📒 Files selected for processing (3)
  • docs/src/content/docs/changelog.mdx (1 hunks)
  • v3/pkg/application/linux_cgo.go (1 hunks)
  • v3/pkg/application/webview_window_linux.go (2 hunks)
🔇 Additional comments (2)
v3/pkg/application/webview_window_linux.go (1)

162-167: Consider making fallback resolution configurable.

Falling back to 1920×1080 is a practical default, but consider providing a way to customize this fallback or query system defaults. Hardcoding a single fallback may lead to unexpected behavior on non-1080p systems.

Do you want me to propose an approach for making the fallback resolution configurable?

docs/src/content/docs/changelog.mdx (1)

42-42: PR reference looks good!

Good job referencing PR #3979 for the min/max width fix. This is consistent with the user’s PR description and helps track the resolution context.

@leaanthony leaanthony merged commit e0c5de6 into wailsapp:v3-alpha Jan 10, 2025
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
fix min/max options for linux

changelog.md

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
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