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 757687 - Screenshot functionality broken under Wayland
Screenshot functionality broken under Wayland
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other Linux
: Normal normal
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2015-11-06 14:26 UTC by Christian Fredrik Kalager Schaller
Modified: 2016-03-29 21:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christian Fredrik Kalager Schaller 2015-11-06 14:26:36 UTC
Under Wayland the Gimps screenshot functionality only produces black boxes. The Gimp would need to rely on the GNOME Shell dbus API for this to work.
Comment 1 Michael Natterer 2015-11-06 15:11:24 UTC
How would we figure that we are running on GNOME shell? Can you paste
an URL about that API please, I have never heard of it.
Comment 3 Bastien Nocera 2015-11-06 15:45:49 UTC
There's code in:
https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/media-keys/gsd-screenshot-utils.c
which calls out to gnome-shell to do that.

You'd look for the well-known D-Bus name at line 35 on the session bus, and use it if available.

API is here:
https://git.gnome.org/browse/gnome-shell/tree/data/org.gnome.Shell.Screenshot.xml
Comment 4 Matthias Clasen 2015-11-06 15:46:30 UTC
The API is here:

https://git.gnome.org/browse/gnome-shell/tree/data/org.gnome.Shell.Screenshot.xml

You can also introspect it live:

gdbus introspect --session --dest  org.gnome.Shell.Screenshot --object-path /org/gnome/Shell/Screencast

Finding out if you are running under gnome-shell could be done multiple ways, the most straightforward may be to just see if the name org.gnome.Shell.Screenshot is taken on the bus (you need a proxy for that nameanyway, to call the methods)
Comment 5 Michael Natterer 2015-11-06 17:38:41 UTC
Thanks guys, that should do it :) Can I place a feature request right here?
It would be nice to have a method to pick a window and grab only that,
optionally with decoration/shadow.
Comment 6 Matthias Clasen 2015-11-06 19:55:57 UTC
    <!--
        ScreenshotWindow:
        @include_frame: Whether to include the frame or not
        @include_cursor: Whether to include the cursor image or not
        @flash: Whether to flash the window area or not
        @filename: The filename for the screenshot
        @success: whether the screenshot was captured
        @filename_used: the file where the screenshot was saved

        Takes a screenshot of the focused window (optionally omitting the frame)
        and saves it in @filename as png image, it returns a boolean
        indicating whether the operation was successful or not.
        @filename can either be an absolute path or a basename, in
        which case the screenshot will be saved in the $XDG_PICTURES_DIR
        or the home directory if it doesn't exist. The filename used
        to save the screenshot will be returned in @filename_used.
    -->

Should do most of what you want. You can't get your hands on another apps windows under Wayland, so there is no way for _you_ to pick the window and pass the information into the call, but you can tell the user to focus the window and call after a timeout, which seems fairly standard in screenshooting tools...
Comment 7 Michael Natterer 2015-11-07 14:54:18 UTC
Step one...

commit e1c4314a8ef524a2e2f03ac83c7f647b756f739e
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat Nov 7 15:52:44 2015 +0100

    Bug 757687 - Screenshot functionality broken under Wayland
    
    Move the screenshot plug-in to its own directory, it's about to be
    split up into multiple files.

 configure.ac                     |    3 +-
 plug-ins/Makefile.am             |    3 +
 plug-ins/common/.gitignore       |    2 -
 plug-ins/common/Makefile.am      |   23 -
 plug-ins/common/gimprc.common    |    1 -
 plug-ins/common/plugin-defs.pl   |    1 -
 plug-ins/common/screenshot.c     | 1451 --------------------------------------
 plug-ins/screenshot/.gitignore   |    6 +
 plug-ins/screenshot/Makefile.am  |   51 ++
 plug-ins/screenshot/screenshot.c | 1451 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 1512 insertions(+), 1480 deletions(-)
Comment 8 Michael Natterer 2015-11-07 21:41:28 UTC
And more preparation...

commit e4ff6b40da511fae4b6864f280e5e9981799b509
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat Nov 7 22:21:53 2015 +0100

    Bug 757687 - Screenshot functionality broken under Wayland
    
    Move OS X and X11 specific code to its own files, to prepare for more
    shooting backends being added. Also remove unimplemented G_OS_WIN32
    stubs, if anyone feels like implementing a Windows backend, by all
    means go ahead.

 plug-ins/screenshot/Makefile.am      |   7 +-
 plug-ins/screenshot/screenshot-osx.c | 118 +++++
 plug-ins/screenshot/screenshot-osx.h |  33 ++
 plug-ins/screenshot/screenshot-x11.c | 702 +++++++++++++++++++++++++
 plug-ins/screenshot/screenshot-x11.h |  33 ++
 plug-ins/screenshot/screenshot.c     | 966 +++--------------------------------
 plug-ins/screenshot/screenshot.h     |  49 ++
 po-plug-ins/POTFILES.in              |   1 +
 8 files changed, 1019 insertions(+), 890 deletions(-)
Comment 9 Michael Schumacher 2015-11-10 07:08:41 UTC
Not being able to select a window will feel like a huge step backwards to many users. Is this a design decision for Wayland, or does this just happen to not be there?
Comment 10 Matthias Clasen 2015-11-10 16:09:10 UTC
(In reply to Michael Schumacher from comment #9)
> Not being able to select a window will feel like a huge step backwards to
> many users. Is this a design decision for Wayland, or does this just happen
> to not be there?

It is inherent in design decision to isolate applications from each other under Wayland, to avoid the glaring insecurities of the X protocol. There is no way for you to pick another applications window - you can't see them or talk about them...

What we can and perhaps should do is extend the org.gnome.Screenshot API to have a method that instructs gnome-shell to let the user pick a window (instead of just using the focused window).
Comment 11 Michael Natterer 2016-03-29 20:11:29 UTC
More preparation:

commit a1785e9823e691b5167be42096b2726cc7956230
Author: Michael Natterer <mitch@gimp.org>
Date:   Tue Mar 29 22:06:31 2016 +0200

    Bug 757687 - Screenshot functionality broken under Wayland
    
    Some more abstraction in the screenshot plug-in, now allows for
    runtime backend selection. Add stubs for the gnome-shell backend,
    registers itself as unavailable because it's still unimplemented.

 plug-ins/screenshot/Makefile.am              | 12 ++++---
 plug-ins/screenshot/screenshot-gnome-shell.c | 50 +++++++++++++++++++++++++++++
 plug-ins/screenshot/screenshot-gnome-shell.h | 31 ++++++++++++++++++
 plug-ins/screenshot/screenshot-osx.c         |  6 ++++
 plug-ins/screenshot/screenshot-osx.h         |  2 ++
 plug-ins/screenshot/screenshot-x11.c         |  8 ++++-
 plug-ins/screenshot/screenshot-x11.h         |  2 ++
 plug-ins/screenshot/screenshot.c             | 80 ++++++++++++++++++++++++++++++----------------
 plug-ins/screenshot/screenshot.h             | 13 ++++++--
 9 files changed, 168 insertions(+), 36 deletions(-)
Comment 12 Michael Natterer 2016-03-29 21:39:41 UTC
Fixed in master:

commit cf6cb8d1ff0b448265150e5875144eb59fd0dc10
Author: Michael Natterer <mitch@gimp.org>
Date:   Tue Mar 29 23:36:12 2016 +0200

    Bug 757687 - Screenshot functionality broken under Wayland
    
    Implement screenshot-gnome-shell.c using the DBus API.

 plug-ins/screenshot/screenshot-gnome-shell.c | 96 +++++++++++++++++++++++++++-
 1 file changed, 93 insertions(+), 3 deletions(-)