This blog post has been in my drafts folder for weeks and I just thought it’s time to publish it - ready for Akademy :-) And if somebody is really interested we could have a BOF session at Akademy. I think Plasma devs want us to write a slide effect to replace their custom popup animation. That would be a perfect example to get your hands dirty.

I wrote a new Kwin effect and thought this is the ideal effect for writing a small howto. It is an effect which helps resizing windows by colouring the changed geometry. I was told that resizing is not optimal in KWin, that is if the window content is shown while resizing it is slow and if the window content is not shown it is ugly. This effect should fill the gap. Unfortunately the current code will only work with the slow show window content while resizing (the API has to be changed). Nevertheless I decided to show the code in this tutorial.

Von KWin

The effect has been committed to trunk. So you can have a look at it and if you’re running trunk you can even try it. The effect which we will write has the name “Resize”. It will support both backends: XRender and OpenGL. Each effect has an own directory in kwin/effects so we create a new directory resize. There we create the following files:

  • CMakeLists.txt
  • resize.h
  • resize.cpp
  • resize.desktop

We have to include this directory into the build, so we edit the CMakeLists.txt in the effects directory. We just add the following line to the section marked as “Common effects”:

include( resize/CMakeLists.txt )

If it were an OpenGL only effect we would place this line in the section marked as “OpenGL-specific effects”.

So at this point we are finished with the preparation. So let’s start looking at the files. First the desktop file:

[Desktop Entry]
Name=Resize Window
Icon=preferences-system-windows-effect-resize
Comment=Effect to outline geometry while resizing a window

Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Martin Gräßlin
X-KDE-PluginInfo-Email=kde@martin-graesslin.com
X-KDE-PluginInfo-Name=kwin4_effect_resize
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Window Management
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=60

Most of it is self explaining and just needed for the “All effects” tab in the compositing kcm. The most important value is the “X-KDE-PluginInfo-Name”. This is the name used to load the effect and has to start with “kwin4_effect_” followed by your custom effect name. This last part will be needed in the source code.

Each effect is a subclass of class Effect defined in kwineffects.h and implements some of the virtual methods provided by Effect. There are methods for almost everything the window manager does. So by implementing those methods you can react on change of desktop or on opened/closed windows. In this effect we are interested in resize events so we have to implement method “windowUserMovedResized( EffectWindow *w, bool first, bool last )”. This method is called whenever a user moves or resizes the given window. The two boolean values indicate if it is the first, last or an intermediate resize event.

But there are more methods we have to implement. The effect should paint the changed geometry while resizing. So we have to implement the methods required for custom painting. KWin’s painting pass consists of three stages:

  1. pre paint
  2. paint
  3. post paint

These stages are executed once for the complete screen and once for every window. All effects are chained and each effect calls the stage for the next effect. How this works we will see when looking at the implementation. You can find a good documentation in the comments of scene.cpp

Now it’s time to have a look at the header file:

#ifndef KWIN_RESIZE_H
#define KWIN_RESIZE_H

#include <kwineffects.h>

namespace KWin
{

class ResizeEffect
    : public Effect
    {
    public:
        ResizeEffect();
        ~ResizeEffect();
        virtual void prePaintScreen( ScreenPrePaintData& data, int time );
        virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
        virtual void windowUserMovedResized( EffectWindow *w, bool first, bool last );

    private:
        bool m_active;
        EffectWindow* m_resizeWindow;
        QRegion m_originalWindowRect;
    };

}

#endif

We see that there are three member variables. The boolean is used to indicate if there is a window being resized, that is if we have to do some painting. The EffectWindow is a pointer on the window being resized and the QRegion stores the windows’s geometry before the start of resizing.

So now we can have a look at the implementation. I will split the code in small parts and explain the code. So first let’s look at the includes:

#include "resize.h"

#ifdef KWIN_HAVE_OPENGL_COMPOSITING
#include <GL/gl.h>
#endif
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#endif                                                                

#include <KColorScheme>

