Maintaining history – done wrong

Disclaimer: this post represents my personal opinion and does not represent the opinion of any community I’m involved with. The motiviation of this post is mostly the fact that I tried several times to get the project to stop their fork.

This week the Trinity Desktop Project released a bug fix release with very bold statements in their release announcement especially emphasizing on the 141 bug fixes and 1193 applied patches. Given that they include a fork of an application I know quite good I decided to try to validate their work on kwin. The release has been in work about a year and KWin has quite some bug fixes for reports dating back to the times of the forked application. I just used our bug database and searched for all KDE 2/3 bugs we fixed in the last year and I found the following 20 reports:

Bug Fixes

  • 70943: Xinerama – position should be transformed to another screen
  • 74546: High focus stealing prevention problem with independent configure dialogs
  • 78739: Non-critical: Window lower border leaves margins in some cases
  • 81271: A minimizied, shaded window shows up as not minimized in kicker
  • 81743: Useraction menu closes when focus passes to another window
    This change will be available in version 4.9
  • 95627: Ghost window after dragging a window to another desktop with special window settings
  • 97616: Maximize button not shown when window maximum size becomes larger than work area
  • 130190: delayed focus problem when changing active windows
  • 136856: Dragging items between desktops not controlable with enabled active desktop borders
    Git Commit
  • 142040: “Focus follows mouse” does not change focus after clicking away a menu
  • 146741: Initial fullscreen not set properly

New Features

  • 80196: Sending window to background keeps it active
  • 80749: Expad a window to one/all xinerama screens
  • 90678: Fitts’ Law for decoration buttons
  • 92290: JJ: change focus only when moving mouse
    This change will be available in version 4.9
  • 106818: separate “skip taskbar” from (not) receiving focus
  • 107594: JJ: syntax checks for fields of the window-specific settings
  • 123420: trying to max. a win. resizable in 1 dimension only should max. the win. in that dimension
  • 124612: JJ: kwin fulscreen / un-fullscreen system notifications
    This change will be available in version 4.9
  • 136194: allow moving and resizing of maximized windows — split

Overall there are eight commits to kwin (Trinity) in the range v3.5.13..v3.5.13.1 performed by exactly one developer. The diffstat is an impressive:

62 files changed, 410 insertions(+), 397 deletions(-)

If I look at current KWin statistics our churn is much bigger, though most changes are most likely introduced by scripty and I don’t know how to filter out those commits.

Now lets have a look at what actually changed and whether the bold statements still hold. I did not expect much but I was really shocked when I looked through the diff. I did not see anything useful. The complete diff is cluttered with garbage like the following:

-            positionGeometryTip(); // shown, otherwise it would cause tqrepaint problems in case
+            positionGeometryTip(); // shown, otherwise it would cause repaint problems in case

or

-//     fLay->addColSpacing(0,QMAX(autoRaiseOn->tqsizeHint().width(),
-//                                clickRaiseOn->tqsizeHint().width()) + 15);
+//     fLay->addColSpacing(0,QMAX(autoRaiseOn->sizeHint().width(),
+//                                clickRaiseOn->sizeHint().width()) + 15);

and even in ui files we find this junk:

diff --git a/kwin/kcmkwin/kwinrules/detectwidgetbase.ui b/kwin/kcmkwin/kwinrules/detectwidgetbase.ui
index af4ca96..b13e794 100644
--- a/kwin/kcmkwin/kwinrules/detectwidgetbase.ui
+++ b/kwin/kcmkwin/kwinrules/detectwidgetbase.ui
@@ -29,7 +29,7 @@
             <property name="sizeType">
                 <enum>Expanding</enum>
             </property>
-            <property name="tqsizeHint">
+            <property name="sizeHint">

What I can hardly show here in the excerpts but what I had seen in the git diff commit is lots of red. For those not familiar with colorful git diff output: red means introduced whitespace changes. So the script did not only convert nonsense in comments but also introduced trailing whitespaces and replaced either tabs by whitespaces or whitespaces by tabs.

Anyway it looks like they had a stupid script and reverted the changes. That would be in fact quite good to realize it was bad and to revert, unfortunately that is not the case. There is not one commit doing these changes there are four of the eight commits introducing these changes. E.g. "Rename old tq methods that no longer need a unique name". I don’t want to know how much broken code there is still around due to not being able to run a sed script properly and how many more issues got introduced by running such scripts again.

