Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include mk/config.mk
include mk/sources.mk
include mk/common.mk
include mk/library.mk
include mk/libxt.mk
include mk/tests.mk
include mk/examples.mk
include mk/upstream-headers.mk
Expand Down
31 changes: 31 additions & 0 deletions include/X11/ICE/ICElib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Stub X11/ICE/ICElib.h for libx11-compat's libXt build
*
* Copyright 2026 libx11-compat contributors
* SPDX-License-Identifier: MIT
*/

/* libXt's Shell.c includes this header at the top of the file even when
* XT_NO_SM keeps every ICE/SM call out of the compiled translation unit.
* Provide an opaque IceConn type plus the small set of helpers and
* constants the in-tree compatibility surface references so the header
* resolves without dragging libICE into the build closure.
*/
#ifndef _LIBX11_COMPAT_ICELIB_H_
#define _LIBX11_COMPAT_ICELIB_H_

typedef struct _IceConn *IceConn;

/* Real libICE defines IceProcessMessagesStatus as an enum too, but the
* values themselves are commonly probed via macros in some downstream
* code. Mirror with #ifndef so any later #include of the real header
* (e.g. through a Motif build pulling system X11 headers) does not
* collide on the enum tag. */
#ifndef IceProcessMessagesSuccess
typedef enum {
IceProcessMessagesSuccess = 0,
IceProcessMessagesIOError = 1,
IceProcessMessagesConnectionClosed = 2
} IceProcessMessagesStatus;
#endif

#endif /* _LIBX11_COMPAT_ICELIB_H_ */
115 changes: 115 additions & 0 deletions include/X11/SM/SMlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* Stub X11/SM/SMlib.h for libx11-compat's libXt build
*
* Copyright 2026 libx11-compat contributors
* SPDX-License-Identifier: MIT
*/

/* libXt's generated Shell.h unconditionally includes this header even
* when session management is compiled out via XT_NO_SM. ShellP.h also
* declares a SmcConn slot in the WidgetClass record so the struct layout
* stays binary-compatible. libx11-compat ships no libSM and runs in a
* single process with no XSMP peer, so the type lives only as an opaque
* pointer here and the few constants that downstream code probes are
* synthesized as enums.
*/
#ifndef _LIBX11_COMPAT_SMLIB_H_
#define _LIBX11_COMPAT_SMLIB_H_

#include <X11/Xfuncproto.h>
#include <X11/Xosdefs.h>

typedef struct _SmcConn *SmcConn;
typedef struct _SmsConn *SmsConn;
typedef void *SmPointer;

typedef struct {
int length;
SmPointer value;
} SmPropValue;

typedef struct {
char *name;
char *type;
int num_vals;
SmPropValue *vals;
} SmProp;

typedef int SmcCallbacks;

/* Real libSM ships these as #define macros, so we mirror the same shape
* with #ifndef guards. Using `enum { SmProtoMajor = 1, ... }` here would
* conflict at preprocess time if any consumer also pulled in the system
* <X11/SM/SMlib.h>, because its `#define SmProtoMajor 1` would expand
* inside our enum declaration to `1 = 1`. */
#ifndef SmProtoMajor
#define SmProtoMajor 1
#endif
#ifndef SmProtoMinor
#define SmProtoMinor 0
#endif
#ifndef SmDialogError
#define SmDialogError 0
#endif
#ifndef SmDialogNormal
#define SmDialogNormal 1
#endif
#ifndef SmInteractStyleNone
#define SmInteractStyleNone 0
#endif
#ifndef SmInteractStyleErrors
#define SmInteractStyleErrors 1
#endif
#ifndef SmInteractStyleAny
#define SmInteractStyleAny 2
#endif
#ifndef SmSaveGlobal
#define SmSaveGlobal 0
#endif
#ifndef SmSaveLocal
#define SmSaveLocal 1
#endif
#ifndef SmSaveBoth
#define SmSaveBoth 2
#endif
#ifndef SmRestartIfRunning
#define SmRestartIfRunning 0
#endif
#ifndef SmRestartAnyway
#define SmRestartAnyway 1
#endif
#ifndef SmRestartImmediately
#define SmRestartImmediately 2
#endif
#ifndef SmRestartNever
#define SmRestartNever 3
#endif
#ifndef SmcSaveYourselfProcMask
#define SmcSaveYourselfProcMask 1
#endif
#ifndef SmcDieProcMask
#define SmcDieProcMask 2
#endif
#ifndef SmcSaveCompleteProcMask
#define SmcSaveCompleteProcMask 4
#endif
#ifndef SmcShutdownCancelledProcMask
#define SmcShutdownCancelledProcMask 8
#endif

