Using xdg-desktop-portal-kde to take screenshots

Jan Grulich jgrulich at redhat.com
Tue Sep 29 06:43:49 BST 2020


Hi,

this all looks good to me. Is your class WaylandImageGrabber QObject based?
That's the only thing that comes to my mind.

Regards,
Jan

ne 27. 9. 2020 v 10:03 odesílatel Damir Porobic <damir_porobic at live.com>
napsal:

> I have had a look at the dbus monitor and this is what I see after hitting
> the save button in the dialog:
>
> **************************
> signal time=1601192691.549507 sender=:1.17 -> destination=(null
> destination) serial=55 path=/scheduler; interface=org.kde.baloo.scheduler;
> member=stateChanged
>    int32 3
> signal time=1601192691.559384 sender=:1.17 -> destination=(null
> destination) serial=56 path=/scheduler; interface=org.kde.baloo.scheduler;
> member=stateChanged
>    int32 0
> method return time=1601192691.738677 sender=:1.58 -> destination=:1.53
> serial=36 reply_serial=141
>    uint32 0
>    array [
>       dict entry(
>          string "uri"
>          variant             string
> "file:///home/dporobic/Screenshot_20200927_094451.png"
>       )
>    ]
> signal time=1601192691.739126 sender=:1.53 -> destination=:1.50 serial=143
> path=/org/freedesktop/portal/desktop/request/1_50/u3;
> interface=org.freedesktop.portal.Request; member=Response
>    uint32 0
>    array [
>       dict entry(
>          string "uri"
>          variant             string
> "file:///home/dporobic/Screenshot_20200927_094451.png"
>       )
>    ]
> method call time=1601192691.739267 sender=:1.53 ->
> destination=org.freedesktop.DBus serial=144 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=RemoveMatch
>    string
> "type='signal',sender='org.freedesktop.impl.portal.desktop.kde',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/freedesktop/portal/desktop/request/1_50/u3',arg0='org.freedesktop.impl.portal.Request'"
> method return time=1601192691.739275 sender=org.freedesktop.DBus ->
> destination=:1.53 serial=116 reply_serial=144
> method call time=1601192691.739308 sender=:1.53 ->
> destination=org.freedesktop.DBus serial=145 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=RemoveMatch
>    string
> "type='signal',sender='org.freedesktop.impl.portal.desktop.kde',interface='org.freedesktop.impl.portal.Request',path='/org/freedesktop/portal/desktop/request/1_50/u3'"
> method return time=1601192691.739317 sender=org.freedesktop.DBus ->
> destination=:1.53 serial=117 reply_serial=145
> signal time=1601192692.064469 sender=:1.6 -> destination=(null
> destination) serial=206 path=/; interface=org.kde.KDirNotify;
> member=FilesAdded
>    string "desktop:/"
> signal time=1601192692.064637 sender=:1.6 -> destination=(null
> destination) serial=207 path=/; interface=org.kde.KDirNotify;
> member=FilesAdded
>    string "desktop:/Screenshot_20200927_094451.png"
> signal time=1601192692.064789 sender=:1.6 -> destination=(null
> destination) serial=208 path=/; interface=org.kde.KDirNotify;
> member=FilesAdded
>    string "desktop:/"
> method call time=1601192692.071804 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=15 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=AddMatch
>    string
> "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"
> method call time=1601192692.071946 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=16 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=GetNameOwner
>    string "org.kde.kded5"
> method return time=1601192692.071974 sender=org.freedesktop.DBus ->
> destination=:1.60 serial=9 reply_serial=16
>    string ":1.6"
> method call time=1601192692.072129 sender=:1.60 ->
> destination=org.kde.kded5 serial=17 path=/modules/desktopnotifier;
> interface=org.kde.DesktopNotifier; member=watchDir
>    string "/home/dporobic"
> method call time=1601192692.072140 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=18 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=RemoveMatch
>    string
> "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"
> method call time=1601192692.082794 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=19 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=AddMatch
>    string
> "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"
> method call time=1601192692.082901 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=20 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=GetNameOwner
>    string "org.kde.kded5"
> method return time=1601192692.082918 sender=org.freedesktop.DBus ->
> destination=:1.60 serial=10 reply_serial=20
>    string ":1.6"
> method call time=1601192692.083083 sender=:1.60 ->
> destination=org.kde.kded5 serial=21 path=/modules/desktopnotifier;
> interface=org.kde.DesktopNotifier; member=watchDir
>    string "/home/dporobic"
> method call time=1601192692.083099 sender=:1.60 ->
> destination=org.freedesktop.DBus serial=22 path=/org/freedesktop/DBus;
> interface=org.freedesktop.DBus; member=RemoveMatch
>    string
> "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"
> signal time=1601192696.749626 sender=:1.17 -> destination=(null
> destination) serial=57 path=/scheduler; interface=org.kde.baloo.scheduler;
> member=stateChanged
>    int32 4
> signal time=1601192696.749779 sender=:1.17 -> destination=(null
> destination) serial=58 path=/scheduler; interface=org.kde.baloo.scheduler;
> member=stateChanged
>    int32 0
>
> **************************
>
> And this is what my application console output spits out:
>
> **************************
> Got reply
> The path: /org/freedesktop/portal/desktop/request/1_50/u3
> **************************
>
> The call seems to be correct I guess. Any idea?
>
> Regards,
> Damir
>
> ------------------------------
> *From:* Damir Porobic <damir_porobic at live.com>
> *Sent:* Monday, September 21, 2020 10:31
> *To:* kde-devel at kde.org <kde-devel at kde.org>
> *Subject:* Re: Using xdg-desktop-portal-kde to take screenshots
>
>
> When you run "dbus-monitor --session" and you perform the screenshot, do
> you see this signal to be called at all?
>
>
> Thanks Jan, I'll try that.
>
> Unfortunately no, again a limitation of the portal API as the portal is
> supposed to return an URI. You can however directly use KWin DBus interface
> to get a screenshot, specifying directly what type of screenshot you want
> to tak and you get the raw image. This however will make it work only in
> Plasma and will not work in an application running in sandbox without
> giving it access to DBus.
>
> My Application already supports native Plasma and Gnome Wayland
> Screenshots, but that does don't work if the application is packaged as
> Snap or when non Plasma or Gnome environments are used, so I'm trying to
> make this generic  Wayland solution work.
>
> Also, I've been playing around with this under Gnome too and they have
> also a Dialog but with a Share button instead of Save. I believe they are
> doing it like with the native Wayland solution by saving the image in a
> temp directory that is deleted on reboot and just providing the path to the
> image. The user can decide what to do with the image, save it permanently
> or do nothing and the image is gone. Though there I have the same problem
> that the gotScreenshotResponse is never called.
>
> Best regards,
> Damir
>
> ------------------------------
> *From:* kde-devel <kde-devel-bounces at kde.org> on behalf of Jan Grulich <
> jgrulich at redhat.com>
> *Sent:* Monday, September 21, 2020 08:08
> *To:* kde-devel at kde.org <kde-devel at kde.org>
> *Subject:* Re: Using xdg-desktop-portal-kde to take screenshots
>
> Hi,
>
> ne 20. 9. 2020 v 18:37 odesílatel Damir Porobic <damir_porobic at live.com>
> napsal:
>
> Hello Jan,
>
> finally I  found some time to upgrade my OS and got a newer Plasma Version
> but I'm still struggling with the Screenshot Portal.
>
> Here is my implementation, almost identical to yours from the test that
> you have linked me (pasting here only the relevant methods):I get the
> dialog which asks me what type of screenshot I want to take I select it, a
> small image is show in the dialog and I can click on save (which saves the
> image in my home directory) but the gotScreenshotResponse is never called.
> Any idea why?
>
>
> I have no idea. The code looks good and identical to what I have in the
> example. When you run "dbus-monitor --session" and you perform the
> screenshot, do you see this signal to be called at all?
>
>
> Can I tell the dialog where to save those images?
>
>
> Unfortunately no, I made it very basic, but patches are welcomed, it won't
> be a hard task to implement it.
>
>
> Can I tell the dialog right away what type of screenshot I want to take?
>
>
> Unfortunately no, this is not supported by the portal API.
>
>
> Can I just share the screenshot with my application without saving it?
>
>
> Unfortunately no, again a limitation of the portal API as the portal is
> supposed to return an URI. You can however directly use KWin DBus interface
> to get a screenshot, specifying directly what type of screenshot you want
> to tak and you get the raw image. This however will make it work only in
> Plasma and will not work in an application running in sandbox without
> giving it access to DBus.
>
> Regards,
> Jan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-devel/attachments/20200929/ec233a2c/attachment.htm>


More information about the kde-devel mailing list