How a windowing system is implemented in C ?

Hi All,
I was wondering how using C the programmers have implemented a GUI (x window & ms windows). Am curious to learn about the overall architecture.

I learned a bit about graphics primitives, memory mapped io, etc
I want to learn more whether the above is the foundation upon which modern GUI are built on both Windows & Linux.
Also, i want to know how the Kernel comes into play here.

Xwindows is usually based on the ncurses library. See what your manual page for ncurses shows you.

This is a good how-to document:

NCURSES Programming HOWTO

1 Like

i read very quickly the ncurses manual.

but my question is at a much lower level how the code accesses the bare graphics card?

Actually you should be using Xlib. There are some tutorials around, just google for it. Xlib talks to the Xserver. The Xserver talks to a HAL type driver. I guess you could get the source code to the Xserver and be a replacement Xserver. But you would need to talk to the HAL driver. The HAL drivers talks to a driver supplied by the guys who made the video card. I have heard complaints that they don't open-source their drivers. But I have never looked into that. I really have never peeked inside Xserver, but I gather that you cannot talk directly to the graphics hardware.

I suggest you stick with Xlib.

Nobody except graphics card manufacturers has programmed graphics cards at the bare metal for over 20 years. If you want the best performance, you use the drivers they make. For UNIX, that mostly means using the drivers they make for X11.

Memory-mapped I/O is often involved, yes.

1 Like