Skip to content

Commit

Permalink
tinyx: add xeyes, xclock, xedit, twm ports
Browse files Browse the repository at this point in the history
xedit displays correctly and seems to be functional (reads files, UI is
responsive), but there's an issue with input capture, so editing
capabilities are currently limited

JIRA: RTOS-889
  • Loading branch information
adamgreloch committed Aug 21, 2024
1 parent 046fc99 commit 6fff19f
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 13 deletions.
102 changes: 89 additions & 13 deletions tinyx/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ build_tinyxlib() {
PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/tinyxlib/${short_ref}"
b_port_download "https://github.com/idunham/tinyxlib/archive/" "${archive_filename}"

# TODO move make outside of reconfigure block
if should_reconfigure "tinyxlib/${short_ref}"; then
extract_sources

Expand Down Expand Up @@ -163,7 +164,7 @@ build_tinyxlib() {
build_a_lib() {
libname="$1"
version="$2"
configure_opts="${@:3}"
configure_opts=${@:3}

b_log "tinyx: building ${libname}"

Expand All @@ -179,7 +180,7 @@ build_a_lib() {
b_port_apply_patches "${PREFIX_PORT_SRC}" "${libname}/${version}"

if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then
exec_configure "${configure_opts}"
exec_configure ${configure_opts}
fi

mark_as_configured "${libname}/${version}"
Expand Down Expand Up @@ -282,20 +283,91 @@ build_tinywm() {
b_install "${PREFIX_PORTS_INSTALL}/tinywm" /bin
}

build_x11_app() {
appname="$1"
version="$2"
configure_opts=${@:3}

b_log "tinyx: building ${appname}"

archive_filename="${appname}-${version}.tar.gz"

PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/${appname}/${version}"

b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}"

if should_reconfigure "${appname}/${version}"; then
extract_sources

b_port_apply_patches "${PREFIX_PORT_SRC}" "${appname}/${version}"

if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then
exec_configure ${configure_opts}
fi

# FIXME: this is brutal, see build_tinyx note
find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g'

mark_as_configured "${appname}/${version}"
fi

make -C "${PREFIX_PORT_SRC}"

$STRIP -o "${PREFIX_PROG_STRIPPED}/${appname}" "${PREFIX_PORT_SRC}/${appname}"

b_install "${PREFIX_PORTS_INSTALL}/${appname}" /bin
}


build_xedit() {
b_log "tinyx: building xedit"

version="1.2.4"
archive_filename="xedit-${version}.tar.gz"
PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/xedit/${version}"

b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}"

if should_reconfigure "xedit/${version}"; then
extract_sources

b_port_apply_patches "${PREFIX_PORT_SRC}" "xedit/${version}"

if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then
# exec_configure --with-lispdir="${PREFIX_A}/xedit/lsp" --with-appdefaultdir="$TMP_DIR" --bindir="$TMP_DIR"
exec_configure --with-lispdir="/etc/X11/xedit/lsp" --with-appdefaultdir="/etc/X11/app-defaults" --bindir="$TMP_DIR"
fi

# # FIXME: this is brutal, see build_tinyx note
find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g'

mark_as_configured "xedit/${version}"
fi

make -C "${PREFIX_PORT_SRC}"
# make -C "${PREFIX_PORT_SRC}" install_sh="" install

$STRIP -o "${PREFIX_PROG_STRIPPED}/xedit" "${PREFIX_PORT_SRC}/xedit"

# TODO: install app-defaults

b_install "${PREFIX_PORTS_INSTALL}/xedit" /bin
}

build_xmessage() {
b_log "tinyx: building xmessage"
# requires yacc
build_twm() {
b_log "tinyx: building twm"

version="1.0.7"
archive_filename="xmessage-${version}.tar.gz"
PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/xmessage/${version}"
version="1.0.12"
archive_filename="twm-${version}.tar.gz"
PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/twm/${version}"

b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}"

if should_reconfigure "xmessage/${version}"; then
if should_reconfigure "twm/${version}"; then
extract_sources

b_port_apply_patches "${PREFIX_PORT_SRC}" "xmessage/${version}"
b_port_apply_patches "${PREFIX_PORT_SRC}" "twm/${version}"

if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then
exec_configure
Expand All @@ -304,14 +376,14 @@ build_xmessage() {
# FIXME: this is brutal, see build_tinyx note
find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g'

mark_as_configured "xmessage/${version}"
mark_as_configured "twm/${version}"
fi

make -C "${PREFIX_PORT_SRC}"

$STRIP -o "${PREFIX_PROG_STRIPPED}/xmessage" "${PREFIX_PORT_SRC}/xmessage"
$STRIP -o "${PREFIX_PROG_STRIPPED}/twm" "${PREFIX_PORT_SRC}/src/twm"

b_install "${PREFIX_PORTS_INSTALL}/xmessage" /bin
b_install "${PREFIX_PORTS_INSTALL}/twm" /bin
}


Expand Down Expand Up @@ -349,8 +421,12 @@ build_tinyx

build_tinywm
build_ico
build_xmessage
build_suckless st 0.2 # st compiles, but doesn't work yet
build_suckless dwm 5.1
build_x11_app xmessage 1.0.7
build_x11_app xclock 1.1.1 --without-xft --without-xkb
build_x11_app xeyes 1.1.1 --without-xrender
build_xedit
build_twm

rm -rf "$TMP_DIR"
39 changes: 39 additions & 0 deletions tinyx/patches/tinyx/10-vga.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff -ruN a/kdrive/fbdev/fbdev.c b/kdrive/fbdev/fbdev.c
--- a/kdrive/fbdev/fbdev.c 2024-08-19 09:44:57.484385862 +0200
+++ b/kdrive/fbdev/fbdev.c 2024-08-19 09:57:33.218184783 +0200
@@ -28,6 +28,15 @@
#include <sys/ioctl.h>

#include <errno.h>
+#include <pthread.h>
+
+void refresher(void *arg) {
+ graph_t* g = (graph_t*) arg;
+ while (1) {
+ usleep(33333); // ~30Hz
+ graph_commit(g);
+ }
+}

extern int KdTsPhyScreen;

@@ -92,7 +101,7 @@
FatalError("failed to initialize graphics adapter: %s", strerror(k));
}

- if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_DEFFREQ)) < 0) {
+ if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_30Hz)) < 0) {
FatalError("failed to set graphics mode: %d", k);
}

