>!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//de">

Berlin - Alternative to the X Window System

Down with the X-Wall!

Tobias Hunger

Linux users are getting more and more spoiled - calls for features such as font-anti-aliasing or alphablending are getting louder all the time. At the same time, of course, the system has to be high-performant - the X Window system can help only to a limited extent. The Berlin Project, with its modular, object-orientated architecture, is attempting to make a new start.

More then a decade has now gone by since the development of X Windows. It is not least for this reason that this display system is very robust. Continual new demands from users can be fulfilled with the aid of expansions of the X11-protocol. Despite the far sightedness of its creators, the X Window system is gradually coming up against its limits. 3D applications con only be used efficently with a complicated GLX/DRI mix which does not fit into the architecture very well. Smoothed character sets are still awaited. X also allows only Toolkit related configuration. If you alter your theme in KDE, the appearence of the Gimp does not alter due to the lack of true interoperability.

Fresh start

Berlin offers a central configuration of its appearence. This means that applications present a consistent "Look and Feel" at all times. Gaming fanatics will love the rotating and transparent windows. For programmers the most important feature must surely be the deviceindependent graphics output. The best possible quality is always used, regardless of wether a monitor or a printer is employed for output. As a result, there is no need for the print routines necessary for X, or to adapt a program to different color depths and screen resolutions.

Table 1: History - From InterViews to Berlin

1988 InterViews, Stanfort University (Linton, Calder, Vlissides)
InterViews was a fruitful attempt to combine structured graphics and object orientation. The book "Design patterns" wittnesses this success. Many of the patterns shown there were developed in InterViews.
1994-98 Fresco, X-Consortium
Fresco was the successor of InterViews, extending many of its ideas and integrating the individual libraries into a modular framework. The main focus of the development was a combination of distributed objects and "distributed graphical embedding". The internal use of an ORB even accelerated the development of CORBA. The Fresco project no longer exists, however, Berlin now manages the remaining documents and archives.
1997 GGI-Project, GGI-Team
The GGI Project was established in order to develop a general protocol for writing graphics drivers. By separating the OS kernel from the programming interface, it enables access to all functions of modern graphics hardware in complete safety.
1997 Berlin-Project, Berlin-Consortium
By building on GGI, Berlin was an attempt to produce a very lightweight, fast windowing system. Portability was no objective, but speed and efficicy.
seit 1998 Berlin-Project: 2nd Generation, Berlin-Consortium
The establishment of standards such as OpenGL, CORBA und Unicode caused a change in the original Berlin focus, which is now portability and efficiency through the use of common standard. In the search for inspiration we stumbled across Fresco, from which we have now taken large parts of the sources. Indeed, the Berlin of today has more in common with Fresco than with its own code from before 1998.

Fig. 1: Wether rotated or enlarged: TrueType and Bitmap fonts are improved in quality as the result of edge smoothing. Screenshot

Goals

Berlin's goal is to create an alternative to X11 which can cope better with modern hardware and can be more easily adapted to new input and output devices. The whole system is meant to be modular, so that the actual server is scalable by the selection of suitable modules. Thus the same server should run on both a small PDA and a large 3D graphics workstation. It should also make best use of any available hardware without any changes to its sources. Berlin is trying, by means of abstract interfaces, to develop a system which allows a program to be made usable without alteration in both a walk-in 3D environment as well as in the classic 2D look and potentially even as an "acoustic user interface" for the visualy-impaired. The whole system is being developed under the GNU Library General Public License.

Concepts

Berlin is essentially based on two concepts. The first is that of so-called "structured graphics", where simple objects such as lines, letters, but also transformational functions such as rotations or crops, are integrated into more complex objects. The whole procedure is similar to drafting drawings in vector graphics programs. Figure 2 shows one such (simplified) tree structure and the image created from it. In the example, several glyphs (graphical representations of letters) and a complex vector graphic are combined into an hBox. This element allows all subordinate graphics to be displayed side by side on a common baseline.

Model-View-Controller(MVC) is derived from the programming language Smalltalk and is a second concept which is central for the configurability of the user interface. This means that a program ought to be split into three different function groups. The Model contains the status of the program. That could for example be a number of binary states, a variable value in a given interval or a text. The model is processed by one or more Controllers. As soon as one of these controllers alters the state of the Model, the latter notifies all Views involved. The views thus represent the graphical appearence of a program and the controllers its behaviour. In the interest of configurability by the user, both should be as flexible as possible. The actual program logic stays in the model, the logistical backbone.

Figure 3 shows how these three components interact. Here, the model consists of three numbers, which represent the red, green and blue parts of a colour. The color field in the middle observes this model. If that changes, the colour changes as well. The controllers here are the sliders. If these are moved, they change the corresponding color values of the model. At the same time they are views too. This is necesarry as the sliders need to move if the model is manipulated by the sliders for the other color system.

Fig. 2: Example of a structured graphic (above scenegraph, below result). the corresponding tree example for an structured graphic

Fig. 3: The interplay of model, views and controllers. interplay of Model, View and Controller corresponding graph

...and their realisation

Berlin uses a so called scenegraph for display. This is a struct ured graphic stored in the server. Here it is possible to see the strict separation of the model in the client and the associated views in the server. In the tree-like structure of the scenegraph, each client is responsible for one part of the tree. The client can insert, process or delete graphics here, thus creating their own illustration. These graphics are demanded by the client from various modules in the server. The entire graphical representation of the clients is found there. Subgraphs (such as a window content) can be affected with the aid of upstream decorator patterns. These patterns are in fact invisible graphics, which affect the appearence of theirt dependents. These can be displacement, rotation, or a change of colour or fonts. The displacement of a window may be caused by its descriptive decorator pattern being inserted in front of the window's subgraph. This causes little or no communication with the client as the server has all the information needed to redraw the whole window.

Up to this point no assumptions whatsoever have been made about the hardware used. All details within the scenegraph are abstract. They are also independent of the pixel coordinates and colour encodings of the hardware. For this reason, the normal application developer no longer needs to worry about colour depth, screen resolution and printer support. Berlin adapts the output accurately to the output device in use, regardless of wether this is now a monitor, a video wall or a printer. Various DrawingKits are used to do this. These walk the scenegraph in a so called draw traversal and thereby create an output that can be processed by the underlying hardware. Currently raster and OpenGL display lists are catered for, a Postscript DrawingKit is planned.

Table 2 describes individual components of Berlin. These exclude the DesktopKit, which contains functions to control windows, and the WidgetKit, which provides frequently used graphical user interface element. Those Kits have a similar function in Berlin as the various Windowmanagers and GUI-Toolkits in X11.

CORBA

CORBA (Common Object Request Broker Architecture) is a standard for the development of distributed systems. In such systems the entire functionality of an application is represented by objects. In this architecture , the distinction between client and server becomes blurred. Client-components can create opjects which behave like servers.

The flexibility of distributed systems arises from the fact that all components possess a defined interface. This interface tells the components which services another component provides and how these can be used. As long as this interface remains unchanged, the implementation of a component can alter fundamentaly, without the other objects involved being aware of this.

With Interface Definition Language (IDL), CORBA provides a standard mechanism for the definition of such interfaces. IDL is not an implementation language - only interfaces between objects can be defined. Source texts are created next from these definitions that implement these interfaces. These texts can be in any programming language that features a CORBA binding. Now you "only" need to add the program logic. Using this feature Berlin clients in C++, Python, Perl and Java have already been realized.

In addition, CORBA offeres various services which make it possible to find an object. It also allows communication between objects in different address spaces and even on different computers. This communication is mediated through one ore more ORBs (Object Request Brokers). On the basis of its Object Reference, the ORB can find and contact the object in the network.

Interaction

