After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791360 - Add Screenshot implementation for KDE/Wayland
Add Screenshot implementation for KDE/Wayland
Status: RESOLVED OBSOLETE
Product: GIMP
Classification: Other
Component: Plugins
git master
Other Linux
: Normal normal
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
https://bugs.kde.org/show_bug.cgi?id=...
Depends on:
Blocks:
 
 
Reported: 2017-12-07 18:13 UTC by Jehan
Modified: 2018-05-24 18:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
org.kde.kwin.Screenshot API (158.86 KB, image/png)
2017-12-08 19:27 UTC, Jehan
Details

Description Jehan 2017-12-07 18:13:09 UTC
KDE provides also a dbus API for screenshots. Of course screenshots on KDE/X11 stills works right now, but we need to use the API for KDE/Wayland.

I have been in contact with the KDE developer (Martin Flöser) who gave me info on the interface:

--------------------------------------
Sorry that we don't have an xml description of the protocol. I'll try to reverse engineer one. We are a little bit too pampered by Qt which can generate the API from a class.

Service: org.kde.KWin
Object: /Screenshot
Interface: org.kde.kwin.Screenshot

There are several methods for different features:
 * interactive (fd, mask)
 * interactive (fd)
 * screenshotFullscreen (fd, bool)
 * screenshotFullscreen (fd)
 * screenshotScreen(fd, bool)
 * screenshotScreen(fd)

The interactive allows to screenshot a window which the user can select, the argument mask is:
 * Include window decoration (1 << 0)
 * include cursor (1 << 1)

The variant without mask is both bits not set.

The screenshotFullscreen takes a screenshot of all screens. The (optional) boolean is whether to include mouse cursor.
The screenshotScreen allows to let the user click on a screen to capture in a multi screen setup. The bool is whether to include mouse cursor.

[…]
> Again, RGB or ARGB? :-)

Yes, ARGB - important for window capture mode.

[…]
>     Also are you saying the result is just an array of unsigned ints? If
>    so, what are the width/height of the image to reconstruct it? It's a
>    bit hard to see this in the code. :-/

I have no idea how the data is transferred. Once again we use Qt functionality and use a QDataStream to write a QImage and use a QDataStream to read back the QImage. Qt guarantees that this works. It was three lines of code to transfer the image without having to worry about any protocols.

Qt's documentation says: "Writes the given image to the given stream as a PNG image, or as a BMP image if the stream's version is 1. Note that writing the stream to a file will not produce a valid image file."

How exactly that works internally is something I would have to look into the Qt implementation.
--------------------------------------

Let's try and see if we could implement this for 2.10. How the output is to be used is still a bit fuzzy right now as one can see, since Qt apps just get it as a QImage but apparently we should be able to get it as raw data as well.
Here how a Qt application makes a screenshot with the API: https://cgit.kde.org/spectacle.git/tree/src/PlatformBackends/KWinWaylandImageGrabber.cpp
Comment 1 Jehan 2017-12-08 19:27:41 UTC
Created attachment 365270 [details]
org.kde.kwin.Screenshot API

Ok so I had a look with d-feet at the KDE API.
Turns out they have variants for most methods returning a temporary file as in GNOME API. So I used these variants.
Only feature I could not implement is the area screenshot. They have a "screenshotArea" though, but I could not find an API to get area coordinates, though it has to exist (otherwise "screenshotArea" loses a lot of interest).

commit b9034e26a92e80351982b2f46af061a9b1b349e9 (HEAD -> master, origin/master, origin/HEAD)
Author: Jehan <jehan@girinstud.io>
Date:   Fri Dec 8 19:17:58 2017 +0100

    Bug 791360 - Add Screenshot implementation for KDE/Wayland.
    
    Only thing I could not properly figure out yet is how to select an area.
    The "screenshotArea" method is there in KDE API, but it needs
    coordinates and I can't find the API to grab coordinates in Wayland (as
    in GNOME shell API).

 plug-ins/screenshot/Makefile.am       |   2 ++
 plug-ins/screenshot/screenshot-kwin.c | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 plug-ins/screenshot/screenshot-kwin.h |  32 ++++++++++++++++++
 plug-ins/screenshot/screenshot.c      |   8 +++++
 plug-ins/screenshot/screenshot.h      |   1 +
 5 files changed, 235 insertions(+)
Comment 2 Jehan 2017-12-08 23:25:50 UTC
I opened a bug report for the last issue: https://bugs.kde.org/show_bug.cgi?id=387721
Comment 3 Jehan 2017-12-10 01:00:53 UTC
I made a few more tweaks. The feature looks good now. It only misses ability to shot a rectangular area but we are waiting for the proper APIs to be implemented on KDE side (cf. comment 2). There is nothing more we can do for the time being.

So I remove the blocker status though I keep the report opened.
Comment 4 GNOME Infrastructure Team 2018-05-24 18:51:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/1250.