domenica 11 agosto 2013

Hawaii memory usage

Since Hawaii 0.2.0 is closer I wanted to collect some stats about its memory usage.

Measuring resources usage reliably is a bit hard, but it seems that KSysGuard provides detailed results and keep shared libraries into account.

While I'm here I will compare Hawaii with XFCE, although there's no much value in it due to the difference between the two stacks except for being aware of what another low footprint desktop is doing in its current form.

So, let's see how much memory does it take Hawaii, measuring a session with some applications open (System Preferences, Terminal, Eyesight, Swordfish and QupZilla and Communi) after using it for a while.

Currently Hawaii is using Weston although in the future it will use Green Island, a QtQuick compositor using the QtCompositor API.

As you can see from the screenshot below, there are two Weston processes running.

Weston processes
Details below:

weston process memory usage
weston-keyboard process memory usage
Total memory usage: 23.4 MB

Now let's see the desktop environment...

Hawaii Shell memory usage
dconf-service memory usage

dconf-service is included to match XFCE which has xfconfd.

Total memory usage: 64.47 MB

Compare now with a low footprint X11 desktop environment: XFCE.

In the X11 world we need two programs to cover the Weston features: the Xorg server and a window manager/compositor, XFCE uses xfwm4.

Total memory usage: 122.9 MB

From the features point of view we should compare Xorg + xfwm4 with weston (122.9 MB vs 9 MB) but I think this is due to the different architecture.

To be fair I'm measuring only XFCE components that has a Hawaii counterpart, so xfce4-power-manager is not included and judging by the package description xfconfd can be compared to dconf.

The panel-6-systray process is not included either, if it does what the name suggests then Hawaii can't match it because it doesn't support the System Tray Protocol.

xfsettingsd might be left out (although I'm not sure) because Hawaii doesn't have a daemon to propagate settings.  However Hawaii doesn't need it for settings such as icon theme, widgets style, fonts etc... they are managed by a platform theme plugin but other settings such as mouse cursor theme and size would need something to propagate those settings to Qt applications as well as non-Qt applications.

XFCE doesn't have a PolicyKit agent like Hawaii, or at least I couldn't find any.

xfce4-panel memory usage 
xfdesktop memory usage
panel-2-actions memory usage 
xfconfd memory usage
xfce4-notifyd memory usage
Total memory usage: 31.22 MB

Weston 9 MB
Hawaii (weston-keyboard + hawaii-desktop-shell + dconf) 14.4 + 63.7 + 0.773 = 78.83 MB
Total: 9 + 78.83 = 87.87 MB
Xorg and xfwm4 115.7 + 7.2 = 122.9 MB
XFCE (xfce4-panel + xfdesktop + xfce4-session + panel-2-actions + xfconfd + xfsettings + xfce4-notifyd) 9.8 + 6.5 + 4.2 + 2.8 + 0.721 + 2.9 + 4.3 = 31.22 MB
Total: 122.9 + 31.22 = 154.12 MB

EDIT: As requested in the comments I capture the output of free and memuse on my Archlinux system before running Hawaii from KMS (fullscreen 2560x1440) and from the Hawaii session.

Output of free after the system is started:
Output of memuse after the system is started:

Output of free running from Hawaii on KMS:
Output of memuse running from Hawaii on KMS:

mercoledì 12 giugno 2013

Hawaii System Preferences, Part 2: How preflets are loaded

System Preferences can be extended with plugins.

Plugins inherit PreferencesModulePlugin and return a new PreferencesModule instance that has preflet information such as name, description, icon name, category, whether it requires administrative privileges (helpful for preflets that deal with system settings).

System Settings has a simple model that iterates over the plugins directory, load plugins with QPluginLoader and create module instances.

In the QtWidgets-based version, PreferencesModule inherited from QWidget, the preflet was then a widget that System Preferences added to a stacked widget. When the corresponding icon was clicked, the current index was changed showing the preflet's widget.

Since I'm rewriting everything in QML, PreferencesModule now inherits from QObject and has a new item() method that preflets implement returning a QQuickItem object created by loading the QML code embedded into the resources with QQmlComponent.

The loading mechanism is pretty much the same, the model exposes the QQuickItem with the item role, when the preflet icon is clicked the item is pushed to a StackView.

venerdì 7 giugno 2013

Hawaii System Preferences

With the imminent release of Qt 5.1, QML is going to be a serious tool for desktop applications development.

With QtQuick Layouts and QtQuick Controls we can finally create complex user interfaces and drop QtWidgets and that's exactly my goal for the Hawaii System Preferences applications.

This is how it looks like today:

System Preferences uses KDE's categorized view imported into Vibe, which is a nice view that allows you to categorize a list view and filter the results; in this case I filter the results by keyword to gray out and disable icons that don't meet the search criteria:

However, as you can see from the screenshots, there's an annoying bug that cuts the labels out.

Rewriting it with QML is easy, here's the code for the main window:
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import Hawaii.SystemPreferences 0.1

ApplicationWindow {
    id: root
    title: qsTr("System Preferences")
    width: 640
    height: 640
    minimumWidth: 640
    minimumHeight: 640

    toolBar: ToolBar {
        id: mainToolBar
        width: parent.width

        RowLayout {
            anchors.fill: parent
            spacing: 10

            ToolButton {
                action: actionBack

            Item {
                Layout.fillWidth: true

            TextField {
                id: searchEntry
                placeholderText: qsTr("Keywords")

                Layout.alignment: Qt.AlignVCenter | Qt.AlignRight

    Action {
        id: actionBack
        iconName: "view-grid-symbolic"

    StackView {
        id: pageStack
        anchors.fill: parent

        initialItem: Item {
            width: parent.width
            height: parent.height

            ColumnLayout {
                anchors.fill: parent

                Repeater {
                    model: CategoriesModel {}

                    GroupBox {
                        title: label

                        Layout.fillWidth: true
                        Layout.fillHeight: true

                        ScrollView {
                            anchors.fill: parent

                            GridView {
                                id: gridView
                                model: PrefletsProxyModel {}
                                delegate: GridDelegate {
                                    width: gridView.cellWidth
                                clip: true
                                cellWidth: 100

                                Component.onCompleted: gridView.model.setFilterFixedString(name)

Unfortunately I couldn't find a replacement for the categorized view so I decided to repeat a scrollable grid view inside a group box for each category. Far from what I want but it seems the grid view doesn't have something like this, but there's time to improve System Preferences.

The grid delegate was easy to do:
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0

ColumnLayout {
    Image {
        source: "image://desktoptheme/" + iconName
        sourceSize: Qt.size(48, 48)
        width: 48
        height: 48

        Layout.alignment: Qt.AlignCenter

    Label {
        text: title
        horizontalAlignment: Qt.AlignHCenter
        wrapMode: Text.Wrap

        Layout.fillWidth: true

And here's how it looks like:

Colors are from the standard Qt palette which will be replaced with some grayish palette for Hawaii soon.

venerdì 15 marzo 2013

Qt AccountsService

Recently I started working on a Qt 5 addon for AccountsService.

AccountsService is a D-Bus service for accessing the list of user accounts and information attached to those accounts, as its web site says.

You can learn more about it here.

Qt AccountsService Addon is basically a Qt-style API to use this D-Bus service and also offers a model that represents users, the API can also be used from QML.

You can check out the source code from here.

The code works, I'm already using it in several projects but there's no promise of API stability right now although I haven't made too much changes lately.