Implementing the X Server
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Implementing the X Server
Does anyone here know of any tutorial/good resources for implementing the X server? Has anyone here done so?
Thanks
Thanks
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
Re: Implementing the X Server
Still asking for tutorials? You're not going to be able to do better than the documentation: https://x.org/releases/X11R7.7/doc/xpro ... tocol.html
That's the network protocol. How you turn that into pixels on a screen is up to you. Actually, it is just the core protocol. You might need to implement quite a few extensions also (e.g. you will need Xrender to support many applications using freetype), but the core protocol should be a good starting place.
That's the network protocol. How you turn that into pixels on a screen is up to you. Actually, it is just the core protocol. You might need to implement quite a few extensions also (e.g. you will need Xrender to support many applications using freetype), but the core protocol should be a good starting place.
Carpe diem!
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Re: Implementing the X Server
I did extensive research and couldn't find anything, so I just asked in case I missed something.nullplan wrote:Still asking for tutorials?
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
Re: Implementing the X Server
Are you looking to implement it from scratch rather than porting it? In the latter case the source code is freely available - in the former you surely wouldn't want to follow a tutorial.
Presumably you have already implemented a TCP/IP stack?
Presumably you have already implemented a TCP/IP stack?
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Re: Implementing the X Server
I am looking to implement it from scratch, as a sort of learning excercise. My understanding was that the OS provided a network stack.iansjack wrote:Are you looking to implement it from scratch rather than porting it? In the latter case the source code is freely available - in the former you surely wouldn't want to follow a tutorial.
Presumably you have already implemented a TCP/IP stack?
I am more interested in how X actually goes from XDrawLine to an actual line of pixels on screen.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
Re: Implementing the X Server
You misunderstand. I wasn't asking if you had found any, I was asking why you with your multiple years of OS dev experience had not yet moved on to reading documentation instead of looking for someone else who read it, and then transcribed their understanding into an incomplete and possibly incorrect tutorial.PavelCheckov wrote:I did extensive research and couldn't find anything, so I just asked in case I missed something.
Bresenham's algorithm, but before you get there, you need a host of other things in place. For example, you need an idea of how to represent your clients in memory (on the frame buffer). X11 is a memory-conservative protocol, and allows the server to get by with remembering pretty much only coordinates of each window, but that is already a computationally interesting proposition. If a foreground window is moved, you need to tell the window that was moved where it was moved to, but you also need to tell all the windows behind it to update their contents. So how do you best determine which windows where behind it? Quadtrees may be a good answer here, but require a lot of thought to use well.PavelCheckov wrote:I am more interested in how X actually goes from XDrawLine to an actual line of pixels on screen.
You know, thinking about it, Bresenham's algorithm really is the least of it. You have to deal with different data formats. Some applications get by on monochrome, some need full 32-bit framebuffers with alpha-blending. Some applications use ZPixmaps to render stuff, some use XYPixmaps, so you need to translate data unless you want to go crazy. And you have to provide events (and process reactions to those) in a timely manner. Some of those are more complicated than others.
If you are merely interested in rendering stuff, maybe something like XWayland is more up your alley? Wayland provides the frame buffer and events, XWayland merely translates from one to the other. And Wayland doesn't handle rendering, it tells lets the client do it and expects to be told to just update the window contents.
Carpe diem!
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Re: Implementing the X Server
It would still save me quite a bit of time in understanding the basics.nullplan wrote:You misunderstand. I wasn't asking if you had found any, I was asking why you with your multiple years of OS dev experience had not yet moved on to reading documentation instead of looking for someone else who read it, and then transcribed their understanding into an incomplete and possibly incorrect tutorial.
I figured that much out, I was more referring to actually displaying the pixel on the screen.nullplan wrote:Bresenham's algorithm
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
-
- Member
- Posts: 425
- Joined: Tue Apr 03, 2018 2:44 am
Re: Implementing the X Server
A quick search for "windowing system tutorial" brings up:
And/or, you could compile up Xnest, and run it under a debugger on an existing desktop, and trace the code from network input to writing to the virtual (nested) screen.
- http://www.jk-quantized.com/blog/2020/1 ... -tutorial/ (which references)
- https://web.archive.org/web/20180715114 ... ectangles/
And/or, you could compile up Xnest, and run it under a debugger on an existing desktop, and trace the code from network input to writing to the virtual (nested) screen.
Re: Implementing the X Server
You probably should've started with that as your question; it can get frustrating when people ask broad questions like "how to implement an X server" because there is no simple answer and it is unclear at what level the question is aimed. (You have a bit of a history of asking such questions; I don't think you realise how frustrating it can be). If you ask the right question to begin with, it's better for everyone.PavelCheckov wrote:I figured that much out, I was more referring to actually displaying the pixel on the screen.
With that said, on Linux for instance this can be done via the framebuffer device (documentation is available, but not very comprehensive. I suggest searching for a examples).
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Re: Implementing the X Server
Thank you, I will keep that in mind when asking future questions. I apologize.davmac314 wrote:You probably should've started with that as your question; it can get frustrating when people ask broad questions like "how to implement an X server" because there is no simple answer and it is unclear at what level the question is aimed. (You have a bit of a history of asking such questions; I don't think you realise how frustrating it can be). If you ask the right question to begin with, it's better for everyone.PavelCheckov wrote:I figured that much out, I was more referring to actually displaying the pixel on the screen.
With that said, on Linux for instance this can be done via the framebuffer device (documentation is available, but not very comprehensive. I suggest searching for a examples).
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
Re: Implementing the X Server
I doubt that anyone was crazy enough to implement an X server during the last 3 decades, even large corporations. Everyone would just fork the Xorg code. I will likely be proven wrong quickly, but the point is that this would be a monstrous undertaking that you probably don’t want to get yourself into.
Re: Implementing the X Server
Classic case of an x-y problem.davmac314 wrote:You probably should've started with that as your question; it can get frustrating when people ask broad questions like "how to implement an X server" because there is no simple answer and it is unclear at what level the question is aimed. (You have a bit of a history of asking such questions; I don't think you realise how frustrating it can be). If you ask the right question to begin with, it's better for everyone.
The closest I can think of is that someone implemented an Xlib compatibility layer for Haiku. They skipped the "build an X server" part by translating Xlib calls to Haiku's graphics API.Ringding wrote:I doubt that anyone was crazy enough to implement an X server during the last 3 decades, even large corporations. Everyone would just fork the Xorg code. I will likely be proven wrong quickly, but the point is that this would be a monstrous undertaking that you probably don’t want to get yourself into.
Re: Implementing the X Server
Hi Pavel,
This seems like a well documented project which might help you in your quest.
https://github.com/ghaerr/microwindows
This seems like a well documented project which might help you in your quest.
https://github.com/ghaerr/microwindows
~Voldemort~
- PavelChekov
- Member
- Posts: 113
- Joined: Mon Sep 21, 2020 9:51 am
- Location: Aboard the Enterprise
Re: Implementing the X Server
Thanks! Also, I noticed people referring to me as "Pavel", which I just want to put on the record is my username based on Checkov from Star Trek, because some people on here have assumed I'm Russian and that I don't speak English, neither of which are true (Slava Ukraini!).Voldemort wrote:Hi Pavel,
This seems like a well documented project which might help you in your quest.
https://github.com/ghaerr/microwindows
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
The Final Frontier,
Space,
The Universe
Live Long And Prosper
Slava Ukraini!
Слава Україні!
Re: Implementing the X Server
If you style yourself after a character, you should expect as much, Mr. Checkov. Do you know where I can find any nuclear wessels?PavelCheckov wrote:Thanks! Also, I noticed people referring to me as "Pavel", which I just want to put on the record is my username based on Checkov from Star Trek
(btw your name is spelled wrong, it should be Chekov!)