GNOME Bugzilla – Bug 757687
Screenshot functionality broken under Wayland
Last modified: 2016-03-29 21:39:41 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.
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.
https://git.gnome.org/browse/gnome-screenshot/commit/?id=56065725542e36bdde6acd66b8b071fbd0b08e6f has an example how to do it.
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
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)
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.
<!-- 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...
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(-)
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(-)
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?
(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).
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(-)
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(-)