As our effect should support both XRender and OpenGL we have to include the headers for both. As it is possible that the effect is compiled on a system which does not support one of both we use ifdef. We can be sure that at least one of both is available or the effects wouldn’t be compiled at all. If you write an OpenGL only effect you do not have to bother about such things. Also if you only use KWin’s high level API you don’t need to include those headers. But we want to paint on the screen using OpenGL or XRender directly.

So let’s have a look at the next part:

namespace KWin
{                    

KWIN_EFFECT( resize, ResizeEffect )                                                                                                                                                            

ResizeEffect::ResizeEffect()
    : m_active( false )
    , m_resizeWindow( 0 )
    {
    reconfigure( ReconfigureAll );
    }                                                                                                                           

ResizeEffect::~ResizeEffect()
    {
    }

Here we see the use of a macro. This has to be included or your effect will not load (it took me ten minutes to notice I forgot to add this line). The first value is the second part of X-KDE-PluginInfo-Name - I told you we will need it again. The second value is the class name. Following is constructor and deconstructor.

So let’s look at the pre paint screen stage:

void ResizeEffect::prePaintScreen( ScreenPrePaintData& data, int time )
    {
    if( m_active )
        {
        data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
        }
    effects->prePaintScreen( data, time );
    }

Here we extend the mask to say that we paint the screen with transformed windows when the effect is active. That’s not completely true - we don’t transform a window. But this flag indicates that the complete screen will be repainted, so we eliminate the risk of artefacts. We could also track the parts which have to be repainted manually but this would probably be more work for the CPU than the complete repaint for the GPU. At this point we see the chaining for the first time. The effects->prePaintScreen( data, time ); will call the next effect in the chain. effects is a pointer on the EffectsHandler and a very useful helper.

So now we start looking at the heart of the effect:

void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
    {
    effects->paintWindow( w, mask, region, data );
    if( m_active && w == m_resizeWindow )
        {
        QRegion intersection = m_originalWindowRect.intersected( w->geometry() );
        QRegion paintRegion = m_originalWindowRect.united( w->geometry() ).subtracted( intersection );
        float alpha = 0.8f;
        QColor color = KColorScheme( QPalette::Normal, KColorScheme::Selection ).background().color();

We first continue the paint window effect chain - this will paint the window on the screen. Now we check if we are in resizing mode (m_active) and if the currently painted window is the window which is repainted. In that case we calculate the region which has to be painted. We just subtract the intersection of current geometry with saved geometry from the union of those two. The next two lines are for the color definition. We use the background color of a selection with 80 % opacity.

Now we have to do a little bit OpenGL. In most effects where you just transform windows you don’t have to write OpenGL at all. There is a nice high level API which allows you to translate, scale and rotate windows or the complete screen. Also transforming single quads can be completely done without knowing anything about OpenGL.

#ifdef KWIN_HAVE_OPENGL_COMPOSITING
        if( effects->compositingType() == OpenGLCompositing)
            {
            glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
            glEnable( GL_BLEND );
            glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
            glColor4f( color.red() / 255.0f, color.green() / 255.0f, color.blue() / 255.0f, alpha );
            glBegin( GL_QUADS );
            foreach( const QRect &r, paintRegion.rects() )
                {
                glVertex2i( r.x(), r.y() );
                glVertex2i( r.x() + r.width(), r.y() );
                glVertex2i( r.x() + r.width(), r.y() + r.height() );
                glVertex2i( r.x(), r.y() + r.height() );
                }
            glEnd();
            glPopAttrib();
            }
#endif

We check if KWin uses OpenGL as a backend. We enable blending in the OpenGL state machine (needed to have translucent colors) and set the color for our rects. OpenGL clamps colors in the range [0,1] that’s why we can’t use the values from QColor directly. Last but not least we just paint one quads for each rect of our regin.

Now just the XRender part is missing. This part is taken from show paint effect - I don’t know anything about XRender ;-)

#ifdef KWIN_HAVE_XRENDER_COMPOSITING
        if( effects->compositingType() == XRenderCompositing)
            {
            XRenderColor col;
            col.alpha = int( alpha * 0xffff );
            col.red = int( alpha * 0xffff * color.red() / 255 );
            col.green = int( alpha * 0xffff * color.green() / 255 );
            col.blue= int( alpha * 0xffff * color.blue() / 255 );
            foreach( const QRect &r, paintRegion.rects() )
                XRenderFillRectangle( display(), PictOpOver, effects->xrenderBufferPicture(),
                    &col, r.x(), r.y(), r.width(), r.height());
            }
#endif
        }
    }