@@ -100,6 +109,10 @@
FatalError(stderr, "32-bit video resolution required");
}

+ pthread_t thread;
+
+ pthread_create(&thread, NULL, (void*) refresher, &priv->g);
+
priv->fb = priv->g.data;

priv->g.height = priv->g.height;
78 changes: 78 additions & 0 deletions tinyx/patches/tinyx/eed490/10-vga.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
diff -ruN a/kdrive/fbdev/fbdev.c b/kdrive/fbdev/fbdev.c
--- a/kdrive/fbdev/fbdev.c 2024-08-21 13:07:32.038968445 +0200
+++ b/kdrive/fbdev/fbdev.c 2024-08-21 12:26:44.467523732 +0200
@@ -28,6 +28,15 @@
#include <sys/ioctl.h>

#include <errno.h>
+#include <pthread.h>
+
+void refresher(void *arg) {
+ graph_t* g = (graph_t*) arg;
+ while (1) {
+ usleep(12588); // ~70Hz
+ graph_commit(g);
+ }
+}

extern int KdTsPhyScreen;

@@ -80,7 +89,6 @@

int k;

- priv->bits_per_pixel = 32;
priv->smem_len = 0x2000;

if ((k = graph_init()) < 0) {
@@ -92,15 +100,16 @@
FatalError("failed to initialize graphics adapter: %s", strerror(k));
}

- if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_DEFFREQ)) < 0) {
+ if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_70Hz)) < 0) {
FatalError("failed to set graphics mode: %d", k);
}

- if (priv->g.depth != 4) {
- FatalError(stderr, "32-bit video resolution required");
- }
+ pthread_t thread;
+
+ pthread_create(&thread, NULL, (void*) refresher, &priv->g);

priv->fb = priv->g.data;
+ priv->bits_per_pixel = priv->g.depth * 8;

priv->g.height = priv->g.height;
priv->g.width = priv->g.width;
@@ -316,22 +325,22 @@
FbdevPriv *priv = screen->card->driver;
int depth = priv->bits_per_pixel;

- screen->width = 640;
- screen->height = 400;
+ screen->width = priv->g.width;
+ screen->height = priv->g.height;
screen->rate = 30;
screen->fb.depth = depth;

- depth = priv->bits_per_pixel;
-
/* Calculate line_length if it's zero */
if (!priv->line_length)
priv->line_length = (priv->g.width * depth + 7) / 8;

screen->fb.visuals = (1 << TrueColor);
+
#define Mask(o,l) (((1 << l) - 1) << o)
- screen->fb.redMask = Mask(16,8);
- screen->fb.greenMask = Mask(8,8);
- screen->fb.blueMask = Mask(0,8);
+ int offset = depth / 4;
+ screen->fb.redMask = Mask(offset * 2, offset);
+ screen->fb.greenMask = Mask(offset * 1, offset);
+ screen->fb.blueMask = Mask(0,offset);
screen->fb.bitsPerPixel = priv->bits_per_pixel;

