Skip to content

[V2 - Linux] Bugfix/2431 wayland max size #4047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions v2/internal/frontend/desktop/linux/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ static bool isNULLRectangle(GdkRectangle input)
return input.x == -1 && input.y == -1 && input.width == -1 && input.height == -1;
}

static gboolean onWayland()
{
const char *gdkBackend = getenv("XDG_SESSION_TYPE");
if(gdkBackend != NULL && strcmp(gdkBackend, "wayland") == 0)
{
return TRUE;
}

return FALSE;
}

static GdkMonitor *getCurrentMonitor(GtkWindow *window)
{
// Get the monitor that the window is currently on
Expand Down Expand Up @@ -238,11 +249,28 @@ void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_wid
{
return;
}

int flags = GDK_HINT_MAX_SIZE | GDK_HINT_MIN_SIZE;

size.max_height = (max_height == 0 ? monitorSize.height : max_height);
size.max_width = (max_width == 0 ? monitorSize.width : max_width);
size.min_height = min_height;
size.min_width = min_width;

// On Wayland window manager get the decorators and calculate the differences from the window size.
if(onWayland())
{
int windowWidth, windowHeight;
gtk_window_get_size(window, &windowWidth, &windowHeight);

GtkAllocation windowAllocation;
gtk_widget_get_allocation(GTK_WIDGET(window), &windowAllocation);

// Add the decorator difference to the window so fullscreen and maximise can fill the window.
size.max_height = (windowAllocation.height-windowHeight)+size.max_height;
size.max_width = (windowAllocation.width-windowWidth)+size.max_width;
}

gtk_window_set_geometry_hints(window, NULL, &size, flags);
}

Expand Down
4 changes: 4 additions & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fixed Window size issues on Wayland [PR](https://github.com/wailsapp/wails/pull/4047) by [@lyimmi](https://github.com/lyimmi)


### Changed
- Updated recommendation for Svelte router in [#4085](https://github.com/wailsapp/wails/pull/4085) by [@benmccann](https://github.com/benmccann)

Expand Down
Loading