This does the same as the OpenGL part just with XRender.

Last but not least we have to track the window resizing:

void ResizeEffect::windowUserMovedResized( EffectWindow* w, bool first, bool last )
    {
    if( first && last )
        {
        // not interested in maximized
        return;
        }
    if( first && w->isUserResize() && !w->isUserMove() )
        {
        m_active = true;
        m_resizeWindow = w;
        m_originalWindowRect = w->geometry();
        w->addRepaintFull();
        }
    if( m_active && w == m_resizeWindow && last )
        {
        m_active = false;
        m_resizeWindow = NULL;
        effects->addRepaintFull();
        }
    }

} // namespace

So and that’s all. When a resize event is started we activate the effect and trigger a repaint of the window (probably not needed, but doesn’t hurt). And when the resizing is finished we deactivate the effect and trigger another repaint of the complete screen just to make sure that there are no artefacts left.

The CMakeLists.txt could just be taken from any other effect and be adjusted. So here’s the example:

#######################################
# Effect

# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
    resize/resize.cpp
    )

# .desktop files
install( FILES
    resize/resize.desktop
    DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

#######################################
# Config

Now you can compile and try your new effect.

2. Juli 2009, 11:06 Uhr

Dies ist eine Übersetzung des Englischen Posts A new KWin window decoration theme engine

Ich habe mit der Arbeit an einer neuen Theme Engine für Fensterdekorationen begonnen. Das Ziel ist Themes für Dekos so einfach zu machen wie Themes für Plasma. Also nutzt es Plasma Technologien, insbesondere FrameSvg ;-) Hier ist ein Screenshot des aktuellen Stand:

Von KWin

Der Hintergrund der Dekoration basiert auf Air’s transparenten Hintergrund und die Icons… nun man sieht, dass ich kein Künstler bin (und serenity auch nicht, der den Schließen Knopf erstellt hat). Es gibt bisher auch nur einen Minimieren und einen Schließen Knopf. Wie man sieht wird KWin’s neue ARGB Dekoratioen benutzt und das Theme zeichnet eigene Schatten. Die Engine unterstützt jedoch noch nicht wirklich undurchsichtige Dekorationen und das ist einer der noch ausstehenden Todos. Aber es wurde auch entwickelt mit Gedanken an ARGB Dekos :-)

Aktuell fehlen noch zwei Dinge: ein Name und Beispielthemes. Wenn jemand Ideen für Namen hat, bitte einfach einen Kommentar hinterlassen. Und wer Interesse hat ein Theme zu erstellen, soll mich doch bitte einfach kontaktieren.

Ach ich habe noch keinen Code ins SVN eingespielt, aber die Engine wird bald in playground zu finden sein. Es gibt da noch ein paar Blocker (zum Beispiel der fehlende Name), welche zuerst behoben werden müssen, bevor ich den Code teile.

10. Juni 2009, 8:33 Uhr

I started to work on a new theme engine for window decoration. The goal is to make deco themes as easy as Plasma themes. So it’s using Plasma technologies, that is FrameSvg ;-) Well here is a screenshot of current state:

Von KWin

The decoration background is based on Air’s translucent background and the icons… well you see I’m not an artist. And there is only a minimize and a close button. As you can see it uses KWin’s new ARGB decoration and the theme paints it’s own shadows. The engine does not yet really support opaque decorations that’s one of the left todos. But it’s thought with ARGB decos in mind :-)

Currently two things are still missing: a name and example themes. So if you have ideas for names please leave a comment and if you are interested in creating a theme, please contact me.

Ah I have not yet committed any code into SVN, but you will soon find the engine in playground. There are some blockers (like the name) which have to be fixed before I want to share the code.

