Compare commits

...
4 Commits
Author SHA1 Message Date
haraldandClaude Opus 5.5 d610ca019a chore(release): bump version to 0.39.1
Build & Publish Release / Build Packages & Publish to Gitea (push) In progress
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:46:13 +01:00
haraldandClaude Opus 5.5 8034c88f8b fix(windows): don't let Windows Ink report the mouse as a pen (Issue #48)
octotablet's default emulates a pen tool from the mouse on Windows Ink, so
every mouse move counted as pen hover and every click as pen down, while the
regular mouse events were ignored as duplicates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:44:42 +01:00
haraldandClaude Opus 5.5 1492f8affb chore(release): bump version to 0.39.0
Build & Publish Release / Build Packages & Publish to Gitea (push) Successful in 18m6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:16:45 +01:00
haraldandClaude Opus 5.5 e5a8601f87 feat: Windows build and Android groundwork (Issues #48, #42)
Shared groundwork:
- paths.rs: folders for data, settings and downloads per system (Linux XDG
  unchanged, Windows %APPDATA%/%LOCALAPPDATA%, Android app folder)
- Linux-only parts behind cfg: Wayland on-screen keyboard (osk/wayland.rs),
  display backend and app id, the vendored winit touch extensions
- run_with(event_loop) so that other entry points can start the app

Windows (#48):
- cross-compiled with MinGW into a portable ink-notes_<version>_x86_64.exe
  (system DLLs only), no console window in release builds
- file picker: user folders and drives; held notebook locks are detected
  (ERROR_LOCK_VIOLATION)
- updater: replaces the running .exe via rename, active at the next start
- octotablet panicking without the Tablet PC components no longer crashes
  the app
- release: .exe built in CI and part of the signed checksums
- all library tests pass under wine

Android (#42):
- android_main entry point, winit with android-native-activity,
  android_logger; octotablet and arboard left out there
- cargo check and the cdylib build for aarch64-linux-android pass; the window
  surface does not follow the activity lifecycle yet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:13:37 +01:00
29 changed files with 790 additions and 272 deletions

No files matched your search

+2 -1
View File
@@ -35,6 +35,7 @@ jobs:
libxrandr-dev \
libxi-dev \
libxkbcommon-dev \
gcc-mingw-w64-x86-64 \
squashfs-tools \
dpkg-dev \
curl \
@@ -62,7 +63,7 @@ jobs:
cargo clippy --all-targets -- -D warnings
cargo test
- name: Build Release Artifacts (.deb, .AppImage, SHA256SUMS.txt + .minisig)
- name: Build Release Artifacts (.deb, .AppImage, .exe, SHA256SUMS.txt + .minisig)
run: |
chmod +x scripts/*.sh
./scripts/build-release.sh
Generated
+30 -1
View File
@@ -85,6 +85,24 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android_log-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d"
[[package]]
name = "android_logger"
version = "0.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f"
dependencies = [
"android_log-sys",
"env_logger",
"log",
"once_cell",
]
[[package]]
name = "android_system_properties"
version = "0.1.6"
@@ -699,6 +717,15 @@ dependencies = [
"syn 2.0.119",
]
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"log",
]
[[package]]
name = "epaint"
version = "0.27.2"
@@ -1411,9 +1438,10 @@ dependencies = [
[[package]]
name = "ink-notes"
version = "0.38.0"
version = "0.39.1"
dependencies = [
"ab_glyph",
"android_logger",
"arboard",
"base64",
"bytemuck",
@@ -1426,6 +1454,7 @@ dependencies = [
"hayro",
"hayro-svg",
"image",
"log",
"minisign-verify",
"naga",
"octotablet",
+23 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "ink-notes"
version = "0.38.0"
version = "0.39.1"
edition = "2021"
description = "Notizbuch-App für Stift, Touch und Maus unter Linux"
repository = "https://gitea.pansi.eu/harald/ink-notes"
@@ -38,11 +38,9 @@ semver = "1.0"
sha2 = "0.10"
ureq = { version = "2.10", default-features = false, features = ["tls", "gzip", "json"] }
url = "2.5"
octotablet = "0.1.0"
# Bilder einfügen: Dekodieren (PNG/JPEG/GIF/WebP/BMP) und Systemzwischenablage
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp"] }
arboard = { version = "3", default-features = false, features = ["image-data"] }
minisign-verify = "0.3.0"
fs2 = "0.4"
hayro = "0.8"
@@ -58,11 +56,33 @@ resvg = { version = "0.49", default-features = false, features = ["raster-images
# Text-Werkzeug: Schriftmetriken und Rasterung (Schriften aus egui)
ab_glyph = "0.2"
# Pen input with pressure on Linux (Wayland/X11) and Windows (Windows Ink)
[target.'cfg(not(target_os = "android"))'.dependencies]
octotablet = "0.1.0"
# Systemzwischenablage (Bilder und Text)
arboard = { version = "3", default-features = false, features = ["image-data"] }
# Bildschirmtastatur unter Wayland anfordern (eigenes text-input-Objekt, siehe src/osk.rs)
[target.'cfg(target_os = "linux")'.dependencies]
wayland-client = "0.31"
wayland-backend = { version = "0.3", features = ["client_system"] }
wayland-protocols = { version = "0.31", features = ["client", "unstable"] }
# Android (Issue #42): winit bound to the native activity. The library is built as
# cdylib with `cargo rustc --lib --crate-type cdylib --target aarch64-linux-android`
[target.'cfg(target_os = "android")'.dependencies]
winit = { version = "0.29", features = ["rwh_06", "android-native-activity"] }
android_logger = { version = "0.13", default-features = false }
log = "0.4"
[package.metadata.android]
package = "eu.pansi.inknotes"
apk_name = "ink-notes"
[package.metadata.android.sdk]
min_sdk_version = 26
target_sdk_version = 34
[profile.dev]
opt-level = 1 # Erhöht Rendering-Performance auch im Debug-Modus
+10 -3
View File
@@ -13,7 +13,7 @@
ink-notes speichert Handschrift als Vektoren, erkennt auf Wunsch Formen, kann PDFs zum Beschriften sowie Notizbücher aus Xournal++, Rnote und Saber importieren, Bilder und Textfelder einfügen und alles wieder als PDF, PNG oder SVG exportieren. Gespeichert wird automatisch im Hintergrund.
Getestet wird vor allem unter Zorin OS 18 / Ubuntu 24.04 (Wayland und X11).
Getestet wird vor allem unter Zorin OS 18 / Ubuntu 24.04 (Wayland und X11). Eine Windows-Version gibt es als experimentelles portables Programm.
Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemsprache, umstellen lässt sie sich im ☰-Menü unter „Sprache / Language“.
@@ -87,7 +87,7 @@ Die Oberfläche gibt es auf Deutsch und Englisch; ink-notes folgt der Systemspra
## Installation
Pakete gibt es unter [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) als `.deb` und `.AppImage` (x86_64). `<version>` steht für die Versionsnummer, z. B. `0.11.0`.
Pakete gibt es unter [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) als `.deb`, `.AppImage` und für Windows als `.exe` (x86_64). `<version>` steht für die Versionsnummer, z. B. `0.11.0`.
```bash
# Debian-Paket (Zorin OS 18 / Ubuntu 24.04)
@@ -102,6 +102,8 @@ Hinweise:
- Benötigt `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) und einen Grafiktreiber mit Vulkan oder OpenGL.
- Meldet das AppImage einen Fehler zu `libfuse.so.2`, entweder `sudo apt install libfuse2t64` installieren oder mit `--appimage-extract-and-run` starten.
**Windows (experimentell):** `ink-notes_<version>_x86_64.exe` ist ein portables Programm für Windows 10/11 – ohne Installation einfach starten (Windows SmartScreen fragt evtl. einmal nach, da das Programm nicht signiert ist). Stifteingabe mit Druck läuft über Windows Ink (noch nicht auf echter Hardware getestet). Notizbücher und Einstellungen liegen in `%APPDATA%\ink-notes`. Updates ersetzen die `.exe` an Ort und Stelle und gelten ab dem nächsten Start.
---
## Tastenkürzel
@@ -152,6 +154,10 @@ cargo test # Unit- und Integrationstests
Die CI prüft zusätzlich `cargo fmt --check` und `cargo clippy --all-targets -- -D warnings`.
Andere Systeme:
- **Windows** wird unter Linux übersetzt: `scripts/package-windows.sh` (braucht `gcc-mingw-w64-x86-64`); die Tests laufen mit `wine` als Runner (`CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine cargo test --target x86_64-pc-windows-gnu`).
- **Android** (in Arbeit, Issue #42): `cargo check --target aarch64-linux-android` und `cargo rustc --lib --crate-type cdylib --target aarch64-linux-android` mit dem NDK-Compiler in `CC_aarch64_linux_android`. Dort startet die App noch nicht: Die Fensterfläche muss erst dem Lebenszyklus der Activity folgen.
### Projektstruktur
```text
@@ -187,7 +193,8 @@ src/
├── page_export.rs # Seite als PNG/SVG, Auswahl als Bild
├── file_picker.rs # Eingebaute Dateiauswahl
├── settings.rs # Einstellungen (~/.config/ink-notes/ui.json)
├── platform.rs # Wayland/X11-Erkennung
├── platform.rs # Wayland/X11-Erkennung, Unterschiede zwischen Linux, Windows und Android
├── paths.rs # Ordner für Daten, Einstellungen und Downloads je System
├── updater.rs # Updates von Gitea (Signatur- und Prüfsummenprüfung)
└── ui.rs # Oberfläche (egui): Werkzeugleiste, Menüs, Dialoge
```
+10 -3
View File
@@ -13,7 +13,7 @@
ink-notes stores handwriting as vectors, can recognize shapes, imports PDFs for annotation as well as Xournal++, Rnote and Saber notebooks, inserts images and text boxes, and exports everything again as PDF, PNG or SVG. Saving happens automatically in the background.
It is mainly tested on Zorin OS 18 / Ubuntu 24.04 (Wayland and X11).
It is mainly tested on Zorin OS 18 / Ubuntu 24.04 (Wayland and X11). A Windows version is available as an experimental portable program.
The interface is available in English and German; ink-notes follows the system language, and you can switch it in the ☰ menu under "Sprache / Language".
@@ -87,7 +87,7 @@ The interface is available in English and German; ink-notes follows the system l
## Installation
Packages are available under [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) as `.deb` and `.AppImage` (x86_64). `<version>` stands for the version number, e.g. `0.30.2`.
Packages are available under [Releases](https://gitea.pansi.eu/harald/ink-notes/releases) as `.deb`, `.AppImage` and for Windows as `.exe` (x86_64). `<version>` stands for the version number, e.g. `0.30.2`.
```bash
# Debian package (Zorin OS 18 / Ubuntu 24.04)
@@ -102,6 +102,8 @@ Notes:
- Requires `glibc >= 2.39` (Ubuntu 24.04, Zorin OS 18) and a graphics driver with Vulkan or OpenGL.
- If the AppImage reports an error about `libfuse.so.2`, either install `sudo apt install libfuse2t64` or start it with `--appimage-extract-and-run`.
**Windows (experimental):** `ink-notes_<version>_x86_64.exe` is a portable program for Windows 10/11 – no installation, just start it (Windows SmartScreen may ask once, as the program is not signed). Pen input with pressure uses Windows Ink (not yet tested on real hardware). Notebooks and settings are stored in `%APPDATA%\ink-notes`. Updates replace the `.exe` in place and take effect at the next start.
---
## Keyboard shortcuts
@@ -152,6 +154,10 @@ cargo test # unit and integration tests
CI additionally checks `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings`.
Other systems:
- **Windows** is cross-compiled on Linux: `scripts/package-windows.sh` (needs `gcc-mingw-w64-x86-64`); the tests run with `wine` as runner (`CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine cargo test --target x86_64-pc-windows-gnu`).
- **Android** (in progress, Issue #42): `cargo check --target aarch64-linux-android` and `cargo rustc --lib --crate-type cdylib --target aarch64-linux-android` with the NDK compiler in `CC_aarch64_linux_android`. The app does not start there yet: the window surface still has to follow the activity lifecycle.
New code comments and commit messages are written in English; older code and history still contain German.
### Project structure
@@ -189,7 +195,8 @@ src/
├── page_export.rs # Page as PNG/SVG, selection as image
├── file_picker.rs # Built-in file picker
├── settings.rs # Settings (~/.config/ink-notes/ui.json)
├── platform.rs # Wayland/X11 detection
├── platform.rs # Wayland/X11 detection, differences between Linux, Windows and Android
├── paths.rs # Folders for data, settings and downloads per system
├── updater.rs # Updates from Gitea (signature and checksum verification)
└── ui.rs # Interface (egui): toolbar, menus, dialogs
```
+2
View File
@@ -29,6 +29,8 @@ Dieses Dokument beschreibt, wo und wie ink-notes Notizbücher speichert, und die
~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) Einstellungen der Oberfläche
```
Unter Windows liegt dieselbe Struktur in `%APPDATA%\ink-notes` (Notizbücher, `recovery`, `ui.json`); heruntergeladene Updates landen in `%LOCALAPPDATA%\ink-notes`.
Der Ordner `notebooks/` lässt sich in den Einstellungen verlegen (`storage_dir` in `ui.json`), z. B. nach `~/Nextcloud/ink-notes`; `recovery/` bleibt, wo es ist.
- **Notizbuch-IDs** werden aus dem Titel und dem Zeitpunkt gebildet (z. B. `mathematik_1775460000`); das erste Notizbuch heißt `default`.
+2
View File
@@ -29,6 +29,8 @@ This document describes where and how ink-notes stores notebooks, and the versio
~/.config/ink-notes/ui.json ($XDG_CONFIG_HOME) interface settings
```
On Windows the same structure lies in `%APPDATA%\ink-notes` (notebooks, `recovery`, `ui.json`); downloaded updates go to `%LOCALAPPDATA%\ink-notes`.
The folder `notebooks/` can be moved elsewhere in the settings (`storage_dir` in `ui.json`), e.g. to `~/Nextcloud/ink-notes`; `recovery/` stays where it is.
- **Notebook IDs** are built from the title and the time (e.g. `mathematik_1775460000`); the first notebook is called `default`.
+10
View File
@@ -84,6 +84,16 @@
</branding>
<content_rating type="oars-1.1" />
<releases>
<release version="0.39.1" date="2026-10-27">
<description>
<p>Windows: the mouse works again; Windows Ink no longer reports it as a pen.</p>
</description>
</release>
<release version="0.39.0" date="2026-10-27">
<description>
<p>First experimental Windows version as a portable program. Internal groundwork for Android; nothing changes on Linux.</p>
</description>
</release>
<release version="0.38.0" date="2026-10-27">
<description>
<p>The notebooks can be stored in a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox. Changes from other devices are taken over automatically, conflict copies become pages of their own, and a warning appears when a notebook is open on another device.</p>
+39
View File
@@ -116,6 +116,32 @@
"dest": "cargo/vendor/android-properties-0.2.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/android_log-sys/android_log-sys-0.3.2.crate",
"sha256": "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d",
"dest": "cargo/vendor/android_log-sys-0.3.2"
},
{
"type": "inline",
"contents": "{\"package\": \"84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d\", \"files\": {}}",
"dest": "cargo/vendor/android_log-sys-0.3.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/android_logger/android_logger-0.13.3.crate",
"sha256": "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f",
"dest": "cargo/vendor/android_logger-0.13.3"
},
{
"type": "inline",
"contents": "{\"package\": \"c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f\", \"files\": {}}",
"dest": "cargo/vendor/android_logger-0.13.3",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
@@ -1013,6 +1039,19 @@
"dest": "cargo/vendor/enum_dispatch-0.3.13",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
"url": "https://static.crates.io/crates/env_logger/env_logger-0.10.2.crate",
"sha256": "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580",
"dest": "cargo/vendor/env_logger-0.10.2"
},
{
"type": "inline",
"contents": "{\"package\": \"4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580\", \"files\": {}}",
"dest": "cargo/vendor/env_logger-0.10.2",
"dest-filename": ".cargo-checksum.json"
},
{
"type": "archive",
"archive-type": "tar-gzip",
+10
View File
@@ -84,6 +84,16 @@
</branding>
<content_rating type="oars-1.1" />
<releases>
<release version="0.39.1" date="2026-10-27">
<description>
<p>Windows: the mouse works again; Windows Ink no longer reports it as a pen.</p>
</description>
</release>
<release version="0.39.0" date="2026-10-27">
<description>
<p>First experimental Windows version as a portable program. Internal groundwork for Android; nothing changes on Linux.</p>
</description>
</release>
<release version="0.38.0" date="2026-10-27">
<description>
<p>The notebooks can be stored in a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox. Changes from other devices are taken over automatically, conflict copies become pages of their own, and a warning appears when a notebook is open on another device.</p>
+2
View File
@@ -3,6 +3,8 @@
Notebook app for pen, touch and mouse on Linux (tested on Zorin OS 18 / Ubuntu 24.04).
### Highlights:
- **Windows mouse fix**: The mouse works normally again in the Windows version – Windows Ink reported it as a pen, so clicks and moves went the wrong way. Nothing changes on Linux
- **Windows (experimental)**: `ink-notes_<version>_x86_64.exe` is a portable program for Windows 10/11 – just start it, no installation. Notebooks and settings are stored in `%APPDATA%\ink-notes`, pen input uses Windows Ink, updates replace the `.exe` and take effect at the next start. Not yet tested on real tablet hardware – feedback welcome. Nothing changes on Linux; internally the groundwork for an Android version was laid
- **Sync between devices**: ☰ → Storage location puts the notebooks into a folder synced by Nextcloud, Google Drive, Syncthing or Dropbox (existing notebooks are copied, the originals stay). Changes from other devices show up within seconds while everything local is saved, conflict copies of the sync client become pages of their own, and opening a notebook that is open on another device shows a warning
- **Import from Saber**: ☰ → Import (or dragging the file into the window) now also opens Saber notebooks (`.sbn2` with its asset files next to it, `.sba` archives, old `.sbn`) – strokes with pen pressure, highlighters, shapes, typed text, images and PDF backgrounds
- **Import from Xournal++ and Rnote**: ☰ → Import (or dragging the file into the window) now also opens Xournal++ (`.xopp`, `.xoj`) and Rnote (`.rnote`) notebooks as new notebooks – strokes with pen pressure, highlighters, shapes, texts, images, paper patterns and Xournal++ PDF backgrounds; PDF pages imported in Rnote become images, infinite Rnote documents an endless notebook
+9 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# ==============================================================================
# Haupt-Release-Build-Skript für ink-notes (Zorin OS 18 / Linux)
# Erstellt .deb, .AppImage, SHA256-Prüfsummen und deren Minisign-Signatur in target/
# Erstellt .deb, .AppImage, Windows-.exe, SHA256-Prüfsummen und deren Minisign-Signatur in target/
# ==============================================================================
set -euo pipefail
@@ -13,6 +13,7 @@ cd "${ROOT_DIR}"
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
DEB_NAME="ink-notes_${VERSION}_amd64.deb"
APPIMAGE_NAME="ink-notes_${VERSION}_x86_64.AppImage"
EXE_NAME="ink-notes_${VERSION}_x86_64.exe"
CHECKSUM_FILE="SHA256SUMS.txt"
echo "======================================================================"
@@ -25,12 +26,15 @@ echo "======================================================================"
# 2. AppImage bauen (.AppImage)
"${SCRIPT_DIR}/package-appimage.sh"
# 3. Checksums berechnen
# 3. Portable Windows program (.exe)
"${SCRIPT_DIR}/package-windows.sh"
# 4. Checksums berechnen
echo "=== Berechne SHA256-Prüfsummen in target/${CHECKSUM_FILE} ==="
cd "${ROOT_DIR}/target"
sha256sum "${DEB_NAME}" "${APPIMAGE_NAME}" > "${CHECKSUM_FILE}"
sha256sum "${DEB_NAME}" "${APPIMAGE_NAME}" "${EXE_NAME}" > "${CHECKSUM_FILE}"
# 4. Prüfsummen signieren (Pflicht für In-App-Updates)
# 5. Prüfsummen signieren (Pflicht für In-App-Updates)
# Signiert wird mit rsign2 (minisign-kompatibles Format): Der Schlüssel wurde mit
# `rsign generate -W` erzeugt; das minisign-CLI kann ihn ohne Terminal nicht laden.
SIGNATURE_FILE="${CHECKSUM_FILE}.minisig"
@@ -73,7 +77,7 @@ fi
echo "======================================================================"
echo "Release-Artefakte für v${VERSION} erfolgreich erstellt:"
echo "======================================================================"
ls -lh "${DEB_NAME}" "${APPIMAGE_NAME}" "${CHECKSUM_FILE}"
ls -lh "${DEB_NAME}" "${APPIMAGE_NAME}" "${EXE_NAME}" "${CHECKSUM_FILE}"
if [ -f "${SIGNATURE_FILE}" ]; then ls -lh "${SIGNATURE_FILE}"; fi
echo ""
echo "Inhalt von target/${CHECKSUM_FILE}:"
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# ==============================================================================
# Builds the portable Windows program target/ink-notes_<version>_x86_64.exe (Issue #48)
# by cross-compiling on Linux. Needs the MinGW-w64 compiler
# (Debian/Ubuntu: gcc-mingw-w64-x86-64) for the C parts of the dependencies.
# ==============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${ROOT_DIR}"
TARGET="x86_64-pc-windows-gnu"
VERSION=$(grep -m1 '^version = ' Cargo.toml | cut -d '"' -f2)
EXE_NAME="ink-notes_${VERSION}_x86_64.exe"
if ! command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1; then
echo "FEHLER: x86_64-w64-mingw32-gcc nicht gefunden (Paket gcc-mingw-w64-x86-64)."
exit 1
fi
if command -v rustup >/dev/null 2>&1; then
rustup target add "${TARGET}"
fi
echo "=== Baue ${EXE_NAME} ==="
cargo build --release --target "${TARGET}"
cp "${CARGO_TARGET_DIR:-target}/${TARGET}/release/ink-notes.exe" "target/${EXE_NAME}"
ls -lh "target/${EXE_NAME}"
+4 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# ==============================================================================
# Veröffentlicht ein Release auf dem Gitea-Server (gitea.pansi.eu)
# Lädt .deb, .AppImage, SHA256SUMS.txt und SHA256SUMS.txt.minisig idempotent als Release-Assets hoch.
# Lädt .deb, .AppImage, .exe, SHA256SUMS.txt und SHA256SUMS.txt.minisig idempotent als Release-Assets hoch.
# ==============================================================================
set -euo pipefail
@@ -32,6 +32,7 @@ RELEASE_TITLE="ink-notes ${TAG_NAME}"
DEB_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_amd64.deb"
APPIMAGE_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_x86_64.AppImage"
EXE_FILE="${ROOT_DIR}/target/ink-notes_${VERSION}_x86_64.exe"
CHECKSUMS_FILE="${ROOT_DIR}/target/SHA256SUMS.txt"
SIGNATURE_FILE="${CHECKSUMS_FILE}.minisig"
TEMPLATE_FILE="${ROOT_DIR}/packaging/release-notes.md.tmpl"
@@ -42,7 +43,7 @@ if [ ! -f "${TEMPLATE_FILE}" ]; then
fi
# Sicherstellen, dass die Artefakte existieren
if [ ! -f "${DEB_FILE}" ] || [ ! -f "${APPIMAGE_FILE}" ] || [ ! -f "${CHECKSUMS_FILE}" ]; then
if [ ! -f "${DEB_FILE}" ] || [ ! -f "${APPIMAGE_FILE}" ] || [ ! -f "${EXE_FILE}" ] || [ ! -f "${CHECKSUMS_FILE}" ]; then
echo "Artefakte nicht vollständig gefunden. Führe build-release.sh aus..."
"${SCRIPT_DIR}/build-release.sh"
fi
@@ -236,6 +237,7 @@ except Exception:
upload_asset "${DEB_FILE}"
upload_asset "${APPIMAGE_FILE}"
upload_asset "${EXE_FILE}"
upload_asset "${CHECKSUMS_FILE}"
upload_asset "${SIGNATURE_FILE}"
+61 -43
View File
@@ -3,6 +3,18 @@
//! notebook persistence (autosave). Lives in the library so that other entry points (e.g.
//! Android, Issue #42) can start it too.
// On Android the pen state is unused until pen input arrives there (Issue #44)
#![cfg_attr(
target_os = "android",
allow(
unused_mut,
unused_variables,
unused_assignments,
unused_imports,
dead_code
)
)]
use std::path::{Path, PathBuf};
use std::sync::mpsc::{self, Sender};
use std::sync::Arc;
@@ -11,10 +23,8 @@ use winit::{
event::{
ElementState, Event, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent,
},
event_loop::{ControlFlow, EventLoopBuilder},
event_loop::ControlFlow,
keyboard::{Key, ModifiersState, NamedKey},
platform::{wayland::EventLoopBuilderExtWayland, x11::EventLoopBuilderExtX11},
raw_window_handle::{HasDisplayHandle, RawDisplayHandle},
window::{Window, WindowBuilder},
};
@@ -31,7 +41,7 @@ use crate::image_layer::TextureSource;
use crate::library::Library;
use crate::osk::{self, KeyboardRequester};
use crate::pdf_doc::PdfRenderService;
use crate::platform::{self, DisplayBackend};
use crate::platform;
use crate::selection::{
render_selection_overlay, scale_factors, DragMode, SelectionHandleHit, SelectionState,
};
@@ -163,6 +173,7 @@ fn activate_tool(tool: ActiveTool, ui_state: &mut UiState, canvas: &mut CanvasSt
/// Kennung einer Stifttaste, die über Programmstarts hinweg gleich bleibt (die Tablet-
/// Schnittstelle liefert nur eine undurchsichtige, aber vergleichbare Kennung).
#[cfg(not(target_os = "android"))]
fn stylus_button_key(id: &octotablet::tool::ButtonID) -> u64 {
use std::hash::{Hash, Hasher};
// DefaultHasher::new() verwendet feste Schlüssel: gleiche Taste, gleicher Wert
@@ -523,7 +534,7 @@ impl Drop for SlowEventLog {
/// Zwischenablage: interne Objekte (Strg+C in ink-notes), Bilder aus der
/// Systemzwischenablage (Screenshots, aus anderen Programmen kopierte Bilder) und Text.
struct ClipboardBridge {
system: Option<arboard::Clipboard>,
system: Option<platform::clipboard::Clipboard>,
/// Prüfsumme des Systembildes zum Zeitpunkt des letzten internen Kopierens: Strg+V fügt
/// das Systembild nur ein, wenn es danach kopiert wurde (die jüngste Kopie gewinnt)
image_hash_at_copy: Option<[u8; 32]>,
@@ -544,9 +555,9 @@ impl ClipboardBridge {
}
/// Bild in der Systemzwischenablage samt Prüfsumme.
fn system_image(&mut self) -> Option<(arboard::ImageData<'static>, [u8; 32])> {
fn system_image(&mut self) -> Option<(platform::clipboard::ImageData<'static>, [u8; 32])> {
if self.system.is_none() {
self.system = arboard::Clipboard::new()
self.system = platform::clipboard::Clipboard::new()
.map_err(|e| eprintln!("[Zwischenablage] Nicht verfügbar: {e}"))
.ok();
}
@@ -563,7 +574,7 @@ impl ClipboardBridge {
/// Text in der Systemzwischenablage (nicht nur Leerraum).
fn system_text(&mut self) -> Option<String> {
if self.system.is_none() {
self.system = arboard::Clipboard::new().ok();
self.system = platform::clipboard::Clipboard::new().ok();
}
let text = self.system.as_mut()?.get_text().ok()?;
(!text.trim().is_empty()).then_some(text)
@@ -596,12 +607,12 @@ impl ClipboardBridge {
}
};
if self.system.is_none() {
self.system = arboard::Clipboard::new().ok();
self.system = platform::clipboard::Clipboard::new().ok();
}
let Some(system) = self.system.as_mut() else {
return false;
};
let data = arboard::ImageData {
let data = platform::clipboard::ImageData {
width: image.width as usize,
height: image.height as usize,
bytes: std::borrow::Cow::Owned(image.pixels),
@@ -1252,7 +1263,16 @@ fn insert_image_file(
}
/// Runs the app until the window is closed (the desktop entry point is `src/main.rs`).
#[cfg(not(target_os = "android"))]
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
// Anzeigesystem wählen: Unter WSL (WSLg) bricht Wayland ab, X11 (Xwayland) läuft stabil
run_with(platform::desktop_event_loop()?)
}
/// Runs the app on `event_loop` (desktop: [`run`], Android: `android_main` in `lib.rs`).
pub fn run_with(
event_loop: winit::event_loop::EventLoop<()>,
) -> Result<(), Box<dyn std::error::Error>> {
// Gespeicherte UI-Einstellungen; zuerst, damit alle Texte in der gewählten Sprache sind
let ui_settings_path = UiSettings::default_path();
let mut ui_settings = ui_settings_path
@@ -1261,20 +1281,6 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
.unwrap_or_default();
i18n::set_language(ui_settings.language.unwrap_or_else(Language::system));
// Anzeigesystem wählen: Unter WSL (WSLg) bricht Wayland ab, X11 (Xwayland) läuft stabil
let mut event_loop_builder = EventLoopBuilder::new();
match platform::display_backend_from_env() {
DisplayBackend::X11 => {
eprintln!("[Anzeige] Verwende X11 (unter WSL Standard; übersteuerbar mit INK_NOTES_DISPLAY=wayland)");
event_loop_builder.with_x11();
}
DisplayBackend::Wayland => {
eprintln!("[Anzeige] Verwende Wayland (INK_NOTES_DISPLAY=wayland)");
event_loop_builder.with_wayland();
}
DisplayBackend::Automatic => {}
}
let event_loop = event_loop_builder.build()?;
// App-Kennung wie die .desktop-Datei (eu.pansi.ink-notes): Daran ordnen Dock und Taskleiste
// das Fenster dem App-Symbol zu (Wayland: app_id, X11: WM_CLASS). Das Fenstersymbol selbst
// nutzt nur X11.
@@ -1282,10 +1288,7 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
.with_title("ink-notes")
.with_inner_size(winit::dpi::LogicalSize::new(1280.0, 850.0))
.with_window_icon(app_icon());
let builder =
winit::platform::wayland::WindowBuilderExtWayland::with_name(builder, APP_ID, "ink-notes");
let builder =
winit::platform::x11::WindowBuilderExtX11::with_name(builder, APP_ID, "ink-notes");
let builder = platform::with_app_id(builder, APP_ID);
let window = Arc::new(builder.build(&event_loop)?);
let mut canvas = match pollster::block_on(CanvasState::new(window.clone())) {
@@ -1296,25 +1299,36 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
}
};
let mut tablet_manager = match octotablet::builder::Builder::default().build_shared(&window) {
Ok(mgr) => {
// Android has no octotablet: the pen arrives as touch events there (Issue #44).
// octotablet panics on Windows without the Tablet PC components (RealTimeStylus not
// registered); the app then runs with mouse and touch events only
#[cfg(not(target_os = "android"))]
let tablet_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
// Windows Ink would otherwise report the mouse as a pen (Issue #48): every mouse
// move counted as pen hover, every click as pen down next to the normal mouse events
octotablet::builder::Builder::default()
.emulate_tool_from_mouse(false)
.build_shared(&window)
}));
#[cfg(not(target_os = "android"))]
let mut tablet_manager = match tablet_result {
Ok(Ok(mgr)) => {
println!("[Input] Octotablet Stylus-/Tablet-Manager erfolgreich initialisiert (Wayland/X11 Tablet-Protokoll aktiv).");
Some(mgr)
}
Err(err) => {
Ok(Err(err)) => {
println!("[Input] Hinweis: Octotablet Tablet-Manager nicht aktiv ({err}). Nutze Standard-Event-Pipeline.");
None
}
Err(_) => {
println!("[Input] Hinweis: Octotablet Tablet-Manager abgestürzt. Nutze Standard-Event-Pipeline.");
None
}
};
// Bildschirmtastatur (nur Wayland): eigenes text-input-Objekt, siehe osk.rs
let mut keyboard_requester = match window.display_handle().map(|handle| handle.as_raw()) {
// Safety: `window` lebt bis zum Ende von main, die Event-Schleife besitzt beide
Ok(RawDisplayHandle::Wayland(handle)) => {
Some(unsafe { KeyboardRequester::new(handle.display.as_ptr()) })
}
_ => None,
};
// Safety: `window` lives until the end of run(), the event loop owns both
let mut keyboard_requester = unsafe { KeyboardRequester::for_window(&window) };
let mut ime_was_active = false;
let mut ime_composing = false;
@@ -1515,6 +1529,7 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
// that touch it while the pen is near, are ignored until they are lifted
let mut palm_touch_ids: std::collections::HashSet<u64> = std::collections::HashSet::new();
let mut stylus_left_at: Option<Instant> = None;
#[cfg(not(target_os = "android"))]
let mut stylus_tool_id: Option<octotablet::tool::ID> = None;
// Gedrückte Stifttaste (Kennung, Belegung) und das Werkzeug, das während eines Strichs mit
// einer Werkzeug-Taste (Auswählen, Textmarker, Stift) vertreten wird
@@ -1695,7 +1710,10 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
}
// Stylus-/Tablet-Events via Octotablet abfragen (Wayland/X11 Tablet-Protokoll für aktive Stifte wie Lazarite)
#[cfg(not(target_os = "android"))]
if let Some(ref mut mgr) = tablet_manager {
// Infallible on Windows
#[allow(irrefutable_let_patterns)]
if let Ok(tablet_events) = mgr.pump() {
let scale = window.scale_factor() as f32;
let now = start_time.elapsed().as_secs_f64();
@@ -1744,8 +1762,7 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
pinch_prev_distance = None;
pinch_prev_center = None;
stylus_left_at = None;
#[cfg(target_os = "linux")]
winit::platform::wayland::ignore_decoration_touches_until(Some(
platform::ignore_decoration_touches_until(Some(
Instant::now() + Duration::from_secs(24 * 3600),
));
window.request_redraw();
@@ -1760,8 +1777,7 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
| octotablet::events::ToolEvent::Removed => {
if is_stylus_in_proximity {
stylus_left_at = Some(Instant::now());
#[cfg(target_os = "linux")]
winit::platform::wayland::ignore_decoration_touches_until(Some(
platform::ignore_decoration_touches_until(Some(
Instant::now() + PALM_GRACE,
));
}
@@ -3038,7 +3054,7 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
let handled_at = Instant::now();
let event_time = match touch.phase {
TouchPhase::Cancelled => None,
phase => winit::platform::wayland::take_touch_time(touch.id, phase),
phase => platform::take_touch_time(touch.id, phase),
};
if let (TouchPhase::Started, Some(time)) = (touch.phase, event_time) {
touch_clock = Some((handled_at, time));
@@ -4139,6 +4155,8 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
UiAction::InstallOrOpenUpdate(path) => {
if let Err(err) = updater.install_or_open(&path) {
ui_state.set_export_message(t!("Update-Fehler: {err}", err = err));
} else if matches!(updater.runtime(), crate::updater::RuntimeEnvironment::WindowsExe { .. }) {
ui_state.set_export_message(t!("Update installiert – gilt ab dem nächsten Start"));
} else {
ui_state.set_export_message(t!("Update gestartet / geöffnet"));
}
+3 -15
View File
@@ -690,21 +690,9 @@ impl AutosaveController {
/// Liefert das Verzeichnis für Notfall-Wiederherstellungsdateien ($XDG_DATA_HOME/ink-notes/recovery).
pub fn recovery_dir() -> PathBuf {
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {
if !xdg.is_empty() {
return PathBuf::from(xdg).join("ink-notes").join("recovery");
}
}
if let Ok(home) = std::env::var("HOME") {
if !home.is_empty() {
return PathBuf::from(home)
.join(".local")
.join("share")
.join("ink-notes")
.join("recovery");
}
}
PathBuf::from(".").join(".recovery")
crate::paths::data_dir()
.map(|d| d.join("recovery"))
.unwrap_or_else(|| PathBuf::from(".").join(".recovery"))
}
impl Drop for AutosaveController {
+9 -12
View File
@@ -56,19 +56,16 @@ pub fn default_documents_dir() -> PathBuf {
}
}
if let Ok(home) = std::env::var("HOME") {
if !home.trim().is_empty() {
let home = PathBuf::from(home);
let user_dirs =
std::fs::read_to_string(home.join(".config/user-dirs.dirs")).unwrap_or_default();
if let Some(dir) =
crate::file_picker::parse_user_dir(&user_dirs, "XDG_DOCUMENTS_DIR", &home)
.filter(|dir| *dir != home)
{
return dir;
}
return home.join("Documents");
if let Some(home) = crate::paths::home_dir() {
let user_dirs =
std::fs::read_to_string(home.join(".config/user-dirs.dirs")).unwrap_or_default();
if let Some(dir) =
crate::file_picker::parse_user_dir(&user_dirs, "XDG_DOCUMENTS_DIR", &home)
.filter(|dir| *dir != home)
{
return dir;
}
return home.join("Documents");
}
PathBuf::from(".")
+26 -1
View File
@@ -140,7 +140,7 @@ pub fn list_dir(dir: &Path, kind: PickerKind) -> std::io::Result<Vec<PickerEntry
/// mit den Ordnern aus `~/.config/user-dirs.dirs` (z. B. „Bilder“ statt „Pictures“). Die
/// Bezeichnungen sind deutsch, angezeigt werden sie mit `i18n::tr`.
pub fn shortcuts() -> Vec<(&'static str, PathBuf)> {
let Some(home) = std::env::var_os("HOME").map(PathBuf::from) else {
let Some(home) = crate::paths::home_dir() else {
return Vec::new();
};
let user_dirs =
@@ -162,6 +162,30 @@ pub fn shortcuts() -> Vec<(&'static str, PathBuf)> {
list.push((tn!("🖥 Schreibtisch"), p));
}
list.push((tn!("🏠 Persönlicher Ordner"), home));
// Drives (Windows has no single root)
#[cfg(windows)]
{
const DRIVES: [&str; 24] = [
"💽 C:", "💽 D:", "💽 E:", "💽 F:", "💽 G:", "💽 H:", "💽 I:", "💽 J:", "💽 K:",
"💽 L:", "💽 M:", "💽 N:", "💽 O:", "💽 P:", "💽 Q:", "💽 R:", "💽 S:", "💽 T:",
"💽 U:", "💽 V:", "💽 W:", "💽 X:", "💽 Y:", "💽 Z:",
];
// Looked up once: a disconnected network drive can take seconds to answer
static FOUND: std::sync::OnceLock<Vec<(&str, PathBuf)>> = std::sync::OnceLock::new();
let found = FOUND.get_or_init(|| {
DRIVES
.iter()
.map(|label| {
(
*label,
PathBuf::from(format!("{}\\", &label[label.len() - 2..])),
)
})
.filter(|(_, root)| root.is_dir())
.collect()
});
list.extend(found.iter().cloned());
}
list
}
@@ -254,6 +278,7 @@ mod tests {
}
#[test]
#[cfg(unix)]
fn test_parse_user_dirs() {
let home = Path::new("/home/anna");
let content = "# Kommentar\nXDG_DESKTOP_DIR=\"$HOME/Schreibtisch\"\nXDG_PICTURES_DIR=\"$HOME/Bilder\"\nXDG_MUSIC_DIR=\"/daten/Musik\"\n";
+5
View File
@@ -484,4 +484,9 @@ pub const EN: &[(&str, &str)] = &[
("✔ Diesen Ordner wählen", "✔ Choose this folder"),
("📁 Ändern …", "📁 Change …"),
("📁 Speicherort wählen", "📁 Choose storage location"),
("Update installiert – gilt ab dem nächsten Start", "Update installed – takes effect at the next start"),
("🔄 Update installieren", "🔄 Install update"),
("Konnte Backup ({path}) nicht anlegen: {e}. Update abgebrochen, altes Programm unverändert.", "Could not create backup ({path}): {e}. Update cancelled, old program unchanged."),
("Konnte Programm nicht ersetzen: {e}. Altes Programm bleibt unverändert.", "Could not replace the program: {e}. The old program stays unchanged."),
("Ungültiger Programmpfad.", "Invalid program path."),
];
+34
View File
@@ -18,6 +18,7 @@ pub mod import;
pub mod library;
pub mod osk;
pub mod page_export;
pub mod paths;
pub mod pdf_doc;
pub mod pdf_merge;
pub mod platform;
@@ -33,3 +34,36 @@ pub mod ui;
pub mod updater;
pub mod viewport;
pub mod xopp;
/// Entry point on Android (Issue #42), called by the native activity.
///
/// Builds with `cargo rustc --lib --crate-type cdylib --target aarch64-linux-android`. Not
/// usable yet: the window surface still has to be created on `Resumed` and dropped on
/// `Suspended`.
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app: winit::platform::android::activity::AndroidApp) {
use winit::platform::android::EventLoopBuilderExtAndroid;
android_logger::init_once(
android_logger::Config::default()
.with_max_level(log::LevelFilter::Info)
.with_tag("ink-notes"),
);
if let Some(dir) = app.internal_data_path() {
paths::set_app_dir(dir);
}
let event_loop = match winit::event_loop::EventLoopBuilder::new()
.with_android_app(app)
.build()
{
Ok(event_loop) => event_loop,
Err(err) => {
log::error!("event loop: {err}");
return;
}
};
if let Err(err) = app::run_with(event_loop) {
log::error!("{err}");
}
}
+8
View File
@@ -3,6 +3,14 @@
//!
//! Desktop entry point; the app itself is [`ink_notes::app`].
// No console window next to the app on Windows (debug builds keep it for the log)
#![cfg_attr(all(windows, not(debug_assertions)), windows_subsystem = "windows")]
#[cfg(not(target_os = "android"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
ink_notes::app::run()
}
/// On Android the app starts in `android_main` of the library.
#[cfg(target_os = "android")]
fn main() {}
+21 -142
View File
@@ -12,21 +12,29 @@
//! ohnehin nicht aus. Daher meldet das eigene Objekt einen Platzhalter als Umgebungstext und
//! übersetzt die Löschwünsche in Tastendrücke (Rücktaste/Entf) für egui.
use std::ffi::c_void;
#[cfg(target_os = "linux")]
mod wayland;
#[cfg(target_os = "linux")]
pub use wayland::KeyboardRequester;
use wayland_client::{
delegate_noop,
protocol::{wl_registry, wl_seat},
Connection, Dispatch, EventQueue, QueueHandle,
};
use wayland_protocols::wp::text_input::zv3::client::{
zwp_text_input_manager_v3::ZwpTextInputManagerV3,
zwp_text_input_v3::{self, ZwpTextInputV3},
};
/// Elsewhere the system shows the on-screen keyboard by itself; nothing to request.
#[cfg(not(target_os = "linux"))]
pub struct KeyboardRequester;
/// Platzhalter-Umgebungstext: ein Zeichen vor der Schreibmarke, damit die Rücktaste der
/// Bildschirmtastatur immer etwas zu löschen hat (ein Byte = ein Zeichen)
const SURROUNDING_PLACEHOLDER: &str = " ";
#[cfg(not(target_os = "linux"))]
impl KeyboardRequester {
/// # Safety
/// Nothing to uphold; `unsafe` like the Wayland version.
pub unsafe fn for_window(_window: &winit::window::Window) -> Option<Self> {
None
}
pub fn request(&mut self) {}
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
Vec::new()
}
}
/// Wandelt Texteingaben ohne Vorschau (Preedit) in normale Texteingaben um.
///
@@ -74,135 +82,6 @@ pub fn should_request(was_active: bool, active: bool, pressed: bool) -> bool {
active && (!was_active || pressed)
}
#[derive(Default)]
struct State {
seat: Option<wl_seat::WlSeat>,
manager: Option<ZwpTextInputManagerV3>,
text_input: Option<ZwpTextInputV3>,
/// Von der Bildschirmtastatur gewünschtes Löschen (Zeichen vor/nach der Schreibmarke)
delete_back: u32,
delete_forward: u32,
}
/// Eigenes text-input-Objekt, mit dem ink-notes die Bildschirmtastatur anfordert
pub struct KeyboardRequester {
conn: Connection,
queue: EventQueue<State>,
state: State,
}
impl KeyboardRequester {
/// Hängt sich an die Wayland-Verbindung des Fensters.
///
/// # Safety
/// `wl_display` muss auf die `wl_display` des Fensters zeigen und gültig bleiben, solange
/// der `KeyboardRequester` lebt.
pub unsafe fn new(wl_display: *mut c_void) -> Self {
// Safety: an den Aufrufer weitergereicht
let backend =
unsafe { wayland_backend::client::Backend::from_foreign_display(wl_display.cast()) };
let conn = Connection::from_backend(backend);
let queue = conn.new_event_queue();
conn.display().get_registry(&queue.handle(), ());
let _ = conn.flush();
Self {
conn,
queue,
state: State::default(),
}
}
/// Verarbeitet eingetroffene Ereignisse; einmal pro Frame aufrufen.
pub fn pump(&mut self) {
let _ = self.queue.dispatch_pending(&mut self.state);
if self.state.text_input.is_none() {
if let (Some(manager), Some(seat)) = (&self.state.manager, &self.state.seat) {
self.state.text_input =
Some(manager.get_text_input(seat, &self.queue.handle(), ()));
}
}
}
/// Bittet den Compositor, die Bildschirmtastatur einzublenden. Muss nach dem `enable` von
/// winit kommen (also nach `handle_platform_output`).
pub fn request(&mut self) {
self.pump();
if let Some(text_input) = &self.state.text_input {
text_input.enable();
self.send_surrounding_placeholder();
}
}
/// Tastendrücke für das seit dem letzten Aufruf gewünschte Löschen (vor `begin_frame`
/// aufrufen und an die egui-Eingabe anhängen)
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
self.pump();
// Den Platzhalter hier nicht neu melden: Die Tastatur löscht bei jeder neuen Meldung
// erneut, solange die Rücktaste gedrückt ist – ein kurzes Antippen löschte sonst doppelt.
let back = std::mem::take(&mut self.state.delete_back);
let forward = std::mem::take(&mut self.state.delete_forward);
deletion_key_events(back, forward)
}
fn send_surrounding_placeholder(&self) {
if let Some(text_input) = &self.state.text_input {
let len = SURROUNDING_PLACEHOLDER.len() as i32;
text_input.set_surrounding_text(SURROUNDING_PLACEHOLDER.to_owned(), len, len);
text_input.commit();
let _ = self.conn.flush();
}
}
}
impl Dispatch<wl_registry::WlRegistry, ()> for State {
fn event(
state: &mut Self,
registry: &wl_registry::WlRegistry,
event: wl_registry::Event,
_: &(),
_: &Connection,
qh: &QueueHandle<Self>,
) {
if let wl_registry::Event::Global {
name, interface, ..
} = event
{
match interface.as_str() {
"wl_seat" if state.seat.is_none() => {
state.seat = Some(registry.bind(name, 1, qh, ()));
}
"zwp_text_input_manager_v3" if state.manager.is_none() => {
state.manager = Some(registry.bind(name, 1, qh, ()));
}
_ => {}
}
}
}
}
delegate_noop!(State: ignore wl_seat::WlSeat);
delegate_noop!(State: ZwpTextInputManagerV3);
impl Dispatch<ZwpTextInputV3, ()> for State {
fn event(
state: &mut Self,
_: &ZwpTextInputV3,
event: zwp_text_input_v3::Event,
_: &(),
_: &Connection,
_: &QueueHandle<Self>,
) {
// Getippter Text kommt über winit; hier nur das Löschen
if let zwp_text_input_v3::Event::DeleteSurroundingText {
before_length,
after_length,
} = event
{
state.delete_back += before_length;
state.delete_forward += after_length;
}
}
}
#[cfg(test)]
mod tests {
use super::*;
+163
View File
@@ -0,0 +1,163 @@
//! Wayland part of [`super`]: an own text-input object on the window's connection.
use std::ffi::c_void;
use wayland_client::{
delegate_noop,
protocol::{wl_registry, wl_seat},
Connection, Dispatch, EventQueue, QueueHandle,
};
use wayland_protocols::wp::text_input::zv3::client::{
zwp_text_input_manager_v3::ZwpTextInputManagerV3,
zwp_text_input_v3::{self, ZwpTextInputV3},
};
use super::deletion_key_events;
/// Platzhalter-Umgebungstext: ein Zeichen vor der Schreibmarke, damit die Rücktaste der
/// Bildschirmtastatur immer etwas zu löschen hat (ein Byte = ein Zeichen)
const SURROUNDING_PLACEHOLDER: &str = " ";
#[derive(Default)]
struct State {
seat: Option<wl_seat::WlSeat>,
manager: Option<ZwpTextInputManagerV3>,
text_input: Option<ZwpTextInputV3>,
/// Von der Bildschirmtastatur gewünschtes Löschen (Zeichen vor/nach der Schreibmarke)
delete_back: u32,
delete_forward: u32,
}
/// Eigenes text-input-Objekt, mit dem ink-notes die Bildschirmtastatur anfordert
pub struct KeyboardRequester {
conn: Connection,
queue: EventQueue<State>,
state: State,
}
impl KeyboardRequester {
/// Requester for the window if it runs on Wayland.
///
/// # Safety
/// The window must outlive the requester.
pub unsafe fn for_window(window: &winit::window::Window) -> Option<Self> {
use winit::raw_window_handle::{HasDisplayHandle, RawDisplayHandle};
match window.display_handle().map(|handle| handle.as_raw()) {
// Safety: passed on to the caller
Ok(RawDisplayHandle::Wayland(handle)) => {
Some(unsafe { Self::new(handle.display.as_ptr()) })
}
_ => None,
}
}
/// Hängt sich an die Wayland-Verbindung des Fensters.
///
/// # Safety
/// `wl_display` muss auf die `wl_display` des Fensters zeigen und gültig bleiben, solange
/// der `KeyboardRequester` lebt.
pub unsafe fn new(wl_display: *mut c_void) -> Self {
// Safety: an den Aufrufer weitergereicht
let backend =
unsafe { wayland_backend::client::Backend::from_foreign_display(wl_display.cast()) };
let conn = Connection::from_backend(backend);
let queue = conn.new_event_queue();
conn.display().get_registry(&queue.handle(), ());
let _ = conn.flush();
Self {
conn,
queue,
state: State::default(),
}
}
/// Verarbeitet eingetroffene Ereignisse; einmal pro Frame aufrufen.
pub fn pump(&mut self) {
let _ = self.queue.dispatch_pending(&mut self.state);
if self.state.text_input.is_none() {
if let (Some(manager), Some(seat)) = (&self.state.manager, &self.state.seat) {
self.state.text_input =
Some(manager.get_text_input(seat, &self.queue.handle(), ()));
}
}
}
/// Bittet den Compositor, die Bildschirmtastatur einzublenden. Muss nach dem `enable` von
/// winit kommen (also nach `handle_platform_output`).
pub fn request(&mut self) {
self.pump();
if let Some(text_input) = &self.state.text_input {
text_input.enable();
self.send_surrounding_placeholder();
}
}
/// Tastendrücke für das seit dem letzten Aufruf gewünschte Löschen (vor `begin_frame`
/// aufrufen und an die egui-Eingabe anhängen)
pub fn take_deletions(&mut self) -> Vec<egui::Event> {
self.pump();
// Den Platzhalter hier nicht neu melden: Die Tastatur löscht bei jeder neuen Meldung
// erneut, solange die Rücktaste gedrückt ist – ein kurzes Antippen löschte sonst doppelt.
let back = std::mem::take(&mut self.state.delete_back);
let forward = std::mem::take(&mut self.state.delete_forward);
deletion_key_events(back, forward)
}
fn send_surrounding_placeholder(&self) {
if let Some(text_input) = &self.state.text_input {
let len = SURROUNDING_PLACEHOLDER.len() as i32;
text_input.set_surrounding_text(SURROUNDING_PLACEHOLDER.to_owned(), len, len);
text_input.commit();
let _ = self.conn.flush();
}
}
}
impl Dispatch<wl_registry::WlRegistry, ()> for State {
fn event(
state: &mut Self,
registry: &wl_registry::WlRegistry,
event: wl_registry::Event,
_: &(),
_: &Connection,
qh: &QueueHandle<Self>,
) {
if let wl_registry::Event::Global {
name, interface, ..
} = event
{
match interface.as_str() {
"wl_seat" if state.seat.is_none() => {
state.seat = Some(registry.bind(name, 1, qh, ()));
}
"zwp_text_input_manager_v3" if state.manager.is_none() => {
state.manager = Some(registry.bind(name, 1, qh, ()));
}
_ => {}
}
}
}
}
delegate_noop!(State: ignore wl_seat::WlSeat);
delegate_noop!(State: ZwpTextInputManagerV3);
impl Dispatch<ZwpTextInputV3, ()> for State {
fn event(
state: &mut Self,
_: &ZwpTextInputV3,
event: zwp_text_input_v3::Event,
_: &(),
_: &Connection,
_: &QueueHandle<Self>,
) {
// Getippter Text kommt über winit; hier nur das Löschen
if let zwp_text_input_v3::Event::DeleteSurroundingText {
before_length,
after_length,
} = event
{
state.delete_back += before_length;
state.delete_forward += after_length;
}
}
}
+74
View File
@@ -0,0 +1,74 @@
//! Folders for notebooks, settings and downloads on each platform (Issues #42, #48).
//!
//! - Linux: XDG (`~/.local/share/ink-notes`, `~/.config/ink-notes`, `~/.cache/ink-notes`)
//! - Windows: `%APPDATA%\ink-notes` for data and settings, `%LOCALAPPDATA%\ink-notes` for
//! downloads
//! - Android: the app's internal folder, set once at startup with [`set_app_dir`]
//!
//! The environment is read on every call, so tests can point the folders elsewhere.
use std::path::PathBuf;
use std::sync::OnceLock;
/// Fixed app folder (Android: internal storage of the app)
static APP_DIR: OnceLock<PathBuf> = OnceLock::new();
/// Puts data, settings and downloads below `dir` (Android, where there is no XDG or home).
pub fn set_app_dir(dir: PathBuf) {
let _ = APP_DIR.set(dir);
}
/// Value of an environment variable, unless empty.
fn env_dir(key: &str) -> Option<PathBuf> {
std::env::var_os(key)
.filter(|v| !v.to_string_lossy().trim().is_empty())
.map(PathBuf::from)
}
/// Home folder of the user.
pub fn home_dir() -> Option<PathBuf> {
if cfg!(windows) {
env_dir("USERPROFILE").or_else(|| env_dir("HOME"))
} else {
env_dir("HOME")
}
}
/// Folder for notebooks and emergency backups.
pub fn data_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.clone());
}
if cfg!(windows) {
return env_dir("APPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_DATA_HOME")
.or_else(|| home_dir().map(|h| h.join(".local").join("share")))
.map(|d| d.join("ink-notes"))
}
/// Folder for the settings (`ui.json`).
pub fn config_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.join("config"));
}
if cfg!(windows) {
return env_dir("APPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_CONFIG_HOME")
.or_else(|| home_dir().map(|h| h.join(".config")))
.map(|d| d.join("ink-notes"))
}
/// Folder for downloaded updates.
pub fn cache_dir() -> Option<PathBuf> {
if let Some(dir) = APP_DIR.get() {
return Some(dir.join("cache"));
}
if cfg!(windows) {
return env_dir("LOCALAPPDATA").map(|d| d.join("ink-notes"));
}
env_dir("XDG_CACHE_HOME")
.or_else(|| home_dir().map(|h| h.join(".cache")))
.map(|d| d.join("ink-notes"))
}
+113
View File
@@ -58,6 +58,69 @@ pub fn display_backend_from_env() -> DisplayBackend {
)
}
/// Event loop for the desktop; on Linux with the display backend chosen above.
#[cfg(not(target_os = "android"))]
pub fn desktop_event_loop() -> Result<winit::event_loop::EventLoop<()>, winit::error::EventLoopError>
{
#[allow(unused_mut)]
let mut builder = winit::event_loop::EventLoopBuilder::new();
#[cfg(target_os = "linux")]
{
use winit::platform::{wayland::EventLoopBuilderExtWayland, x11::EventLoopBuilderExtX11};
match display_backend_from_env() {
DisplayBackend::X11 => {
eprintln!("[Anzeige] Verwende X11 (unter WSL Standard; übersteuerbar mit INK_NOTES_DISPLAY=wayland)");
builder.with_x11();
}
DisplayBackend::Wayland => {
eprintln!("[Anzeige] Verwende Wayland (INK_NOTES_DISPLAY=wayland)");
builder.with_wayland();
}
DisplayBackend::Automatic => {}
}
}
builder.build()
}
/// Gives the window the app id (Wayland: app_id, X11: WM_CLASS), so that dock and task bar
/// show the app icon for it.
pub fn with_app_id(
builder: winit::window::WindowBuilder,
#[allow(unused_variables)] app_id: &str,
) -> winit::window::WindowBuilder {
#[cfg(target_os = "linux")]
{
let builder = winit::platform::wayland::WindowBuilderExtWayland::with_name(
builder,
app_id,
"ink-notes",
);
winit::platform::x11::WindowBuilderExtX11::with_name(builder, app_id, "ink-notes")
}
#[cfg(not(target_os = "linux"))]
builder
}
/// Ignores touches on the client-side title bar until `until` (palm rejection while the pen
/// is near; only Wayland draws its own title bar).
pub fn ignore_decoration_touches_until(
#[allow(unused_variables)] until: Option<std::time::Instant>,
) {
#[cfg(target_os = "linux")]
winit::platform::wayland::ignore_decoration_touches_until(until);
}
/// Time of a touch event as reported by the compositor (milliseconds, Wayland only).
pub fn take_touch_time(
#[allow(unused_variables)] id: u64,
#[allow(unused_variables)] phase: winit::event::TouchPhase,
) -> Option<u32> {
#[cfg(target_os = "linux")]
return winit::platform::wayland::take_touch_time(id, phase);
#[cfg(not(target_os = "linux"))]
None
}
/// Bringt die Ereignisse eines Tablet-Frames in eine brauchbare Reihenfolge: octotablet meldet
/// das Aufsetzen des Stifts (`Down`) vor der Position desselben Frames (`Pose`). Bis dahin
/// gälte noch die alte Position – kam der Stift schnell heran (Annähern und Aufsetzen im selben
@@ -91,6 +154,56 @@ pub fn down_after_pose<T>(
ordered
}
/// System clipboard: arboard on the desktop; on Android not available yet (Issue #42).
pub mod clipboard {
#[cfg(not(target_os = "android"))]
pub use arboard::{Clipboard, ImageData};
#[cfg(target_os = "android")]
pub use android::{Clipboard, ImageData};
#[cfg(target_os = "android")]
mod android {
use std::borrow::Cow;
pub struct ImageData<'a> {
pub width: usize,
pub height: usize,
pub bytes: Cow<'a, [u8]>,
}
impl ImageData<'_> {
pub fn to_owned_img(&self) -> ImageData<'static> {
ImageData {
width: self.width,
height: self.height,
bytes: Cow::Owned(self.bytes.to_vec()),
}
}
}
pub struct Clipboard;
impl Clipboard {
pub fn new() -> Result<Self, &'static str> {
Err("not available on Android")
}
pub fn get_image(&mut self) -> Result<ImageData<'static>, &'static str> {
Err("not available on Android")
}
pub fn get_text(&mut self) -> Result<String, &'static str> {
Err("not available on Android")
}
pub fn set_image(&mut self, _image: ImageData) -> Result<(), &'static str> {
Err("not available on Android")
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
+2 -6
View File
@@ -258,13 +258,9 @@ impl Default for UiSettings {
}
impl UiSettings {
/// Standardpfad gemäß XDG-Spezifikation.
/// Standardpfad gemäß XDG-Spezifikation (see [`crate::paths`] for other systems).
pub fn default_path() -> Option<PathBuf> {
let base = match std::env::var("XDG_CONFIG_HOME") {
Ok(dir) if !dir.trim().is_empty() => PathBuf::from(dir),
_ => PathBuf::from(std::env::var("HOME").ok()?).join(".config"),
};
Some(base.join("ink-notes").join("ui.json"))
crate::paths::config_dir().map(|d| d.join("ui.json"))
}
/// Lädt die Einstellungen; bei fehlender oder beschädigter Datei gelten Standardwerte.
+8 -16
View File
@@ -994,21 +994,9 @@ fn copy_dir(from: &Path, to: &Path) -> io::Result<()> {
/// Gibt das Standard-Verzeichnis für Notizbücher zurück (gemäß XDG-Spezifikation).
pub fn default_storage_dir() -> PathBuf {
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {
if !xdg.is_empty() {
return PathBuf::from(xdg).join("ink-notes").join("notebooks");
}
}
if let Ok(home) = std::env::var("HOME") {
if !home.is_empty() {
return PathBuf::from(home)
.join(".local")
.join("share")
.join("ink-notes")
.join("notebooks");
}
}
PathBuf::from("./data/notebooks")
crate::paths::data_dir()
.map(|d| d.join("notebooks"))
.unwrap_or_else(|| PathBuf::from("./data/notebooks"))
}
/// Status eines Notizbuchs in der Dokumentenliste.
@@ -1130,7 +1118,11 @@ impl NotebookLock {
}
Err(e) => {
let kind = e.kind();
if kind == io::ErrorKind::WouldBlock || e.raw_os_error() == Some(11) {
// Windows reports a held lock as ERROR_LOCK_VIOLATION
if kind == io::ErrorKind::WouldBlock
|| e.raw_os_error() == Some(11)
|| e.raw_os_error() == fs2::lock_contended_error().raw_os_error()
{
Err(StorageError::AlreadyLocked(t!(
"Notizbuch '{path}' wird bereits von einer anderen Instanz verwendet",
path = notebook_dir.display()
+2
View File
@@ -5076,6 +5076,7 @@ pub fn render_ui(
let is_recommended = match updater.runtime() {
crate::updater::RuntimeEnvironment::AppImage { .. } => is_appimage,
crate::updater::RuntimeEnvironment::DebPackage { .. } => is_deb,
crate::updater::RuntimeEnvironment::WindowsExe { .. } => asset.name.ends_with(".exe"),
_ => false,
};
@@ -5141,6 +5142,7 @@ pub fn render_ui(
crate::updater::RuntimeEnvironment::DebPackage { .. } => t!("📦 Paket mit Software-Center öffnen / installieren"),
crate::updater::RuntimeEnvironment::PortableOrDev { .. }
| crate::updater::RuntimeEnvironment::Flatpak => t!("📂 Im Dateimanager anzeigen"),
crate::updater::RuntimeEnvironment::WindowsExe { .. } => t!("🔄 Update installieren"),
};
ui.horizontal(|ui| {
+80 -19
View File
@@ -121,6 +121,8 @@ pub enum RuntimeEnvironment {
/// Als Flatpak installiert: Updates kommen über die Software-Verwaltung, ink-notes lädt
/// selbst nichts herunter (Vorgabe von Flathub)
Flatpak,
/// Portable `.exe` on Windows (Issue #48), replaced in place like the AppImage
WindowsExe { exe_path: PathBuf },
}
impl RuntimeEnvironment {
@@ -132,8 +134,13 @@ impl RuntimeEnvironment {
) {
return RuntimeEnvironment::Flatpak;
}
let appimage_var = std::env::var("APPIMAGE").ok();
let current_exe = std::env::current_exe().unwrap_or_else(|_| PathBuf::from("ink-notes"));
if cfg!(windows) {
return RuntimeEnvironment::WindowsExe {
exe_path: current_exe,
};
}
let appimage_var = std::env::var("APPIMAGE").ok();
Self::detect_from(appimage_var.as_deref(), &current_exe)
}
@@ -166,6 +173,7 @@ impl RuntimeEnvironment {
RuntimeEnvironment::DebPackage { .. } => t!("System-Paket (.deb)"),
RuntimeEnvironment::PortableOrDev { .. } => t!("Entwicklung / Lokal"),
RuntimeEnvironment::Flatpak => "Flatpak",
RuntimeEnvironment::WindowsExe { .. } => "Windows",
}
}
@@ -210,18 +218,9 @@ pub fn sanitize_asset_name(raw_name: &str) -> Result<String, String> {
/// Liefert das isolierte Cache-Verzeichnis für Downloads pro Nutzer mit Rechten 0700.
pub fn get_updates_cache_dir() -> Result<PathBuf, String> {
let base = if let Ok(xdg) = std::env::var("XDG_CACHE_HOME") {
let trimmed = xdg.trim();
if !trimmed.is_empty() {
PathBuf::from(trimmed)
} else {
default_user_cache_dir()?
}
} else {
default_user_cache_dir()?
};
let dir = base.join("ink-notes").join("updates");
let dir = crate::paths::cache_dir()
.ok_or_else(|| t!("HOME-Umgebungsvariable ist nicht gesetzt.").to_string())?
.join("updates");
std::fs::create_dir_all(&dir).map_err(|e| {
t!(
"Konnte Update-Cache-Verzeichnis nicht anlegen ({path}): {e}",
@@ -239,12 +238,6 @@ pub fn get_updates_cache_dir() -> Result<PathBuf, String> {
Ok(dir)
}
fn default_user_cache_dir() -> Result<PathBuf, String> {
let home = std::env::var("HOME")
.map_err(|_| t!("HOME-Umgebungsvariable ist nicht gesetzt.").to_string())?;
Ok(PathBuf::from(home).join(".cache"))
}
/// Löscht alte temporäre Downloads aus dem Cache-Verzeichnis.
pub fn cleanup_old_updates() {
if let Ok(dir) = get_updates_cache_dir() {
@@ -551,6 +544,48 @@ fn http_get_with_auth_guard(
Err(t!("Zu viele Weiterleitungen (Redirect-Schleife abgebrochen).").to_string())
}
/// Replaces the running `.exe` with the downloaded one (Windows). A running program can't be
/// overwritten but can be renamed: the old one becomes `<name>.bak`, the new one takes its
/// place and starts with the next launch.
pub fn replace_running_exe(downloaded: &Path, exe_path: &Path) -> Result<(), String> {
let file_name = exe_path
.file_name()
.ok_or_else(|| t!("Ungültiger Programmpfad.").to_string())?
.to_string_lossy()
.into_owned();
let dir = exe_path
.parent()
.ok_or_else(|| t!("Ungültiger Programmpfad.").to_string())?;
let new_file = dir.join(format!("{file_name}.new"));
let backup = dir.join(format!("{file_name}.bak"));
std::fs::copy(downloaded, &new_file).map_err(|e| {
let _ = std::fs::remove_file(&new_file);
t!("Konnte temporäre Update-Datei nicht schreiben: {e}", e = e)
})?;
// A backup of an earlier update is no longer running
let _ = std::fs::remove_file(&backup);
if let Err(e) = std::fs::rename(exe_path, &backup) {
let _ = std::fs::remove_file(&new_file);
return Err(t!(
"Konnte Backup ({path}) nicht anlegen: {e}. Update abgebrochen, altes Programm unverändert.",
path = backup.display(),
e = e
));
}
if let Err(e) = std::fs::rename(&new_file, exe_path) {
// Put the old program back
let _ = std::fs::rename(&backup, exe_path);
let _ = std::fs::remove_file(&new_file);
return Err(t!(
"Konnte Programm nicht ersetzen: {e}. Altes Programm bleibt unverändert.",
e = e
));
}
let _ = std::fs::remove_file(downloaded);
Ok(())
}
/// Asynchroner Controller für Update-Prüfung und Asset-Download.
pub struct UpdaterController {
config: UpdaterConfig,
@@ -915,6 +950,7 @@ impl UpdaterController {
"Die Flatpak-Version wird über die Software-Verwaltung aktualisiert."
)
.to_string()),
RuntimeEnvironment::WindowsExe { exe_path } => replace_running_exe(file_path, exe_path),
}
}
@@ -1102,6 +1138,31 @@ dcdeb7ac87d9e6cb8022e5a71bc7f2c56d779b4fce4efdd5bae5be3b0214884a ink-notes_0.1.
);
}
#[test]
fn test_replace_running_exe() {
let dir = tempfile::tempdir().unwrap();
let exe = dir.path().join("ink-notes.exe");
let downloaded = dir.path().join("ink-notes_9.9.9_x86_64.exe");
std::fs::write(&exe, b"old").unwrap();
std::fs::write(&downloaded, b"new").unwrap();
replace_running_exe(&downloaded, &exe).unwrap();
assert_eq!(std::fs::read(&exe).unwrap(), b"new");
assert_eq!(
std::fs::read(dir.path().join("ink-notes.exe.bak")).unwrap(),
b"old"
);
assert!(!downloaded.exists());
// Again: the backup of the first update is replaced
std::fs::write(&downloaded, b"newer").unwrap();
replace_running_exe(&downloaded, &exe).unwrap();
assert_eq!(std::fs::read(&exe).unwrap(), b"newer");
assert_eq!(
std::fs::read(dir.path().join("ink-notes.exe.bak")).unwrap(),
b"new"
);
}
#[test]
fn test_flatpak_detection_disables_self_update() {
assert!(is_flatpak(Some("eu.pansi.ink-notes"), false));