Well anyway there must be something useful in these remaining four commits, right? When I asked them to stop forking an application which they obviously do not understand and cannot develop I pointed out that they introduced possible ABI issues by reordering an enum. That’s now "fixed":

commit a65ae76df3276bf1925673dd6b6ec565448428ba
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   Mon Feb 13 13:30:41 2012 -0600

    Clean up 9cc1e2c1 changes to enum
    This corrects a potential ABI compat problem noted by Martin Gräßlin
    (cherry picked from commit 77041d785dbbede734f8dc44aa454d07d14f0317)

diff --git a/kwin/lib/kdecoration.h b/kwin/lib/kdecoration.h
index 5f7e7fb..9d7fe39 100644
--- a/kwin/lib/kdecoration.h
+++ b/kwin/lib/kdecoration.h
@@ -97,10 +97,10 @@ public:
         LowerOp,
         FullScreenOp,
         NoBorderOp,
-       ShadowOp,
         NoOp,
         SetupWindowShortcutOp,
-        ApplicationRulesOp     ///< @since 3.5
+        ApplicationRulesOp,    ///< @since 3.5
+        ShadowOp               ///< @since 3.5.12
         };
     /**
      * Basic color types that should be recognized by all decoration styles.

Sorry, you are doing it wrong. Now you fixed the ABI break prior to 3.5.13 by introducing another ABI break to 3.5.13.1. Lucky Trinity users that the ABI is so broken that loading a KWin 3 decoration will just crash KWin (Trinity) – hmm not sure whether that is better… Hint: reverting that change again will introduce another break.

So anything? Maybe one commit which is useful, any problem which is not already fixed in KWin? Well there would be one to workaround a problem with libre office:

commit 2482dd05e5b7806b4bad69ac8e07dbc4dd6714e0
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   Sat Mar 3 13:45:23 2012 -0600

    Fix hostname display in titlebar with certain programs
    This closes Bug 889
    Thanks to Slávek Banko for the patch!
    (cherry picked from commit 9e3f8a7f0c9f2ed1125c717f5374aaf8d4ec225e)

diff --git a/kwin/utils.cpp b/kwin/utils.cpp
index 34d29f9..a2e563d 100644
--- a/kwin/utils.cpp
+++ b/kwin/utils.cpp
@@ -18,6 +18,8 @@ License. See the file "COPYING" for the exact licensing terms.
 #include "utils.h"
 
 #include <unistd.h>
+#include <string.h>
+#include <netdb.h>
 
 #ifndef KCMRULES
 
@@ -323,6 +325,27 @@ bool isLocalMachine( const TQCString& host )
             if( host == hostnamebuf )
                 return true;
             }
+        else
+            { // e.g. LibreOffice likes to give FQDN, even if gethostname() doesn't include domain
+            struct addrinfo hints, *res, *addr;
+            bool is_local = false;
+
+            memset (&hints, 0, sizeof (hints));
+            hints.ai_family = PF_UNSPEC;
+            hints.ai_socktype = SOCK_STREAM;
+            hints.ai_flags |= AI_CANONNAME;
+
+            if( getaddrinfo( host, NULL, &hints, &res ) != 0)
+                return false;
+            for(addr = res; !is_local && addr; addr = addr->ai_next)
+                {
+                if( res->ai_canonname &&
+                    host == TQCString( res->ai_canonname ))
+                    is_local = true;
+                }
+            freeaddrinfo(res);
+            return is_local;
+            }
         }
     return false;
     }

What a pity that KWin already has a patch for that much longer:

commit c24ea2b4aac214ce29afc013cc037c110a24aa12
Author: Luboš Lu?ák <l.lunak@suse.cz>
Date:   Fri Mar 4 16:22:23 2011 +0100

    do not show hostname in titlebar if it's FQDN of localhost

diff --git a/kwin/utils.cpp b/kwin/utils.cpp
index 20d2ad0..92a89e5 100644
--- a/kwin/utils.cpp
+++ b/kwin/utils.cpp
@@ -421,6 +421,13 @@ bool isLocalMachine(const QByteArray& host)
             *dot = '\0';
             if (host == hostnamebuf)
                 return true;
+        } else { // e.g. LibreOffice likes to give FQDN, even if gethostname() doesn't include domain
+            QByteArray h = hostnamebuf;
+            if( getdomainname( hostnamebuf, sizeof hostnamebuf ) >= 0 ) {
+                hostnamebuf[sizeof(hostnamebuf)-1] = 0;
+                if( host == h + '.' + QByteArray( hostnamebuf ))
+                    return true;
+            }
         }
     }
     return false;

What strikes me as odd here is that the comment is exactly the same. Might it be that someone started of with the patch from KWin? If their patch is better why has it not been upstreamed?

Apart from that there is not much. One more commit fixing a warning in kcompmgr melded together with a completely unrelated change in a different application and one commit cleaning the CMakeLists.txt they introduced. Speaking of cmake: why would anyone change to cmake and not delete the Makefile.am files?

So overall none of the bugs fixed in KWin got backported to the fork, no issue from KDE 3.5 time got fixed. The majority of changes are some automated and rather stupid scripts which can nicely be shown by the diffstat without those commits:

4 files changed, 30 insertions(+), 17 deletions(-)

Given that analysis I find it an even more ridiculous joke to include the ohloh.net stats on the main home page. Yeah an impressive 14 developers having developed 14 million lines of code. From those 14 developers one is a KDE admin who created the repository and one automated system. I quite dislike someone who adorns himself with borrowed plumes like in the case of a fork. Even more if the developers still do not know who developed the code base they forked. Hint: KDE e.V. does not develop source code or release software. A nice example for taking credit for what one has not done is this change I run into:

diff --git a/doc/kdm/index.docbook b/doc/kdm/index.docbook
index 730eb11..443a8c1 100644
--- a/doc/kdm/index.docbook
+++ b/doc/kdm/index.docbook
@@ -18,9 +18,9 @@
 <title>The &kdm; Handbook</title>
 
 <authorgroup>
-<author>
-&Oswald.Buddenhagen; &Oswald.Buddenhagen.mail;
-</author><!-- 
+<corpauthor>
+The &kde; Documentation Team
+</corpauthor><!-- 
 <othercredit role="developer">
 &Oswald.Buddenhagen; &Oswald.Buddenhagen.mail;
 <contrib>Developer</contrib>

I think it summarizes nicely what one should expect from this project. I can only recommend everybody to keep away from the junk this project is producing. I’m quite glad they try to cut off all connections to KDE because this project is seriously harming the reputation of KDE.

[Help KWin] Update screen when Dim Inactive Effect Configuration Changes

Today I have a very easy coding task. In fact writing this blog post is more work than fixing it myself 🙂 I thought this is a wonderful task for anyone who wants to start contributing to KWin as a developer.

The task is documented in Bug 308283. If you want to work on it, just assign the bug to yourself, once you are finished either create a review request or upload a git format-patch to the bug report (git format-patch so that we can easily include it).

Please work on top of the KDE/4.9 branch as that should go into the next bug fix release and master and branch have diverged.

To llvmpipe or Not?

Some days ago I prepared a patch which moves the decision which compositor to use inside the driver detection code. This allows us to remove hacks we currently have inside the compositor initialization code to move specific drivers (e.g. the software rasterizer) to a better suited compositor. The base idea is that we always give a user the compositor which is best suited for her system. It’s in my opinion not a good idea to push users on the OpenGL 2 compositor, just because the hardware supports the required extensions, if we know that the hardware is actually not capable of performing well. For such users the OpenGL 1 based compositor is better suited or maybe even the XRender based compositor.

As well for rather old hardware it’s a better idea to not provide any OpenGL based compositing even if theoretically the driver supports it.

But automatism is not always the best solution. Yes giving from experience the best suited compositor is a good idea, but still it makes sense to allow the user to overwrite it. In this case the “user” is mostly myself and other developers who have to be able to easily switch the compositor. For me this is most easily done using an environment variable as I am restarting KWin all the time anyway and is faster than going into a UI and changing the settings and afterward changing them back. Of course although this is controlled through an environment variable, there are also settings to control the chosen compositor. E.g. you can select XRender or disable the OpenGL 2 based compositor. But there is no UI option to enforce the OpenGL 2 compositor if our driver recommendation is to use OpenGL 1 or XRender (we don’t want to provide users the option to destroy their system).

One of the side-effects of this driver based recommendation is that the hack to switch to XRender for software based rasterizers has been removed in the patch. Instead these drivers now recommend to use the XRender based compositor. And in combination with the changes in the handling of the KWIN_COMPOSE environment variable this results in the possibility to run OpenGL based compositing with the llvmpipe driver.

But as you can see one has to manually enforce it through an environment variable and I would not recommend anybody (or any distribution) to use it. OpenGL based compositing over llvmpipe is considered as a fallback approach for other OpenGL based desktop environments like GNOME Shell and Unity. But I do not consider it as a solution for the KDE Plasma Workspaces. I think we have better solutions for fallback (XRender or no compositing).

Let’s have a look on the use cases for llvmpipe based compositing:

  • Outdated hardware not providing OpenGL
  • Too new hardware without driver yet
  • Embedded hardware without driver yet
  • Virtual machines
  • RMS not like binary drivers

If your hardware is too old to provide the requirements for OpenGL based compositing, it is quite likely that your CPU is also rather old. We can assume a single-core CPU of either the Pentium era or an early Atom. You don’t want your CPU which is not suited for this task to spend all the time rendering the desktop. If I enable llvmpipe for KWin on my system (quad core) it puts about one core under full steam.

The case that there is new hardware without drivers available on Linux has luckily become a very rare case. Basic modesetting support for NVIDIA’s latest hardware (Kepler) was available on the same day as the announcement of the hardware. And the blobs do support also their latest hardware. So in most cases all that is needed is installing the latest driver or upgrading the distribution. If you spend lots of money for new hardware you probably want to use it and not have the CPU emulate what your expensive hardware is supposed to do.

In the case of embedded hardware it’s unfortunately still rather common that there are no drivers available. But ARM based systems are also not known for having extreme power. If you don’t want your high-end system to use llvmpipe based OpenGL compositing you even less want your low-end system to do it. You bought your Raspberry Pi hopefully for more useful things than running at full-steam to render the desktop.

If you run a virtual machine your resources are rather limited. It needs to share the resources with other virtual machines and your host system. If you run in a cloud you probably don’t want to pay for rendering the desktop through llvmpipe. You have a task to solve and the more CPU that task gets the less you have to pay. In case of a local system you also don’t want to have the virtual system run at full-steam just to render the desktop. There are really better things to do with a VM.

Last but not least there are the users who don’t want to run binary drivers. Sorry I cannot help you there. If you really think you want to spend lots of money for hardware that you don’t use, that’s fine with me. But I would suggest to only buy hardware which has free drivers available and there are nowadays options from all of the three big GPU providers.

Overall we see that llvmpipe as a backend for OpenGL based compositing is actually not needed in the case of the KDE Plasma Workspaces. We have working fallbacks like XRender or no compositing at all and those do not put the system under full-steam.

Given that I am not considering to turn llvmpipe into an option for KWin. I think that most users who would need llvmpipe are better suited with XRender based compositing even if a few effects are missing then. For me as a developer on the other hand llvmpipe is a very interesting target as it can help to optimize our rendering stack.

Of course what I considered in this blog post is only relevant for OpenGL based compositing of the KDE Plasma Workspaces. We do have proper fallbacks like XRender or no compositing which is not available in other environments which decided to use llvmpipe as a fallback. They have to do a different evaluation and I cannot provide it for them as my evaluation result would be: use KWin 😉

KWin Hacking++

Very soon after joining the KWin development team almost five years ago, I realized that KWin would need at least one full time developer. It is one of the most important parts for the user experience of the KDE Plasma Workspaces and we have seen quite often that important changes for the user experience could not be implemented due to lack of manpower.

With the upcoming required changes like Qt 5 and Wayland the need for developers is increasing. I think it’s currently a wonderful time to join the KWin development. It’s a very interesting and challenging work and working on KWin means working on the future of the free desktop.

Lately I had more possibilities to work on KWin and starting from January I will join Blue Systems for working on KWin. I want to thank Blue Systems for this great opportunity and also for all the other sponsored work in the KDE community.

I’m really excited about this new possibility and are looking forward to it. I want to use this chance to work on bringing KWin to the world of Wayland. As explained in my blog post about the current state of development, I’m very satisfied with all the preparation work which went into KWin and I think it’s now in a state that we can start hacking on it 🙂 And I hope to see lots of involvement from the community. All the work will go directly into master, so it will be easy to test the new features but also easy to contribute to it. I intend to continue setting up simple tasks for the community and announce them through my blog.

[Help KWin] Document Effect Animations

Given the success of the two community involvements I recently tried with KConfigXT and UI files (both merged into master), I decided to set up regular tasks and announce them through my blog. I will mark those in the caption with [Help KWin].

And this weeks task is a no coding task, but a documentation task. It is a task which can be considered as part of the Extra Mile project.

Let me introduce to the idea: some days ago I sent a mail to the kde-artist mailing list to get help on having better animations, because somehow it doesn’t feel as smooth as other compositors, but performance is not a problem. So our animations have to be wrong (I assumed) and I wanted help from people who understand it.

Well we figured out quite fast that the actual issue is that our animations are not consistent, e.g. two fade animations don’t look the same. Now that is actually pretty easy to fix and would give a much better user experience.

But before we can do so we need to know our animations and to be honest we do not know. So I call for help! Help us document all the animations going on. This would allow us afterwards to define basic patterns for the animations.

I just created a wiki page to document the progress and to explain how one can find the animations even if one is not familiar with C++. While programming skills can be helpful it’s not required for this task, it’s basically just “reading text” in the browser.

This week in KWin (2012, week 39)

And another week gone. Major event of course tagging of 4.9.2 and a few more bug fixes for this version. But that’s not the only work that happened. I still have a few changes under review but also merged in some further changes for the OpenGL compositor I had been working on during XDC. Nothing really special except maybe that the specific OpenGL compositors can now be referenced by an enum type which simplifies the code checking for OpenGL 1/2 specific code in the effects.

Summary

Crash Fixes

    Critical Bug Fixes

      Bug Fixes

      • 307365: Decoration broken in maximized state
        This change will be available in version 4.9.2
        Git Commit
      • 307609: Zoom effect broken in master
        This change will be available in version 4.10
        Git Commit
      • 307125: Closed Windows stay in dock apps like AWN and docky with desktop-effects enabled
        This change will be available in version 4.9.2
        Git Commit

      New Features

        Tasks

          Who needs GLX? KWin does not

          I’m very excited about a change I have been working on for KWin since yesterday and which has entered the review process today. The result of it can be seen in this debug output of KWin:

          kwin(17876) KWin::Compositor::slotCompositingOptionsInitialized: Initializing OpenGL compositing
          kwin(17876) KWin::SceneOpenGL::createScene: Forcing EGL Windowing System through environment variable
          kwin(17876) KWin::EglOnXBackend::initRenderingContext: EGL version:  1 . 4
          OpenGL vendor string:                   X.Org
          OpenGL renderer string:                 Gallium 0.4 on AMD TURKS
          OpenGL version string:                  2.1 Mesa 8.0.4
          OpenGL shading language version string: 1.20
          Driver:                                 R600G
          GPU class:                              NI
          OpenGL version:                         2.1
          GLSL version:                           1.20
          Mesa version:                           8.0.4
          X server version:                       1.12.3
          Linux kernel version:                   3.2
          Direct rendering:                       yes
          Requires strict binding:                no
          GLSL shaders:                           yes
          Texture NPOT support:                   yes
          kwin(17876) KWin::ShaderManager::initShaders: Ortho Shader is valid
          kwin(17876) KWin::ShaderManager::initShaders: Generic Shader is valid
          kwin(17876) KWin::ShaderManager::initShaders: Color Shader is valid
          kwin(17876) KWin::SceneOpenGL2::SceneOpenGL2: OpenGL 2 compositing successfully initialized
          

          Everything looks quite normal. OpenGL 2 based compositing, everything works fine, all effects load. But still there is something very exciting going on. Instead of GLX, the EGL backend is used, which has been written for the OpenGL ES 2.0 compositor. But this is the normal KWin, not the kwin_gles. We run OpenGL over EGL. To do so the current patch uses an environment variable KWIN_OPENGL_WS which can be set to egl. By default we still use GLX as that’s the safest what we can get at the moment with the available driver collection (and our egl backend needs some more love to be honest). It shows how important the refactoring which I have blogged about last week has been: without it this change would not have been possible.

          This is a very exciting change as it means we have one backend to serve both OpenGL and OpenGL ES 2.0, it is also very exciting as it means that KWin is already prepared for the proposed new OpenGL ABI, which will deprecate GLX. The current OpenGL ABI pulls in GLX even if you don’t want GLX at all. I’m very happy that we have this EGL backend as this can turn out to be very important for the adoption of the new OpenGL ABI. It has been noted during the discussion at XDC that there is a chicken and the egg problem by distributions not providing EGL and software therefore not using EGL which means distros do not provide EGL. We can help here as we are a component which most distributions ship and which now requires (currently still optionally) EGL.

          As a free software user I’m also excited that this is a change fully built on top of the free OpenGL stack. For a long time quite some functionality of KWin had only been available with proprietary drivers. Now not only the free OpenGL stack provides all we need, it also allows us to move into areas where the proprietary drivers are not yet. With my KWin developer hat on, I of course hope that the proprietary drivers will start to provide EGL, too.

          Last but not least I am excited about this change as it is another small step on our long road through the country. It means that changes which will need to happen in the future can also be provided to the OpenGL version of KWin even if we do no longer use GLX as the primary backend.

          This week in KWin (2012, week 38)

          This week we have seen quite some bug fixes for 4.9.2 and the inclusion of the refactoring I blogged about in the beginning of the week. This of course still continues and more patches are in the pipeline. Also a few more effect configurations got ported over to KConfigXT.

          Summary

          Crash Fixes

          • 303244: Kwin 4.9 beta crashes on logout
            This change will be available in version 4.9.2
            Git Commit
          • 305361: Kwin crashed after changing qtcurve configuration
            This change will be available in version 4.9.2
            Git Commit

          Critical Bug Fixes

            Bug Fixes

            • 289747: Desktop Grid effect gets “confused” when adding a new desktop
              This change will be available in version 4.9.2
              Git Commit
            • 301730: Ugly half drawn shadows (hardcut) in (qml)windowsswitcher grid
              This change will be available in version 4.9.2
              Git Commit
            • 306281: autoraise raises inactive window under mouse when switching workspaces or closing active window
              This change will be available in version 4.9.2
              Git Commit
            • 177495: Fullscreen windows unusable due to heavy flickering

            New Features

              Tasks

                A real update on the progress of Wayland in KWin and KDE

                This week I have been at the XDC 2012 kindly hosted by SUSE in Nuremberg. It was a very useful conference for me and I’m very glad I went there. There is not much difference to a KDE conference, even the N9 density was kind of the same. Of course I was asked quite often about the current state of Wayland in KDE and I honestly replied which resulted in rather incorrect “news” postings about Wayland in KDE not happening “any time soon” (whatever that is supposed to mean) to “Wayland for KDE will be delayed” (given that we never had a schedule in the first place, it cannot be delayed).

                Actually there is not much to write about as to a reader of my blog you are already aware of all the work I am currently putting into Wayland. It’s just that I never write that I do something with Wayland in mind, because I don’t want to hype the technology.

                Nevertheless I had been asked recently rather often about a status update and also promised that I would write a blog post if we reach the fund raising aim for the Randa sprint (thanks a lot for the great support on the last day of the fund raising campaign). So I want to give here a general overview of all the things which need to be done for Wayland.

                Porting KDE to Wayland

                For a general “KDE on Wayland” we have to consider three areas:

                • Applications
                • Desktop Shell
                • Compositor

                For those we have different things which needs to be done and so I will discuss them separately.

                KDE Applications on Wayland

                For most KDE Applications there is not much work to be done. Thanks to the Windows and OS X ports the code is no longer platform dependent, so all which is needed is having a Wayland backend instead of an X11 backend.

                This problem is solved with Qt 5. Once our applications use Qt 5 and KDE Frameworks 5 they should run fine on any Wayland compositor, e.g. Weston. Of course there are a few applications which use X11 directly (e.g. ksnapshot), those needs to be adjusted in addition or be morphed into KDE’s Wayland Compositor (that is something I expect to happen with tools like ksnapshot or klipper).

                KDE Plasma

                Our Plasma Desktop Shells (Desktop/Netbook/Device) need more adjustments than a normal KDE Application. Plasma is still doing quite some X11 directly for various tasks, like e.g. the tasks manager or pretty much any communication with KWin.

                Before we can start working on adjusting Plasma for Wayland we need to get it to Qt 5 first and that requires KDE Frameworks 5 and that requires libplasma2. Currently our Plasma hackers are meeting in Randa thanks to your support to work on libplasma2.

                Once Plasma is running on top of libplasma2 we can start working on Wayland support. How that will look like, I don’t know. It’s not a problem we can tackle right now, so it does not make much sense to think a lot of it. We know we need to change a few things here and there to make it work.

                But what is really important is that we Do not want to break the desktop. Neither with going to libplasma2 nor with going to Wayland. So any fast steps do not make any sense. It’s important to get this right before giving it to the users. Wayland is an awesome technology, we all want it, we all support it and we don’t want to damage the technology by going to it too early. This has happened too often in the past (not only in KDE) that great technology got damaged because it got released too early on the users. (NOTE: with this I do not mean that Wayland is not ready yet, but that going to Wayland will cause regressions inside Plasma/KWin and there is no need to expose these to the users if we have a wonderfully working X11 backend.)

                KWin

                Our current planning is to make KWin our Wayland Compositor. This seems like a useful approach as that can help us having a consistent window management experience no matter whether you run on X11 or on Wayland. Even in a Wayland world we will still need to support X11, it’s not like that will go away. I expect that the Linux world will have to support X11 at least for the next 25 years, we have many legacy applications around, which still use things like Motif, so that won’t change. We have with KWin a very good X11 based window manager so it seems quite logical to me that also in a Wayland world KWin will be responsible for being the X11 based window manager.

                Given that our manpower is rather limited and given that X11 is what we have right now and we do not have the resources to develop two Compositors (one for Wayland, one for X11) it seems to me that extending KWin with Wayland support is the only possible solution right now.

                Now KWin is an X11 based window manager and compositor. It’s development started in a time when nobody expected that there could be anything else than X11, so you could say that it expects that all that exists is X11. This means the difficulty in porting KWin to Wayland is not in adding Wayland support to KWin, but in making it possible to have a KWin without X11 support or at least to be able to start KWin without needing an X Server.

                For adding the initial Wayland support to KWin which allowed to include a window in the scene graph and pass input events to it, I only needed around three days of development (that included getting used to the new windowing system and hitting my head against a wall because I was too stupid to find the documentation and too proud to ask for help).

                Current State of Porting KWin

                For me it is important that going to Wayland does not decrease the code quality of KWin. I don’t want to have many if (X11) { foo(); } else if (Wayland) { bar(); } code blocks. I want to have KWin in a state that it can be easily maintained, that we are able to maintain the X11 code base even once we all run and use Wayland.

                There is a git branch with some patches to have KWin support Wayland clients. If you look into the branch you will notice that it does not contain any new commits for more than a year. So it seems that nothing has happened in that area.

                Well that’s not true. All the work I have put into KWin over the last year have been with Wayland in mind. I have a pretty clear plan on what needs to be done inside KWin to go to Wayland and I tend to follow that plan. I get side-tracked from time to time to improve the KWin out there right now (e.g. performance improvements) but in general I follow that master plan.

                An example for that is the support for KWin Scripting. That might be surprising, what is the relationship between Scripting and Wayland? To have Scripting support I had to add Q_PROPERTIES to the class representing a window (class Toplevel) and to the class representing a managed window (class Client). This means we kind of extracted the interface of how a window needs to look like. The Client class has never be meant to be used for inheritance, so we did not know how the interface looks like. But in future we will need to have a WaylandClient and an XClient. That’s quite a change and scripting helps a lot to know how we need to make the class abstract.

                Furthermore I hope that scripting helps to allow us to perform unit testing. I do want to add a unit test for each method before turning it abstract (remember that we don’t want to break the desktop) and to ensure through testing that the X11 and Wayland based implementation behaves the same from a window management perspective.

                Another example of work going into Wayland to have the KWin improved right now is this bug I fixed some time ago. For the time being it means that when a window closes it is not raised on top of other windows any more. What has that to do with Wayland? The bug has been that KWin only kept track of the stacking order of Clients, but not of the more general class Toplevel. In order to go to Wayland and to be able to properly integrate Wayland Clients into our stacking order this had to change to keep track of the stacking order of Toplevels instead. It was a difficult to fix bug, but a very important change for going to Wayland.

                Also the refactoring work I recently blogged about is an important step on the road towards Wayland. Especially the splitting of the OpenGL compositor is very important. This means that the actual Compositor (SceneOpenGL) does no longer depend on X11. The dependency has been moved into an OpenGLBackend with currently an GlxBackend and EglOnXBackend. This makes it much easier to add further backends in future to e.g. support KWin on top of another Wayland compositor or KWin on top of KMS through libgbm.

                Personally I’m very satisfied with the progress we have made over the last year in preparing KWin for the important task of adding Wayland support. I think we are completely on schedule and the state is really looking good.

                The Schedule

                There is actually no schedule for the porting of KWin or KDE to Wayland. Many things like KDE Applications and KDE Plasma completely depend on the progress of Qt 5 and KDE Frameworks 5.

                So what about those dates one can read about in the Internets? Well that are dates coming from my presentation at last year’s Desktop Summit. I put up there a very tough time line for the case that we could get many people involved in working on Wayland. That hasn’t happened so far. Also parts of the time line were just stupid. I wanted to have a first prototype already in KWin at the time of 4.8. It just didn’t make any sense. Wayland was still a too strong moving target and distributions did not yet include the needed libraries any way, so it did not make much sense. It would not have been anything for users and in case anyone wants really to play with it or develop it, there was the branch. As that has not happened I did not see any advantage in merging the code into master.

                The second item on the time line was an idea to have Plasma Active running on Wayland rather soon, but that actually did not make any sense without Qt 5/KDE Frameworks 5. So that was really a stupid thing to put into the time line.

                The third item in the time line when we actually have everything in place had a strong “It’s done, when it’s done” and “Don’t break the desktop” note. So any references on when I said when KDE will be on Wayland is just wrong. And I do hope that I have clarified this with this blog post. The times I set out where ambitious and idiotic. I do apologize for putting them up in the first place and would kindly ask anyone to realize how idiotic they have been and no longer refer to them. Thank you.

                What next?

                I’m personally quite satisfied with the current state of preparing KWin for Wayland and I think we have reached a point where we can seriously start thinking about adding real code specific for Wayland to KWin.

                Given that we have a nicely refactored OpenGL backend I want to experiment with having KWin run on top of KMS or on top of another Wayland compositor. When I will find time for that I do not know, but given the already upcoming feature freeze it will be hard to have anything in 4.10.

                Also quite some required dependencies are not there yet. Libgbm will be out with Mesa 9.0, the release of Wayland 1.0 is expected somewhen soonish and XWayland might hit the next X-Server release which will happen around March. The dependencies are rather important as we cannot depend on unreleased code in KDE. Quite a lot people would complain if KWin would depend on an unreleased X-Server. So that is clearly something to keep in mind when adding the code. Not to mention that I run Debian Testing and don’t like building everything from code.

                An update on KDE on Wayland

                Now that I have your attention 🙂 To get Plasma running on Wayland we first need Qt 5 and KDE Frameworks 5. An important part of going to Frameworks 5 is libplasma2. At the moment we are preparing a developer sprint in Randa to make libplasma2 happen. You can read more about the importance of this sprint in sebas’s blog post.

                KDE has started a fund raising campaign to make this sprint possible. But we are still lacking around 2000 EUR at the time of this writing and just a little bit more than 200 people participated in this fund raising.

                Now you are probably interested in getting a real update on the work which happened over the last year in the efforts to bring KDE (in particular KWin) to Wayland and I really want to provide it to you so that you don’t have to rely on articles about an informal chat over lunch. But I’m currently lacking motivation to write such a blog post. I think I would be much more motivated to write such a post if when I get home this evening from XDC I see our fund raising succeeded. It would show me that people really want to see progress in the KDE Plasma workspaces.