LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-17-2007, 11:50 AM   #1
kellogs
Member
 
Registered: Dec 2007
Location: romania
Distribution: mandriva 2010.1
Posts: 30

Rep: Reputation: 0
How does GUI work in linux?


Hello folks,

I am a linux nooby comming from .. sigh .. good ol' Windoze, and I am tring to adapt fit into the great wide open (source community). Now, I do have some GUI experience from Windows, but things were far less complicated for a poor programmer there. There was the WinAPI library funcions we all used happilly as a last resort, and all the rest (MFC, .NET) where just more or less wrappers over winapi and that was it. Simple, huh ?

But linux .. nonono, linux has : 700 desktops KDE, GNOME + some ugglier others. Is this right or I am lost at sea ? So there is basically a"winapi" collection of functions for eachand everyone of them ? And if iit is so, well.. linux gotta take care of all this API calls. How does he manage ? How is this related to X server ? How does this all relates to window managers like xdm/kdm/others? Are there other window managers ? I have seen it is possible to choose in KDE between xdm / kdm ... what's the point ? And finally, how does the KDE relates to KDM + X + OS + beryl/compiz + actual graphical drvier ?

Gee that will be hard to answer, but really, I want to make an image about GUI in linux. Thanks all.

Oh, and .. anyone knows to remediate the missing "log out" menu options (like shutdown and restart - missing from my menu). I have searched the forums and found 3 kind of answers: 1 - goto control panel goto kde components (i am on kde) login tools or whatever, check the "offer shutdown options" box - ofc it was already checkd; 2 - the window manager is to blame: if u have KDE stick with kdm - ofc it was kdm the manager selected; 3 - the 3D desktop is to blame ... might just be, but I dont wanna give up compiz. It rocks. Any other directions ?

Thanks again
 
Old 12-17-2007, 12:40 PM   #2
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Well, I'll try to put some light on the subject...

In GNU/Linux, there is never just one option. People tend to customize things, and we have a gazillion Window Managers to chose from. I use Enlightenment and Gnome, mainly. You've landed on KDE.

In Unix world, every tool does just one job. X server takes care of hardware and interface it, Window Managers build upon it, and give us windows, themes, and such. You need to get grasp that concept, and once you get used to it, you'll see it's the best approach to computer sciences.

As for programming, well, you have a privilege to choose your API, or toolkit as we call it. It all depends what you want to do. KDE's Qt and Gnome's GTK are the roads most often taken. But you can use XForms, WxWidgets, and others if you find them easier to code (WxWidgets is very rapid for development).

Anyway, welcome to *nix world, and please try to embrace the difference. One and only one way (WinAPI) is very bad thing - and you'll soon begin to notice why.
 
Old 12-17-2007, 12:44 PM   #3
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
Does each desktop have its own API? Sadly, this is pretty much the case with KDE and GNOME, and most desktops do provide their own API's to do common things. Your right its a problem, but not one that will be stopped anytime soon because the reason for those API's over other libraries is simply portability: a program written in those API's should be (relatively) easy to port to any system that those API's support, such as Windows, and other *nix's.

X is a server that provides a mechanism for a windowing system (allowing programs to create windows, and send/receive events to those windows), colormaps, images (in its own format), drawing to its images or windows, fonts, etc. X also managers hardware access, and usually provides its own drivers (so the OS kernel dosnt need to run the graphics drivers) X is only ment to provide mechanism, this means programs must draw their own UI's (usually they use a GUI toolkit to do this, or some other wrapper, because X is a real pain to work with). Also, top-level windows (such as a applications window, the one that gets window manager decorations) in X are not managed by X, but instead by a X client known as the window manager. The window manager requests all X events on the root window, and manipulates any such requests. For example, when a window is created as a child of the root window, the event is passed from the X server to the window manager, the window manager will usually create its own window to hold the decorations, then move the application window into this decoration window. All events that effect the application window, such as moving, resizing, etc, are passed to the window manager to handle. As such, all programs must be prepared to deal with situations when they dont get what they asked for.

