[V3 alpha] Fix ultrawide monitor support on Wayland (fixes #4429) (#4561)

* Fixed Wayland related window maximum size issues on ultrawide monitors by adding a monitor-window search fallback.

* Fixed Wayland related window maximum size issues on ultrawide monitors by adding a monitor-window search fallback.

* Added note to UNRELEASED_CHANGELOG.md regarding Wayland ultrawide monitor fix of issue 4439.

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
samstanier 2025-09-25 07:01:16 +01:00 committed by GitHub
commit bb53fcbfac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 11 deletions

View file

@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file
## Fixed
<!-- Bug fixes -->
- Fixed Wayland window size maximising issues (https://github.com/wailsapp/wails/issues/4429) by [@samstanier](https://github.com/samstanier)
## Deprecated
<!-- Soon-to-be removed features -->

View file

@ -33,16 +33,16 @@ func main() {
app := clir.NewCli("wails", "The Wails3 CLI", "v3")
app.NewSubCommand("docs", "Open the docs").Action(openDocs)
app.NewSubCommandFunction("init", "Initialise a new project", commands.Init)
build := app.NewSubCommand("build", "Build the project")
var buildFlags flags.Build
build.AddFlags(&buildFlags)
build.Action(func() error {
return commands.Build(&buildFlags, build.OtherArgs())
})
app.NewSubCommandFunction("dev", "Run in Dev mode", commands.Dev)
pkg := app.NewSubCommand("package", "Package application")
var pkgFlags flags.Package
pkg.AddFlags(&pkgFlags)

View file

@ -284,17 +284,17 @@ func getLinuxWebviewWindow(window Window) *linuxWebviewWindow {
if window == nil {
return nil
}
webviewWindow, ok := window.(*WebviewWindow)
if !ok {
return nil
}
lw, ok := webviewWindow.impl.(*linuxWebviewWindow)
if !ok {
return nil
}
return lw
}
@ -928,13 +928,33 @@ func (w *linuxWebviewWindow) fullscreen() {
}
func (w *linuxWebviewWindow) getCurrentMonitor() *C.GdkMonitor {
// Get the monitor that the window is currently on
display := C.gtk_widget_get_display(w.gtkWidget())
gdkWindow := C.gtk_widget_get_window(w.gtkWidget())
if gdkWindow == nil {
return nil
if gdkWindow != nil {
monitor := C.gdk_display_get_monitor_at_window(display, gdkWindow)
if monitor != nil {
return monitor
}
}
return C.gdk_display_get_monitor_at_window(display, gdkWindow)
// Wayland fallback: find monitor containing the current window
n_monitors := C.gdk_display_get_n_monitors(display)
window_x, window_y := w.position()
for i := 0; i < int(n_monitors); i++ {
test_monitor := C.gdk_display_get_monitor(display, C.int(i))
if test_monitor != nil {
var rect C.GdkRectangle
C.gdk_monitor_get_geometry(test_monitor, &rect)
// Check if window is within this monitor's bounds
if window_x >= int(rect.x) && window_x < int(rect.x+rect.width) &&
window_y >= int(rect.y) && window_y < int(rect.y+rect.height) {
return test_monitor
}
}
}
return nil
}
func (w *linuxWebviewWindow) getScreen() (*Screen, error) {

View file

@ -6,12 +6,13 @@ import (
"fmt"
"time"
"unsafe"
"github.com/bep/debounce"
"github.com/wailsapp/wails/v3/internal/assetserver"
"github.com/wailsapp/wails/v3/internal/capabilities"
"github.com/wailsapp/wails/v3/internal/runtime"
"github.com/wailsapp/wails/v3/pkg/events"
"unsafe"
)
type dragInfo struct {