ghaerr / microwindows

The Nano-X Window System
Other
648 stars 91 forks source link

I am so confused! #65

Closed GNUfan42 closed 2 years ago

GNUfan42 commented 2 years ago

I'm trying to port a few programs to DOS, which use X11 library, and I found this library. According to the Readme.md, Nano-X and Microwindows seems to be two names refer to the exact same thing. I was thinking about if this library has functions required by the program, so I looked for X11's header files and I found some at src/nx11/X11-local/X11 and I couldn't find Xrender.h which is needed by the program. After a while, I found this website. It says:

It says Nano-X and Microwindows are two different things. I looked around on the website, and I found this file names djgppn.zip. This is a djgpp installation and in djgpp/include/X11 there are much more X11 header files. So here are my questions:

  1. What are Nano-X and Microwindows exactly?
  2. Why there're more X11 header files in that archive?
  3. What is the relationship between this repo and the website?

Thank you!

ghaerr commented 2 years ago

Hello @GNUfan42,

First, thank you for looking at Microwindows/Nano-X. I'm sorry for your confusion; I'll try explain a bit.

Microwindows was the original name of this project, but it was changed at Microsoft's demand to Nano-X. The two terms are used similarly for the project name, but each has a distinct meaning within the project; the project is actually a low-memory footprint 2D graphics engine and window system that has two APIs built on top of it: the first, a Microsoft Win32-compatible API, is called Microwindows, and the second, an Xlib-like (but not strictly compatible) called nano-X.

The nano-X API is similar to X11, in that it uses windows, contexts, IDs, and is client/server based. That is, the application is the client and issues draw commands from its main loop to the graphics server, which is an application usually named nano-X.

At one point, various older graphics libraries, like FLTK, which lacked windowing systems, were written for X11. Users wanted to run FLTK programs on (embedded) Linux without X11. An X11-to-Nano-X (NXlib) library was built that was X11-compatible on the front and, and translated the calls to nano-X API calls talking to nano-X. This NXlib library was then added directly to the Microwindows / Nano-X project, and worked pretty well.

At a later point, Georg Potthast ported NXlib and Nano-X to DJGPP. This particular version used a feature that allowed the client and server "programs" to operate as one, that is, no client/server. The website you refer to is probably some of that code, as this repo doesn't directly support DJGPP (since I have no system to run that on, and that port has been relatively unmaintained).

Finally, the NXlib library and/or portions of current Nano-X that deal with X11 had a problem: they needed to be (cross) compiled on systems that didn't necessarily have X11 installed (as Nano-X was an X11 replacement, after all). Because of this, a certain number of basic X11 header files were included in nano-X to allow the NXlib library to compile. In older versions, more header files were linked to than required; in the current version, only a minimal number of X11 header files are included, along with the option to point to the installed X11 header files.

I hope this makes more sense to you, please let me know if you need more help. At this point, I would not suggest using Nano-X out of the box for DOS, as it will require getting the unmaintained DJGPP port working again (although I can help you with that if you'd like).

Thank you!

GNUfan42 commented 2 years ago

Hello @ghaerr,

Thank you for your explanation! I thought that there're not enough header files is beacuse the X11 functions are not fully implemented by NXlib. But what your meaning is, these X11 header files are only used by NXlib, and after it is compiled it will generate header files for actual development, right?

However I don't care about using an older version of the library, as long as it works.

Thank you!

ghaerr commented 2 years ago

But what your meaning is, these X11 header files are only used by NXlib, and after it is compiled it will generate header files for actual development, right?

Almost - the X11 header files are only used to compile NXlib, then a library is produced that can be linked directly with already-compiled X11 programs - instead of linking with -lX11, one uses -lNX11. If dynamic libraries are used, libNX11.so can be renamed to libX11.so with no relink required. NXlib isn't a replacement for having X11 headers installed or available for cross-compilation, it only redirects X11 calls to the nano-X server.

For the X11 functions not fully implemented, either a link error results, or an included stub gives a warning.