There are about 20 window managers, only about 10 of any popularity. XDM/KDM are not window managers, window managers usually end in "WM", "DM" stands for "display manager", and its job is to handle logins to the computer, creating a new X session for each one, basically, they manage the X displays. The display manager can start a number of sessions, such as a KDE session, by running the right script, which calls all the required programs. The user can basically say what session to start if the display managers supports this.

compiz is a window manager, but also a composite manager. In X, a new extension called the composite extension allows for windows to be drawn offscreen in memory, and allowing a composite manager to draw it to the screen. The composite manager can do all sorts of manipulations. These manipulations are usually slow do to how X works, and that such manipulations occur on the CPU, recent extensions (and in some cases redesigns of X) have allowed the use of server side 3D to drastically boost the composite managers performance with manipulations, allowing for all the graphical effects you see in compiz and the like.

Last edited by SciYro; 12-17-2007 at 12:46 PM.
 
Old 12-17-2007, 01:53 PM   #4
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
But actually it is not that difficult under Linux (I think, but I'm used to it), but of course it's rather much to handle.

There's the X server with its underlying graphic's device drivers. X has an API to draw with which can be used directly - that's the Xlib. In principle, it's perfectly fine to use X and GUI applications without any kind of windowmanager - it would be just a rectangle on some background. Because that's usally not what most people want, you'll get yourself some windowmanager - icewm, fvwm, mwm, olvwm, fluxbox ... they all add some more eye-candy like borders around the rectangle, add some keyboard support for shortcuts, virtual desktops, maybe some menus or icons of any kind and stuff like that.

To make things easier, several widget sets are available to work on top of Xlib - Gtk (for Gnome and Xfce) is one option, Qt (for KDE) another one - but there are many more, so you don't have to program your windowmanager directly on Xlib.

Either Gtk and Qt need a bunch of helper libs - libpng, zlib, libsvg - you name it. Some things Qt supports on its own. Gtk for example is depending on Glib which also makes accessing the libc - THE most central lib within a Linux system - a little bit more handy.

With Gtk and Qt, you also get the possibility to an entire desktop environment - which in short is adding more administration and cooperation between all the GUI applications and a consistent look and feel. But: Under Linux/Unix this is something what is not as badly necessary to be done from some GUI environment, because one cool thing about Unix/Linux has always been the possibility of connecting apps of any kind with each other and put output from one as input to another - even over the network - in a way, GUI just sugarcoats procedures which could be perfectly well done with command line options. That's why there isn't just one model of desktop enviroment or just 2 windowmanagers but so much in between with more support for this and less support for something else.

And as all this stuff is open source, many people use GUI with a state of mind like "if I don't like it, I'll do my own.." - and that is why there are so many windowmanagers out there. And as programming languages are also vastly available under Linux, you'll even get to choose wether you'd like to program you supadupaWM with Lisp, based on the widget set of Gtk, but with native SVG-drawing support from cairo directly and with an animated icon mechanism based on whatever. Someone else may choose Python with Qt.

It's the power of combination what made Unix and later on Linux so immensely powerful and this hasn't change until today.

A future example will be the "web on the desktop" stuff which is available as Silverlight under Windows. Well, there's a Linux version in Mono (Linux' version of .NET) called "moonlight", but the competing "AiR" from Adobe (Flash-based) will also be available for Linux and of course there's Mozilla's "Prism" which is what I'm going to use.

I for example hate KDE and I'm still not really friend with Gnome, so I use fvwm because of it's flexibility. Nevertheless, I love Gtk-based application for several reasons, so my fvwm does actually look like a pink girly Gnome desk with SVG-drawn icons, but hasn't all the clutter Gnome comes with. But my preferred programming language is Perl, so I don't code Gtk-stuff in pure C, but use Gtk-Perl. My video support comes from mplayer and not from Xine or Gstreamer and so the list goes on and on.

You'll gonna like it and the day where you start thinking about "well, I'd really like to have my GUI totally different..." you're in the right state of mind.

