<div dir="ltr"><div>Hi,</div><div><br></div><div>this all looks good to me. Is your class WaylandImageGrabber QObject based? That's the only thing that comes to my mind.</div><div><br></div><div>Regards,</div><div>Jan</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">ne 27. 9. 2020 v 10:03 odesílatel Damir Porobic <<a href="mailto:damir_porobic@live.com">damir_porobic@live.com</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div>
<div id="gmail-m_-7823695991821364903appendonsend" style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have had a look at the dbus monitor and this is what I see after hitting the save button in the dialog:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
**************************<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:Consolas,Courier,monospace">signal time=1601192691.549507 sender=:1.17 -> destination=(null destination) serial=55 path=/scheduler; interface=org.kde.baloo.scheduler; member=stateChanged</span>
<div><span style="font-family:Consolas,Courier,monospace"> int32 3</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192691.559384 sender=:1.17 -> destination=(null destination) serial=56 path=/scheduler; interface=org.kde.baloo.scheduler; member=stateChanged</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> int32 0</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method return time=1601192691.738677 sender=:1.58 -> destination=:1.53 serial=36 reply_serial=141</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> uint32 0</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> array [</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> dict entry(</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "uri"</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> variant string "file:///home/dporobic/Screenshot_20200927_094451.png"</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> )</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> ]</span></div>
<div><span style="font-family:Consolas,Courier,monospace">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</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> uint32 0</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> array [</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> dict entry(</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "uri"</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> variant string "file:///home/dporobic/Screenshot_20200927_094451.png"</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> )</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> ]</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192691.739267 sender=:1.53 -> destination=org.freedesktop.DBus serial=144 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> 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'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method return time=1601192691.739275 sender=org.freedesktop.DBus -> destination=:1.53 serial=116 reply_serial=144</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192691.739308 sender=:1.53 -> destination=org.freedesktop.DBus serial=145 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> 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'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method return time=1601192691.739317 sender=org.freedesktop.DBus -> destination=:1.53 serial=117 reply_serial=145</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192692.064469 sender=:1.6 -> destination=(null destination) serial=206 path=/; interface=org.kde.KDirNotify; member=FilesAdded</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "desktop:/"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192692.064637 sender=:1.6 -> destination=(null destination) serial=207 path=/; interface=org.kde.KDirNotify; member=FilesAdded</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "desktop:/Screenshot_20200927_094451.png"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192692.064789 sender=:1.6 -> destination=(null destination) serial=208 path=/; interface=org.kde.KDirNotify; member=FilesAdded</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "desktop:/"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.071804 sender=:1.60 -> destination=org.freedesktop.DBus serial=15 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.071946 sender=:1.60 -> destination=org.freedesktop.DBus serial=16 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "org.kde.kded5"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method return time=1601192692.071974 sender=org.freedesktop.DBus -> destination=:1.60 serial=9 reply_serial=16</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string ":1.6"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.072129 sender=:1.60 -> destination=org.kde.kded5 serial=17 path=/modules/desktopnotifier; interface=org.kde.DesktopNotifier; member=watchDir</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "/home/dporobic"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.072140 sender=:1.60 -> destination=org.freedesktop.DBus serial=18 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.082794 sender=:1.60 -> destination=org.freedesktop.DBus serial=19 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.082901 sender=:1.60 -> destination=org.freedesktop.DBus serial=20 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "org.kde.kded5"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method return time=1601192692.082918 sender=org.freedesktop.DBus -> destination=:1.60 serial=10 reply_serial=20</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string ":1.6"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.083083 sender=:1.60 -> destination=org.kde.kded5 serial=21 path=/modules/desktopnotifier; interface=org.kde.DesktopNotifier; member=watchDir</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "/home/dporobic"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">method call time=1601192692.083099 sender=:1.60 -> destination=org.freedesktop.DBus serial=22 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.kde.kded5'"</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192696.749626 sender=:1.17 -> destination=(null destination) serial=57 path=/scheduler; interface=org.kde.baloo.scheduler; member=stateChanged</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> int32 4</span></div>
<div><span style="font-family:Consolas,Courier,monospace">signal time=1601192696.749779 sender=:1.17 -> destination=(null destination) serial=58 path=/scheduler; interface=org.kde.baloo.scheduler; member=stateChanged</span></div>
<div><span style="font-family:Consolas,Courier,monospace"> int32 0</span></div>
<br>
**************************</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
And this is what my application console output spits out:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
**************************<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:Consolas,Courier,monospace">Got reply</span>
<div><span style="font-family:Consolas,Courier,monospace">The path: /org/freedesktop/portal/desktop/request/1_50/u3</span></div>
**************************<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The call seems to be correct I guess. Any idea? <br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Damir<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7823695991821364903divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Damir Porobic <<a href="mailto:damir_porobic@live.com" target="_blank">damir_porobic@live.com</a>><br>
<b>Sent:</b> Monday, September 21, 2020 10:31<br>
<b>To:</b> <a href="mailto:kde-devel@kde.org" target="_blank">kde-devel@kde.org</a> <<a href="mailto:kde-devel@kde.org" target="_blank">kde-devel@kde.org</a>><br>
<b>Subject:</b> Re: Using xdg-desktop-portal-kde to take screenshots</font>
<div> </div>
</div>
<div dir="ltr">
<blockquote style="border-left:3px solid rgb(200,200,200);border-top-color:rgb(200,200,200);border-right-color:rgb(200,200,200);border-bottom-color:rgb(200,200,200);padding-left:1ex;margin-left:0.8ex;color:rgb(102,102,102)">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
When you run "dbus-monitor --session" and you perform the screenshot, do you see this signal to be called at all?<br>
</div>
</blockquote>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks Jan, I'll try that. </div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<blockquote style="border-left:3px solid rgb(200,200,200);border-top-color:rgb(200,200,200);border-right-color:rgb(200,200,200);border-bottom-color:rgb(200,200,200);padding-left:1ex;margin-left:0.8ex;color:rgb(102,102,102)">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:14px;background-color:rgb(255,255,255);display:inline">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. </span></div>
</blockquote>
<div><font color="#000000"><span style="font-size:14px">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.</span></font></div>
<div><font color="#000000"><span style="font-size:14px"><br>
</span></font></div>
<div><font color="#000000"><span style="font-size:14px">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. </span></font></div>
<div><font color="#000000"><span style="font-size:14px"><br>
</span></font></div>
<div><font color="#000000"><span style="font-size:14px">Best regards,</span></font></div>
<div><font color="#000000"><span style="font-size:14px">Damir</span></font></div>
<div>
<div id="gmail-m_-7823695991821364903x_appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7823695991821364903x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> kde-devel <<a href="mailto:kde-devel-bounces@kde.org" target="_blank">kde-devel-bounces@kde.org</a>> on behalf of Jan Grulich <<a href="mailto:jgrulich@redhat.com" target="_blank">jgrulich@redhat.com</a>><br>
<b>Sent:</b> Monday, September 21, 2020 08:08<br>
<b>To:</b> <a href="mailto:kde-devel@kde.org" target="_blank">kde-devel@kde.org</a> <<a href="mailto:kde-devel@kde.org" target="_blank">kde-devel@kde.org</a>><br>
<b>Subject:</b> Re: Using xdg-desktop-portal-kde to take screenshots</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>
<div dir="ltr">ne 20. 9. 2020 v 18:37 odesílatel Damir Porobic <<a href="mailto:damir_porobic@live.com" target="_blank">damir_porobic@live.com</a>> napsal:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello Jan,</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
finally I found some time to upgrade my OS and got a newer Plasma Version but I'm still struggling with the Screenshot Portal.</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Here is my implementation, almost identical to yours from the test that you have linked me (pasting here only the relevant methods):<span style="font-size:12pt">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?</span></div>
</div>
</blockquote>
<div><br>
</div>
<div>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?</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Can I tell the dialog where to save those images? </div>
</div>
</blockquote>
<div><br>
</div>
<div>Unfortunately no, I made it very basic, but patches are welcomed, it won't be a hard task to implement it.</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Can I tell the dialog right away what type of screenshot I want to take?</div>
</div>
</blockquote>
<div><br>
</div>
<div>Unfortunately no, this is not supported by the portal API.</div>
<div> </div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Can I just share the screenshot with my application without saving it? </div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:Arial,Helvetica,sans-serif;font-size:small;color:rgb(34,34,34)"></span></div>
</div>
</blockquote>
<div><br>
</div>
<div>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.</div>
<div> </div>
<div>Regards,</div>
<div>Jan</div>
<div><br></div></div></div></div></div></div></div></div></blockquote></div></div>