[ACCEPTED]-How do you make linux GUI's?-native
X is a hideous layer to program for and, despite 25 your intent to avoid Java, QT or any of 24 the excellent UI abstraction layers, you'll 23 be doing yourself a disservice by coding 22 to that level. I've done it (a long time 21 ago when Motif was in its infancy on the 20 platform we were using) and I would not do 19 it again if there was an easier way.
Your 18 use of the phrase "native programming" confuses 17 me a little. If you want to learn native 16 programming, it's to the APIs that you choose 15 to call. Using similar reasoning, you shouldn't 14 be coding in C either, instead opting for 13 assembler (or direct machine code) since 12 C provides an abstraction to the hardware.
If 11 you want to learn X programming, that's 10 fine. You'll end up with a lot more control 9 over your interface but almost everyone 8 else will be out-performing you in terms 7 of delivery of software. Myself, I'd prefer 6 to code to a higher-level API that I can 5 use on many platforms - it gives me both 4 faster delivery times and more market potential.
You 3 don't build a house out of atoms, you build 2 it out of bricks. My suggestion is to use 1 the tools, that's what they're there for.
I don't want to use anything like QT, GTK, or wxWidgets or any tool kits. I'd like to learn native programming and this sort of defeats the purpose.
No you don't. Back in an early version 3 of X11, like R1 or R2, I coded a complete 2 "Hello, world" program in Xlib alone.
Roughly 1 700 lines of C.
You don't want to go there.
I guess you could write C code directly 3 against Xlib, but you'd end up recreating all 2 the functionality that GTK+ or QT provide 1 that X doesn't alone.
Unix (and by extension, Linux) doesn't actually 12 define anything to do with GUIs. X, which 11 is commonly used, doesn't define anything 10 to do with widgets or styles or anything 9 of that nature - it's concerned mostly with 8 drawing primitives and event handling. Essentially, if 7 you wanted to write in pure X, you'd be 6 defining the shape and behaviour of every 5 element on screen. If you were crazy enough 4 to abandon X, you'd be working at the graphics 3 framebuffer level...
You're better off using 2 some toolkit - if you're looking for light-weight, why 1 not try FLTK?
GTK, QT and wx are toolkits that build on 9 X to provide a friendlier API.
If you don't 8 use an existing toolkit you'll need to write 7 things at a very low level - directly handling 6 mouse and keyboard events. If you want a 5 button or a textbox you'll have to write 4 it yourself using the low level xlib primitives.
Before 3 trying this you're probably better off picking 2 the toolkit of your preferred desktop environment 1 and starting with that.
There is simply no such thing as "native" in 2 this case. Windows and OS X just have an 1 official option, while X does not.
The "native" interface for Linux & most 23 other Unix-like OSs is Xlib, the lowest-level 22 C API for X11.
GTK, Qt & others are all 21 (so far as I know) implemented in terms 20 of Xlib at their core. As others have said, Xlib 19 gives you maximal control but you'll have 18 to work for it (and others may run circles 17 around you in terms of delivering a product).
As 16 a point of reference, I personally implemented 15 a fairly feature-rich & modern (i.e. flowable) cross-platform 14 (Win32 + X11) GUI library in C++. Total 13 count is about 29 KLOC of C++, of which 12 about 2500 lines each was required for the 11 X11 & Win32 shimming. The rest is for 10 platform-neutral Widget implementations. Unless 9 you're prepared to make a commitment like 8 that, I strongly recommend going with one 7 of the higher level libraries (Qt would 6 probably be my choice, though I can't stand 5 the preprocessor approach).
BTW, a big plus 4 for Xlib is its raw portability--any Unix 3 box with a screen will have it, and it can 2 be made to work on Windows & OS X as 1 well.
I feel it necessary to counterpoint the 29 unanimity of the other answers here. X11 28 is indeed low level. But to "truly" understand 27 what's going on, you should have some familiarity 26 with how X11 works. Since all the toolkits 25 work on top of X, you're using it whether 24 you like it or not. There is nice tutorial 23 online somewhere that I'm too lazy to search 22 for. It guides you through building a simple 21 Hello World. To do it, you'll have to learn 20 how to create a window, request events, map 19 the window, and process events in a loop. You 18 could even go so far as to order some used 17 books on Amazon. The O'Reilly vols 1 and 16 2 (for now get the cheapest editions, but 15 nothing earlier than X11R4) are essential 14 for reference and to get the full story 13 of how the pieces work together. For learning, however, the 12 best book is X Window Applications Programming 11 by Eric Johnson and Kevin Reichard.
At some 10 point along this journey, as everyone else 9 says, you will find you've had enough. Two 8 pages of code just to select a visual, and 7 then you still have to populate a colormap 6 before you can paint your custom bitmap. And 5 then two days of rewriting and debugging 4 to realize that it all does work; you just forgot 3 to XFlush()
!
The struggle is important, because you'll 2 appreciate the toolkits more once you find 1 the one you like.
I would suggest lesstif/motif as well. It 8 also builds on top of X and the learning 7 curve is, in my opinion, isn't as steep 6 as GTK or Qt. The UI's you build with it 5 aren't going to be as sophisticated as ones 4 you could build with GTK or Qt though. More 3 information can be found here.
As others have 2 mentioned you probably don't want to X it's 1 a pain.
Why not choose one among, say, Qt, wxWidgets 10 and GTK and learn its internals, rather 9 than its API? I do not mean just for the 8 sake of it, but with the aim of contributing 7 to the parts you find most appealing. In 6 this way you'd fulfill your goal and get 5 to do something useful, for you and also 4 for others. I think this would be more rewarding 3 than assigning yourself the rather artificial 2 task of building an application with what 1 amount to the wrong tools.
oh yeah, there is such "native" things:
FBUI, svgalib, directfb, exa(kdrive), SDL, Allegro..+Wayland, although 1 not mainstream.
http://home.comcast.net/~fbui/
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.