tauri-apps / tao

The TAO of cross-platform windowing. A library in Rust built for Tauri.
Apache License 2.0
1.63k stars 191 forks source link

[bug][linux][WSL] Wayland protocol error 71 when restoring maximized window state #977

Closed Zamoca42 closed 1 month ago

Zamoca42 commented 2 months ago

Describe the bug

Gdk-Message: Error 71 (Protocol error) dispatching to Wayland display.

`wl_display@1.error(xdg_wm_base@20, 4, "xdg_surface buffer (1160 x 757) does not match the configured maximized state (0 x 0)"

[3521097-278] -> xdg_toplevel@22.set._maximized()
[3521097.300] -> xdg_toplevel@22.unset_fullscreen()
[3521098.399] xdg_toplevel@22.configure(0, 0, array[4])
[3521098.410] xdg_surface@21.configure (900)
[3521101.5681] → xdg_toplevel@22.set_min_size(900, 587)
[3521101.586] -> xdg_toplevel@22.set_max_size (3840, 2160)
[3521101.617] -> xdg_surface@21.set_window_geometry(0, 0, 1160, 757)

I'm encountering a Wayland protocol error when restoring a maximized window state using tauri-plugin-window-state plugin on WSL. This issue is based on https://github.com/gitbutlerapp/gitbutler/pull/4864 and the xdg-shell.xml specification.

According to the xdg-shell.xml specification:

<request name="set_window_geometry">
  <description summary="set the new window geometry">
    The window geometry of a window is its "visible bounds" from the user's perspective. It includes title bars and borders if they are drawn by the client, but excludes drop shadows. The geometry is double-buffered, and will be applied at the time wl_surface.commit of the corresponding wl_surface is called.

    **A client cannot set the window geometry of a maximized or fullscreen window, as the window dimensions are determined by the compositor.**

    When applied, the effective window geometry will be the rectangular region of the visible area of the window.
  </description>
  <!-- ... -->
</request>

In the Wayland protocol, the compositor determines the size of a maximized window, and the client must adhere to this size. If a client attempts to change the size of a maximized window, it is considered a protocol violation, resulting in an error.

Steps To Reproduce

https://github.com/gitbutlerapp/gitbutler/issues/4039 https://github.com/tauri-apps/tauri/issues/10702

  1. The maximized window state in Wayland has 0 x 0.
  2. The saved window size is 1167 x 575.
  3. When trying to restore the window to the saved size, a resize attempt is made.
  4. This leads to a surface mismatch, causing the display server to terminate.

Expected behavior

The window restoration logic should match the inner size and the window size when in the maximized state on Wayland.

Platform and Versions (please complete the following information):

OS: WSL, ubuntu 22.04 Rustc: 1.71.0

Additional context

In my opinion, it seems necessary to modify the resize-related code in window.rs or event_loop.rs within the tao source code for Linux. I'd be happy to work on a fix for this issue if you think it's appropriate.