And: It's all rather well documented - it's not that you can't find anything about programming Python with Qt or Lisp with Gtk or Xlib directly in pure C.
 
Old 12-18-2007, 01:35 AM   #5
kellogs
Member
 
Registered: Dec 2007
Location: romania
Distribution: mandriva 2010.1
Posts: 30

Original Poster
Rep: Reputation: 0
Well folks, it looks like im not in the dark anymore. Thank you for clarifications. First i am going to whine a bit about the whole graphical system's fiability.

i have had mandriva distro stay on my computer because of the 3 distros i have tried this one had xgl graphics for my video card. That means a non-proprietary driver that enabled 3d acceleration. So all was good, 3d effects worked ok , and also my favourite game, which uses hardware acceleration to run. (without direct 3d support, it does not even launch). I did not touch anything in the X server's configuration - at least I didnt do any obvious damage anyay - and today , 3d desktop still works ok but that game doesnt. It starts , it cannot get fullscreen mode, texture is all corrupt, and fps is really low - i don't think it uses any hardware acceleration, and there is no solution on the forums i have lookked on.

Ok some other thing to whine about: i have tried 3 other window managers that kdm suports - icewm, drak3d and evilwm, of which only one worked properly - icewm. Well that doesnt bother me cause i like kde anyways.

And finally, i'll get to the programming part. I have landed in linux world because of some retard teacher who insisted in making a netsnmp monitoring application on linux, not on windows. Now there wher some veeeery nice wrappers over the winsnmp api's on codeproject.com. And it even has examples of how to use those classes. Vveeeery convenient and fast to develop. But no, teacher wants linux. And the netsnmp counterpart for linux systems have dozens of functions ,headers and source files instead of just a few those win wrapers provide, some hard to work with documentation, and i have found no examples which i can use for my app. and as if it wasnt enough, there is no msdn.com for linux so i do not have any last resort. Or am I mistaken ?

thanks a lot
 
Old 12-18-2007, 04:42 AM   #6
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
You simply make one mistake: You're mapping the windows realm into the Linux world and expect things working and looking like you're used to it.

Stop trying to speak italian in Japan.

With KDM and GDM, every and any windowmanager should be possible to be started - KDM and GDM are just graphical representations of the command line option "startx" called as a user, reading certain config files. They just load the windowmanager you've configured.

Your missing Win-API is simply the libc and other libraries in the Linux world and instead of loading just one huge thingie, you'll just use what you actually need. It's as simple as that. WHAT you actually need for your project can be read in extremely well and understandable written books like Steven's "Advanced Programming In The Unix Enviroment" or in one of the many "Introduction into Linux system programming" out there and I assume you went through the net-smnp Wiki with it's examples and tutorials.

I suppose msdn.com is something Windows developer related, with Linux you're usally simply reading the project's webpage - in case of net-smnp this seems to be http://net-snmp.sourceforge.net. Sometimes, the stuff is really good, sometimes not.

Remember, people are doing the coding in their spare time in the evening after work without getting paid for it. Show some respect for a decade of work noone's ever paid a cent for.

And as all distributions actually use the same X.org, ALL distributions are able to be used with Xgl. A distribution is just the whole packages with some corporate identity added and some fancy install stuff wrapped around and a handful of tools on top of that - package manager for example - under all this, all and every Linux distributions consists of the same X.org, the same Apache, the same KDE and the same Gnome. Some are just better oder differently giftwrapped than others.

Please, just read an overview over Linux system programming - after that, you'll see much clearer.
 
Old 12-18-2007, 09:46 AM   #7
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
As for netsnmp, it is very easy: http://net-snmp.sourceforge.net/tuto...5/toolkit/mfd/

And, can be veeeerrryyy easy: http://search.cpan.org/dist/Net-SNMP/ (if you can code Perl, that is).
 
Old 12-18-2007, 07:25 PM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,673
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
One of the key differences between Windows and Linux is that Linux is highly decentralized. What you see on a Linux desktop might "look" like what you're used to seeing in Windows, and there are plenty of Linux developers who work hard to achieve that, but the implementation is completely different.