One part of the scenegraph consists of controllers. These are graphic objects which can receive, process and if necessary pass on events. So controllers are special decorator patterns, which alter not the appearence, but the behaviour of their dependents. Any graphics you desire can be converted, into a button for example, by adding a corresponding controller. All controllers are combined into another graph, the control graph. A pick traversal is applied to this, to find the right recipient of an event.

Events in Berlin are kept more abstract then for example in X in order to be prepared for future input devices. This also makes events easier to synthesise. Used perhaps to simulate a mouse via the keyboard or to enable a pen-based input on a PDA.

Communication

Sice controllers live in the server, many events can be carried out without any communication whatsoever with the client. The displacement of windows is such an example. The responsible controller of the DesktopKit communicates directly with the transformer of the window.

CORBA, with all its functions, seems ideal to take over the communication between server and client-objects. The Berlin interfaces defined in IDL correspond in their function to the X-protocol. But as a rule, communication via CORBA is slower than via sockets. This frequently leads to the assumption that Berlin must be slower then the X Window system. But since the vast majority of communication takes place in the address space of the server, slower communication between client and server is just a bad memory.

Kits

The separation of interface and implementation makes little sense if a programmer can only create elementary objects such as lines, letters or simple controllers. It makes much more sense to create special objects, so-called factory objects. These can make and "wire" complex trees of elementary objects in a single step. In Berlin there are several such factory objects. These are all responsible for a specified type of objects and are combined into Kits. These kits are the mechanism on which the whole modularity and configurability of Berlin is based on. The server itself has just one function - to load kits dynamically at runtime. It does not even need to know which interfaces a kit makes available to do this. It is enough that the application program knows.

Widgets and Taskets

One of the most interesting aspects of drafting user interfaces is the interaction between man and machine. Over the course of time certain metaphors, such as icons, buttons and scrollbars, have been developed. If the architecture itself demands a separation of data and presentation (keyword MVC), it can't be that difficult to design the presentation objects in such a way that their appearance, as well as their function can be configured.

What looks to the user like a complex product, perhaps a scrollbar, is displayed as a structure in Berlin. Elsewhere, objects have defined attributes and status variables. Here these are an arrangement of graphic and controller objects, created with the aid of one or more factory objects. The creating kit is the only authority that knows the precise structure. This is the basis for the selection of different display methods. By exchanging the "WidgetKit", a different appearence is archived.

More abstract levels can be permitted. When one considers the function of a scrollbar, one notes that it alters a value within given limits. If one takes these tasks, one reaches the term Taskets. When a user whiches to pick one of a list of values, he can do so in various ways ranging from menus, up to radio-buttons. All perform this same task, so implementations can be one and the same tasket. In addition to the WidgetKit, Berlin also provides another more abstract TasketKit enabling the user to select his preffered selection method. This can either demand a radio-button group from the WidgetKit or instead do something completely different. The limit is the sky. A menu for example is less useful than an acoustic response for the visually impaired. The application developer has the option to either impose the appearence of his/her application, by manipulating elementary graphics objects, or work as usual with Widgets. He or she can decided to work with even more abstract objects, such as taskets.

Table 2: The components of Berlin
Components
Display Server Like the X-Server it presents the graphical user interface of a client.
libBerlin, libWarsaw connect the client or server respectivly to the Object Request Broker (ORB). Both are created by a compiler from Berlin's CORBA interfaces.
ORB The CORBA ORB allows communication between client and server, regardless of their respective locations in the network.
libPrague contains classes, which abstract Berlin from its underlying hardware. This library is intended to allow easy porting of Berlin.
Console Another abstraction. The console converts events from external libraries that query the hardware into Berlin events.
Kits are dynamically loadable modules, which provide defined functions. Configuration of Berlin is possible by simply exchanging kits at runtime.

Getting started...

Much has changed in this area since this article was published in the Linux Magazine. Please read the INSTALL file of the distribution. Additional help can be found in doc/Tutorial/.

Development status and prospects

