Skip to content

fix(v3,linux): implement native frameless window resize#5159

Merged
leaanthony merged 2 commits intowailsapp:v3-alphafrom
BenAicholtz:fix/linux-start-resize
Apr 20, 2026
Merged

fix(v3,linux): implement native frameless window resize#5159
leaanthony merged 2 commits intowailsapp:v3-alphafrom
BenAicholtz:fix/linux-start-resize

Conversation

@BenAicholtz
Copy link
Copy Markdown
Contributor

@BenAicholtz BenAicholtz commented Apr 16, 2026

Summary

linuxWebviewWindow.startResize was a no-op stub, so wails:resize:<edge> messages sent by the runtime's drag.ts were dispatched but never acted upon. Frameless windows on Linux could only be dragged, not resized from edges/corners.

This PR wires both CGo backends up to the underlying GTK resize APIs.

Changes

  • GTK3 (linux_cgo.go): map the eight edge strings to GdkWindowEdge and call gtk_window_begin_resize_drag, using the mouse state captured by the existing button-press-event handler.
  • GTK4 (linux_cgo_gtk4.go): same mapping to GdkSurfaceEdge, dispatched through the beginWindowResize C helper that was already defined in linux_cgo_gtk4.c / .h but never called.
  • webview_window_linux.go: remove the // FIXME: what do we need to do here? stub so the per-backend implementations are the only definitions.

The pattern mirrors the existing startDrag implementations on both backends — the w.drag state populated by mousedown is reused with no new plumbing.

Why this matters

  • Frameless windows on Linux are common for PiP / floating video overlays / custom chromeless apps. Without resize support the only workarounds are (a) a non-frameless window with system decorations, or (b) a manual JS implementation that round-trips SetSize/SetPosition over the IPC channel per mousemove — visibly janky compared to native resize.
  • The C helper and the --wails-resize / wails:resize: runtime plumbing already exist; this PR only wires them together.

Fixes

Test plan

  • Build a frameless window app on GTK3 (default): drag from each of 8 edges/corners → window resizes smoothly and stops on mouseup.
  • Build the same app with -tags gtk4: drag from each of 8 edges/corners → same behavior.
  • Confirm that passing an unknown border string returns a clear error (unknown resize border: %q) rather than silently doing nothing.
  • Verify the existing startDrag behavior is unchanged.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added window resize-drag functionality for Linux applications, allowing users to resize windows by dragging from any border edge (north, south, east, west, and corner edges).

The Linux implementation of linuxWebviewWindow.startResize was a no-op
stub, so `wails:resize:<edge>` messages from the runtime's drag.ts were
dispatched but never acted upon. Frameless windows on Linux could only
be dragged, not resized from edges/corners.

Wire both CGo backends up to the underlying GTK APIs:

- GTK3 (linux_cgo.go): map the eight edge strings to GdkWindowEdge and
  call gtk_window_begin_resize_drag with the mouse state captured by the
  existing button-press-event handler.
- GTK4 (linux_cgo_gtk4.go): same mapping to GdkSurfaceEdge, dispatched
  through the beginWindowResize C helper that was already defined in
  linux_cgo_gtk4.c / .h but never called.
- webview_window_linux.go: remove the `// FIXME: what do we need to do
  here?` stub, which used to shadow the new per-backend implementations.

Matches the startDrag pattern already in place on both backends, so the
"drag state" populated by mousedown is reused without any new plumbing.

Fixes wailsapp#4976.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

Walkthrough

Added window resize functionality for Linux by implementing the startResize method in both GTK3 and GTK4 platform-specific implementations, with border string validation and drag state integration. Removed the previous stub method.

Changes

Cohort / File(s) Summary
GTK3 Implementation
v3/pkg/application/linux_cgo.go
Added gdkEdgeForBorder lookup table mapping Wails border strings to GTK edges and implemented startResize method that validates border input and initiates window resize via C.gtk_window_begin_resize_drag using stored drag state.
GTK4 Implementation
v3/pkg/application/linux_cgo_gtk4.go
Replaced placeholder comment with functional implementation: added gdkSurfaceEdgeForBorder map for border-to-edge translation and implemented startResize method using C.beginWindowResize with validated border mapping and drag state.
Stub Removal
v3/pkg/application/webview_window_linux.go
Removed the empty startResize stub method that previously had no implementation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Bug, Linux, v3, v3-alpha, size:M, lgtm

Suggested reviewers

  • leaanthony

Poem

🐰 A window dancing to resize,
With borders mapped and drag-state wise,
GTK3 and four now play along,
The resize logic strong and long!
hops with joy

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarizes the main change: implementing native frameless window resize on Linux, which is the core objective of the PR.
Description check ✅ Passed Description is comprehensive and well-structured, covering the problem, solution details for both GTK backends, motivation, and test plan, though required template sections are not fully checked.

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

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

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v3/pkg/application/linux_cgo.go`:
- Around line 1770-1801: The build breaks because linux_purego.go lacks the
startResize(border string) error method required by the webviewWindowImpl
interface; add a method named startResize on the linuxWebviewWindow type in
linux_purego.go that matches the signature (func (w *linuxWebviewWindow)
startResize(border string) error) and either implement equivalent purego
behavior or return a no-op nil/error indicating unsupported resize-drag;
alternatively, add a no-op stub with that same signature to
webview_window_linux.go so purego builds satisfy the interface (ensure the
symbol name startResize and receiver type linuxWebviewWindow match existing
code).
🪄 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: d6a7590e-6275-4c49-88d1-80335e90794a

📥 Commits

Reviewing files that changed from the base of the PR and between 25403ff and b4e8d98.

📒 Files selected for processing (3)
  • v3/pkg/application/linux_cgo.go
  • v3/pkg/application/linux_cgo_gtk4.go
  • v3/pkg/application/webview_window_linux.go
💤 Files with no reviewable changes (1)
  • v3/pkg/application/webview_window_linux.go

Comment thread v3/pkg/application/linux_cgo.go
Copy link
Copy Markdown
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on!

@leaanthony leaanthony enabled auto-merge (squash) April 20, 2026 11:52
@leaanthony leaanthony merged commit a04e16c into wailsapp:v3-alpha Apr 20, 2026
59 of 60 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.

2 participants