Skip to content
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

[V2] Bugfix/2431 wayland max size #4047

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

lyimmi
Copy link
Contributor

@lyimmi lyimmi commented Feb 5, 2025

Description

This PR Fixes #2431 the fullscreen and maximise issue on wayland.

To fix the issue I compared the window's allocated and reported size from GTK. The allocated size contains the header, title, shadows, etc. while the reported windows size does not.

I stored the decorators width & height, because when the window is unfullscreened GTK reports the window as undecorated and from that point on the calculation is wrong and the wrong size is set for GTK. From that point on all the WM's and wails' functions behave badly. And this way it has check the decorators only once.

It could have been solved another way, but I think this is the most backward compatible. (Without refactoring maximise, minimise, fullscreen, unfullscreen)

My original solution used an IFDEF, but changed it to an onWayland function, if we found other wayland specific issues it can be used to decide if the program runs on wayland or not.

Please test this fork / PR on existing applications before we merge it!

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

Checked on Ubuntu 24.04, wayland, X11, with multiple window configurations.

Test Configuration

# Wails
Version         | v2.9.2
Package Manager | apt   

# System
┌───────────────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                             |
| Version      | 22.04                                              |
| ID           | ubuntu                                             |
| Go Version   | go1.23.3                                           |
| Platform     | linux                                              |
| Architecture | amd64                                              |
| CPU          | Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz            |
| GPU          | HD Graphics 530 (Intel Corporation) - Driver: i915 |
| Memory       | 32GB                                               |
└───────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Installed | 27.5.1                  |
| gcc        | build-essential       | Installed | 12.9ubuntu3             |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.33-1ubuntu2.2      |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.46.5-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 8.19.2                  |
| *nsis      | nsis                  | Available | 3.08-2                  |
| pkg-config | pkg-config            | Installed | 0.29.2-1ubuntu3         |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - nsis: sudo apt install nsis

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features

    • Improved window behavior on Linux when using the Wayland display server. Windows now accurately adjust their size and fill the available space when maximized or in fullscreen mode, ensuring a smoother user experience.
    • Added an option to set the window class name on Windows for enhanced customization.
  • Bug Fixes

    • Resolved window size issues on Wayland.
    • Fixed various bugs including logging issues in development mode and crashes in the Windows SaveDialog.
    • Updated Mac App Store guide to support app names with spaces.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This pull request enhances Linux desktop window management under Wayland. It introduces a new function to check for Wayland sessions by inspecting the XDG_SESSION_TYPE environment variable. The SetMinMaxSize function is modified to adjust maximum window sizes based on the presence of window decorations when running under Wayland, ensuring proper window sizing in maximized and fullscreen states.

Changes

File(s) Change Summary
v2/internal/frontend/.../linux/window.c - Added static function onWayland() to check if running on Wayland
- Modified SetMinMaxSize() to adjust window sizes based on Wayland detection and window decorations
website/src/pages/changelog.mdx - Removed documentation reference regarding default module name
- Updated Mac App Store guide for app names with spaces
- Added option to set window class name on Windows
- Documented bug fixes including window size issues on Wayland

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant SMS as SetMinMaxSize
    participant OW as onWayland
    participant Env as Environment

    App->>SMS: Call SetMinMaxSize
    SMS->>OW: Invoke onWayland()
    OW->>Env: Read XDG_SESSION_TYPE
    Env-->>OW: Return session type (Wayland/X11)
    OW-->>SMS: Return true/false based on Wayland
    SMS->>SMS: Adjust size constraints if Wayland true
    SMS-->>App: Apply adjusted window dimensions
Loading

Assessment against linked issues

Objective Addressed Explanation
Resolve window maximum width/height issues (#2431)

Possibly related PRs

Poem

I'm hopping with joy, a rabbit so light,
New Wayland logic makes my code take flight.
Checking sessions with a whisker of glee,
Adjusting sizes smartly for all to see.
Here's to smooth windows and nights so bright!
🐇✨
Hippity hoppity into the future we go!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89db2ad and 347d8cf.

📒 Files selected for processing (1)
  • v2/internal/frontend/desktop/linux/window.c (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2/internal/frontend/desktop/linux/window.c

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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: 0

🧹 Nitpick comments (1)
v2/internal/frontend/desktop/linux/window.c (1)

273-292: Validate decorator measurements & fix minor typo.

  1. The approach of computing decorator offsets once may cause issues if decorations change at runtime (e.g., toggling between decorated/undecorated mode). Consider recalculating decoratorWidth and decoratorHeight if the window’s decoration state changes in the future.
  2. There's a small typo in the comment. Here's a suggested fix:
-    // On Wayland window manager get the decoratgors and calculate the differences from the windows' size.
+    // On Wayland window manager, get the decorators and calculate the differences from the window size.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a1d101 and f07ead3.

📒 Files selected for processing (1)
  • v2/internal/frontend/desktop/linux/window.c (3 hunks)
🔇 Additional comments (3)
v2/internal/frontend/desktop/linux/window.c (3)

17-19: Clarify sentinel usage for uninitialized states.
Using -1 as a sentinel is fine, but consider adding a brief comment indicating that -1 denotes "not yet detected" or "unknown." This helps future readers quickly understand the initialization logic of wmIsWayland, decoratorWidth, and decoratorHeight.


74-93: Document or handle fallback logic for unusual sessions.
The onWayland() function looks correct for typical Wayland/X11 usage. However, you might want to document any fallbacks if XDG_SESSION_TYPE is set to something unexpected.


266-267: Proper usage of geometry hints.
Combining GDK_HINT_MAX_SIZE and GDK_HINT_MIN_SIZE into flags is valid and aligns well with GTK’s geometry hint practices. No concerns here.

@lyimmi lyimmi changed the title Bugfix/2431 wayland max size [V2] Bugfix/2431 wayland max size Feb 5, 2025
Copy link
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: 0

🧹 Nitpick comments (1)
website/src/pages/changelog.mdx (1)

38-38: Clarify the fix description for Wayland window issues.
The new bullet clearly states that window size issues on Wayland have been fixed (as per PR #4047 by @lyimmi). To further aid users, consider adding a brief note clarifying that the fix addresses discrepancies due to window decoration differences (e.g., header and title offsets) when exiting fullscreen. This additional context would directly link the changelog entry to the PR objectives without requiring users to click through, while maintaining consistency with the rest of the changelog.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d1e518 and 89db2ad.

📒 Files selected for processing (1)
  • website/src/pages/changelog.mdx (1 hunks)

@leaanthony
Copy link
Member

leaanthony commented Feb 7, 2025

Thanks for opening this @lyimmi 🙏 I've made a couple of changes to make the methods thread safe. They shouldn't be called that often so it was probably never going to hit a race condition but just in case... I'm also not sure what would happen if you plugged in a new monitor and called it there... I'm ok with recalculating 👍

LMK if this works for you and I'll merge 👍

@lyimmi
Copy link
Contributor Author

lyimmi commented Feb 8, 2025

Thanks for opening this @lyimmi 🙏 I've made a couple of changes to make the methods thread safe. They shouldn't be called that often so it was probably never going to hit a race condition but just in case... I'm also not sure what would happen if you plugged in a new monitor and called it there... I'm ok with recalculating 👍

LMK if this works for you and I'll merge 👍

I'll test it and get back to you.

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.

Window maximum width and height issues on Linux Wayland
2 participants