It may appear that the Berlin Project has done little in recent months. But there have been a few changes in the internal structure. First of all, many dependencies on other projects have been dissolved. Berlin no longer needs MesaGGI because of the new libArtDrawingKit. A new hardware abstraction layer, the console means that even the dependency on the GGI (Generic Graphics Interface) has now gone. The ORB has now become exchangeable. Apart from this, the whole architecture is more robust. This is the result of improved memory management. Berlin is now truly stable and a bit faster than in previous versions, although there is still a great deal of room for refinement. Nevertheless, Berlin is not suitable for end users yet. Apart from a few demos, there are still no applications. There isn't even a complete set of widgets to develop these. At present, Berlin should be regarded as more of an experimentation field for developing man-machine interaction.

Compatibility

Berlin and X have so little in common that the user cannot simply use his normal applications under Berlin. This is a serious drawback. Who wants to do without his favourite application? So how can Berlin be adjusted to represent existing programs?

Pixel-Level bridge

X in Berlin in X

The simplest option for archieving X-compatibility is to run an X-Server in a window. This option is technically relativly simple to realize and makes it possible to use all X-applications under Berlin. The drawback is that none of the advantages of Berlin come into play in the conversion. The pixel-level bridge is already being worked on. Displaying already functions (see figure above), but there is as yet no passing of events from Berlin to X.

Widget bridge

In the widget bridge a wrapper library is written to convert calls to a X-based GUI-Toolkit into corresponding Berlin structures. Such a bridge has the advantage that the fundamental characteristics of Berlin (transformation, server-side object communication) are largely retained. However realisation is very time consuming and does not result in any additional functionality with respect to the X-version of the GUI-Toolkit.

High-Level-Bridge

Many applications nowaday use GUI description languages, mostly based on XML, such as Glade, XUL and Entity. With such "global knowledge" about the user interface it may be that better conversions can be made between X-Toolkit widgets and Berlin.

Since the architecture is now in for large sections, work is now slowly b eginning on the implementation of additional widgets. Portage to BSD and other s ystems is in the pipeline, together with the integration of additional libraries such as SDL and GLUT into Berlin. The developers are hoping that this will provide the long awaited hardware support for display. Until now, Berlin has had to manage with just software rendering. At the same time, portage onto an SGI Onyx is in the works. The project team members are hoping to be able to try out Berlin in a real, walk-in 3D environment on this machine. In preparation for this a so-called PrimitiveKit is being worked on. This will make it possible to insert simple three-dimensional objects such as spheres and cudes into the scenegraph. Of course, the development of the so-called canvas widget is not standing still, either. This could be used to embed an X-Server into Berlin. The TextKit is currently in a revision phase, because it still does not provide the bi-directional textflow which will be necessary for multilingual text editing.

It is obvious that there is still a great deal to be done before Berlin is seen as the dreamed-of alternative to X11. The team of the Berlin Project would be delighted to recieve any assistance in further development.

Infos

[1] Berlin Homepage: http://www.berlin-consortium.org/
[2] Fresco Homepage: http://www2.berlin-consortium.org/fresco/
[3] CORBA Informations: http://www.corba.org/
[4] Unicode Informations: http://www.unicode.org/
[5] OpenGL Informations: http://www.opengl.org/
[6] GNU Library General Public License: http://www.gnu.org/copyleft/lgpl.html
[7] Mesa (free OpenGL-Implementation): http://www.mesa3d.org/
[8] libArt: http://www.levien.com/libart/
[9] GGI Project: http://www.ggi-project.org/
[10] FreeType: http://www.freetype.org/
[11] libPNG: http://www.libpng.org/pub/png/
[12] zlib: http://www.info-zip.org/pub/infozip/zlib/
[13] omniORB: http://www.uk.research.att.com/omniORB/
[14] Berlin Sourcecode: http://www.berlin-consortium.org/install.html

The Author

Tobias Hunger is a student of computer science at the University of Kaiserslautern. He also runs a company dealing with questins concerning network and computer security.

Published with kind permission of the Linux Magazine.

Comments to this article