Skip to content

Fix Wayland work-around for COSMIC, and add to the PyPI entry point - #602

Merged
jmwright merged 3 commits into
CadQuery:masterfrom
willstott101:wayland-platform-fix
Sep 20, 2026
Merged

jmwright merged 3 commits into
CadQuery:masterfrom
willstott101:wayland-platform-fix

Conversation

@willstott101

Copy link
Copy Markdown
Contributor

The work-around from #575 lives only in run.py, the PyInstaller entry point (pyinstaller.spec runs Analysis(['run.py'])), which is not shipped in the wheel. Installs from PyPI enter at cq_editor.cqe_run:main and never ran it -- #266 was reported against the cq-editor console script, so the fix did not reach it.

Additionally: skipping the fix-up whenever QT_QPA_PLATFORM is already set reads the variable as user intent, but COSMIC and others export "wayland;xcb" session-wide, so on exactly those systems nothing happened and the viewer still died with BadWindow.

Move the logic to cq_editor/qt_platform.py, called from both entry points, and reorder the plugin list rather than replacing it: wayland* entries are demoted but kept, so an explicitly requested plugin is still reachable as a fallback and an offscreen or eglfs choice is untouched. Only an unset variable defaults to xcb.

The work-around from CadQuery#575 lives only in run.py, the PyInstaller entry point
(pyinstaller.spec runs Analysis(['run.py'])), which is not shipped in the wheel.
Installs from PyPI enter at cq_editor.cqe_run:main and never ran it -- CadQuery#266 was
reported against the cq-editor console script, so the fix did not reach it.

Additionally: skipping the fix-up whenever QT_QPA_PLATFORM is already set reads
the variable as user intent, but COSMIC and others export "wayland;xcb"
session-wide, so on exactly those systems nothing happened and the viewer still
died with BadWindow.

Move the logic to cq_editor/qt_platform.py, called from both entry points, and
reorder the plugin list rather than replacing it: wayland* entries are demoted
but kept, so an explicitly requested plugin is still reachable as a fallback and
an offscreen or eglfs choice is untouched.  Only an unset variable defaults to
xcb.
@tsokar

tsokar commented Sep 16, 2026

Copy link
Copy Markdown

I confirm that this commit made it possible to run cq-editor under kde 6.7.5 (arch)

@jmwright

Copy link
Copy Markdown
Member

Thanks @willstott101

One thing to consider:

python -m cq_editor still bypasses the fix so env stays wayland;xcb. One call at the top of cq_editor/__main__.py, above the module-level QApplication(...), should cover every entry point without side effects (that I'm aware of): run.py, cqe_run.py, and -m. It should also let both of the PR's call sites be deleted.

@willstott101

willstott101 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

That makes sense - I mostly went this way to be similar to #575 I'll test and push an update to simplify it to one call site soon(-ish).

Reorder QT_QPA_PLATFORM so Qt reaches a Wayland plugin only after everything
else has failed to load, defaulting to xcb when unset. Desktops such as COSMIC
export "wayland;xcb" session-wide; we respect that config as far as possible
without running on Wayland.

On Wayland occt_widget hands winId() to OCP's Xw_Window, which needs an X11
window id and gets a Wayland surface id instead, dying with BadWindow. OCCT
does not yet support Wayland.

Inline in __main__ (rather than a separate module) as it must run before the
QApplication is created, and both cqe_run and `python -m cq_editor` import it.
@willstott101

Copy link
Copy Markdown
Contributor Author

I have de-duplicated the calls, and then inlined the function, I don't think it warrants it's own module anymore with one call-site.

@jmwright

Copy link
Copy Markdown
Member

Thanks @willstott101

@jmwright
jmwright merged commit abb1d3e into CadQuery:master Sep 20, 2026
3 checks passed
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.

3 participants