Skip to content

Wayland fix (namely pncconf's sample panel) - #4523

Open
NTULINUX wants to merge 1 commit into
LinuxCNC:masterfrom
NTULINUX:wayland-fix
Open

NTULINUX wants to merge 1 commit into
LinuxCNC:masterfrom
NTULINUX:wayland-fix

Conversation

@NTULINUX

Copy link
Copy Markdown
Contributor

Fixes: #4522

Fixes: LinuxCNC#4522

Signed-off-by: Alec Ari <neotheuser@ymail.com>
@BsAtHome

Copy link
Copy Markdown
Contributor

What about the other GUIs?
Also, is there an interaction if this would be run in, for example, xvfb? You set the variable unconditionally. Is that the proper way?

@grandixximo

Copy link
Copy Markdown
Contributor

Good questions.

The other GUIs are already covered: everything launched through the linuxcnc script inherits PYOPENGL_PLATFORM=x11 from scripts/linuxcnc.in:30-34, so Axis, gmoccapy and qtvcp in normal use never hit this. The gap is only tools started outside that script, pncconf being the report here, and all of them reach OpenGL through gremlin, which is GLX-only code anyway (it imports GdkX11 and dlopens libGL directly). So setting the platform in gremlin covers exactly the consumers that can hit the failure, and nowhere else. Qt-based GUIs use Qt's GL stack and are unaffected either way.

It is not actually unconditional: os.environ.setdefault only sets the variable when it is unset, so an explicit user setting or the linuxcnc.in export takes precedence. Under xvfb there is no Wayland session, so PyOpenGL would select the GLX/x11 platform natively; the setdefault merely pins the value it would have picked anyway, so behavior under xvfb is unchanged. The value x11 also matches what linuxcnc.in already exports.

@rene-dev

Copy link
Copy Markdown
Member

if gremlin has been converted to modern opengl, we dont need the dlopen hack anymore, and can use gtkglarea, which might or might not work on wayland. Background: the hack was needed, as gtkglarea cannot provide a legacy opengl context. this was a major pain during the gtk3 conversion.

@alex-pres

Copy link
Copy Markdown
Contributor

if gremlin has been converted to modern opengl, we dont need the dlopen hack anymore, and can use gtkglarea, which might or might not work on wayland. Background: the hack was needed, as gtkglarea cannot provide a legacy opengl context. this was a major pain during the gtk3 conversion.

I will check what can be done for this.

@alex-pres

alex-pres commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

pncconf and gremlin are confirmed to run on Weston Wayland with #4538 and without this fix.

There are other showstoppers to run on native Wayland [ for example use of GtkSocket in gmoccapy - that is X11-only, CasildaCompositor probably can help here ], but at least Gremlin is now ready for this move.

@rene-dev

Copy link
Copy Markdown
Member

What is gtksocket used for?

@alex-pres

Copy link
Copy Markdown
Contributor

What is gtksocket used for?

AI generated:

Verdict

Nothing in the tree runs under native Wayland by default — scripts/linuxcnc forces the X11 backend for every toolkit before any GUI starts. Even with that override removed, the Tk half of LinuxCNC (AXIS, tklinuxcnc, PyVCP, vismach, halshow, tooledit, ngcgui…) can never run natively, and the XEmbed panel system (EMBED_TAB_COMMAND) is X11-protocol by definition.

Only the Qt (qtvcp) family and the GTK3 GUIs without embedded tabs are close to native-capable.


S1 — Hard blockers (no Wayland path exists)

1. The launcher pins everything to X11

scripts/linuxcnc.in:30

if [[ ! -v LINUXCNC_OPENGL_PLATFORM || "${LINUXCNC_OPENGL_PLATFORM}" == "glx" ]]; then
    export PYOPENGL_PLATFORM="x11"
    export GDK_BACKEND="x11"
    export QT_QPA_PLATFORM="xcb"
fi

Default path forces XWayland for GTK, Qt and PyOpenGL simultaneously. There is no wayland/egl branch — LINUXCNC_OPENGL_PLATFORM is only consumed here and in the test rig (tests/ui-smoke/_lib/qtdragon-prepare.sh:46, which sets offscreen).

2. Tk/Tkinter has no Wayland backend — and it is the primary GUI

AXIS is the default GUI (16 of the sim configs; tklinuxcnc 4 more). Tk 8.6/9.0 on Linux is X11-only upstream; there is no port. Affected entry points found in-tree:

Component File
AXIS src/emc/usr_intf/axis/scripts/axis.py
Togl GL widget (C, GLX+Xlib) src/emc/usr_intf/axis/extensions/togl.c
tklinuxcnc tcl/tklinuxcnc.tcl
PyVCP src/hal/user_comps/pyvcp.py:44
vismach (all 15 machine GUIs) lib/python/vismach.py:19lib/python/rs274/OpenGLTk.py:16
halshow / halconfig / genedit / popimage tcl/bin/*.tcl
tooledit, ngcgui, pickconfig, moveoff_gui tcl/*.tcl, scripts/moveoff_gui
hal_manualtoolchange, linuxcnctop, debuglevel, teach-in, image-to-gcode, axis-remote src/emc/usr_intf/axis/scripts/
latency-histogram, latency-plot, mdro, monitor-xhc-hb04 scripts/, src/emc/usr_intf/mdro/
update_ini (the INI-version upgrade GUI) src/emc/ini/update_ini.py
qtplasmac's G-code dialog (Tk inside a Qt app) src/emc/usr_intf/qtplasmac/qtplasmac_gcode.py:1571

Togl specifics: 28 glX* calls, direct X11/Xlib.h, XCreateWindow, XCreateColormap, XmuLookupStandardColormap, XSGIStereo*. Links -lX11 -lXmu -lGL (src/emc/usr_intf/axis/Submakefile:24).

3. XEmbed — the entire EMBED_TAB_COMMAND / -x {XID} panel system

Wayland has no cross-process window embedding. Every panel-in-GUI feature is X11 protocol:

4. Synthetic key-event forwarding between processes

AXIS_FORWARD_EVENTS_TO carries AXIS's root XID (axis.py:4182); embedded panels push synthetic XKeyPress into it via Xlib send_eventgladevcp/xembed.py:106, qtvcp/lib/xembed.py:56. Wayland forbids one client injecting input into another. No replacement exists.

5. On-screen keyboard integration

onboard --xid / matchbox-keyboard --xid + Gtk.Socket.add_id()gmoccapy.py:2336, gscreen.py:3138. Both the --xid handshake and the socket are X11. (QtVCP has a native fallback: lib/python/qtvcp/lib/virtual_keyboard.py.)

6. Tk send IPC

axis-remote drives AXIS entirely through Tk's send, which is X11-only (SendCommand over X properties): axis-remote.py:87-101. Also axis.py:4162 and scripts/linuxcnc.in:249 (send -async popimage destroy .).


S2 — Functional breakage (app starts, feature silently dead)

Item Location Wayland behaviour
xhost -SI:localuser:gdm -SI:localuser:root at AXIS import axis.py:142 no-op / error
same in ngcgui tcl/ngcgui.tcl:2762 no-op
xset -r <keycode> to kill autorepeat for jogging qt_action.py:854 no-op; uneven jog repeat returns
Tk detectable-autorepeat (XkbSetDetectableAutoRepeat) tkdarmodule.c X-only by construction
Xinerama multihead query for screen layout emcsh.cc:3584, linked -lXinerama (Submakefile:25) X-only
d.warp_pointer() (touchy invisible-cursor hack) touchy.py:1226 unsupported on GDK Wayland
Absolute window placement window1.move(x, y) gmoccapy.py:3343, :5334, :5340, :5349, :5357; gscreen.py:1622 ignored — no client-side positioning
Notification popup placement gmoccapy/notification.py:204, :283 ignored
w.get_origin() for dialog placement gscreen.py:2387 returns garbage/0
halmeter -g x y src/hal/utils/meter.c:316 gtk_window_move ignored
QtVCP -g +x+y qtvcp.py:417 window.move() ignored
QtVCP --always-top qtvcp.py:438 WindowStaysOnTopHint ignored (no protocol)
Tk wm attributes -topmost / overrideredirect / +x+y tcl/bin/halshow.tcl:105,1201,1511, tcl/bin/popimage:79, tcl/scripts/balloon.tcl:104 X-only
cv2.imshow camera windows set_offsets.py:275 OpenCV highgui is X11 on Debian

S3 — Packaging / build

  • debian/control has no qtwayland5 / libqt5waylandclient5 dependency → QT_QPA_PLATFORM=wayland fails on a stock install even for qtvcp.
  • Hard build deps on X: AC_PATH_XTRA, X11/extensions/Xinerama.h (mandatory), X11/Xmu/Xmu.h (mandatory, error if missing) — src/configure.ac:1569, :1576, :1743.
  • Runtime deps: python3-xlib, x11-xserver-utils, x11-utils, tcl8.6/tk8.6debian/control:41,47, debian/control.main-pkg.in:24,37.
  • All UI tests run under xvfb-run (tests/ui-smoke/_lib/launch.sh:61); tests/ui-smoke/_lib/window-fit.sh requires xwininfo. There is zero Wayland test coverage in-tree.

Already Wayland-clean

  • gremlin GTK preview — ported to Gtk.GLArea on this branch (d79f87ed67, gremlin.py:93); all GLX/Xlib/GdkX11 removed, EGL via GDK.
  • qtvcp previewQOpenGLWidget (qt5_graphics.py:224).
  • qt_vismachQOpenGLWidget (qt_vismach.py:67), unlike Tk vismach.
  • halmeter / halscope / miscgtk — plain GTK3 C, no X calls (only the -g placement above).
  • stepconf / pncconf, gladevcp standalone (no -x) — plain GTK3.

Minimum viable native-Wayland target

gmoccapy / touchy / gscreen / qtvcp without EMBED_TAB_* and without onboard, after: dropping the GDK_BACKEND/QT_QPA_PLATFORM force in scripts/linuxcnc.in, adding qtwayland5 to debian/control, and accepting that window placement, always-on-top and xset autorepeat become no-ops.

AXIS, tklinuxcnc, PyVCP, vismach and all XEmbed panels stay on XWayland until they are rehosted on a non-Tk toolkit and the panel system is replaced with in-process loading (GTK4/Qt) or a Wayland subsurface protocol.

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.

PYOPENGL_PLATFORM=glx must be set if using Wayland (pncconf)

5 participants