tauri: [bug] Can't move or resize the main window

Describe the bug

I can’t move or resize a window after upgrading to tauri latest rc (2.0.0-rc.3 at that time) when running as dev.
The thing is it doesn’t come from that tauri version as downgrading it doesn’t solve the problem.

Reproduction

  1. Create a minimal tauri app using the latest release candidate.
    cargo create-tauri-app --rc

  2. Run the app in dev mode. cargo tauri dev

Expected behavior

Be able to move or resize the application’s window.

Full tauri info output

WARNING: no lock files found, defaulting to npm

[✔] Environment
    - OS: Fedora 40.0.0 X64
    ✔ webkit2gtk-4.1: 2.44.2
    ✔ rsvg2: 2.57.1
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.6.0
    - npm: 10.8.1
    - bun: 1.1.24

[-] Packages
    - tauri [RUST]: 2.0.0-rc (no lockfile)
    - tauri-build [RUST]: no manifest (no lockfile)
    - wry [RUST]: no manifest (no lockfile)
    - tao [RUST]: no manifest (no lockfile)
    - tauri-cli [RUST]: 2.0.0-rc.3
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-rc.3

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 33 (10 by maintainers)

Commits related to this issue

Most upvoted comments

It also happens in release mode. For some reason this is specific for Gnome + Wayland

KDE + X11 -> Can resize and move KDE + Wayland -> Can resize and move GNOME + X11 -> Can resize and move GNOME + Wayland -> The issue appears.

following on hint by @ndom91, I found out that reversing changes of fix(linux): prevent firing duplicate mouse events in tao fixes move/size issue, but brings back duplicate mouse events.

using xprop method of detecting if application is running native wayland or thru xwayland (shows crosshair on xwayland and no cursor change on wayland). I have found out:

  • Running my app uses native wayland, move/resize DOESN’T work
  • Running my app with GDK_BACKEND=wayland uses native wayland, move/resize DOESN’T work
  • Running my app with GDK_BACKEND=x11 uses xwayland, move/resize works
  • Running gtk’s example/application1 with GDK_BACKEND=x11 uses xwayland, move/resize works
  • Running gtk’s example/application1 with GDK_BACKEND=wayland uses native wayland, move/resize DOES work

This suggests that the problem is in tauri/tao/wry and not in the system.

My current workaround is setting env var “GDK_BACKEND” to x11 at top of the main() function.

p.s. beware of running your app from vs code terminal as it sets GDK_BACKEND to x11

Closed by https://github.com/tauri-apps/tao/pull/979, if the issue happens after release, please let me know

The issue might come from tauri-runtime-wry. I’ve found that adding it to the Cargo.toml to set it to its last version (2.0.0-rc.6) brings the bug.

Also, both minimize and close buttons work and I can move the window when “dragging” them.

[✔] Environment
    - OS: Fedora 40 X64
    ✔ webkit2gtk-4.1: 2.44.2
    ✔ rsvg2: 2.57.1
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 22.6.0
    - npm: 10.8.1
    - bun: 1.1.24

[-] Packages
    - tauri [RUST]: 2.0.0-rc.1
    - tauri-build [RUST]: 2.0.0-rc.1
    - wry [RUST]: 0.42.0
    - tao [RUST]: 0.29.1
    - tauri-cli [RUST]: 2.0.0-rc.3

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:3000/

I’ve gone through and tried all tauri-runtime-wry versions from rc.8 back down to rc.2 and it seems that it really has broken in rc.3, that was the first release where my app also began experiencing these issues in wayland+gnome DE’s

I found the root cause of this issue when troubleshooting the issue https://github.com/tauri-apps/tao/issues/929. Adding a comment here for future reference.

It turns out to be an issue of the GTK or Wayland under certain scenarios.

By tracking the history, I found that this issue was introduced by #941, which is trying to fix the duplicated mouse event triggered by a single click on Linux. The solution in this PR is to prevent the related event from being propagated.

Since the issue is Wayland-specific. I reproduced this issue with a minimal GTK app using the gtk-rs crate.

use gtk::{glib, prelude::*};
use gtk::{Application, ApplicationWindow};

fn main() {
  let app = Application::builder()
    .application_id("org.example.HelloWorld")
    .build();

  app.connect_activate(|app| {
    // We create the main window.
    let win = ApplicationWindow::builder()
      .application(app)
      .default_width(320)
      .default_height(320)
      .title("Hello, World!")
      .build();

    win.connect_button_press_event(|_win, event| {
      dbg!(event);
      glib::Propagation::Stop
    });

    win.show_all();
  });

  app.run();
}

On Wayland, running the above code directly will cause the window to not move. If you run the code with GDK_BACKEND=x11 (i.e., XWayland is used) or on X11, the window can move.

The reason is that clicking on the window title bar will trigger a button press event on Wayland, and the connect_button_press_event callback stops the event. So the window cannot move. However, on XWayland or X11, clicking on the window title bar will not trigger a button press event, so the window can move.

So, this could be a bug in GTK or Wayland. I have reported it at: https://gitlab.gnome.org/GNOME/gtk/-/issues/7327


BTW, using GDK_BACKEND=x11 will use XWayland on the Wayland environment. If you enable Tauri’s tray icon, this will cause the two system tray icons (one is active, another is dead) problem.

@amrbashir i tested the new release and that’s not really a solution. The custom header has 2 serious problems:

  1. the header does not follow the platform theme (light/dark);
  2. the size of the window is wrong because the header height is not taken into account. This means that the available area is different between platforms with Linux Wayland getting less vertical space than, for example, Windows.

Please, reopen this bug report until a proper fix is implemented.

@Khalid-Nowaf I have implemented a header for Wayland, and it will be included in the next version once https://github.com/tauri-apps/tao/pull/982 is released.