2

Recently, I am studying Xlib and come to have a question: What system calls (API's) does X.Org Server use to realize GUI environment.

In terms of output, what system calls enable us to draw windows (that is, certain rectangles with colors) on a screen. And in terms of input, what system calls enable us to get keyboard and mouse input information.

Can we draw windows without the help of X.Org Server? Of course, it is not practical. But I am eager to know if possible or not.

0

2 Answers 2

3

What system calls (API's) does X.Org Server use to realize GUI environment.

Networking/domain sockets for communication between the X server and the X clients.

Whatever the hardware driver needs to control the hardware: In early Linux this was mostly memory-mapped I/O and ports, now it is mostly kernel drivers with their own API.

what system calls enable us to draw windows

There is no system call for this.

And in terms of input, what system calls enable us to get keyboard and mouse input information.

X still has low-level drivers for this, but today basically everything uses the evdev driver, which hooks into the kernel input layer.

Can we draw windows without the help of X.Org Server?

Yes, with the framebuffer driver. Basically you have a device like /dev/fb0 which can be mmaped to represent the framebuffer, with a few ioctl to select video mode etc.

Of course, it is not practical.

It's very practical, many embedded Linux systems use it.

4
  • 2
    Also note that "drawing windows" is mostly done circumventing X11, kind of, these days. You still speak to X to get your window, but then you just directly deal with the buffers, GL contexts that this entails, and don't use a single X11 drawing routine. There's no advantage to your X11 server drawing a line into a picture buffer - the client can do it just as efficiently, but it doesn't have to send a million line-drawing requests over some mechanism to the X server. Not to mention that a lot of things are actually GPU-acceleratedly drawn directly by the client. Commented Mar 5, 2022 at 13:15
  • @MarcusMüller True, but if your process is connected to a remote X server, then it has to use the X11 protocol (or something) through the socket connection because it won't have direct access to the display hardware. Commented Mar 5, 2022 at 14:12
  • 1
    @AndrewHenle but even then modern clients will sent buffer updates (minimized via xdamage), and not individual drawing requests. (I don't think Qt5 knows how do draw a QButton using XDrawLines; it makes little sense.) Commented Mar 5, 2022 at 14:17
  • @dirkt Thank you for your answer. I was thinking that there are some screen-drawing system calls and Xlib uses them. But it seems that I was misunderstanding.
    – user356126
    Commented Mar 9, 2022 at 3:30
2

Just an addendum to dirkt's excellent answer:

Can we draw windows without the help of X.Org Server?

The whole ca 14 years of existence of Wayland would like to remind you that by now, not using X should be the norm, not the exception. (It's not, due to lack of support. If it takes a pandemic to realize screensharing is not a nice-to-have-in-the-future feature, then Wayland might not have been as mature as thought as of lately.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .