Image Map Image Map
Results 1 to 8 of 8

Thread: low-level X window program

  1. #1

    Default low-level X window program

    Is it possible to open a TCP port on localhost (port 6000?) and send X11 protocol commands to implement a GUI application on a Linux system? Or is that not how things are done? It sounds like the 'normal' way to interface with X would be through libX11 but can that abstraction layer be cut out? My goal would be to open a window and display a bitmap image, like the GUI equivalent of a hello-world program.

  2. #2

    Default

    With a total and overwhelming bias I'd try to hunt down a copy of the excellent

    Programming in X-Windows
    IBM Redbook GG24-3382
    Maria and I (marcus) wrote the whole redbook together and indeed there was a hello world xlib program
    Since this was written in 1989 not sure how available it is any more

    m

  3. #3

    Default

    I wouldn't consider libX11 very much of an abstraction over the wire protocol. In terms of your Hello World example, writing code directly to the X11 wire protocol would be like making the Linux kernel device calls to output characters vs. using printf(). If you can't find a copy of amouse's manual, you can find electronic versions of the O'Reilly books here:

    https://www.x.org/releases/current/d...11/libX11.html

    and the libX11 code here:

    https://gitlab.freedesktop.org/xorg/lib/libx11
    Last edited by resman; November 27th, 2020 at 07:59 AM. Reason: Clarity

  4. #4

    Default

    Quote Originally Posted by resman View Post
    like making the Linux kernel device calls to output characters vs. using printf()
    Well, that is exactly what I'm doing I'm starting from scratch with my own compiler and linker, so the INT 0x80 interface is all I have at the moment. Before I can use xlib I would need to add dynamic linking capability to my linker or figure out how to load the library and locate function entry points at runtime. Maybe I should do that first. But since the X11 protocol seems to be designed for use over a network connection and the protocol spec is easily found, I thought maybe that could be a shortcut.

  5. #5
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    4,264

    Default

    Providing you obey the network protocol, you can do anything you want to do...

    Just watch the byte ordering, alignment and padding.

    You must also ensure that you track any state information at your end that you are expected to do by the other end.

    Dave

  6. #6

    Default

    Just use xlib man. It's extremely low-level already. You'll basically just be rewriting your own version of xlib anyway. Which I mean that's cool if that's what you want to do, but I don't think it's very practical for your use-case of displaying a bitmap image.

    It's not quite as simple as just opening a TCP connection and sending some commands and then being done. X11 is event-driven and asynchronous, so if you want it to work right I expect you'll have to completely reimplement xlib's event dispatcher and who knows what else. It's been like 20 years or more since I actually did any direct xlib programming, but my recollection is that things aren't going to work right unless you properly implement the expose, resize, etc events because the x-server and/or window manager is going to be raising them to your application as it maps the window frame and whatever else.

    But like I said, it's been years, and I may be full of poo.

    PS: If this is going to be a non-Unix box running the x-client, I think there are implementations of some of the client-side x11 stuff in cygwin that you may be able to borrow and make work with non-Unixen.

    PPS: A simpler option might be to run your own daemon on the x-server side of things that listens on some other port, sucks the bitmap data through when it gets a connection, and then opens the window and displays your stuff using some higher level windowing library. SDL or something. Then you could port your server-side stuff to non-X displays pretty easily.
    Last edited by bladamson; November 27th, 2020 at 03:22 PM.
    -- Lee
    If you get super-bored, try muh crappy YouTube channel: Old Computer Fun!
    Looking to Buy/Trade For (non-working is fine): Tandy 1000 EX/HX power supply, Mac IIci hard drive sled and one bottom rubber foot, Multisync VGA CRTs, Decent NuBus video card, PC-era Tandy stuff, Weird Old Unix Stuff, Aesthetic Old Serial Terminals (HP and Data General in particular)

  7. #7
    Join Date
    May 2011
    Location
    Outer Mongolia
    Posts
    3,229

    Default

    I second either using Xlib or using some kind of “display proxy” layer in between your home brew code and the display. Likewise it’s been a long time since I even thought about it, but my understanding was that X11 is *really* low level and there’s a lot of overhead setting up a session; it’s not as simple as just opening up a socket, sending a “hey, display these pixels for me, kthxbye!” command.
    My Retro-computing YouTube Channel (updates... eventually?): Paleozoic PCs

  8. #8

    Default

    Quote Originally Posted by bakemono View Post
    Is it possible to open a TCP port on localhost (port 6000?) and send X11 protocol commands to implement a GUI application on a Linux system?
    Yes, but it is not an easy path. Also, applications use Unix Domain sockets to connect to the X server instead of TCP. Most distributions disable the TCP listener for their X support by default, although it can easily be enabled.

    Quote Originally Posted by bakemono View Post
    It sounds like the 'normal' way to interface with X would be through libX11 but can that abstraction layer be cut out? My goal would be to open a window and display a bitmap image, like the GUI equivalent of a hello-world program.
    There are basically two abstraction layers available, xlib and xcb. Both libraries are, to my knowledge, close to the wire protocol; xcb does not attempt to hide the fact that X11 is asynchronous and therefore allows higher performance with well-written applications. Also, everyone and their most famous child recommends moving away from xlib.

    If you actually want to get down to the wire, the documentation is available at:
    https://www.x.org/releases/X11R7.7/d...1protocol.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •