tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
814 stars 224 forks source link

[window-state] Y Axis Drift #377

Open meanbeanmachine opened 1 year ago

meanbeanmachine commented 1 year ago

Using Pop!_OS 22.04 X64

What I did

-use basic tauri app example -add window-state plugin

The Problem

When the app is closed and then re-opened, the Y coordinate drifts +37 pixels. I thought this was a very strange number, but suspected what it might be. I took a screenshot of the app and opened GIMP, and sure enough, the title bar of the app is exactly 37 pixels in height. I'm not sure if this is a Linux issue but it seems the window-state plugin is not accounting for the title bar in some way, resulting in a compounding 37px drift every time the app is opened.

screenshot

mflorence99 commented 1 year ago

Using Ubuntu 22.04.2 LTS, I can confirm a similar situation:

What I did -use basic tauri app example -add window-state plugin

My Problem The window grows in height each time the app is closed then re-opened, leading me to the same conclusion as @meanbeanmachine.

Initially, I wasn't aware of this plugin, so I had rolled my own solution in Javascript, using appWindow.onResized() and appWindow.onMoved(). My code has exactly the same trouble. I found that appWindow.innerSize() and appWindow.outerSize() were returning identical values, and I believe that's a pointer to the root cause of the issue in the plugin.

FabianLars commented 1 month ago

Can one of you confirm whether this is still an issue? Especially interested in v2 but iirc both versions received a few changes that touched the size getters.

meanbeanmachine commented 4 weeks ago

Checked Tauri v2...Still drifts on the Y axis every run.

run1 run1

run2 run2

run3 run3

pewsheen commented 1 week ago

Looks like the gtk get position won't include the decoration's height. However, when setting (moving) the window, Gtk will move the whole frame (including the decoration) to the position.

pewsheen commented 1 week ago

It seems that setting window gravity to Static or SouthXXX can solve the issue, but I'm not sure what will be broken...