Wednesday, March 4, 2009

How To Write an X11 Application

Linux Hater has not posted any tutorials for a while, so I will do it. Here is my first tutorial; it shows you how to write an X11 application (even a server, especially a server).

  • Be sure to switch the meaning of client and server for no good reason. This makes your app seem avant-garde!

  • Make sure your application follows the ICCCM to a T but is still unable to copy-paste properly.

  • Furthermore, include at least two methods to copy and paste just to cause confusion.

  • Include massive amounts of conflicting code to handle fonts that, at the end of the day, only handles DejaVu Sans properly.

  • Don't bother supporting multiple monitors. Nobody uses those anyway!

  • Make sure your app does not need hardware acceleration to function properly. Save that for the wobbly windows!

  • Alright, maybe your app can use hardware acceleration. But don't you dare try talking to the driver directly and not paying your performance toll to the X server.

  • Okay, maybe you can talk to the driver directly. Or at least you will be able to . . . . eventually.

  • Rewrite your app constantly, but make sure not to fix the major underlying problems.

  • Make sure that users can use your app over the network, even though they never will.

  • Tell at least three people that X-Windows has nothing to do with Microsoft. Because they care.

  • Do not provide a user interface. Instead, provide an API (or, even better, several layers of APIs) that allow users to create their own interface. This gives lusers the ability to make half-assed clones of better designed interfaces for your app.

  • Reassure yourself that, even if your app sucks, at least it sucks on twenty different platforms!

Next time, I will show you how to write an X11 Window manager.

UPDATE: If you like the tutorial, then please digg it. Let's show all the lusers how X11 application writing is really done!


oiaohm said...

Or take the sane path. Code your application use QT and don't bother about all the headaches.

Its a rare application for windows that is build in raw Win32 GDI functions. Building a Linux application way you cover is exactly the same.

Anonymous said...

In vista there is no such thing as "raw win32 gdi" anymore. It is just a compatibility layer to the DWM and WPF now. I beleive it has been depreciated as well...

You havent used windows this decade have you?

oiaohm said...

XP the most commonly used OS has it.

Vista is a tech change. Exactly like all tech changes it broke a lot of applications. PS XP is not a decade old.

QT again simpler it natively supports Vista and XP system so for cross OS release you don't have to bother about what MS changes. It takes care of it for you.

Anonymous said...

XP came out in October of 2001. It is seven and a half years old (but, considering the RTM version of XP was largely a spit-and-shine on W2K for consumer usability, that age is being kind). That's right at that nifty little halfway point between rounding up to a decade or rounding down to half a decade.

In any case, that's semantics. Vista 'broke' only applications that were doing naughty naughty things. Y'know, when they were going places they shouldn't be going, having access to things they shouldn't have access to, using undocumented, and hence ripe for change, features and functionality. And that's a damn good thing. It strengthens the Windows security model and allowed MS to institute a new sound system that virtually eliminated BSODs caused by poor software accessing audio because it simply wouldn't allow them to continue accessing it in an unsafe manner.

This is in stark contrast to changes to Linux, where applications can break for daring to use a function exactly as it was intended before the update.

oiaohm said...

Do you call having font size different being naughty.

Use the one set of functions and your font height is different to what it was under XP. So you windows end up screwed up.

There are a massive stack of minor errors in Vista that add up to major application problems. Even open something as simple as a file dialog with particular functions breaks. Reason two sections that under XP program guide should have had null null in them now has to have secuirty information.

Do I have to go on with the list of errors Vista API alterations has caused.

oiaohm said...

Vista has done exactly what Linux has done from time to time. Programs running by the book broken.

Anonymous said...


Im calling you a liar. I don't think you have used Vista enough to have an informed opinion about Vista.

oiaohm said...

Custom applications used inside business.

I do have a informed option thing that even a program made by microsoft for creating labels fails due to not being able to open anything.

If you run Vista with Vista compatible applications no problems. If you know how to code extra shims to expand the compatibility system no problem again.

If you are trying out the box with a random selection of applications that are key to run a business with Vista that all worked in XP and were all coded by the program documentation in the MSDN you could be in tears if you don't have the resources to deal with the problem.