For example, X-windows ("XFree86" or "XOrg") is a client-server window-manager and nothing else. It lets one computer create "windows" that the same or a different computer(!) can see. (Yes, you can happily run a graphic session against a computer that does not, itself, even have a graphics-card... so long as yours does.)

Built on top of that ... and I'm simplifying a bit ... is a window-manager that presents you with a familiar GUI, as well as a display-manager that gives you a graphical login-screen. Each of these are separate and distinct components, and you can choose from among several.

It's entirely possible to wrap Unix or Linux with layers of software so that you'd never guess that Unix or Linux have anything to do with it. For example, every OS/X machine (Macintosh, iPhone, many iPods) is using Unix, and you'd never know.

Here's the difference: when you push against the limits of Microsoft Windows, you quickly hit "the end of the trail." The edge of the world is very easy to find. But Linux/Unix systems aren't built that way, and so, well, "they just go on forever." When Apple wanted to do the iPhone, which of course is really a palm-sized Macintosh, they didn't have to redesign their system to accommodate this very-different piece of hardware. Like it or not, Microsoft cannot enter that market using their Windows product.
 
Old 12-19-2007, 12:29 PM   #9
kellogs
Member
 
Registered: Dec 2007
Location: romania
Distribution: mandriva 2010.1
Posts: 30

Original Poster
Rep: Reputation: 0
hvala kotnik. I did search the net for netsnmp examples dunno how did I miss that. Danke su-shee, and thanks sundial and SciYro. What do I know, this really is an open community. And a helpful one too. Okay folks, I'll just try and fix the 3d driver issue, then start coding the snmp app.

And as for www.msdn.com - it is some sort of immense help collection for winapi and related. If there is a simmilar thing for linux,I will happilly bookmark and use it.

Merci and happy holidays
 
Old 12-19-2007, 01:59 PM   #10
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
There really isn't anything like msdn that i know of, but all major projects ship with texinfo manuals. I would recommend you install tkinfo to browse these info manuals (the GNOME help browser seems to be most unstable, and slow, i cant comment about KDE's, but tkinfo is both stable and fast, just not pretty). Most projects just convert the info files into html for use as their online documentation.

Combined with a good use of google, its usually not hard to find out about something.

edit: some library projects refer to use doxygen, these usually output html files. Im not sure about your distro, but Gentoo puts all extra documentation (anything thats not info or man, such as html, NEWS files, FAQ's, etc) in /usr/share/doc/(progname).

Last edited by SciYro; 12-19-2007 at 02:01 PM.
 
Old 12-20-2007, 03:25 PM   #11
kotnik
Member
 
Registered: Nov 2004
Location: Novi Sad, Serbia
Distribution: Debian, Slackware, Gentoo, openSuSE
Posts: 254

Rep: Reputation: 31
Yeah, as others stated, there is no such thing as centralised anything in GNU/Linux. And that's a good thing.

Let's say you want to implement that tab-menu-bar-thing, whatever M$ marketing department called it, in your program. You'd have to spend days and days on msdn, try a lot, and maybe wouldn't be able to becose it uses some undocumented (read hidden) M$ APIs.

In GNU/Linux when you see something, you check out it's code and use it.

There is no better documentation that the code itself.
 
Old 12-20-2007, 04:57 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Just for background comparison, you might find this a good read: http://linux.oneandoneis2.org/LNW.htm (Linux is not Windows)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GUI doesn't work Executor21 Mandriva 7 11-11-2006 09:44 AM
Linux-GUI doesn't work with X.org 7.1 and Geforce FX 6600 Namorok Linux - Software 1 09-01-2006 11:46 AM
Getting a GUI to work totalshredder Debian 3 01-02-2005 11:31 AM
Isn't Windows 95 or 98 a better GUI solution for old machines than an old Linux GUI lynchmob09 General 10 04-20-2004 01:24 AM
Can't get dc-gui to work.. JoooN Linux - Software 4 02-18-2003 08:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration