[gimp] plug-ins: do not show our own dialog with Freedesktop screenshot portal.



commit aab1d0c227ca9a571abb3842117819a372c0f5e8
Author: Jehan <jehan girinstud io>
Date:   Wed Dec 30 17:21:43 2020 +0100

    plug-ins: do not show our own dialog with Freedesktop screenshot portal.
    
    Today I have only re-tested the GNOME implementation (in particular not
    the KDE one) of the portal API org.freedesktop.portal.Screenshot but I
    assume it is similar because the dbus function does not provide any
    useful options anyway. This is why the portal comes with its own dialog
    providing the various common screenshot features (delay, window picking,
    area selection, etc.). Showing our dialog first is therefore redundant.
    
    Also I updated setting the monitor profile only in the case where the
    loaded image result from the portal did not have an embedded profile. To
    be fair, the GNOME implementation at least does not embed a profile to
    this day. So this is only for the future case where they will finally do
    the right thing and embed the display profile (or for other desktops'
    implementations where they maybe already do the right thing).

 plug-ins/screenshot/screenshot-freedesktop.c | 38 +++++++++++++++++++---------
 plug-ins/screenshot/screenshot.c             | 19 +++++++++++---
 2 files changed, 42 insertions(+), 15 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-freedesktop.c b/plug-ins/screenshot/screenshot-freedesktop.c
index c6c0a3b0f7..214051d509 100644
--- a/plug-ins/screenshot/screenshot-freedesktop.c
+++ b/plug-ins/screenshot/screenshot-freedesktop.c
@@ -172,19 +172,33 @@ screenshot_freedesktop_shoot (ScreenshotValues  *shootvals,
       /* Signal got a response. */
       if (*image)
         {
-          GimpColorProfile *profile;
-
-          /* Just assign profile of current monitor. This will work only
-           * as long as this is a single-display setup.
-           * We need to figure out how to do better color management for
-           * portal screenshots.
-           * TODO!
-           */
-          profile = gimp_monitor_get_color_profile (monitor);
-          if (profile)
+          if (! gimp_image_get_color_profile (*image))
             {
-              gimp_image_set_color_profile (*image, profile);
-              g_object_unref (profile);
+              /* The Freedesktop portal does not return a profile, so we
+               * don't have color characterization through the API.
+               * Ideally then, the returned screenshot image would have
+               * embedded profile, but this depends on each desktop
+               * implementation of the portal (and at time of writing,
+               * the GNOME implementation of Freedesktop portal at least
+               * didn't embed a profile with the returned PNG image).
+               *
+               * As a last resort, we assign the profile of current
+               * monitor. This will actually only work if we use the
+               * portal on X11 (because we don't have monitor's profile
+               * access on Wayland AFAIK), and only as long as this is a
+               * single-display setup.
+               *
+               * We need to figure out how to do better color management for
+               * portal screenshots. TODO!
+               */
+              GimpColorProfile *profile;
+
+              profile = gimp_monitor_get_color_profile (monitor);
+              if (profile)
+                {
+                  gimp_image_set_color_profile (*image, profile);
+                  g_object_unref (profile);
+                }
             }
 
           return GIMP_PDB_SUCCESS;
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 4221454d88..33878b0d02 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -300,9 +300,22 @@ screenshot_run (GimpProcedure        *procedure,
           shootvals.shoot_type = SHOOT_ROOT;
         }
 
-      /* Get information from the dialog */
-      if (! shoot_dialog (&monitor))
-        status = GIMP_PDB_CANCEL;
+      /* Get information from the dialog. Freedesktop portal comes with
+       * its own dialog.
+       */
+      if (backend != SCREENSHOT_BACKEND_FREEDESKTOP)
+        {
+          if (! shoot_dialog (&monitor))
+            status = GIMP_PDB_CANCEL;
+        }
+      else
+        {
+          /* This is ugly but in reality we have no idea on which monitor
+           * a screenshot was taken from with portals. It's like a
+           * better-than-nothing trick for easy single-display cases.
+           */
+          monitor = gdk_display_get_monitor (gdk_display_get_default (), 0);
+        }
       break;
 
     case GIMP_RUN_NONINTERACTIVE:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]