return fbdevMapFramebuffer(screen);
24 changes: 24 additions & 0 deletions tinyx/patches/tinyxlib/9862f3/18-Xtranssock-dontwait.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff -ruN a/libxtrans/Xtranssock.c b/libxtrans/Xtranssock.c
--- a/libxtrans/Xtranssock.c 2024-08-05 09:04:38.631732705 +0200
+++ b/libxtrans/Xtranssock.c 2024-08-21 17:11:03.820006544 +0200
@@ -1547,11 +1547,17 @@
{
/* this bufsize doesn't really matter, but using recv() as a replacement
* for ioctl/FIONREAD is quite slow
- * TODO implement ioctl/FIONREAD in phoenix kernel */
+ * Maybe implement ioctl/FIONREAD in phoenix kernel? */
#define BUFSIZE 64
static char buf[BUFSIZE];
- *pend = recv(ciptr->fd, buf, BUFSIZE, MSG_PEEK);
- if (pend < 0) return -1;
+ int k = recv(ciptr->fd, buf, BUFSIZE, MSG_PEEK | MSG_DONTWAIT);
+ if (k < 0) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN)
+ k = 0;
+ else
+ return -1;
+ }
+ *pend = k;
return 0;
}

73 changes: 73 additions & 0 deletions tinyx/patches/twm/1.0.12/01-twm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff -ruN a/configure.ac b/configure.ac
--- a/configure.ac 2022-04-02 20:36:49.000000000 +0200
+++ b/configure.ac 2024-08-20 10:45:57.220251974 +0200
@@ -50,10 +50,6 @@

# Checks for pkg-config packages
PKG_CHECK_MODULES([TWM], [x11 xext xt xmu ice sm xproto >= 7.0.17])
-PKG_CHECK_MODULES([XRANDR], [xrandr], [have_xrandr=yes], [have_xrandr=no])
-if test "$have_xrandr" = yes; then
- AC_DEFINE([HAVE_XRANDR], [1], [Define to 1 if you have the xrandr headers/libraries])
-fi

AC_CONFIG_FILES([Makefile
src/Makefile
diff -ruN a/src/menus.c b/src/menus.c
--- a/src/menus.c 2022-04-02 20:36:49.000000000 +0200
+++ b/src/menus.c 2024-08-20 10:53:18.394309064 +0200
@@ -79,7 +79,9 @@
#include "session.h"
#include <X11/Xmu/CharSet.h>
#include "version.h"
-#include <X11/extensions/sync.h>
+#include <X11/Xmd.h>
+#include <X11/extensions/syncconst.h>
+#include <X11/extensions/syncstr.h>
#include <X11/SM/SMlib.h>

int RootFunction = 0;
@@ -1906,6 +1908,7 @@
Bell(XkbBI_MinorError, 0, tmp_win->w);
break;

+#if 0
case F_CIRCLEUP:
XCirculateSubwindowsUp(dpy, Scr->Root);
break;
@@ -1913,6 +1916,7 @@
case F_CIRCLEDOWN:
XCirculateSubwindowsDown(dpy, Scr->Root);
break;
+#endif

case F_EXEC:
PopDownMenu();
diff -ruN a/src/parse.c b/src/parse.c
--- a/src/parse.c 2022-04-02 20:36:49.000000000 +0200
+++ b/src/parse.c 2024-08-20 10:48:18.826964856 +0200
@@ -69,8 +69,10 @@
#include "gram.h"
#include "parse.h"

+#include <X11/Xmd.h>
#include <X11/Xatom.h>
-#include <X11/extensions/sync.h>
+#include <X11/extensions/syncconst.h>
+#include <X11/extensions/syncstr.h>

#ifndef SYSTEM_INIT_FILE
#define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc"
diff -ruN a/src/twm.c b/src/twm.c
--- a/src/twm.c 2022-04-02 20:36:49.000000000 +0200
+++ b/src/twm.c 2024-08-20 10:53:07.850111898 +0200
@@ -81,7 +81,9 @@
#include <X11/Xatom.h>
#include <X11/SM/SMlib.h>
#include <X11/Xmu/Error.h>
-#include <X11/extensions/sync.h>
+#include <X11/Xmd.h>
+#include <X11/extensions/syncstr.h>
+#include <X11/extensions/syncconst.h>
#include <X11/Xlocale.h>

#ifdef XPRINT
Loading

0 comments on commit 6fff19f

Please sign in to comment.