10. Juni 2009, 8:18 Uhr

Es gibt eine öffentliche Petition gegen Zensursulas Pläne das Internet zu zensieren: Keine Indizierung und Sperrung von Internetseiten

Aktuell gibt es bereits über 4000 Mitzeichner, alle anderen öffentlichen Petitionen sind nur im dreistelligen Bereich. Durch das Mitzeichnen kann man denke ich sehr gut Zensursula zeigen, was die Bevölkerung von den Plänen hält.

Also an alle: auf die Seite gehen, registrieren, Captcha überwinden, auf Bestätigungsmail warten, Link in Mail anklicken, anmelden und mitzeichnen. Zeigt der Regierung was ihr von Zensur haltet!

4. Mai 2009, 4:00 Uhr

Nach Ansicht von Zensursula können nur 20 Prozent der Internetnutzer die lächerliche mit DNS Poisoning umgesetzte Sperre umgehen, und die sind zum Teil schwer Pädokriminelle. Frau von der Leyen: ich betrachte das als eine sehr schwere Beleidigung nicht nur mir gegenüber, weil ich seit über 10 Jahren in der Lage bin meinen DNS Server selber einzustellen und ich deswegen noch lange nicht pädophil bin, sondern auch gegenüber den 80 % der Bevölkerung, der Sie die Kompetenz absprechen ein 30 Sekunden Video bei YouTube zu verfolgen.

Ach ja Ihre Chefin wird morgen von mir Post erhalten, weil Sie gegen Ihren Amtseid verstoßen. Sie haben geschworen das Grundgesetz zu wahren. Eine willkürliche, geheime, nicht kontrollierte Sperrliste, bei der ein Aufruf einer dieser Adressen zu einem Strafverfahren und Hausdurchsuchung führen kann, verstößt gegen Artikel 5: “Jeder hat das Recht, seine Meinung in Wort, Schrift und Bild frei zu äußern und zu verbreiten und sich aus allgemein zugänglichen Quellen ungehindert zu unterrichten.” Das Internet ist eine “allgemein zugängliche Quelle.

Sehr schade, dass der Verstoß gegen den Amtseid in Deutschland keine strafrechtlichen Folgen hat. Ich war in letzter Zeit sehr oft von der Politik enttäuscht: Hackerparagraph, Vorratsdatenspeicherung und Bundestrojaner. Aber Zensursula ist einfach nicht mehr zu überbieten. Ich kann meine Gefühle, die das Vorgehen dieser Frau auslösen, nicht mehr in Worte ausdrücken.

26. April 2009, 8:27 Uhr

Es ist mal wieder diese besondere Zeit des Jahres - ein neues Kubuntu Release steht vor der Türe. Wie so oft habe ich bereits aktualisiert und wie jedes halbe Jahr wieder, sind die Übersetzungen zerstört.

Zuvor hab ich Intrepid Ibex mit KDE 4.2 aus dem PPA benutzt. Übersetzung: top, fast 100 % alles vorhanden. Nach dem Upgrade auf Jaunty, war auch noch alles in Ordnung. Ja und dann, dann kamen irgendwann neue Updates. Und plötzlich war die Übersetzung wieder weg. Zuerst ist es mir nur in den Systemsettings aufgefallen, das plötzlich die Einträge auf Englisch sind, aber wenn man auf einen Eintrag klickt, öffnet sich ein deutsches Menü. Dachte mir natürlich “hoppla da sind wohl meine Spracheinstellungen durcheinander gegangen”. Also umgestellt auf Englisch, zurück auf Deutsch und es war immer noch gemischt. Na ja stört ja nicht weiter. Nach ein paar Tagen noch mehr Updates. Und mit jedem mal wird es mehr und mehr Englisch.

