Skip to content

fix(windows): align StandardPaths with GNUInstallDirs and honor FCITX_DATA_DIRS#1544

Open
gaboolic wants to merge 4 commits intofcitx:masterfrom
gaboolic:master
Open

fix(windows): align StandardPaths with GNUInstallDirs and honor FCITX_DATA_DIRS#1544
gaboolic wants to merge 4 commits intofcitx:masterfrom
gaboolic:master

Conversation

@gaboolic
Copy link
Copy Markdown

@gaboolic gaboolic commented Apr 3, 2026

Align the built-in paths on Windows with the actual installation tree and complete the FCITX_DATA_DIRS to match the behavior of Linux and meet the requirements of portability/TSF integration; failure to complete any of these steps will result in incorrect directory search or ignore the data path injected at startup during actual deployment.

  1. The built-in paths must be consistent with the CMake / GNUInstallDirs installation layout. In master, standardpaths_p_win.cpp writes the "built-in tree next to the executable file" as ../data, ../data/fcitx5, ../data/locale. In fact, under Windows / cross-compilation, fcitx5 is actually installed in share/, share/fcitx5, share/locale (consistent with GNUInstallDirs), not with a separate data/ prefix.

If it is not changed to "share/", in the scenario of "portable directory / installation tree with the same prefix as binary", the theme, locale, pkgdata, etc. will point to non-existent directories, resulting in resource loading failures. Therefore, the datadir / pkgdatadir / localedir of the built-in must be aligned with the actual installation layout. This is not a style issue but a path semantic error.

  1. FCITX_DATA_DIRS must be supported (and consistent with Unix behavior)
    On Unix, FCITX_DATA_DIRS is already involved in the PkgData search for fcitx5 (see standardpaths_p_unix.cpp / standardpath.cpp).
    Windows follows an independent standardpaths_p_win.cpp. If this variable is not read, it will be inconsistent with Unix, and downstream cannot inject additional data roots.

fcitx5-windows and others will set FCITX_DATA_DIRS when starting up (data directories under the portable package and the prefix of the IME side injection installation). It is not parsed on the Win side, and these settings are invalid for PkgData, causing the portable/custom layout to break. The separator used is ;, which is consistent with the common writing style of multiple paths in Windows environment variables.

  1. The expected results of unit tests must be updated in accordance with the layout corrections. The assertion for the "last item of the built-in PkgData" in teststandardpaths_win.cpp must be consistent with the above-mentioned share/fcitx5; otherwise, CI will falsely report a failure. This modification is a direct consequence of the first two points and is not an optional test tweak.

让 Windows 上的 内置路径与真实安装树一致,并 补齐 FCITX_DATA_DIRS,从而与 Linux 行为对齐且满足便携/TSF 集成;缺任一环节都会在真实部署中找错目录或忽略启动时注入的数据路径。

  1. 内置路径必须跟 CMake / GNUInstallDirs 安装布局 一致
    master 里 standardpaths_p_win.cpp 把「可执行文件旁的内置树」写成 ../data、../data/fcitx5、../data/locale。
    fcitx5 在 Windows / 交叉编译下实际安装的是 share/、share/fcitx5、share/locale(与 GNUInstallDirs 一致),不是单独的 data/ 前缀。

若不改成 share/,在「便携目录 / 与 binary 同前缀的安装树」场景下,主题、locale、pkgdata 等会指向不存在的目录,表现为资源加载失败。因此 builtin 的 datadir / pkgdatadir / localedir 必须与真实安装布局对齐,这不是风格问题,是路径语义错误。

  1. 必须支持 FCITX_DATA_DIRS(并与 Unix 行为一致)
    在 Unix 上,FCITX_DATA_DIRS 已参与 fcitx5 的 PkgData 搜索(见 standardpaths_p_unix.cpp / standardpath.cpp)。
    Windows 走独立的 standardpaths_p_win.cpp,若不读该变量,则与 Unix 不一致,且下游无法注入额外数据根。

fcitx5-windows 等在启动时会设置 FCITX_DATA_DIRS(便携包、IME 侧注入安装前缀下的数据目录)。不在 Win 侧解析它,这些设置对 PkgData 无效,便携/定制布局会断。分隔符使用 ;,与 Windows 环境变量里多路径的常见写法一致。

  1. 单测期望必须随布局修正
    teststandardpaths_win.cpp 里对「内置 PkgData 最后一项」的断言必须与上述 share/fcitx5 一致,否则 CI 会误报失败;该修改是前两点的直接结果,而非可有可无的测试 tweak。

- Map builtin dirs to share/fcitx5 and share/locale (GNUInstallDirs layout).

- Honor FCITX_DATA_DIRS (semicolon-separated) when resolving fcitx5 pkg data.

- Add EventDispatcher::dispatchPending() for same-thread deferred work (TSF).

Made-with: Cursor
fix(windows): align StandardPaths with GNUInstallDirs and honor FCITX_DATA_DIRS
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 this pull request may close these issues.

1 participant