tauri-apps / tauri

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

[bug] A full-size window is created (without enabling fullscreen), but the window has 8px on each side where mouse events cannot be captured. #10205

Closed kingyang closed 1 week ago

kingyang commented 1 week ago

Describe the bug

A full-size window is created (without enabling fullscreen), but the window has 8px on each side where mouse events cannot be captured.

I want to create a fullscreen window, similar to a screenshot application, but the edges of the screen do not respond to mouse events. Is this a bug, or is there an issue with my code?

my code:

const screenWindow = new WebviewWindow(`${screenLabel}-${m.id}`, {
        alwaysOnTop: true,
        decorations: false,
        resizable: false,
        shadow: false,
        skipTaskbar: true,
        transparent: true,        
        url,
        visible: false,
      })
      const unlistenFn1 = await screenWindow.once('tauri://created', async () => {
        unlistenFn1()
        screenWindow.setPosition(new PhysicalPosition(m.position[0], m.position[1]))
        screenWindow.setSize(new PhysicalSize(m.size[0], m.size[1]))
      })
// show
// m.position[0] =0 
// m.position[1] =0
// m.size[0] =screen width
// m.size[1] = screen hight

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22635 X64
    ✔ WebView2: 126.0.2592.87
    ✔ MSVC: Visual Studio Community 2022
    ✔ 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-pc-windows-msvc (default)
    - node: 21.7.3
    - pnpm: 9.4.0
    - yarn: 1.22.22
    - npm: 10.5.0
    - bun: 1.1.10

[-] Packages
    - tauri [RUST]: 2.0.0-beta.23
    - tauri-build [RUST]: 2.0.0-beta.18
    - wry [RUST]: 0.41.0
    - tao [RUST]: 0.28.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.12
    - @tauri-apps/cli [NPM]: 2.0.0-beta.12

[-] App
    - build-type: bundle
    - CSP: default-src * filesystem: data: blob: stream: tauri: ipc: asset:
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

Legend-Master commented 1 week ago

I can't reproduce this (tested with size setting to the monitor size but didn't record that one), but I did find another bug which might be causing this

https://github.com/tauri-apps/tauri/assets/68118705/ec472e0a-e1af-4457-bb1c-5c5b570bd3cb

kingyang commented 1 week ago

@Legend-Master
Thank you for your reply

const screenWindow=new __TAURI__.webviewWindow.WebviewWindow("temp",{
    alwaysOnTop: true,
    decorations: false,
    resizable: false,
    shadow: false,
    skipTaskbar: true,
    transparent: true,
    url:"https://example.com"
});
screenWindow.once('tauri://created', async () => {
  screenWindow.setPosition(new __TAURI__.dpi.PhysicalPosition(0, 0))
  screenWindow.setSize(new __TAURI__.dpi.PhysicalSize(600, 1000))
 })
// screenWindow devtools
document.onmousemove=console.debug

I test mousemove mousedown mouseup ...

https://github.com/tauri-apps/tauri/assets/1540211/0f37f77b-a06f-4602-a027-baabf1d2a931

Legend-Master commented 1 week ago

I can't reproduce it with mouse move event either, don't know if it's related but you can try #10211 and see if that fixes it

https://github.com/tauri-apps/tauri/assets/68118705/1a199567-72ee-4552-9426-e9d1589ddfc6

kingyang commented 1 week ago

Could you please help me test my mouse trajectory? When I tested it, the mouse moved along the left edge and the top edge of the screen. It can be observed that when moving along the left edge, the minimum value of screenX is 8, and similarly, when moving along the top edge, the minimum value of screenY is 8. (In my previous video, I didn't test the right edge and the bottom edge).

Legend-Master commented 1 week ago

Left and top edges are the same as right and bottom on my machine, all working just fine

kingyang commented 1 week ago

I forgot to mention that the parent window also has decorations=false. However, I tested this, and it doesn't seem to be related.

But it is indeed related to decorations:false.

As for #10211, I commented out the dynamic setting, and it can still be stably reproduced.

const screenWindow=new __TAURI__.webviewWindow.WebviewWindow("temp",{
    alwaysOnTop: true,
    decorations: false,
    resizable: true,
    shadow: false,
    skipTaskbar: true,
    transparent: true,
    url:"https://example.com"
});
// Comment the code below
//screenWindow.once('tauri://created', async () => {
//  screenWindow.setPosition(new __TAURI__.dpi.PhysicalPosition(0, 0))
//  screenWindow.setSize(new __TAURI__.dpi.PhysicalSize(600, 1000))
// })

Could it be related to the environment?

Legend-Master commented 1 week ago

Might be, I'm on Windows 10 and I think you're on 11? I don't have a Windows 11 device right now so I can't test it

kingyang commented 1 week ago

I reviewed the reproduction process again. It might be related to the tauri_plugin_window_state plugin. The issue occurs when this plugin is enabled (my previous tests were conducted with this plugin enabled). Additionally, it happens on the second execution within the same "label".

const screenWindow=new __TAURI__.webviewWindow.WebviewWindow("temp3",{
    alwaysOnTop: true,
    decorations: false,
    resizable: false,
    shadow: false,
    skipTaskbar: true,
    transparent: true,
    url:"https://example.com"
});

https://github.com/tauri-apps/tauri/assets/1540211/ac316a67-9486-409f-a459-347b78b206ea

Legend-Master commented 1 week ago

In that case I would guess it's just https://github.com/tauri-apps/tauri/pull/10211

kingyang commented 1 week ago

Ok, thank you. I will close this issue for now.