This week in KWin (2013, week 4)

This week quite some bug fixes have entered both 4.10 and master branch. One of the most interesting one is the improved detection for whether a window is on the local system or on a remote one. If you want to get more information about that read my dedicated blog post. But there are also some nice general improvements. The first KConfigXT patch has entered and work has started to make use of it in our Options class. The XCB porting continous with an improved Xcb::Wrapper class – for this I plan to write a dedicated post as it’s an interesting topic from the C++ perspective.

Summary

Crash Fixes

  • 313655: unloading of “Mouse Click Animation” result in kwin crash
    This change will be available in version 4.10
    Git Commit

Critical Bug Fixes

    Bug Fixes

    • 313950: Typo in compact/contents/ui/main.qml
      This change will be available in version 4.10
      Git Commit
    • 308438: When compositing is disabled, opening a window which blocks compositing *enables* it
      This change will be available in version 4.10
      Git Commit
    • 302248: Show Desktop has inconsistent behavior when launching KRunner
      This change will be available in version 4.10
      Git Commit
    • 312956: Desktop Effects – Zoom: Mouse Tracking “Push” laggy, inprecise and/or not working
      This change will be available in version 4.11
      Git Commit
    • 270586: build fails – getdomainname
      This change will be available in version 4.11
      Git Commit
    • 308391: KWin uses getdomainname() to obtain the hostname, should use getaddrinfo()
      This change will be available in version 4.11
      Git Commit
    • 304435: Track mouse effect generates graphics artifacts
      This change will be available in version 4.11
      Git Commit

    New Features

      Tasks

        About network access, fuzzy specifications and non-POSIX calls with window managers

        KWin supports a feature to recognize windows from a remote host. If KWin recognizes such a window it adds the host name (as provided by the property WM_LOCALE_NAME) to the caption. This is a very handy feature in case you work with remote system and use X11 network transparency. But it is also a feature hardly known or needed by most users.

        Unfortunately this feature does not work properly for LibreOffice, because LibreOffice uses the FQDN instead of the hostname and KWin checked for the hostname. Some time ago the problem got fixed by using getdomainname to work around the LibreOffice situation. But this does not work in all cases and introduced issues with non-Linux systems as it is a non-POSIX call[1].

        Of course one might ask why we don’t fix LibreOffice if only their usage of FQDN is causing a problem instead of fixing KWin. In this case it’s quite simple: LibreOffice is doing it right, everyone else is doing it wrong. Let me quote a section from the NETWM specification:

        If _NET_WM_PID is set, the ICCCM-specified property WM_CLIENT_MACHINE MUST also be set. While the ICCCM only requests that WM_CLIENT_MACHINE is set “ to a string that forms the name of the machine running the client as seen from the machine running the server” conformance to this specification requires that WM_CLIENT_MACHINE be set to the fully-qualified domain name of the client’s host.

        Of course the specification does not say anything about the case that the client’s host is the localhost. I would assume that the specification only considers the remote host case, but this is my personal interpretation based on the overall fuzziness of the specification. Given that it doesn’t say anything of the local system case, the interpretation of LibreOffice is absolutely correct by providing the FQDN. Also I can understand that one doesn’t want to maintain two code paths.

        Now the fun part is that it looks like everyone else is not NETWM compliant in that point. In preparation for this blog post I forwarded an GTK+ based and a Qt (4) based application to another system and looked at the properties. _NET_WM_PID is set and WM_CLIENT_MACHINE contains the hostname, not the FQDN.

        The fact that LibreOffice was always considered as a remote system had been unnoticed for quite some time. Personally I’m surprised by that and can only assume that users think that it was supposed to be called like that. I myself try to not use office applications and if I have to I use applications of the Calligra suite. But apparently it got noticed in the Trinity fork and a patch had been prepared there. After my last rant, the developer who wrote the patch, proposed it for inclusion on ReviewBoard. The patch used getaddrinfo to resolve the domain name for the provided client’s hostname. We decided against the patch because it is a blocking call to the network and in KWin we don’t do blocking calls. A blocking call in a window manager is pretty bad as it means that you can no longer interact with your windowing system in any way that would require a window manager. A blocking call in the compositor is deadly as the screen does not get updated any more. The system appears as being frozen. That’s why we have a clear no blocking call policy. This problem has been communicated to the Trinity developers and I suggested them to revert the patch [2].

        I had put quite some thought into the problem and realized that it’s not going to be an easy fix and requires some internal rework to ensure that KWin can properly resolve whether a window is on the local machine even if it does not provide the hostname. Recently I sat down and turned my thoughts into working code. The general idea is to split out the complete hostname resolving into an own class to have this encapsulated. This class can provide whether the hostname it is encapsulating is on the local machine, so that we don’t have to query again and again – a problem I noticed when looking at the code: whenever the information was needed, it was queried again, which makes the interaction quite difficult if we are not allowed to do sync calls.

        The resolving works as it used to be. So first the hostname comparison is used. If this does not work and the hostname looks like a FQDN then we do the resolving with getaddrinfo, but through a helper class and in a background thread. When the information is finally available a signal is emitted that it’s a local system allowing the external world to react on it to e.g. update the window’s caption. Interestingly when I worked on the code and started with the existing patch I noticed that it did not work correctly. Now a remote window with a FQDN was considered local if the name is resolvable. So overall we have now four approaches to get it right (initial code, first fix, Trinity fix and my fix) which shows that this is quite a non-trivial task and I wanted to be sure that it does not break ever again and if it does that we understand it. Therefore I wrote a unit test to cover the cases. I’m rather happy about that test as it is the first unit test I added which actually talks with X. So far I only wrote test code for non-X11 code.

        Unfortunately there are now still cases where the information will be provide too late and a local system will be considered local. For example also the rule system and session management may need this information. Here not much is possible to be done. For window rules it does not really matter as by default we do not match the host at all and even if it’s more likely to try to match remote than local system. Also an adjustment of the rule to match a FQDN would work.

        Overall this has been one of the most interesting bug fixes I had worked on recently which motivated this blog post. As this is a rather large change it is not going to be seen in 4.10, but only available in master (4.11). A decision made due to the long time the issue had not been noticed, which implies that it’s not a real issue for our users.

        [1] This is a classic example for why I think it doesn’t make sense to state that we support non-Linux Unix systems. We break the code without noticing, because nobody is even trying to compile the code on non-Linux systems (also no CI system). The non-Linux system always have to catch up and fix our stuff and then they have a hard time to get the changes back upstream. This issue got reported to us with a patch attached. But I did not accept the patch as I spotted a possible issue and unfortunately there had not been any further trying on improving the patch. I couldn’t do it as I lacked the operating system to test it. Probably it was easier to carry the patch downstream than trying to get it into shape for upstream inclusion.

        [2] That a commit entered Trinity which did not pass code review in KWin due to being dangerous is not surprising. This is no Trinity bashing, but it’s something to be expected when working on a foreign code base in an area that you don’t know. How should a Trinity developer know that you are not allowed to do blocking calls in a window manager? And even if you consider that as being obvious: how should a developer get the feeling to see a piece of code and ask himself instantly “is this blocking?”. This requires experience for working with a window manager and is something I explained to the Trinity developers in my very first mail to them where I suggested to drop their fork of KWin, because of exactly such reasons:

        Working on a window manager and compositor comes with great responsibility. It is one of the most complex parts of the desktop environment and introduced bugs affect all users and can be really harmful and very difficult to debug. Developing a window manager is not trivial and you have to understand how the window manager works

        And this is not a problem just for Trinity, it’s a problem for all such forks, be it Mate’s Metacity fork or Cinnamon’s Mutter fork “Muffin” or now Consort’s fork of whatever window manager they use at base (probably a GTK3 version of Metacity). I can only suggest to work together with the upstreams and unfork what can be unforked.

        4.10 Feature Presentation: Application Menu in Window Decoration

        My favorite new feature in the KDE Plasma workspaces 4.10 (to be released on February, 6th) is the ability to hide an application menu inside the window decoration. I’m someone who is hardly using the menu, I get too lost in it. I’m preferring to use tool bars with the nice icons which help me to recognize what I’m looking for (a scissor is easier to recognize than “Cut” or “Ausschneiden” – depending on the language the app thinks to have to use).

        By removing the window menu the complete window frame gets less cluttered. A huge area containing lots of text is just gone. Just look at this screen shot of Calligra Words, which I use to write this blog post:

        Aus KWin

        While KDE Plasma workspaces does not only allow to have the menu in the window decoration it also provides the possibility to put it into a global menu bar. Personally I do not like this (have used Mac OS, know what I’m talking about) as it disconnects the menu from the window. With the window decoration this problem does not exist and also removes the problem of long mouse distance travels in case of non-maximized windows.

        In 4.10 we provide this new feature only in the Oxygen (default) window decoration. But our 4.11 development branch has seen some activity in this area: all Aurorae themes support it and also the Laptop window decoration.

        This pretty awesome new feature can be enabled in System Settings. Just go to “Application Appearance”, then to “Style”, select the second tab called “Fine Tuning”. If your system provides the required support libraries (if not complain to your distribution) you will find there a section “Menubar” with a dropdown to select the way you want to have it. If you select “Title bar button” the button will be added automatically. As screen shots say more than words:

        Aus KWin

        And last but not least a screenshot with the menu:

        Aus KWin

        This week in KWin (2013, week 3)

        This week has seen lots of last minute polish for the 4.10 release. Most issues should be fixed in RC3, but there is still some work going on to deal with regressions outside of KWin which nobody had noticed for too long. From the features/improvement department: KWin’s support information includes information about screens to finally end the discussions about whether a user is using multi-head, xrandr or who knows what. Our window decoration library gained support for two new window border sizes: no borders on the side and no borders at all. This is highly inspired by the already existing feature in Oxygen and got now also available in Aurorae for QML based themes.

        Last but not least I wanted to remind that the summary below is generated from the bug reports set to resolved fixed in Bugzilla over the last week. This does not mean that the bug got fixed, but that the report had been set to fixed. Sometimes this is done through a commit, sometimes it’s just some house cleaning. The last weeks have seen lots of cleaning. Also the title of a bug report is mostly set by the user and especially in the case of a crash report has very often not much to do with what has really been the case. So if you want to get excited about a bug in that list, you should at least click the link and read through it and see what it is about and when it got fixed. Even if the bug report is more than a decade old it does not say anything without the context.

        Summary

        Crash Fixes

        • 302094: KWin crashes with flash
        • 264897: crash during alt+tab
        • 312712: Assert on “kwin –restart &”
          This change will be available in version 4.10 RC 3
          Git Commit

        Critical Bug Fixes

          Bug Fixes

          • 301909: “No titlebar and frame = Force Yes” does not work
          • 311896: callDBus always fails for methods with signature containing array of strings
            This change will be available in version 4.10
            Git Commit
          • 293734: kwin does not honor disableMultihead=true and causes window focus problems
            This change will be available in version 4.11
            Git Commit
          • 308557: blur left on screen
          • 312851: Windows wider/taller than screen are cut off/partially mirrored when doing a screenshot of them using ksnapshot
            This change will be available in version 4.11
            Git Commit
          • 273104: Dual screen with different dimension screens and one rotated, desktop size is getting strange values

          New Features

            Tasks

              This week in KWin (2013, week 2)

              A rather busy week is behind us. Not only have there been many bugs fixed, but also some feature/refactoring branches were merged which are not listed in the summary. For example a refactoring of virtual desktops landed in master. The management of virtual desktops has been split out of the Workspace class into an own module. As new features we have more support for the application menu button in window decorations. The Laptop decoration got such a button and generic support has been added to the Aurorae theme engine. Now almost all decorations shipped with KWin can provide this button.

              Summary

              Crash Fixes

              Critical Bug Fixes

                Bug Fixes

                • 275235: Logout effect interferes with Plasma extenders effect
                • 299398: shadow on volume OSD is wrong the first time
                • 312835: The keyboard shorcut Ctrl+Alt+Right for “Switch to next desktop” doesn’t work anymore since commit a2a335064e206f0689e315d58c30bedce90decff
                  Git Commit
                • 311319: Color correction breaks EffectFrames
                  Git Commit
                • 306169: Thumbnail Aside effect not updating/disappearing
                  This change will be available in version 4.10 RC 3
                  Git Commit
                • 295055: AbilityUsesAlphaChannel broken when used with shadow pixmap hints
                • 312168: Plasma popup shadows not drawn during slide animation
                  This change will be available in version 4.10 RC 3
                  Git Commit
                • 306404: The “walk through desktop” shortcuts don’t show up in the desktop kcm
                  This change will be available in version 4.11
                  Git Commit
                • 281186: maximizing a full-size window causes title bar corruption
                • 309853: KWin kcm wrongly informs that all effects failed to load
                  This change will be available in version 4.10
                  Git Commit
                • 312784: Can’t drag and drop files or folders on edgeless windows
                  This change will be available in version 4.10 RC 3
                  Git Commit
                • 313091: Kded-appmenu – Enabling makes “Window menu” and “on all desktops” buttons vanish
                  Git Commit

                New Features

                • 312900: wish: kwin option to save vertical space: merge window buttons into menu-bar
                  This change will be available in version 4.10

                Tasks

                  [Help KWin] Create a KConfigXT file for KWin’s configuration

                  Just the other day a user in IRC complained about a default in KWin. I thought that the default he expected, is the one which is set in KWin sources. So I opened the respective source file and saw my assumption confirmed. But still the user claimed that there is a different default and I believed him. Further investigation showed that the source code of the configuration module had a different default set. It’s probably like that for years but it shows a problem: the config values are written and read at different places and the hard coded default values might diverge.

                  This reminded me of the great project we had last year to migrate the configuration of the KWin effects to KConfigXT and of the project to transform the configuration modules in KWin to have ui files. The combination of both calls for a new project: let’s migrate KWin core to KConfigXT. Now this isn’t a project which we will be able to do in one go. So I will split it into three parts:

                  1. Create the kcfg file
                  2. Migrate KWin core
                  3. Migrate the configuration modules

                  Let’s start with the first one: create the kcfg file. Interestingly we already have such a file in the kwin directory – last change: Nov 20th 2007. It might be that some of the options are still encoded correctly, but I rather doubt it and default values are missing anyway. So I suggest to start clean. I would like to split the task into creating the XML part for the different config groups in KWin, so that the tasks are small. Later on we can then put it together to have one complete file. The project is outlined in this wiki page. Just add yourself to a section if you want to work on it 🙂

                  This week in KWin (2012, week 52 and 2013, week 1)

                  With Christmas break over there is again quite some work happening for KWin. Of course given that 4.10 is close by a few bugs got fixed, but with master open for 4.11 we also have the first feature commits. Most of it is in the area of porting KWin to XCB. Those changes are not listed, but they are quite nice as each of them brings a small improvement due to the asynchronous nature of XCB. For the actual features I try to create bug reports again, so that they can be listed in the summary.

                  Summary

                  Crash Fixes

                  • 308040: KWin crashes after restarting it
                    This change will be available in version 4.10
                    Git Commit
                  • 310142: KWin crash due to wobbly windows effect when closing window
                    This change will be available in version 4.10
                    Git Commit

                  Critical Bug Fixes

                    Bug Fixes

                    • 312346: PySolFC (And possibly other Tkinter and Tk programs), after moving window, put the menu at the original menu position.
                      This change will be available in version 4.10
                      Git Commit
                    • 293385: glsl should be disabled for the 945G because it’s slow and broken
                      This change will be available in version 4.10
                      Git Commit
                    • 308919: Window Switcher fails to repaint background if Fade Effect enabled
                    • 311553: No minimum size on the general or effects tab of kwincompositing kcm
                      This change will be available in version 4.10
                      Git Commit

                    New Features

                    • 308992: Use Resize Area in Aurorae
                      This change will be available in version 4.11
                      Git Commit

                    Tasks

                      [Help KWin] Save the Explosion Effect

                      One of our KWin Effects hasn’t seen much love over the last years and is in fact more broken than working. It’s a pure eye-candy effect which means that it is not at all in the development focus of the KWin team. The truth is, that we are tempted to just delete the effect because we won’t fix it. But of course there are users who like it and would be sad if it gets deleted.

                      Here you can help: if the issues gets fixed and the effect becomes maintained there is no need to remove it. So if you want to get your hands dirty with a small OpenGL based effect have a look at the Explosion effect and improve it. Have a look at Bug 312176 and all the linked reports to find the issues.

                      This week in KWin (2012, week 49-51)

                      Due to vacations I was not able to work on any bugs and this also explains the lack of these summaries in the last weeks. Although we are in beta/rc testing phase it’s been not so many new bug reports, but still some work todo. Nevertheless we are already working on 4.11, that is mostly the port to XCB, which is not listed in the summary.

                      Summary

                      Crash Fixes

                      Critical Bug Fixes

                        Bug Fixes

                        • 310562: Alt+Shift+Tab can’t be used to “Walk Through Windows (Reverse)”
                          This change will be available in version 4.10 Beta 2
                          Git Commit
                        • 310497: Zoom desktop effect only support POT cursor sizes
                          Git Commit
                        • 312004: Window operations menu affects only the window in focus.
                          This change will be available in version 4.10 RC 2
                          Git Commit
                        • 310623: Form layout of “Moving” configuration doesn’t resize horizontally/doesn’t fill whitespace
                          Git Commit
                        • 296289: Black boxes shown when using alt-tab switcher with thumbnails
                          This change will be available in version 4.9 RC 1
                          Git Commit
                        • 311712: kwin_gles not working with AMD ATI RS690M
                          This change will be available in version 4.10 RC 2
                          Git Commit
                        • 309958: Application Menu button disappears after placing the application in the systray
                          Git Commit

                        New Features

                          Tasks

                            The road towards KWin on Qt 5

                            The last three weeks I have been on vacations which explains the lack of blog posts. My batteries are fully recharged to work on KWin full time starting from January thanks to Blue Systems.

                            By pure chance I stayed close to the San Francisco Bay Area which allowed me to go to the Qt Developer Days in Santa Clara. It was great to see all the KDE and Qt people again and it was totally worth going there. I’m now looking forward to some great Qt technology coming up with Qt 5 (congrats to the release!) and I’m very very glad that ICS and KDAB organized the Dev Days and showed everyone that Qt has a bright future.

                            For me the conference was very valuable as I had the chance to discuss a few things about the next versions of our KDE workspaces with Aaron and David. And even if we do not yet have plans for a KDE workspaces release based on Qt 5 and KF 5 it became clear to me that my work for the 4.11 cycle will be mostly focused around the porting to Qt 5. This might sound surprising given that Qt promises 99 % source code compatibility. Well Lars Knoll mentioned that only platform dependent code needs to be adjusted and yeah: KWin is the 1 %. I will start to document lots of the tasks which need to be done in our wiki and will blog about it so that you can help with this task. A good example is that QPixmap is no longer bound to an X11 pixmap and well we used to do texture from pixmap from it (only with X11 PaintEngine in Qt).

                            Personally I do not mind much that we have to spend time porting to Qt 5. It gives us the opportunity to improve a few areas where we kept methods around for backwards compatibility in e.g. the D-Bus interfaces. Such methods are already marked as deprecated and some of them had been marked as “Should be removed with KDE 4”. It seems to me like the needed cleanup had been forgotten when we last had the chance. And that’s why I want to get done with the porting early. I would prefer having KWin run on top of Qt 5 as of 4.11 (of course that release will still be Qt 4 based) so that we can spend the 4.12 cycle to do lots of the cleanup.

                            One of the major areas for porting is the switch from XLib to XCB. As far as I have seen we would not be required to port everything to XCB, but overall it is a good idea to do so. It will make KWin faster and of course it’s better to have everything using XCB and using XLib only where – for legacy reasons – it is required: the GLX compositing backend (looks like our current EGL backend is also bound to XLib). Also the porting allows us to do some things “right”. Some KWin effects for example are interacting with X11 directly and that is something which should be tried to be abstracted properly so that we do not need to adjust the effects once we are running on Wayland.

                            Now that I mentioned the W word: you might wonder what happened to the plan to start working on Wayland from January. Well that has not changed much, it’s just that I learned more about the Qt Compositor which is a wonderful Qt-like abstraction on top of the Wayland C libraries. Nothing against the Wayland library, but it’s C. And I prefer working with a C++ Qt like API with CamelCase instead of underscores as so often common in C APIs due to lack of namespaces.

                            Internally we would have used a C++ abstraction anyways, because it’s just easier to work with it. With Qt Compositor we do not only get that for free but we also get a better API as the people at Qt have more experience in defining APIs than we do. And as another plus if we need something further we can just add it to Qt Compositor and share it with everyone. So all the code is set to greater usage.

                            The only “disadvantage” of Qt Compositor is that it absolutely requires Qt 5. So to be able to integrate it into KWin we need to first port to Qt 5. It is hardly any difference: we would have needed to go to Qt 5 anyway, when does not really matter, just that I now have a wonderful motivation to get there.