Sunday, December 28, 2008

What Is a Window Manager?

X-windows is a system that divides the labor up quite a bit. An X-windows application draws and controls only the area "inside" the window, the so-called client area. A totally separate program, called a "window manager" paints the borders and controls (such as resizing edges, maximize, minimize, and close buttons). You can have only one window manager program per X server, and that window manager provides these window "decorations" on behalf of all windows.

The window manager and the X-application communicate in standard ways. For example, when you resize a window by dragging an edge, all the work is done by the window manager program until you release the edge; then the window manager tells the X application about it by sending it a resize message. The application then must repaint itself in the new client area. (This is a bit theoretical: Some window managers send repaint messages while you drag the edge, so the application repaints several times, but you get the idea.) The application is also able to tell the window manager certain things, such as whether or not the window may be resized.

The division of labor has some distinct advantages, especially when you consider X's network capabilities. If the window manager is local, then when, for example, resizing the window of a remote application, only the final "window resize" and screen repaint need go over the network. None of the mouse events or border animation need to generate network traffic. (Again, if your window manager sends repaint messages as it goes, this benefit is lost.)

The other advantage is that you can change window managers. You might have an industrial application that is always maximized and should not be closed. You could write a window manager that doesn't have a close button or resizing decorations and that always sets the client area size to the full screen. Heck, some existing window managers can be configured to do this without any programming.

The details of window managers and their interaction with applications can get quite complex. There is a sort of "minimum standard" set of features a window manager must provide, and there is a "minimum standard" set of window manager messages an X-application must support, but many applications go well beyond this. The increasingly common "desktop" systems for X (KDE and GNOME, for example) extend this set quite, er, extensively. This means that applications that use these features either will run only with that one window manager or will have some functionality unavailable when running under other window managers.

If you want to know more, it is time for you to delve into X-windows programming.

As for X-servers for Windows, a number of commercial ones are available. A free X-server for Windows is available as part of a product called Cygwin, which is a complete POSIX-compliant programming environment for Windows. Cygwin actually makes Windows itself into a decent Unix-like environment. The X-server for Cygwin is the same X-server shipped with most Linux distributions: Xfree86. Cygwin is available from Cygnus Software, which was purchased by RedHat last year. The URL is http://sources.redhat.com/cygwin.

Source of Information : Addison Wesley - Multitool Linux - Practical Uses for Open Source Software

No comments: