OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Jul 05, 2022 9:05 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Implementing the X Server
PostPosted: Sat May 14, 2022 2:10 pm 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 89
Location: Aboard the Enterprise
Does anyone here know of any tutorial/good resources for implementing the X server? Has anyone here done so?

Thanks

_________________
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sat May 14, 2022 2:50 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1253
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.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sat May 14, 2022 3:04 pm 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 89
Location: Aboard the Enterprise
nullplan wrote:
Still asking for tutorials?


I did extensive research and couldn't find anything, so I just asked in case I missed something.

_________________
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 1:59 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4378
Location: Chichester, UK
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?


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 10:05 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 89
Location: Aboard the Enterprise
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 looking to implement it from scratch, as a sort of learning excercise. My understanding was that the OS provided a network 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!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 12:54 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1253
PavelCheckov wrote:
I did extensive research and couldn't find anything, so I just asked in case I missed something.
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 am more interested in how X actually goes from XDrawLine to an actual line of pixels on screen.
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.

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!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 12:58 pm 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 89
Location: Aboard the Enterprise
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.

It would still save me quite a bit of time in understanding the basics.
nullplan wrote:
Bresenham's algorithm

I figured that much out, I was more referring to actually displaying the pixel on the screen.

_________________
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 3:04 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 281
A quick search for "windowing system tutorial" brings up:


Might be a good start.

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.


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Sun May 15, 2022 8:19 pm 
Offline
Member
Member

Joined: Mon Jul 05, 2021 6:57 pm
Posts: 86
PavelCheckov wrote:
I figured that much out, I was more referring to actually displaying the pixel on the screen.

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.

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).


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Mon May 16, 2022 7:20 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 21, 2020 9:51 am
Posts: 89
Location: Aboard the Enterprise
davmac314 wrote:
PavelCheckov wrote:
I figured that much out, I was more referring to actually displaying the pixel on the screen.

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.

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).

Thank you, I will keep that in mind when asking future questions. I apologize.

_________________
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Tue May 17, 2022 1:02 am 
Offline

Joined: Fri Nov 26, 2021 11:08 am
Posts: 3
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.


Top
 Profile  
 
 Post subject: Re: Implementing the X Server
PostPosted: Tue May 17, 2022 3:46 am 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 587
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.

Classic case of an x-y problem.

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.

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.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group