Sorry I do support for businesses. I have far broader numbers of custom applications with source to deal with.

One of the best try getting webcam working with MSN under Vista. Prepare to cry. Works perfectly under XP.

Yes and the calls MSN is using is perfectly to XP API. Some coder at Microsoft needs to replace some NULL entries with secuirty information for vista and it will work. I have made a shim to hack that.

Anonymous said...


Hey what do you know.. we both have the same job. But you know what? The first thing that stands out to me about you?

You are not that good at your job, and certainly not as good as you think you are.

It sounds like you haven't even gotten promoted to the point where you are making purchasing decisions, and don't have any sort of budget.

That tells me all sorts of things about you, and possibly the type of company you work at.

But none the less, you still stand indicted a liar. You lie about your experience. You lie about your stature in your company, or the nature of your company.

And sheesh, go buy a Vista compatible webcam, they are what.. 10-15 bucks???

The thing that really tells me how completely clueless you are is your refusal to go and spend a few bucks on a new web cam. I mean, you can even do it late at night at wallyworld. No one will see you, and I assure you, no one cares.

Or is it... You don't have a car or don't have the pocket change you need to get a web cam?

But whatever man, it obviously permeates everything else you do. You cheap out on software. You cheap out on hardware. You are so cheap you wont even shell out a few bucks for a working webcam.

Man and what is it with slashdotters and that entitlement syndrome. "I bought this web camera 10 years ago and I have a right for it to be supported forever!" LOL.

Anonymous said...

Yes and the calls MSN is using is perfectly to XP API. Some coder at Microsoft needs to replace some NULL entries with secuirty information for vista and it will work. I have made a shim to hack that.

Where is the link to this function?
if this exist, do you know anything about RESERVED fields? win32 has plenty of those, and were, you know, hmm RESERVED for future use, like NOW... idiotic programmers that used them before are just that, idiots

again, show proof of what you are saying, or it will slip off our minds as all of your previous comments have

oiaohm said...

Yes and read the documentation about reserved fields in the programming SDK for XP. Clearly stated put NULL in them for future compatibility. Ie NULL should equal fall back in future forms of the API. Guess what does not happen. NULL==Error under windows Vista. Compatibility breach. How does MS handle this say that all applications having this problem must be doing something risky. So does not have to fix there breach of API.

Following documentation sometimes drops you straight in it.

Anonymous said...

Holy shit dude, I am not the other guy on that other blog calling you a liar.

So how does it feel to be called out as liar by two differnt people on two different blogs within about 15 minutes of each other?

oiaohm said...

Status normal when I have been called a liar about 5 times in 5 mins. Most of the time is lack of homework and MS created myths that cause it.

MS myth that all programs under Vista that don't work are doing something secuirty risky. Is wrong.

Some of it is just pure backward compatibility breaching for no good reason.

Other one personal insults not working. Sorry worked in IT for over 15 years. My skin is insanely thick.

All the one attack proved is they had not tried it. I am not stupid enough to be using anything other than a Vista compatible webcam. Yahoo messager could use it everything else could use it bar MSN. Not that the webcam was not working. It was a mother bug in recent MSN messager about 6 months ago. It was purely related to a code stuff in exactly the same way other applications had failed to work.

By the way there are over 1mil reports of this particular defect with Dell HP and IBM. It made no difference what brand webcam you had. MSN could not access the lot on Vista because it passed a NULL instead of a secuirty permission allowing access. Ie webcam working fine. Secuirty to allow access not working fine.

All were non repairable until MSN gets fixed. I have not bothered tracking that my job was not long term repair. It tells you more the type of company hired me that would waste money making MSN work no matter what.

Basically the insulting guy is a idiot. I can understand why he was not game to put his name to his comment.

Anonymous said...

oiahim, can you for a change give some solid proof of your words? We kind of get tired taking them for granted.

oiaohm said...

Funny enough you don't provide any solid evidence that can be tracked down to back your cases.

I have told you where to look. The information to validate is there. You hide behind anonymous. People say they want this about abusing people. If you want to work in solid facts fine.

Even if I gave linked to documentation backing my case I would expect you guys to find any trick to disregard it.

Simple look where you have been told. The information is findable simple enough. Or do you all in here lack research skills.