Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×

KWin Adds Support for QML Decorations 30

As part of a KDE-wide effort to prepare for Qt 5/QtQuick2, and a push to improve the window manager, KWin now sports QML decoration support. Currently, the C++ API for decorators is "...not very Qt like and requires a strong understanding of how the window decoration in KWin works ... [and] seems to be too difficult to be used." This complexity increases maintenance burden: "In 4.9 we ship four window decorations: the Aurorae theme engine, Oxygen, Plastik, b2 and Laptop. Together they are 10 kSLOC of C++ code and 1 kSLOC QML code (Aurorae). Before Aurorae got ported to QML the size of the decorations was 13 kSLOC. Overall that is about 10 per cent of the KWin source base, which is rather large." Basing his work on the QML version of the Aurorae engine, Martin Gräßlin set out to port Plastik to QML (the C++ version has already bitrotted, and was slated for removal): "After one and a half days of work I’m proud to say that writing decorations in QML is possible. ... In the current state the decoration consists of 370 lines of QML code and I expect to need an additional 100 lines to finish the buttons (they are already functional, that is the close button closes the window) and add some of the configuration options. The same API in C++ consists of 1500 lines of code. So we do not only get fewer lines of code but also a more readable and easier to maintain codebase. For something like a window decoration a declarative approach is much better suited than the imperative C++ way of painting elements."
This discussion has been archived. No new comments can be posted.

KWin Adds Support for QML Decorations

Comments Filter:
  • go KDE (Score:1, Interesting)

    is gnome dying? staring into the abyss — Swfblag []

    • Re:go KDE (Score:5, Informative)

      by Anonymous Coward on Friday July 27, 2012 @05:15PM (#40796621)

      Hi! Welcome to Slashdot! It's good to see new people here, but I'd like to point out to you that we are not twitter. There is no unreasonably short limit on post lengths. Generally, Slashdot, abbreviated by the punctuation "./" by its community members, despise URL shortening services, since they serve to obfuscate where a link will take them, and allows for trolls to post abusive content without being noticed. Please don't use URL shortening services in the future! Thanks, and happy Slashdotting!

      • by Anonymous Coward
        @Anonymous Coward Thanks 4 the tips #newtoslashdot
    • is gnome dying?

      Netcraft confirms it.

  • by Anonymous Coward

    I'm not up on to speed on QML, does anyone know if there will be a change in performance with the move from C++? I think having smaller, more readable code is great and I'm wondering if we might also see a performance boost? Or perhaps a slight performance drop? Or will it all work out to be about the same when it's compiled?

    • I can't really answer that, though in my experience any declarative system has to be converted to old-fashioned native code and that always incurs some overhead. However, for a plain old GUI you're not going to see anything noticeable, and Qt quick has support for openGL and other 3d gfx that I would imagine just passes-through the relevant fast bits to the underlying system.

      There are QML tutorials available. []

    • by Jurily ( 900488 )

      QML is essentially JavaScript, with all its costs.

      • I think the question is, is QML interpreted or compiled? Javascript is interpreted (actually it's just-in-time compiled IIRC), but it doesn't have to be, that's only because of the way it's used. There's nothing but effort and inertia keeping you from using Javascript as a high-level application language.

        If the QML is all compiled, then theoretically there may be no performance difference at all, depending on how good the compiler is.

        • by FranTaylor ( 164577 ) on Friday July 27, 2012 @11:55PM (#40799159)


          It does NOT slow down the user interface experience because JAVASCRIPT CODE IS NOT EXECUTED ON USER ACTIONS.

          • uh? what?

            Sure QML is the definition langauge used for layout, but it is an integral part of Qt Quick, so when a user presses a button, a bit of javascript can be associated with that to perform some actions. Hence js IS executed on user actions using this system.

            I'm just reading the basic tutorial and it shows a bit of javascript associated with a mouse over event.

            • That may be, but are you sure the Javascript is interpreted (or fed to a JIT compiler) when that happens, or is the whole thing compiled beforehand? Theoretically, there's nothing prevent Javascript, in a use case like this, from being compiled beforehand, and JS simply used because it's convenient and well-suited to UI programming. It isn't done with web sites because every web site can have different Javascript, so obviously that can't be compiled beforehand (you only get to download it when you visit t

      • by slack_justyb ( 862874 ) on Friday July 27, 2012 @07:14PM (#40797623)

        QML is essentially JavaScript, with all its costs.

        While not entirely untrue, your post is quite limited in scope. QML should first and foremost be used for the problem that it is addressing, user interfaces, not actions in those interfaces. Agreed that using JavaScript within QML is a quick way of getting things done at the cost of more cycles on your CPU, however, simple tasks should not be entirely excluded. The JS engine that powers QML is made for quick one off operations that affect the UI. Implementing your applications logic at the QML level is strongly discouraged.

        That is the main focus one should keep with QML, UI centric. If a programmer finds themselves doing complex testing within the JS environment they should really consider allowing the logic to be implemented in C++. Doing so is quite easy so it should become the preferred method for logic in QML applications. Remember, and I cannot stress it enough, QML is UI centric.

        That brings me to the point of why QML is what it is. Many people have for years developed Qt applications with the old UI XML format and then loaded said XML via C++ code. Loading the XML created a C++ tree of what you described and then the tree could be handled by your usual C++ methods. However, the XML format for UI did not lend itself to easy operations. The cost of code required to do any single thing was equal (in access terms) to everything else. The tree had to be access, widget pulled, methods called, and so on. Reference pointers usually would be created to common widgets in an application that had a lot of action on them. With the QML engine, some of those one off operations can be implemented into the QML itself, saving the back and forth with C++. That said, the point here is that with QML, yes you loose a little cycle time to the engine, but you gain in the cycles and memory with the reference pointers for one off tasks.

        I know, I keep hammering this one off gong, I apologize for that. However, I think it is one of the strongest motivators for QML adoption, IMHO. QML allows more flexibility between UI and logic, makes code more readable and easier to maintain, and can allow less C++ savvy people who don't want to muck with UI code get to the point in implementing rich UIs. However, and I'll say it again, QML is UI centric and that's where people should keep it.

        I think you would have a very valid point with people who may come into Qt development and think that "Oh Gee! JavaScript! Now I am hackerz!" and start coding up a storm in JS thinking their application will run just as smooth as any other. There is always going to be that crowd, but they alone should not reduce the merit of what QML is accomplishing here.

        I won't sit here and try to sugar coat QML, it is what it is. For better or worst it is where Qt is heading and it has many pros and cons to evaluate when you code your next Qt application. The good thing here is that QML isn't being force upon new developers. UI access code APIs are still there for those that want to, and in some cases should, use them. I don't see QML as an end of the world or road for Qt, but as a tool that should be carefully considered when starting a new Qt project. It offers the ability to quickly develop UI code with C++ code driving the logic and could mean the difference between weeks shaved off development time in trade for a little more overhead; versus a project that dies in inertia and headache UI logic for some of the simplest of tasks. The article deals with KWin and it exposing the needed interface for "QMLing" it. I doubt, but I have not reviewed the code here so I could stand to be wrong, but I doubt that the developers for KWin have made gross assumptions on how those binding should interact with the underlying code that could render brain-dead stubs that increase the overhead by huge margins. Instead I think, nay feel, that the KWin developers are pretty confident that in most cases QML window widgets wil

        • by Anonymous Coward

          Yea I've been writing QML for a living for almost 2 years now - there is VERY little difference between achieving some action in C++ and some action in the JS side of things in QML. I have been writing pure QML, no C++ with an embedded platform as a target - I can safely say that it handles large JS functions with very little issue and faster than I expect in a lot of cases.

          QML is constantly surprising me with what I can do on such limited hardware, so writing a bit for something as simple as decorating win


        Have you EVER used a CONFIGURATION FILE???

        Have you ever WRITTEN A PARSER for a configuration file???

        Did you even stop to consider that perhaps Javascript is an EXCELLENT description language

        Can you PLEASE DESCRIBE how using a Javascript as a description language is SLOWER IN ANY WAY than writing a description language parser from scratch???

      • not really. QML is like HTML or XAML. Its a layout language that allows you to specify where things go and their properties.

        It then also allows you to add bit of code ("code behind" in WPF terms) that is written in javascript to perform activity. Using javascript for this is a good thing, its not particularly slow given that it isn't generally going to be used for anything other than simple stuff (you do not want to write your entire application in QML+js) and acts as a glue to call the underlying program l

  • Can anyone else... (Score:4, Insightful)

    by chispito ( 1870390 ) on Friday July 27, 2012 @05:15PM (#40796629)
    Get through the summary? Or have a general idea why we should read TFA?
    • Well there are way too many irrelevant hyperlinks in the summary.

      But the blog post basically boils down to re-implementing Plastik in QML. That C++ theming is too complex for the average mortal, where a declarative markup language suffices instead.

A mathematician is a device for turning coffee into theorems. -- P. Erdos