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

[bug] Window set_size broken #11740

Closed
richards-native opened this issue Nov 19, 2024 · 1 comment
Closed

[bug] Window set_size broken #11740

richards-native opened this issue Nov 19, 2024 · 1 comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@richards-native
Copy link

Describe the bug

Apologies if this issue already exists, I saw a couple around this but none talking about this problem specifically.

It looks like sometime between 2.0.0 and 2.1.1, window sizing in from the tauri config and using set_size (from Rust or JS) is not working properly. Setting the window size in the config, the values seem to be off by a small amount (14px X and 37px Y on a 528x100px window). Using set_size seems to basically have no effect on the size.

Looking into the source, it appears the issue is in the Tao crate. Commenting out this section of code fixes the issue, initial window size is correct and set_size works again.

if window_flags.contains(WindowFlags::MARKER_UNDECORATED_SHADOW) && !is_decorated {
  let mut pt: POINT = unsafe { mem::zeroed() };
  if unsafe { ClientToScreen(self.hwnd(), &mut pt) }.as_bool() == true {
    let mut window_rc: RECT = unsafe { mem::zeroed() };
    if unsafe { GetWindowRect(self.hwnd(), &mut window_rc) }.is_ok() {
      let left_b = pt.x - window_rc.left;
      let right_b = pt.x + width - window_rc.right;
      let top_b = pt.y - window_rc.top;
      let bottom_b = pt.y + height - window_rc.bottom;

      width = width + (left_b - right_b);
      height = height + (top_b - bottom_b);
    }
  }
}

From this I was able to see it only happens for undecorated windows where shadows are enabled, disabling the shadows does work but that's not the style I am looking for in my application.

Reproduction

No response

Expected behavior

Window resizes correctly.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 130.0.2849.80
    ✔ MSVC:
        - Visual Studio Build Tools 2017
        - Visual Studio Build Tools 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.80.1 (3f5fd8dd4 2024-08-06)
    ✔ cargo: 1.80.1 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 22.7.0
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3
    - wry 🦀: 0.47.0
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-websocket 🦀: 2.0.1
    - @tauri-apps/plugin-websocket : 2.0.0
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : 2.0.0 (outdated, latest: 2.0.2)
    - tauri-plugin-updater 🦀: 2.0.2
    - @tauri-apps/plugin-updater : 2.0.0
    - tauri-plugin-single-instance 🦀: 2.0.1
    - @tauri-apps/plugin-single-instance : not installed!
    - tauri-plugin-log 🦀: 2.0.2
    - @tauri-apps/plugin-log : 2.0.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/tauri-app/browser
    - devUrl: http://localhost:1420/
    - framework: Angular
    - bundler: Webpack

Stack trace

No response

Additional context

No response

@richards-native richards-native added status: needs triage This issue needs to triage, applied to new issues type: bug labels Nov 19, 2024
@amrbashir
Copy link
Member

I believe this to be duplicate of #11695 and thus fixed by tauri-apps/tao#1017

@amrbashir amrbashir closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants