Skip to content

Remove the X11/Xt dependencies (native macOS/Windows clients) #232

Closed

Description

@ohlincha

ECCE links libX11 and libXt. Neither is needed for xterm (an external program). For native macOS and Windows clients (#133) both dependencies have to go or become Linux-only. Inventory on main (Coin3D build, the default since 9.0.0-alpha.4):

Use Files Status
Xt event loop of the job monitor (eccejobstore) src/comm/commxt/JobStore.C live; the only real Xt dependency
Viewer OpenGL glue (GLX/EGL, X display) src/inv/wxinv/SoWxRenderArea.C, SoWxExaminerViewer.C, CoinEglOffscreen.C, src/inv/moiv/sysfonts.C, ChemSelection.C partly live, partly left from the vendored Inventor
Raising windows (X server time) src/wxgui/wxdialogs/WxDavAuth.C, src/apps/hostkeydialog/HostKeyDialogApp.C, src/wxgui/ewxClasses/ewxWindowUtils.C live; also unreliable under Wayland
Motif leftovers (XtManageChild, XtAppAddTimeOut, ...) WxBasisTool.C, WxBasisSetDetail.C, MoPanel.C, NWDirdy.C dead: commented out or inside #if 0000
Vendored SGI Inventor src/inv/db* etc. built only with -DECCE_USE_COIN=OFF; removed with #166 stage 5

Plan:

  1. Remove the dead Motif code and unused X11 includes (no behaviour change).
  2. Raise windows through one wx/GDK helper instead of X11 calls (X11, Wayland, macOS, Windows).
  3. Replace the Xt event loop in eccejobstore with poll() and a self-pipe for signals; tests/launch and the jobstore tests must pass unchanged.
  4. Put GLX/EGL behind one platform layer in the viewer: GLX/EGL on Linux, wx's GL canvas and Coin's offscreen rendering on macOS/Windows. Together with Port the viewer to Coin3D (9.0) #166 stage 5.
  5. Make X11 and Xt optional in CMake (Linux/X11 only), so a macOS build needs no XQuartz.

Steps 1-3 and 5 also help Linux (no Xt dependency, Wayland). Estimated 3-4 days in total.

Related: the editor and terminal are already settings (Edit > Preferences, ECCE_EDITOR, ECCE_TERMINAL). The default editor stays vi on Linux; native clients default to tools present on every machine of that platform (TextEdit and Terminal.app on macOS, Notepad and Windows Terminal on Windows).

Activity

  1. mattasplund commented on Oct 5, 2026

    @mattasplund
    Collaborator

    One more small thing. I have changed the preferences, and realized that I had thought it wasn't working because "Shell in calculation directory" still opens an xterm rather than a gnome-terminal, so that is not following the preferences. I had been changing the shell variables but only checking that so didn't see that things were actually working.
    I have a student that will start helping me this week (I hope) to set up a homebrew build setup on my Mac to try to build a version under MacOS.

  2. ohlincha commented on Oct 5, 2026

    @ohlincha
    CollaboratorAuthor

    Steps 1 and 2 are on branch wip/232-x11-cleanup. Step 1 removed about 560 lines of dead Motif/Xt code and unused X11 includes. Step 2 added ewxRaiseWindow() in ewxWindowUtils, now used by WxDavAuth.C and HostKeyDialogApp.C. The remaining X11/GLX/Xt/EGL uses, for step 4 (and step 3 for JobStore.C):

    Xt (step 3, eccejobstore)

    • src/comm/commxt/JobStore.C:34 #include <X11/Intrinsic.h>, :209 XtAppContext, :285-286 XtToolkitInitialize/XtCreateApplicationContext
    • src/comm/commxt/JobStore.C:1001 XtNoticeSignal, :1087 XtAppAddSignal, :1617/:1924 XtAppAddInput, :1629/:1950 XtRemoveInput, :1792 XtRemoveTimeOut, :1795 XtAppAddTimeOut, :1938 XtAppProcessEvent
    • CMakeLists.txt:63-68 find_package(X11) plus the libXt check, :235 eccecommxt links X11::Xt X11::X11

    GLX/X11 in the viewer (step 4)

    • src/inv/moiv/sysfonts.C:130 <GL/glx.h>, :141 glXGetCurrentDisplay, :150,170,182,213,261,277 XListFonts, :310 glXUseXFont (live under __GLX)
    • src/inv/wxinv/CoinEglOffscreen.C:9 <GL/glx.h>; 13 glX* calls (lines 30-135) that save and restore the GLX context around EGL offscreen rendering
    • include/inv/SoOffscreenRenderer.H:63,67 <GL/glx.h>, <X11/Xlib.h>
    • include/inv/elements/SoWindowElement.H:60 <GL/glx.h>
    • include/inv/SoWx/SoWxViewer.H:10 <X11/Intrinsic.h>
    • Not checked whether they are compiled (the getDisplay() and XSGI* stereo code looks like it could be in disabled blocks): src/inv/wxinv/SoWxViewer.C:903-942,1584-1608, src/inv/wxinv/SoWxExaminerViewer.C:1024, src/inv/wxinv/SoWxRenderArea.C:348
    • CMakeLists.txt:470-495 link X11::X11 for builder, vizthumbnail and the other viewer apps

    GDK-X11 (done, conditional)

    • src/wxgui/ewxClasses/ewxWindowUtils.C:21,57-60 gdk_x11_get_server_time, only under GDK_WINDOWING_X11 with GDK_IS_X11_DISPLAY at runtime. The hostkeydialog no longer links GTK itself.

    Vendored src/inv/db*, actions, nodes, interaction and misc were not touched. They go with #166 stage 5.

  3. ohlincha commented on Oct 5, 2026

    @ohlincha
    CollaboratorAuthor

    Step 4 is on branch wip/232-viewer-gl (fcf5968, d2dd1de, 0c6fb12). It is not merged yet.

    Live X11/GLX/EGL uses in the Coin build, before this step. I found these by preprocessing each file with the build's own flags. Most grep hits are inside /* */, #ifdef __sgi or __sys_fonts blocks.

    • CoinEglOffscreen.C: EGL offscreen contexts, plus the glX* calls that save and restore the current context around them.
    • SoWx.C: calls CoinEglOffscreen::install() under OIV_COIN. That function exists only on Linux, so a macOS link would fail.
    • SoWxViewer.H: <X11/Intrinsic.h>. It was there only for the types of four dead Xt-era methods; those methods are now removed. MoPanel.C had been getting X11's False through this include.
    • SoWxViewer.C: X11's None ended the wx GL attribute list.
    • Not live: sysfonts.C compiles to nothing because __sys_fonts is never defined (labels are drawn by flclient/FreeType). The stereo code was SGI-only. The vendored SoOffscreenRenderer.H and SoWindowElement.H are used only with ECCE_USE_COIN=OFF.

    Design. include/inv/SoWx/GlPlatform.H and src/inv/wxinv/GlPlatform.C hold the current-context query, release and restore (GLX), and installOffscreen(). ECCE_GL_X11 chooses the branch: 1 on Linux/FreeBSD, 0 elsewhere. With 0, the context calls do nothing and Coin uses its own CGL/WGL offscreen renderer. On-screen drawing was already wxGLCanvas/wxGLContext. There is no stereo function, because nothing live would call it.

    Linux. Before and after, 69 renders are pixel-identical: built-in styles, labels, isosurface, thumbnails, the Builder calc scenes (water MO and normal modes, CrCO6 MO), and look_offscreen_shading (canvas, vizfile, offscreen). offscreen-check passes with and without DISPLAY, and the vendored build compiles the changed files.

    Non-X11 compile. There is no wxOSX on Debian, so tools/nonx11/check.py approximates one. It compiles all 271 sources of eccewxinv, eccemoiv, eccevizsg and eccewxviz with ECCE_GL_X11=0, #error stubs for X11/GLX/EGL headers, and wxGTK's GLX canvas header swapped for the portable API. All 271 pass. nm shows no GLX/EGL/Xlib symbols in the layer or its callers. The rest of wx stays wxGTK, so this checks our code only. The real check is the macOS build itself.

    What a macOS build should now get past: the viewer libraries (wxinv, moiv, viz, wxviz).

    What remains:

    • Step 5, CMake:
      • find_package(X11 REQUIRED) (line 63) has to become Linux-only.
      • Drop X11::X11 from builder, vizthumbnail, viewer-scenes, render-rgb and viewer-bench (lines 463-488). The builder already has no libX11 in NEEDED.
      • Gate the OpenGL::EGL link on the same condition as ECCE_GL_X11 and pass ECCE_GL_X11 from CMake.
      • Make the gtk+-3.0/GDK-X11 part of ewxWindowUtils (line 329) conditional.
      • Remove the libegl-dev/libx11-dev build-deps from non-Linux packaging.
    • tools/viewer-bench still calls glX* directly. It is EXCLUDE_FROM_ALL.
    • Untested on a Mac: Coin's CGL offscreen renderer (used for thumbnails), and the alpha-buffer request, which now also applies on wxOSX.
  4. ohlincha commented on Oct 5, 2026

    @ohlincha
    CollaboratorAuthor

    Step 5 is on branch wip/232-cmake-x11 (one commit, not merged).

    Change. The ECCE_GL_X11 option defaults to ON on UNIX but not APPLE. It is passed to every target as a compile definition and gates find_package(X11), the Xt check, X11::X11 in the app link lists, the EGL link and viewer-bench. Deb/rpm dependencies come from shlibdeps and are unchanged.

    Linux. Builder, organizer, eccejobstore and vizthumbnail have identical link command lines before and after. A clean build of the first three gives identical ldd output; both builds stopped at 852/853. A configure with -DECCE_GL_X11=OFF has no X11/EGL in the builder link and no viewer-bench target, and tools/nonx11/check.py passes 271/271 against it. Not checked: a real Mac.

    macOS CI (run 37358122449): configure passes and the build reaches 472/1112 before it stops. The Linux jobs pass. Next obstacles, none involving X11:

    • DirectTransport.C:315,539: sigtimedwait is not declared on macOS.
    • OpenSshTransport.C:724: SOCK_CLOEXEC is not declared on macOS.
    • More errors may follow, since ninja stops at the first failures.
    • The macOS job still installs XQuartz, which is no longer needed.
  5. ohlincha commented on Oct 5, 2026

    @ohlincha
    CollaboratorAuthor

    @mattasplund Thanks for the report about "Shell in calculation directory". It is fixed on main (20e4e87): every local shell or tail (Organizer, Launcher, MD Prepare) now uses Edit > Preferences > Terminal or ECCE_TERMINAL, in the calculation directory, the same way the remote shells already did. As a side effect, a calculation directory whose path contains a space now also works over ssh.

    All five steps of this issue are now on main (48b2292):

      1. dead Motif/Xt code removed;
      1. windows are raised through one wx/GDK helper;
      1. eccejobstore runs on poll() instead of the Xt event loop;
      1. the viewer's GLX/EGL calls sit behind one layer, and macOS uses Coin's own offscreen renderer;
      1. X11, Xt and EGL are found and linked only on Linux/X11.

    A macOS build therefore no longer needs XQuartz or libX11/libXt. On Linux the change is invisible: 69 viewer renders are pixel-identical, and the launch, queue and jobstore suites pass.

    macOS CI (Homebrew, Cocoa wxWidgets) now configures and gets to about 40% of the build (472 of 1112 steps). The next failures are not about X11 but about two Linux-only calls in the remote-shell code: sigtimedwait (src/comm/.../DirectTransport.C) and SOCK_CLOEXEC (OpenSshTransport.C). They are next; more may follow, since the build stops at the first errors. Your student will hit the same places, so it is worth waiting for those two fixes, or starting from them.

    For the editor: vi stays the default on Linux. gedit works via Preferences or ECCE_EDITOR, but use gedit --wait, otherwise ECCE ends the edit session as soon as gedit hands the file to an already open window.

  6. ohlincha commented on Oct 7, 2026

    @ohlincha
    CollaboratorAuthor

    Closing: all five steps are on main (merge 48b2292): dead Motif/Xt code removed, windows raised through ewxRaiseWindow(), eccejobstore on poll() instead of the Xt event loop (src/comm/commxt/JobStore.C has no X11/Xt reference left), the viewer's GLX/EGL behind GlPlatform, and X11/Xt/EGL found and linked only when ECCE_GL_X11 is on (Linux/X11). Covered by tools/nonx11/check.py (271 viewer sources compiled with ECCE_GL_X11=0), the launch/queue/jobstore suites, and the macOS CI build, which now links. Matt's terminal report was fixed separately in 20e4e87. Reopen if a non-Linux build still needs libX11 or libXt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions