Sign in to follow this  

Programming with X

This topic is 4660 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Do any of you know how to program with X? I'm trying to find some good tutorials that will eventually teach me the complete inner workings of it or close to it. If not a link, how about a good book then?

Share this post


Link to post
Share on other sites
O'Reilly publishes the XLib books. That's probably about as good as you're going to get, beyond Googling for XLib or X11 programming.

I'll tell you this, from what I know of it, it's a pain in the ass.

Share this post


Link to post
Share on other sites
Quote:
Original post by RenderTarget
I'll tell you this, from what I know of it, it's a pain in the ass.


I'll second that, if your final goal is to become comfortable with GUI programming you might be better off learning some of the common toolkits (GTK, QT, wxWidgets, etc.).

If you really are interested in X itself you might want to play around with the code for one of the simpler window managers (I'm thinking the *box ones in particular), and it might be a reasonable way to start off.

Share this post


Link to post
Share on other sites
XLib is quite strange, but in some respects, quite similar to Win32's GDI.

Unfortunately it doesn't have an equivalent of Win32's USER library, i.e. there are no standard widgets (If you ignore Xaw).

Xaw is the X "athena widgets" library which dates back to the year ? and can be used to create applications which look... well.... dated :)

For examples of Xaw look at xedit or xfig.

I haven't made anything significant using Xlib, but I recommend that you DON'T write your own WM - everyone seems to have done that already. Plus also WMs are quite arcane beasties.

NOTE: I've just looked on my machine and it seems that my distro has a Xaw library with "3d-look" widgets - which means they almost look 90s vintage :)

Mark

Share this post


Link to post
Share on other sites
I'm interested in X it's self because the NVIDIA driver. But I seam to have forgot about the NVIDIA module that doesn't need X at all. From my understanding, all I need is the interface to the module and I can do what ever I want with it. So I wouldn't need X to run my GeForce I only need the module interfaces that came with the driver. I'm more concerned about hardware acceleration and OpenGL.

I though about writing my own VM but I though that I needed X for most of the support that I will need in my applications. But I guess just using the modules directly would be the same. The main reason I'm wanting to do this type of thing is so that I can make a very custom and unique desktop. I've though about implementing directly with a shell or sort of shell / desktop. Not to be M$ like but to make it easier when programming with it (for me any ways).

Lets see, I don't really need X if I can use may hardware with out it. I can write my own GUI, it's not that hard (in my eyes) but it's very time consuming. I don't mean to shit on everything with Linux, but I just want a support custom OS. X seams to be a little out there if you know what I mean; judging my some of you posts, you do.

I'm looking for something less complicated and more direct. The GUI is just that and that is all I need it for. I think that X uses it's own drivers for stuff, correct? I wouldn't do that, I would leave it to the Kernel to handle it's hardware but have interfaces the components and there implementation just simple accesses those modules. On the other end, the user sees the same thing and so does the programmer.

I'm leaving out a ton of stuff that I've though about and wrote little designs for over some time now. But I want to merge the shell and windowing system into one. You may not agree with me, but wait until I'm finished with it. So the whole reason I'm wanting to learn X is so that I know X, and that I will be able to understand it's architecture better.

Share this post


Link to post
Share on other sites
I didn't know you hadto pay for Qt! I was wanting to get all the KDE sources but I couldn't. I found that I had to pay for Qt unless I get the GPL version. Either of these libraries will not download because of FTP. I can do anthing with FTP for some reason.

Share this post


Link to post
Share on other sites
Although I'd suggest GTK,
What is wrong with the
GPL'd version of QT? It is
the same thing as the commercial
version, just different licensing.
Edit: Both GTK and QT should
be in your distro.

http://www.trolltech.com/download/qt/x11.html
just in case.

Share this post


Link to post
Share on other sites
I'm not running a distro right now. I'm running XP. I've been studying Linux a lot so it'll be easier to use and install. The SuSE Linux that I bought is all messed. So I'm going to build my own Linux from scratch and rewrite any applications I need to. In order to write my own mods for Linuix stuff I need to know it's software architecture. I also need to know what's junk and what isn't.

Share this post


Link to post
Share on other sites
This is my story:

I've read lots of material that dogs on X. I was lucky to find a few articles wrote specifically for it. I see that it's architecture is screwy and that it has it's own driver type of things. I really don't like this because I don't think a window system or GUI should even worry about drivers; that's the Kernel's job. So I need to learn X so I can rewrite the applications I use that use X. I can't convert any applications that use X if I don't understand it.

My type of system is purely interface driven. Implementations are wrote to use the Kernel's drivers modules. The programmer write applications that uses these interfaces. Keeping from them, all the internal workings of things. If a programmer would like to change or add new things to the system, they only need to write the implementation that interfaces with the correct module.

With my system, applications deal directly with the Kernel module's via interface implementation. A programmer doesn't need to worry about the implementations, unless they wish to create there own. It's hard to explain and I'm leaving out lots of details, but it'll be cool when I'm finished with it.

Share this post


Link to post
Share on other sites
First of all, if you want to go "behind the scenes" and actually hack on the X server yourself, do yourself a favour and ignore the proprietary drivers from NVidia and ATI, at least in the beginning. Without access to their source code, you'll be missing *a lot* of crucial code.

Now as far as drivers in userspace are concerned, I suggest you read up on how the DRI works. That's the opensource architecture for 3D accelerated drivers (ATI's proprietary driver is in fact based on the DRI). It's a mix of exokernel and microkernel, with a hint of monolithic thrown in for the aroma.

In the process, I hope you learn that userspace drivers are essential for good performance, and that at the same time, there are in fact efforts to greatly improve the design of X windows and all things related to graphics on Linux. For example, it is possible to run straight fbdev+DRI, without the X server; however, this is still rather hacky and a work-in-progress. In the long term, however, it will allow us to remove most of the DDX (the hardware driver) from the X server, which in turn will clean up the overall design and allow the X server to run as a non-root process.

If you're interested in lowlevel graphics hacking on Linux, this is really where you should focus on. Oh, and driver development, of course - I'm still waiting for someone to come forward and reverse engineer the Geforces' hardware interface :)

cu,
Prefect

Share this post


Link to post
Share on other sites
Quote:
Original post by sakky
I'm interested in X it's self because the NVIDIA driver. But I seam to have forgot about the NVIDIA module that doesn't need X at all.


The NVIDIA kernel module does not need X, but it implements a proprietry interface which interfaces with the NVIDIA X driver itself.

You won't be able to usefully do anything with just the kernel module. This is essentially an internal component of NVIDIA's driver and doesn't implement any documented interface.

It probably also doesn't implement the majority of functions.

Quote:

From my understanding, all I need is the interface to the module and I can do what ever I want with it.


Then your understanding is wrong, I'm afraid.

Quote:

So I wouldn't need X to run my GeForce I only need the module interfaces that came with the driver. I'm more concerned about hardware acceleration and OpenGL.


OpenGL *needs* X. X arbitrates access to the device and manages the windows etc. Xlib provides the basis for the GLX library which allows the application to create OpenGL contexts.

Without an opengl context, opengl is useless.

The NVIDIA driver has several components - but the only one which is programmed directly is the opengl library.

Mark

Share this post


Link to post
Share on other sites
Quote:

OpenGL *needs* X. X arbitrates access to the device and manages the windows etc. Xlib provides the basis for the GLX library which allows the application to create OpenGL contexts.


While this is currently true for all practical purposes, and it is definitely true for the NVidia driver, it is not true to somebody who is interested in low-level graphics hacking.

Look around for Mesa Sola/miniglx: It's a hack that allows you to use the open-source DRI drivers on fbdev without an X server. It is quite likely that this (together with fbdev+DRI merging) will evolve into the basis for an "X-on-GL" X server.

cu,
Prefect

Share this post


Link to post
Share on other sites
Sign in to follow this