Repository navigation
fix linux min/max hints - #5523
Conversation
|
Caution Review failedFailed to post review comments WalkthroughThree coordinated edits: fullscreen now uses logical monitor dimensions; setMinMaxSize no longer falls back to monitor geometry; windowSetGeometryHints applies min/max hints only when positive. ChangesMulti-monitor window sizing fixes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winBug: Monitor coordinates passed as min size constraints.
The
disableSizeConstraintsmethod passes monitor coordinates (x,y) asminWidthandminHeightparameters tosetMinMaxSize. This is incorrect—the function signature issetMinMaxSize(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 infullscreen().🐛 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
📒 Files selected for processing (2)
v3/pkg/application/linux_cgo_gtk3.gov3/pkg/application/webview_window_linux.go
| if minWidth > 0 || minHeight > 0 { | ||
| size.min_width = C.int(minWidth) | ||
| size.min_height = C.int(minHeight) | ||
| mask |= C.GDK_HINT_MIN_SIZE | ||
| } |
There was a problem hiding this comment.
🧩 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.goRepository: 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.goRepository: 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 120Repository: 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 80Repository: 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.goRepository: 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 200Repository: 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 80Repository: 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.
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.
Summary by CodeRabbit