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

[window-state] Does not work with custom titlebar (appWindow.close) #254

Closed
AllanChain opened this issue Oct 6, 2021 · 5 comments · Fixed by #309
Closed

[window-state] Does not work with custom titlebar (appWindow.close) #254

AllanChain opened this issue Oct 6, 2021 · 5 comments · Fixed by #309

Comments

@AllanChain
Copy link

When I close the app with appWindow.close and reopen the app, the window position is not preserved.

It seems that closing app with appWindow.close does not trigger a CloseRequested event, so the state is not read.

If I close the window with system titlebar and reopen the app, the window position is preserved. So I can confirm it's about appWindow.close.

@nothingismagick
Copy link
Sponsor Member

this is great to know, however we need to know about the results of tauri info please.

@AllanChain
Copy link
Author

AllanChain commented Oct 7, 2021

Edited I was using pnpm as package manager, tauri info does not work. Expand to see details.
 app:spawn Running "D:\Desktop\Program\Repo\taulock\node_modules\.pnpm\@tauri-apps+cli@1.0.0-beta.10\node_modules\@tauri-apps\cli\bin\tauri-cli.exe tauri info" +0ms


Operating System - Windows, version 10.0.22000 X64
Webview2 - 94.0.992.31

Node.js environment
  Node.js - 14.16.1
  @tauri-apps/cli - 1.0.0-beta.10
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unexpected character 't' while parsing major version number")', src\info.rs:323:53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  @tauri-apps/api - tauri-apps
 app:spawn Command "D:\Desktop\Program\Repo\taulock\node_modules\.pnpm\@tauri-apps+cli@1.0.0-beta.10\node_modules\@tauri-apps\cli\bin\tauri-cli.exe" failed with exit code: 101 +1ms

And part of package.json:

"@tauri-apps/cli": "^1.0.0-beta.10",
"@tauri-apps/api": "^1.0.0-beta.8",

Cargo.toml:

[build-dependencies]
tauri-build = { version = "1.0.0-beta.3" }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
# tauri = { version = "1.0.0-beta.8", features = ["window-all"] }
[dependencies.tauri]
git = "https://github.com/tauri-apps/tauri/"
branch = "next"
features = ["window-all"]
[dependencies.tauri-plugin-window-state]
git = "https://github.com/tauri-apps/tauri-plugin-window-state"
branch = "dev"

And here is the output after switching to npm:

Downloading Rust CLI...
Download Complete
 app:spawn Running "D:\Desktop\Program\Repo\taulock\node_modules\@tauri-apps\cli\bin\tauri-cli.exe tauri info" +0ms


Operating System - Windows, version 10.0.22000 X64
Webview2 - 94.0.992.31

Node.js environment
  Node.js - 14.16.1
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 7.23.0
  yarn - 1.22.10

Rust environment
  rustc - 1.55.0
  cargo - 1.55.0

App directory structure
/.git
/dist
/node_modules
/public
/src
/src-tauri

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - target/webpack_dist
  devPath - target/webpack_dist
  framework - Vue.js (Vue CLI)
  bundler - Webpack

@lucasfernog
Copy link
Member

pnpm will be fixed on the next Tauri release.
I'll fix this issue, thanks for reporting it.

@FabianLars FabianLars transferred this issue from tauri-apps/tauri-plugin-window-state Feb 15, 2023
@FabianLars FabianLars changed the title Does not work with custom titlebar (appWindow.close) [window-state] Does not work with custom titlebar (appWindow.close) Feb 15, 2023
@jzillmann
Copy link

Still facing this.

  • Using cmd-q for close: ✅ works

  • Clicking the custom titlebar close (appWindow.close): ❗ window state is not memorized

  • tauri version: 1.2.4

  • tauri-plugin-window-state

version = "0.1.0"
source = "git+https://github.com/tauri-apps/plugins-workspace?branch=dev#cea1d4f7b54b94354e8100daf804b810c680efd7"

@FabianLars
Copy link
Member

FabianLars commented Apr 11, 2023

Issue was reintroduced in #104 - not mentioned in this PR but i think we also had complains about slightly degraded performance with the "fixed" approach 🤔

Edit: I think it was this one: #77

@FabianLars FabianLars reopened this Apr 11, 2023
FabianLars added a commit that referenced this issue Apr 17, 2023
* feat(window-state): add js api, closes #254

* symlink tsconfig.json

* update symlink

* Update plugins/window-state/package.json

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>

* Update Cargo.toml

* move to cmd.rs

* Update plugins/window-state/guest-js/index.ts

---------

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
OrIOg pushed a commit to OrIOg/plugins-workspace that referenced this issue Jun 25, 2023
* feat(window-state): add js api, closes tauri-apps#254

* symlink tsconfig.json

* update symlink

* Update plugins/window-state/package.json

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>

* Update Cargo.toml

* move to cmd.rs

* Update plugins/window-state/guest-js/index.ts

---------

Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants