#Tauri remembers where the window was

66 messages ยท Page 1 of 1 (latest)

torn berry
fathom sonnet
#

are you use the latest tauri-plugin-window-state?
I am looked the code, it's restore position only when the saved monitor name is exists.

#

oh, the fix is not released yet, you could use it by directly specify the repo.
like replace original dep by this:

tauri-plugin-window-state = { git = "https://github.com/tauri-apps/tauri-plugin-window-state.git" }
torn berry
#

i will override the dependency probably

torn berry
#

Ok it still happens

#

@fathom sonnet so if you remove the main display and your second display becomes the main one it still happens

#

im checking what i can do, i have already some logs

#

remembered state: Some(WindowMetadata { width: 800.0, height: 600.0, x: -888, y: 234, maximized: false, visible: true, decorated: true, fullscreen: false, monitor: "\\\\.\\DISPLAY2" })
original available monitors: Map { iter: Iter([Monitor { name: Some("\\\\.\\DISPLAY1"), size: PhysicalSize { width: 1920, height: 1080 }, position: PhysicalPosition { x: 0, y: 0 }, scale_factor: 1.0 }, Monitor { name: Some("\\\\.\\DISPLAY2"), size: PhysicalSize { width: 1080, height: 1920 }, position: PhysicalPosition { x: -1080, y: -408 }, scale_factor: 1.0 }]) } is \\.\DISPLAY2

#

me after removing the main monitor: Map { iter: Iter([Monitor { name: Some("\\\\.\\DISPLAY2"), size: PhysicalSize { width: 1920, height: 1080 }, position: PhysicalPosition { x: 0, y: 0 }, scale_factor: 1.0 }]) } is \\.\DISPLAY2

fathom sonnet
#

umm. maybe because it only check monitor name, not checking monitor size

torn berry
#

yeah

#

we might need to save all the information of the original monitor because the name is not enough :c

fathom sonnet
#

but in the logs, it shouldn't happen because size and scale_factor are all same between two monitors

torn berry
#

size isnt the same in my case

#

but it still would happen with same size

#

because position changes

fathom sonnet
#

umm, I think I understand it.

torn berry
#

yeah

#

its not that complicated of an issue

#

i will modify the code and make a PR then

#

gotta add a new struct about each monitor sadly

#

might make it a new field so it doesnt break semver

#

or idk

#

let me see xd

fathom sonnet
#

I think you could check the saved position is or not in the monitor

torn berry
#

yeah

#

what happens if there is a monitor res change?

#

it goes outside it, no?

fathom sonnet
#

I think no

torn berry
#

yeah there are no checks lmao

#

just replaces the physical position of the window

fathom sonnet
torn berry
#

yeah will do

#

and also res check

fathom sonnet
#

I think res check is covered in the position check

torn berry
#

hm

#

yeah you might be right

#

unless we are talking about the main monitor

#

because its position is always 0 0

#

the other monitors will change position when they have a res change

fathom sonnet
#
for m in self.available_monitors()? {
  if m.name().map(ToString::to_string).unwrap_or_default() != state.monitor {
    continue;
  }
  // psudocodes
  if state.x < m.position.x || state.y < m.position.y || state.x > m.position.x + m.size.width || state.x > m.position.y + m.size.height {
    continue;
  }
  // end psudocode
  self.set_position(PhysicalPosition {
    x: state.x,
    y: state.y,
  })?;
  break;
}
#

like this

#

maybe need to subtract some width and height base on window size

fathom sonnet
#

or

if state.x < m.position.x || state.y < m.position.y || state.x + state.width > m.position.x + m.size.width || state.y + state.height > m.position.y + m.size.height {
    continue;
  }
torn berry
#

it should break instead of continuing the loop

#

because it already found the monitor

#

but yeah i catch the idea

fathom sonnet
#

continue because those is check "is not the original name" and check "is outside monitor space"

knotty vapor
torn berry
#

@knotty vapor if you can pls archive the other repo

#

and edit the readme linking to the new repo

#

:p

#

i was gonna make the PR when i have time

knotty vapor
#

@vagrant lily wdyt?

vagrant lily
torn berry
knotty vapor
torn berry
#

welp

#

the pr got merged

#

nice

knotty vapor
#

It took a different approach though, would be great if you can test and let us know if that fixes your issue @torn berry

torn berry
#

i didnt test it but i suspect it works

#

i read the code :p

knotty vapor
#

If it doesn't you can open an issue on the repo there, make a bugreport :]