Tja was ist der Grund? Anscheinend hat wohl irgendein super tolles Tool gemeint sämtliche Upstream Übersetzungen aus den .desktop Dateien zu entfernen. Diese Dateien beeinhalten den Namen und eine Beschreibung eines Programms oder Plugins oder was auch immer und auch die Übersetzungen. Hier mal ein Beispiel aus Kubuntu
[Desktop Entry]
Name=Desktop Cube
Icon=preferences-system-windows-effect-cube
Comment=Display each virtual desktop on a side of a cube

Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Martin Gräßlin
X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
X-KDE-PluginInfo-Name=kwin4_effect_cube
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Window Management
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=50
X-Ubuntu-Gettext-Domain=desktop_kdebase-workspace

Und jetzt die gleiche Datei, wie sie im KDE SVN ist (gekürzt auf nur 10 Sprache):

[Desktop Entry]
Name=Desktop Cube
Name[ar]=مكعب سطح المكتب
Name[be@latin]=Rabočy kub
Name[bg]=Кубичен работен плот
Name[bn]=ডেস্কটপ কিউব
Name[bn_IN]=ডেস্কটপ কিউব
Name[ca]=Cub d’escriptori
Name[cs]=Plochy na kostce
Name[csb]=Szescan pùltu
Name[da]=Desktop-terning
Name[de]=Arbeitsflächen-Würfel
Icon=preferences-system-windows-effect-cube
Comment=Display each virtual desktop on a side of a cube
Comment[ar]=تعرض كل سطح مكتب افتراضي في جانب من جوانب المكعب
Comment[be@latin]=Pakazvaje virtualnyja rabočyja stały na bakoch kuba
Comment[bg]=Всеки виртуален работен плот се показва като страна на куб
Comment[bn]=প্রত্যেকটি ভার্চুয়াল ডেস্কটপ একটি কিউব-এর ধারে দেখাও
Comment[bn_IN]=প্রত্যেকটি ভার্চুয়াল ডেস্কটপ একটি কিউব-এর ধারে দেখাও
Comment[ca]=Visualitza cada escriptori virtual a la cara d’un cub
Comment[cs]=Zobrazuje každou virtuální plochu jako stranu krychle
Comment[csb]=Wëskrzëniô wirtualny pùlt na scanie szescanu
Comment[da]=Vis hver virtuel desktop på en side af en terning
Comment[de]=Zeigt jede virtuelle Arbeitsfläche auf einer Würfelseite an.

Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Martin Gräßlin
X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
X-KDE-PluginInfo-Name=kwin4_effect_cube
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Window Management
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=50

Ich denke man sieht den Unterschied. Das ist mit jeder dieser Dateien passiert.

Aber es wäre doch gelacht, wenn das alle Probleme wären. Nein die KDE Templates in Rosetta sind durcheinander geraten. Jemand kam auf die Idee die Templates zwischen den Quellcode Paketen zu verschieben. Das führt dann dazu dass ganze Anwendungen nicht mehr übersetzt sind, obwohl sie Upstream übersetzt sind und das nicht nur im Deutschen, nein in allen Kubuntu Lokalisierungen.

Der Ansatz von Rosetta vor vielen Jahren war ja mal ganz gut. Leider funktioniert es immer noch nicht und egal was für eine Lösung man hat: Upstream Übersetztungen müssen einfach bevorzugt behandelt werden. Wenn es Fehler bei Upstream gibt (was der einzige Grund wäre, die Übersetzung zu ändern), dann muss das Upstream korrigiert werden und nicht in jeder Downstream.

Das Dilemma kann man hier nachlesen: https://lists.ubuntu.com/archives/ubuntu-translators/2009-April/002313.html

Ach ja, Hoffnung gibt es für mich auch. In etwas mehr als einem Monat kommt die Beta von 4.3 und ich werde wieder mit schönen Upstream Übersetzungen und nicht kaputten .desktop Dateien versorgt und muss nicht länger diesen Deutsch/Englisch Mischmasch ertragen.

7. April 2009, 9:24 Uhr

Dies ist eine Übersetzung des englischen Posts Some not so wobbly news from wobblyland.

Seit langer Zeit kein Post mehr über die letzten Änderungen in KWin, also werde ich mal ein paar neue Feauters vorstellen.

