Skip to content

fix linux min/max hints - #5523

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
atterpac:atterpac/5469-maximize-window-bug
May 31, 2026
Merged

leaanthony merged 3 commits into
wailsapp:masterfrom
atterpac:atterpac/5469-maximize-window-bug

Conversation

@atterpac

@atterpac atterpac commented May 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #5469

A few bugs were causing the issue mainly attempting to apply scale factor in apis that talk in physical units

As well as setting hard limits instead of using hints that can be by-passable. Hard limits were set based on primary monitor so opening windows on a second monitor retained those stale hard limits.

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
| Name                | EndeavourOS                                                                                      |
| Version             | Unknown                                                                                          |
| ID                  | endeavouros                                                                                      |
| Branding            |                                                                                                  |
| Platform            | linux                                                                                            |
| Architecture        | amd64                                                                                            |
| Desktop Environment | Hyprland                                                                                         |
| NVIDIA Driver       | N/A                                                                                              |
| XDG_SESSION_TYPE    | wayland                                                                                          |
| CPU                 | AMD Ryzen 9 5900X 12-Core Processor                                                              |
| GPU 1               | Navi 32 [Radeon RX 7700 XT / 7800 XT] (Advanced Micro Devices, Inc. [AMD/ATI]) - Driver: amdgpu  |
| Memory              | 32GB                                                                                             |
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment

┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-dev                               |
| Go Version   | go1.25.6 X:nodwarf5                      |
| Revision     | a7d115bd54b8ad91f73cd16aa10803816bf4a286 |
| Modified     | true                                     |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOEXPERIMENT | nodwarf5                                 |
| GOOS         | linux                                    |
| vcs          | git                                      |
| vcs.modified | true                                     |
| vcs.revision | a7d115bd54b8ad91f73cd16aa10803816bf4a286 |
| vcs.time     | 2026-03-20T14:37:46Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies

┌───────────────────────────────────────────────────────────────────────────────────────────────────┐
| gcc                          | 15.2.1+r604+g0b99615a8aef-1                                        |
| gtk3                         | 1:3.24.52-1                                                        |
| gtk4 (experimental)          | 1:4.20.3-1                                                         |
| npm                          | 11.12.1                                                            |
| pkg-config                   | 2.5.1-1                                                            |
| webkit2gtk                   | 2.50.6-1                                                           |
| webkitgtk-6.0 (experimental) | 2.50.6-1                                                           |
| docker                       | *Docker version 29.3.1, build c2be9ccfc3 (cross-compilation ready) |
|                                                                                                   |
└───────────────────────────────────── * - Optional Dependency ─────────────────────────────────────┘

Summary by CodeRabbit

  • Bug Fixes
    • Fullscreen on Linux now uses the monitor's reported logical dimensions for sizing, avoiding incorrect scaling and sentinel values.
    • Window sizing constraints now only apply minimum or maximum limits when valid values are provided.
    • Min/max size handling no longer substitutes monitor geometry fallbacks; provided hints are applied as-is.

@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Failed to post review comments

Walkthrough

Three coordinated edits: fullscreen now uses logical monitor dimensions; setMinMaxSize no longer falls back to monitor geometry; windowSetGeometryHints applies min/max hints only when positive.

Changes

Multi-monitor window sizing fixes

Layer / File(s) Summary
Conditional geometry hints builder
v3/pkg/application/linux_cgo_gtk3.go
windowSetGeometryHints now sets GdkGeometry fields and the GdkWindowHints mask only when corresponding minWidth/minHeight or maxWidth/maxHeight are greater than zero, instead of always enabling both min and max hint bits.
Simplified setMinMaxSize removes monitor fallback
v3/pkg/application/webview_window_linux.go
setMinMaxSize no longer queries monitor geometry as a fallback for zero/unset max dimensions; it documents using geometry hints rather than physical monitor limits and passes provided min/max values directly to windowSetGeometryHints.
Fullscreen uses logical sizing and conditional hints
v3/pkg/application/linux_cgo_gtk3.go
linuxWebviewWindow.fullscreen uses logical width/height from getCurrentMonitorGeometry() (bails on -1), sets geometry min/max to zero, and calls setSize(width, height) instead of scaling by scaleFactor to compute physical pixels.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • wailsapp/wails#3979: Also adjusts Linux min/max sizing and how monitor geometry values are handled in setMinMaxSize/windowSetGeometryHints.
  • wailsapp/wails#4047: Makes related changes to GTK window min/max geometry hint logic for fullscreen/maximize behavior under Wayland.

