[gimp] plug-ins: screenshot_x11_available() should not always return TRUE.



commit a29ece23b9ac1ae8d5a815aabcb63e8df0573c10
Author: Jehan <jehan girinstud io>
Date:   Wed Dec 30 16:14:13 2020 +0100

    plug-ins: screenshot_x11_available() should not always return TRUE.
    
    This was true in the "old world" where X11 support being built-in meant
    that X11 screenshot would be usable. Now we must not only check it is
    built, but also that we are actually running under X11. Otherwise with a
    Wayland compositor, screenshot would fail. Also it meant that the
    Freedesktop portal was never tried if both X11 and Wayland support were
    built-in.

 plug-ins/screenshot/screenshot-x11.c | 3 ++-
 plug-ins/screenshot/screenshot.c     | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index b9495e2b8d..46437ba9c2 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -530,7 +530,8 @@ add_cursor_image (GimpImage  *image,
 gboolean
 screenshot_x11_available (void)
 {
-  return TRUE;
+  return (gdk_display_get_default () &&
+          GDK_IS_X11_DISPLAY (gdk_display_get_default ()));
 }
 
 ScreenshotCapabilities
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 5ed158597b..4221454d88 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -235,6 +235,7 @@ screenshot_run (GimpProcedure        *procedure,
   gegl_init (NULL, NULL);
 
   run_mode = GIMP_VALUES_GET_ENUM (args, 0);
+  gimp_ui_init (PLUG_IN_BINARY);
 
 #ifdef PLATFORM_OSX
   if (! backend && screenshot_osx_available ())
@@ -511,8 +512,6 @@ shoot_dialog (GdkMonitor **monitor)
   gboolean       run;
   GtkWidget     *cursor_toggle = NULL;
 
-  gimp_ui_init (PLUG_IN_BINARY);
-
   dialog = gimp_dialog_new (_("Screenshot"), PLUG_IN_ROLE,
                             NULL, 0,
                             gimp_standard_help_func, PLUG_IN_PROC,


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