#define SmCloneCommand "CloneCommand"
#define SmCurrentDirectory "CurrentDirectory"
#define SmDiscardCommand "DiscardCommand"
#define SmEnvironment "Environment"
#define SmProcessID "ProcessID"
#define SmProgram "Program"
#define SmResignCommand "ResignCommand"
#define SmRestartCommand "RestartCommand"
#define SmRestartStyleHint "RestartStyleHint"
#define SmShutdownCommand "ShutdownCommand"
#define SmUserID "UserID"

#define SmARRAY8 "ARRAY8"
#define SmCARD8 "CARD8"
#define SmLISTofARRAY8 "LISTofARRAY8"

#endif /* _LIBX11_COMPAT_SMLIB_H_ */
35 changes: 35 additions & 0 deletions include/X11/Xmu/Editres.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Stub Xmu/Editres.h for libx11-compat's libXt build
*
* Copyright 2026 libx11-compat contributors
* SPDX-License-Identifier: MIT
*/

/* The real Xmu/Editres.h declares the editres-protocol hook that libXt's
* Shell.c registers so an external editres client can introspect a live
* widget tree. libx11-compat ships no Xmu, no editres client targets this
* in-process display, and Shell.c's only use is the function-pointer
* registration. A no-op _XEditResCheckMessages keeps Shell.c compilable
* and link-safe without dragging libXmu into the build.
*/
#ifndef _XMU_EDITRES_H_
#define _XMU_EDITRES_H_

#include <X11/Intrinsic.h>

#define EDITRES_NAME "Editres"
#define EDITRES_COMMAND_ATOM "Comm"
#define EDITRES_PROTOCOL_ATOM "EditresProtocol"
#define EDITRES_VERSION 5

static inline void _XEditResCheckMessages(Widget widget,
XtPointer data,
XEvent *event,
Boolean *cont)
{
(void) widget;
(void) data;
(void) event;
(void) cont;
}

#endif /* _XMU_EDITRES_H_ */
55 changes: 55 additions & 0 deletions include/libxt-build/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Synthesized config.h for the libXt build inside libx11-compat
*
* Copyright 2026 libx11-compat contributors
* SPDX-License-Identifier: MIT
*/

/* libXt expects an autoconf-generated config.h to define a handful of
* platform knobs. We are not running autoconf, so the knobs are pinned
* to values that match the modern macOS / Linux environments libx11-compat
* targets: poll(2) is always available, threads are enabled, and the
* session-management surface is disabled so libICE/libSM stay out of the
* dependency closure (see mk/libxt.mk).
*
* This header lives under include/libxt-build/ rather than the X11/
* namespace because the basename ``config.h'' is too generic to share an
* include path with anything else. mk/libxt.mk adds the parent directory
* to the include path *only* for the libXt translation units.
*/

#ifndef LIBX11_COMPAT_LIBXT_CONFIG_H
#define LIBX11_COMPAT_LIBXT_CONFIG_H

#define PACKAGE_NAME "libXt"
#define PACKAGE_VERSION "1.3.1"
#define PACKAGE_STRING "libXt 1.3.1"
#define PACKAGE_BUGREPORT "https://github.com/sysprog21/libx11-compat/issues"
#define VERSION PACKAGE_VERSION

/* poll() is on every libx11-compat-supported platform. The select() fallback
* path in NextEvent.c is bit-set-sized and predates large fd numbers; we
* never want it. */
#define USE_POLL 1

/* Multi-threaded toolkit. Wires Threads.c's mutex hooks into the XtAppLock
* machinery so XtAppContexts can be shared across threads. */
#define XTHREADS 1

/* Disable session-management hooks in Shell.c so libICE / libSM stay out
* of the link line. SDL has no notion of XSMP and the in-process display
* has no peer to negotiate with. */
#define XT_NO_SM 1

/* HAVE_REALLOCARRAY left undefined deliberately. reallocarray() exists in
* Apple's libSystem and glibc >= 2.26, but the macOS SDK does not declare
* it in <stdlib.h> even with _DARWIN_C_SOURCE, so the implicit-declaration
* error kills the build before the linker would have found it. libXt's
* Alloc.c falls back to Xrealloc + an explicit overflow check when this
* macro is absent, which costs nothing in performance and works on every
* supported host. */

/* asprintf is on every glibc and Apple libc. Initialize.c uses it for
* defaults-file path assembly. */
#define HAVE_ASPRINTF 1

#endif /* LIBX11_COMPAT_LIBXT_CONFIG_H */
Loading
Loading