Suggested labels

Bug, v3, Linux, size:M, lgtm

Suggested reviewers

  • leaanthony

Poem

🐰 I hopped from screen to screen with care,
Logical sizes now fit everywhere.
No more scaling ghosts in flight,
Fullscreen lands just right tonight.
A rabbit cheers—windows aligned and fair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix linux min/max hints' directly and specifically describes the primary changes in the PR, which involve fixing the behavior of min/max geometry hints on Linux.
Description check ✅ Passed The PR description identifies the fixed issue (#5469), explains the root causes (scale factor misapplication and hard limits instead of hints), includes reproduction details, and provides comprehensive test environment configuration via wails doctor output.
Linked Issues check ✅ Passed The code changes directly address issue #5469 by removing scale factor multiplication in fullscreen geometry calculations, changing from hard limits to conditional hint-based geometry, and eliminating monitor-based fallback substitution for min/max values.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the Linux min/max hints issue in the two files modified (linux_cgo_gtk3.go and webview_window_linux.go), with no unrelated functionality introduced.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
v3/pkg/application/webview_window_linux.go (1)

104-107: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Bug: Monitor coordinates passed as min size constraints.

The disableSizeConstraints method passes monitor coordinates (x, y) as minWidth and minHeight parameters to setMinMaxSize. This is incorrect—the function signature is setMinMaxSize(minWidth, minHeight, maxWidth, maxHeight), so monitor position values end up as size constraints.

Additionally, this function still multiplies max dimensions by scaleFactor, which contradicts the new logical-dimension approach used in fullscreen().

🐛 Proposed fix
 func (w *linuxWebviewWindow) disableSizeConstraints() {
-	x, y, width, height, scaleFactor := w.getCurrentMonitorGeometry()
-	w.setMinMaxSize(x, y, int(float64(width)*scaleFactor), int(float64(height)*scaleFactor))
+	// Pass zeros to clear constraints (let windowSetGeometryHints skip setting hints)
+	w.setMinMaxSize(0, 0, 0, 0)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v3/pkg/application/webview_window_linux.go` around lines 104 - 107,
disableSizeConstraints currently passes monitor x,y as minWidth/minHeight and
multiplies max sizes by scaleFactor; update
linuxWebviewWindow.disableSizeConstraints to call setMinMaxSize with minWidth
and minHeight set to 0 (not x,y) and use the logical monitor width/height (do
NOT multiply width/height by scaleFactor) so: call setMinMaxSize(0, 0, width,
height) after obtaining values from getCurrentMonitorGeometry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@v3/pkg/application/linux_cgo_gtk3.go`:
- Around line 1616-1620: The GTK3 branch applies GDK_HINT_MIN_SIZE when either
minWidth or minHeight is > 0 (using "||"), which mismatches the GTK4 behavior
that only sets the hint when both dimensions are specified; update the condition
in linux_cgo_gtk3.go so the block that sets size.min_width, size.min_height and
mask |= C.GDK_HINT_MIN_SIZE runs only when minWidth > 0 && minHeight > 0 (i.e.,
replace the "||" with "&&") to align SetMinSize behavior with the GTK4
implementation.

---

Outside diff comments:
In `@v3/pkg/application/webview_window_linux.go`:
- Around line 104-107: disableSizeConstraints currently passes monitor x,y as
minWidth/minHeight and multiplies max sizes by scaleFactor; update
linuxWebviewWindow.disableSizeConstraints to call setMinMaxSize with minWidth
and minHeight set to 0 (not x,y) and use the logical monitor width/height (do
NOT multiply width/height by scaleFactor) so: call setMinMaxSize(0, 0, width,
height) after obtaining values from getCurrentMonitorGeometry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4dbf78b3-0ace-4472-974f-668261cd559e

📥 Commits

Reviewing files that changed from the base of the PR and between 609a080 and 7d69002.

📒 Files selected for processing (2)
  • v3/pkg/application/linux_cgo_gtk3.go
  • v3/pkg/application/webview_window_linux.go

Comment on lines +1616 to +1620
if minWidth > 0 || minHeight > 0 {
size.min_width = C.int(minWidth)
size.min_height = C.int(minHeight)
mask |= C.GDK_HINT_MIN_SIZE
}

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the GTK4 implementation uses AND for min size check
rg -nA3 'func windowSetGeometryHints' v3/pkg/application/linux_cgo.go

Repository: wailsapp/wails

Length of output: 305


🏁 Script executed:

#!/bin/bash
# Inspect GTK3 windowSetGeometryHints min-size check
sed -n '1600,1635p' v3/pkg/application/linux_cgo_gtk3.go

# Also show the GTK4 snippet again for full context
sed -n '1225,1265p' v3/pkg/application/linux_cgo.go

Repository: wailsapp/wails

Length of output: 2594


🏁 Script executed:

#!/bin/bash
# Find all call sites of windowSetGeometryHints and inspect nearby argument usage
rg -n "windowSetGeometryHints\(" -S v3/pkg/application | head -n 50

# If we find calls, print a bit of context around them
rg -n "windowSetGeometryHints\(" -S v3/pkg/application -n -A6 -B2 | head -n 120

Repository: wailsapp/wails

Length of output: 3349


🏁 Script executed:

#!/bin/bash
# Show the call site and how min/max sizes are computed.
sed -n '130,220p' v3/pkg/application/webview_window_linux.go

# Show setMinMaxSize and any helpers it uses
rg -n "func \\(w \\*linuxWebviewWindow\\) setMinMaxSize" -n v3/pkg/application/webview_window_linux.go
sed -n '220,320p' v3/pkg/application/webview_window_linux.go

# Also find where min/max width/height values come from (options or defaults)
rg -n "MinWidth|MinHeight|minWidth|minHeight|setMinSize\\(" v3/pkg/application/webview_window_linux.go | head -n 80

Repository: wailsapp/wails

Length of output: 5881


🏁 Script executed:

#!/bin/bash
# Inspect where min/max sizes are computed and applied in linuxWebviewWindow.run()
sed -n '300,370p' v3/pkg/application/webview_window_linux.go

# Also check whether setMinSize / setMaxSize are called with potentially mixed values
rg -n "setMinSize\\(|setMaxSize\\(" v3/pkg/application/webview_window_linux.go

Repository: wailsapp/wails

Length of output: 2313


🏁 Script executed:

#!/bin/bash
rg -n "setMinSize\\(" -S v3/pkg/application | head -n 100
rg -n "setMinMaxSize\\(" -S v3/pkg/application | head -n 100
rg -n "setMinMaxSize\\(" -S v3 | head -n 200

Repository: wailsapp/wails

Length of output: 2643


🏁 Script executed:

#!/bin/bash
# Inspect where the implementation setMinSize is called (min/max update flows)
sed -n '520,640p' v3/pkg/application/webview_window.go
sed -n '1200,1260p' v3/pkg/application/webview_window.go

# Also inspect any public methods that might call impl.setMinSize with user-provided values.
rg -n "setMinSize\\(" v3/pkg/application/webview_window.go
rg -n "MinWidth|MinHeight" v3/pkg/application/webview_window.go | head -n 80

Repository: wailsapp/wails

Length of output: 4996


Align GTK3 min-size hint condition with GTK4 (&& vs ||)

v3/pkg/application/linux_cgo_gtk3.go applies GDK_HINT_MIN_SIZE when either minWidth or minHeight is > 0 (minWidth > 0 || minHeight > 0), but v3/pkg/application/linux_cgo.go only applies the min constraint when both are > 0 (minWidth > 0 && minHeight > 0). This can diverge when callers use SetMinSize with one dimension set (e.g., SetMinSize(100, 0)): GTK3 may apply a partially-specified min hint while GTK4 won’t. Initial window setup defaults both mins to 1, so this mostly affects later SetMinSize calls.

🔧 Suggested alignment
-	if minWidth > 0 || minHeight > 0 {
+	if minWidth > 0 && minHeight > 0 {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@v3/pkg/application/linux_cgo_gtk3.go` around lines 1616 - 1620, The GTK3
branch applies GDK_HINT_MIN_SIZE when either minWidth or minHeight is > 0 (using
"||"), which mismatches the GTK4 behavior that only sets the hint when both
dimensions are specified; update the condition in linux_cgo_gtk3.go so the block
that sets size.min_width, size.min_height and mask |= C.GDK_HINT_MIN_SIZE runs
only when minWidth > 0 && minHeight > 0 (i.e., replace the "||" with "&&") to
align SetMinSize behavior with the GTK4 implementation.

@leaanthony
leaanthony enabled auto-merge (squash) May 31, 2026 12:35
@leaanthony
leaanthony merged commit a372e87 into wailsapp:master May 31, 2026
16 of 17 checks passed
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.

[V3, Linux] Maximize window bug

2 participants