Back to KDE, back to work

Posted on Wed 03 May 2017 in tech

Lakademy 2017 members shot

It's been a while since my last effective contribution to the KDE community. I had my share of reasons to not send any code for the last 5 years, but being at LaKademy, I wondered why it took so long to be back. As always, the community is the most valuable item that KDE has. Very welcoming, helpful and playful people.

Lakademy 2017 members shot

I was glad to meet old friends and make new ones, highly skilled and focused people. Besides work, lots of conversations about technicalities and social issues of FOSS and IT environment in general. And, as only can happen with these kinds of people, we came out of LaKademy with lots of memes and inside jokes.

Coding and Debugging

Lakademy 2017 members shot

In my past contributions I had lots of new ideas but usually the impact didn't go as far as I wanted to. After some thought, and a few reads, I came to the conclusion that it's best to solve existing bugs. New features demand a more high understanding of the project you are working (along with a complete new set of bugs). So, I chose this Spectacle bug, since it looked pretty simple to solve (but it wasn't, at least for me :/). I already had my KDE environment set for development, but had a lot of other technical issues to solve, like how to profile DBus interfaces, how to configure and run another X11 inside your current session (in this case, using Xypher), how to attach a new DBus session into this nested X11 session... Lots of particularities that I'll write with more details in another post. But for now I should say that it wasn't so straightforward as I was expecting to be (as anything in tech). After the complete enviroment was set, I manage to check what was causing the bug at Spectacle:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
     if (mCaptureDecorations && isKWinAvailable()) {
         QDBusConnection bus = QDBusConnection::sessionBus();
         bus.connect(QStringLiteral("org.kde.KWin"),
                     QStringLiteral("/Screenshot"),
                     QStringLiteral("org.kde.kwin.Screenshot"),
                     QStringLiteral("screenshotCreated"),
                     this, SLOT(KWinDBusScreenshotHelper(quint64)));
         QDBusInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Screenshot"), QStringLiteral("org.kde.kwin.Screenshot"));

         int mask = 1;
         if (mCapturePointer) {
             mask |= 1 << 1;
         }

         interface.call(QStringLiteral("screenshotWindowUnderCursor"), mask);
         return;
     }

     // else, go native

     return grabApplicationWindowHelper(getRealWindowUnderCursor());
 }

Basically, the function grabWindowUnderCursor calls the KWin screenshotWindowUnderCursor using a QDBusInterface and should receive an emmited pixmap from KWin. Using the dbus-monitor, no "screenshotWindowUnderCursor" interface was being called so I had to download, compile and run a KWin (using Xypher along with a separated DBus session configured for testing it) to investigate this propertly.

I'm still working on this bug, although I can't replicate it in my desktop anymore (IDK yet if there was any significant update at KWin or Spectacle that would fix the call of the "Screenshot" object). I talked with a few people at #kde-devel channel and they couldn't replicate it either. For now, I'll have to investigate KWin DBus interfaces a bit more to check why the issue is supposedly "fixed" or if there is another situation that this might happen.