Es wurde einige Arbeit in die Verbesserung der Tabbox (alt+tab), wenn kein Effekt genutzt wird, investiert. Andreas Pakulat hat eine Umrandung für das ausgewählte Fenster wie in KDE 3 hinzugefügt. Die Tabbox hat eine visuelle Auffrischung erfahren und nutzt nun den Plasma style. Hier möchte ich Nuno danken für seine tolle Hilfe das ganze schön zu machen. Ein paar Pixel hier und da hinzufügen - ich hätte das nicht geschafft.

Nichts ist so gut wie ein Bildschirmfoto:

Plasma styled tabbox mit Umrandung

Plasma styled tabbox mit Umrandung

Aber das ist nicht alles was verbessert wurde. Einige könnten festgestellt haben, dass sie einen Effekt aktiviert haben, aber dass er einfach nicht funktioniert. Das kann verschiedene Ursachen haben: man versucht einen OpenGL Effekt zu aktivieren, aber man benutzt XRender oder der Effekt benötigt OpenGL Shader, aber die Hardware oder die Treiber unterstützen diese nicht. Um das Problem zu lösen, wäre die beste Lösung die nicht unterstützten Effekten im Plugin Wähler zu deaktivieren. Aber das ist nicht möglich, da man die Effekte auch ändern kann, wenn Compositing temporär oder dauerhaft ausgeschaltet ist. Daher bringt es nichts auf OpenGL zu testen und wir können die Effekte nicht einfach in der GUI deaktivieren.

Um etwas Feedback an den Anwender geben zu können, wird eine Benachrichtigung angezeigt, wenn die Effekte geändert werden und man hat einen nicht unterstützten Effekt ausgewählt. Es wird einfach überprüft welche Effekte geladen sind und welche in den Einstellungen ausgewählt wurden.

Benachrichtigung für nicht unterstützte Effekte

Benachrichtigung für nicht unterstützte Effekte

Wir haben auch eine D-Bus Methode toggleCompositing um compositing temporär auszuschalten und wieder zu starten hinzugefügt. Diese wird bereits von PowerDevil benutzt wenn die Option Compositing auszuschalten gesetzt ist. In diesem Fall wird auch eine Benachrichtigung gezeigt, welche mitteilt mit welchem Tastenkürzel Compositing wieder gestartet werden kann.

Und nicht zuletzt gibt es nun ein neues On-Screen-Display, welches angzeigt wird, wenn man den virtuellen Desktop wechselt. Es ist auch Plasma styled und sieht wie der Pager aus. Der neue Desktop wird hervorgehoben und Pfeile vom alten zum neuen Desktop werden angezeigt. Bitte meckert nicht, dass es nur eine Kopie von Mac OS ist - natürlich ist es davon inspiriert. Aber es ist besser. Jemals auf das Mac OS Spaces OSD geschaut? Sieht es aus wie die anderen Bereiche der Arbeitsfläche? Nein sieht es nicht. Unser OSD benutzt den Arbeitsflächen Stil, also ist es besser integriert :-)

Dieses OSD ersetzt den alten Popup. Also muss man nur die Option “Namen der Arbeitsfläche beim Wechsel anzeigen” auswählen um das OSD zu erhalten. Falls jemand das alte Popup weiterhin haben möchte: bitte eine Nachricht hinterlassen. Wenn ein Bedarf besteht, werde ich eine Option hinzufügen um zwischen OSD und Popup zu wählen.

Desktop Wechsel OSD

Desktop Wechsel OSD

Und da ein Bild die dynamischen Animationen nicht zeigen kann (Plasma hat dafür wirklich tolle Möglichkeiten), ist hier das Video (Link für Planet Leser):

6. April 2009, 9:48 Uhr

Long time no post on what has changed in KWin lately. So I’m going to show you some new features.

There has been some work going on to improve the tabbox (alt+tab) when no effect is used. Andreas Pakulat added an outline for the currently selected window like it was in KDE 3 time. Very nice and usefuel - thanks a lot. The tabbox has received some face lifting and uses the Plasma style. On that part I want to thank Nuno for his great help on making the whole thing nice. Adding some pixels here and there - I could not have done it.

Well nothing is as good as a screenshot:

Plasma styled tabbox with outline

