Gtk+ and Window Managers
Many novice developers for Gtk+ get confused about the relationship between the Gtk+ toolkit and the window manager. After all, window managers are part of the graphical interface, and they have elements that control how windows behave. However, there is a great difference between toolkits and the window manager when it comes to X Window programming.
A Window Manager is the part of the system that handles top level windows. For example, when you create a new window by starting an application, the top level window will typically have controls to maximize, minimize, moving, and resizing the application. These are functions performed by the window manager.
While the window manager is responsible for maintaining the top level windows, it is not part of any application. It is a separate process itself, running as part of the X server for the machine you are using.
The reason for the separation may look odd for users accustomed to graphical interfaces such as Microsoft Windows or Apple OS. However it makes sense if you consider the following characteristics of the X Window System:
- X is a client server system. Therefore, applications may be running in different machines. It is therefore natural that applications pass the handling of top level windows to another process running typically on the server. Being a distributed system, X has to divide the responsibilities of maintaining the applications through several cooperating processes.
- Another reason is uniformity. Since X allows applications to define their own graphical interfaces, if they were responsible for top level windows, they each top level window would interact differently. However, it would be very strange to have windows behaving is different ways. For example, if the window frame were left for the application to handle, then each application would be resized in a slight different way. To avoid this chaos, the X Window System requires that a single process be responsible for handling all top level windows.
We see then that having separate window managers is a logical decision on the X Window System. This means that even if we develop our application with Gtk+, there is no guarantee that the window manager for the system we are running is also written in Gtk+.
The good news is that, because X requires the separation between window manager and main application, we don't have to worry about the window manager at all. Every major UNIX system has a predefined window manager that is capable of handling any X application, be it written in Gtk+ or not.
In the Gnome desktop environment, there are several window managers that can be configured by the user. KDE also has a preferred window manager, which integrates with the features provided by the KDE environment. Looking at the preferences settings of your environment you can customize, or change entirely the window manager used in your desktop.
Post a comment