tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.02k stars 2.57k forks source link

[bug] Function Window.set_size does nothing on Linux #5876

Open IAmSegfault opened 1 year ago

IAmSegfault commented 1 year ago

Describe the bug

I am running a tauri 1.2.2 app on Pop!_OS 22.04 (Ubuntu derivative) and have the following tauri command in my rust code:

#[tauri::command]
fn set_window_size(apphandle: tauri::AppHandle<Wry>) {
    let mut window_opt = apphandle.get_window("main");
    match window_opt {
        Some(mut window)  => {
            println!("resizing window");
            window.set_resizable(true);
            window.set_size(Size::Physical(PhysicalSize{width: 1920, height: 1080})).expect("Could not resize!");
        } 
        None => {

        }
    }
}

Calling the command with the following typescript code:

export let onResize = async () => {
    invoke("set_window_size") ;
}

Which is called by a button's onClick event.

The function window.set_size(Size::Physical(PhysicalSize{width: 1920, height: 1080})).expect("Could not resize!"); does not do anything when called on this platform.

In my tauri.conf.json I have

    "windows": [
      {
        "fullscreen": false,
        "height": 720,
        "resizable": true,
        "title": "myapp",
        "width": 1280
      }
    ]

Other functions such as window.set_fullscreen(true); work as intended so the issue has something to do with the set_size function on Linux platforms.

Reproduction

  1. Run the above code and settings in a tauri 1.2.2 app on Pop!_OS 22.04
  2. Click a button with onClick set to onResize in order to attempt to resize the window from 1280x720 to 1920x1080
  3. The window does not resize

Expected behavior

The window should resize itself from 1280x720 to 1920x1080.

Platform and versions

Note: Pop!_OS 22.04 comes with node 12 installed by default which does not appear to be able to run tauri. Node 19.3.0 was manually installed to /run/user/1000/fnm_multishells/11583_1671428736077/bin/node using fnm on the development machine. https://github.com/Schniz/fnm

> myapp@0.0.0 tauri
> tauri info

Environment
  › OS: Pop!_OS 22.04 X64
  › Node.js: 19.3.0
  › npm: 9.2.0
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.66.0
  › cargo: 1.66.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.2.2
  › @tauri-apps/api [NPM]: 1.2.0
  › tauri [RUST]: 1.2.2,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.7,
  › wry [RUST]: 0.23.3,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:1420/
  › framework: React
  › bundler: Vite

App directory structure
  ├─ public
  ├─ dist
  ├─ src-tauri
  ├─ VM
  ├─ .vscode
  ├─ src
  ├─ .idea
  └─ node_modules

Stack trace

No response

Additional context

No response

amrbashir commented 1 year ago

this is an issue with set_resizable on Linux, not set_size, see https://github.com/tauri-apps/tao/issues/561