Plasma styled tabbox with outline

But that’s not the only thing which has improved. Some might have noticed that they activated an effect but it just doesn’t work. This can have different reasons: you want to activate an OpenGL only effect and you are using XRender or the effect requires OpenGL shaders and your hardware or driver does not support shaders. To solve this problem the best solution would be to deactivate the not supported effects in the plugin selection, but that’s not possible as you can change the effects if compositing is suspended or deactivated. So testing if OpenGL is used does not work and we cannot deactivate the effects in the UI.

To give some feedback to the user a notification is shown when you change effects and you have selected a not supported effect. It just checks which effects are loaded and which effects are selected when you change your settings.

Notification for not supported effects

Notification for not supported effects

We also added a D-Bus method toggleCompositing to suspend/resume compositing. This is already used by PowerDevil when the option to disable Compositing is set. In that case another notification is shown, telling you the shortcut to resume compositing. So if you are the author of an application which you know performs badly with compositing (I have heard there are some drivers which don’t like you to play videos when compositing is enabled - should be solved with DRI2) you can automatically suspend compositing.

And last but not least there is a new on-screen-display which is shown when you change the desktop. It’s Plasma styled as well and looks very much like the pager. It highlights the new desktop and arrows from the old desktop to the new desktop are shown. Please don’t tell me that this is just a copy from Mac OS - of course it is inspired. But this one is better. Ever looked at the Mac OS spaces OSD? Does it look like the other parts of the workspace? No it doesn’t. Our OSD uses the workspace style, so it’s better integrated :-)

This OSD replaces the old popup info. So you just have to check the “Show desktop name on change” option to receive this OSD. If you want to keep the old just name option: please leave a note. If there is need for it I will add an option to select between OSD and only desktop name.

Desktop change OSD

Desktop change OSD

And as an image can’t show the dynamic animations (Plasma has really great stuff for that) here’s the video (Link for planet reader):

6. April 2009, 9:19 Uhr

Es gibt seit einer Zeit einen Feature Request um KWin auf die Microsoft Windows Plattform zu portieren (siehe Bug 182700) und wir haben im Geheimen mit der Portierung nach Microsoft Windows Vista begonnen. Und heute sind wir froh verkünden zu können, dass es mit KDE 4.3 ein erstes Release for die Microsoft Windows Plattform geben wird.

Natürlich ist die Portierung einer Anwendung, welche so eng mit der X11 Plattform verzahnt ist, keine einfache Aufgabe. Daher haben wir uns entschlossen keine Fenstermanager Funktionen in der ersten Version bereitzustellen. Es wird nur Compositing Unterstützung geben. Microsoft erlaubt den Zugrif auf Vista’s Aero Funktionen und daher mussten wir nur ein Direct3D Backend implementieren. KWin’s Compositing Unterstützung ist sehr modular und es gibt mit OpenGL und XRender bereits zwei Backends. Daher war das Hinzufügen von Direct3D Unterstützung nicht schwierig. Also haben wir eine neue scene_direct3d.cpp Datei angelegt, welche das Compositing genauso handhabt wie die bereits existierende scene_opengl.cpp.

Eine kompliziertere Aufgabe werden die EffectWindows, welche ein Fenster in den Effekten darstellen. In der bestehenden Implementierung sind diese mit X Clients verzahnt: managed, unmanaged und deleted Clients. Diese Typen haben eine Elternklasse TopLevel. Also mussten wir eine neue Client Implementierung namens WindowsWindow erstellen. Wir sind nicht in der Lage diese Fenster zu verwalten, da - wie gesagt - die Portierung der Fenstermanager Funktionen zu schwierig ist. Für die Effekte ist also alles transparent, nichts ändert sich. Wenn ein EffectWindow in X11 angesprochen wird, dann ist es ein managed oder unmanaged client, in Microsoft Windows ein WindowsWindow.

Natürlich erlaubt unsere Effekte API Zugriff auf die Fensterverwaltung. Es wäre lachhaft, wenn man den Würfel hat, aber die Arbeitsfläche nicht darüber wechseln kann. Da die Microsoft Windows Plattform das Konzept der virtuellen Arbeitsflächen nicht kennt, können wir natürlich diese API Aufrufe nicht bereitstellen. Also mussten we einen WindowsEffectsHandler Implementation erstellen welche Zugriff auf all die Funktionen auf Grund der API Kompatibilität bereitstellt und Standardwerte zurückliefert. effects->numberOfDesktops() wird immer 1 zurückliefern. Daher werden Effekte welche effects->numberOfDesktops() > 1 voraussetzen nicht funktionieren. Daher keinen Würfeleffekt :-(

Wir haben nun einen Punkt in der Portierung erreicht, in dem wir zuversichtlich sind alle wichtigen Effekte portiert zu haben bis zum Hard Freeze. CoverSwitch und FlipSwitch funktionieren bereits, auch kleinere Effekte wie MagicLamp und die MinimizeAnimation sind fast fertig (wir haben immer noch Probleme die Icon Position zu ermitteln).

Ich denke mal es ist Zeit einen Screenshot vom aktuellen Stand zu zeigen. Da FlipSwitch einer der ersten Effekte war, welcher 3D in KWin verwendet, habe ich diesen Port als erstes fertiggestellt und hier ist er:
KWin FlipSwitch in Windows Vista

Leider hat sich niemand vom KWin Team für die Windows 7 Beta Lizenz beworben, daher waren wir bisher nicht in der Lage mit der kommenden Windows Version zu testen. Wir hoffen, dass Microsoft die Chance in einem guten und funktionieren Compositor für ihre Plattform sieht und hoffen, dass sie uns alle benötigte Hilfe inklusive Lizenzen für die neue Version bereitstellt.

1. April 2009, 8:03 Uhr

There has been a Feature Request to port KWin to the Microsoft Windows platform (see Bug 182700) and we have started secretly to port KWin to Microsoft Windows Vista. And today we are proud to announce that there will be a first release for the Microsoft Windows platform with KDE 4.3.

Of course porting an application that is tied so much to the X11 platform is not a simple task. That’s why we won’t provide the window manager functionalities in the first version. There will only be the compositing effects. Microsoft allows to access Vista’s Aero features so we just had to implement a new Direct3D backend. KWin’s compositing support is very modular and there are already two backends OpenGL and XRender, so adding support for Direct3D is not that difficult. So we added a new scene_direct3d.cpp file which handles the compositing the same way as the existing scene_opengl.cpp.

A more complicated task were the EffectWindows which represent a window in the effect. In the current implementation it is tied to X Clients: managed, unmanaged and deleted clients. These types have the parent class TopLevel. So what we needed was a new Client implementation called WindowsWindow. We are not able to manage those windows as porting the window management functions is - as said - too difficult. So for the effects everything is transparent, nothing changed. When accessing an EffectWindow in X11 it will be a managed or unmanaged client, in Microsoft Windows it’s an WindowsWindow.

Of course our Effect API allows to access all the window management functionalities. It would be kind of a joke if you have the cube but cannot change the desktop. As the Microsoft Windows plattform does not know the concept of virtual desktops we can of course not provide these API calls. So we had to implement a WindowsEffectsHandler Implementation which provides access to all the functions for API compatability and just returning dummy values. effects->numberOfDesktops() will always return 1. That is effects relying on effects->numberOfDesktops() > 1 will not work. So no cube effect :-(

We have now reached a point in the porting effort that we are confident to have all the important effects ported till hard freeze. CoverSwitch and FlipSwitch are already working, also small effects like MagicLamp and MinimizeAnimation are nearly done (we still have some problems with retrieving the icon position).

I think you want to see a screenshot of current state. As FlipSwitch was the first effect to use 3D in KWin I finished this port first and here it is:
KWin FlipSwitch in Windows Vista

Unfortunately nobody from KWin team registered for a Windows 7 beta licence. So we are currently unable to test with the upcomming release. We hope that Microsoft will see the chances a good and working Compositing implementation will provide for their platform and that they will provide us all needed help including licences for the new version.

1. April 2009, 7:34 Uhr