[gimp] Bug 757687 - Screenshot functionality broken under Wayland
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 757687 - Screenshot functionality broken under Wayland
- Date: Tue, 29 Mar 2016 20:08:44 +0000 (UTC)
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(-)
---
diff --git a/plug-ins/screenshot/Makefile.am b/plug-ins/screenshot/Makefile.am
index 9cb0629..1f9c798 100644
--- a/plug-ins/screenshot/Makefile.am
+++ b/plug-ins/screenshot/Makefile.am
@@ -48,9 +48,11 @@ libexec_PROGRAMS = screenshot
EXTRA_PROGRAMS = screenshot
screenshot_SOURCES = \
- screenshot.c \
- screenshot.h \
- screenshot-osx.c \
- screenshot-osx.h \
- screenshot-x11.c \
+ screenshot.c \
+ screenshot.h \
+ screenshot-gnome-shell.c \
+ screenshot-gnome-shell.h \
+ screenshot-osx.c \
+ screenshot-osx.h \
+ screenshot-x11.c \
screenshot-x11.h
diff --git a/plug-ins/screenshot/screenshot-gnome-shell.c b/plug-ins/screenshot/screenshot-gnome-shell.c
new file mode 100644
index 0000000..f918eda
--- /dev/null
+++ b/plug-ins/screenshot/screenshot-gnome-shell.c
@@ -0,0 +1,50 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * Screenshot plug-in
+ * Copyright 1998-2007 Sven Neumann <sven gimp org>
+ * Copyright 2003 Henrik Brix Andersen <brix gimp org>
+ * Copyright 2016 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
+
+#include "screenshot.h"
+#include "screenshot-gnome-shell.h"
+
+
+gboolean
+screenshot_gnome_shell_available (void)
+{
+ return FALSE;
+}
+
+ScreenshotCapabilities
+screenshot_gnome_shell_get_capabilities (void)
+{
+ return 0;
+}
+
+GimpPDBStatusType
+screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
+ GdkScreen *screen,
+ gint32 *image_ID)
+{
+ return GIMP_PDB_SUCCESS;
+}
diff --git a/plug-ins/screenshot/screenshot-gnome-shell.h b/plug-ins/screenshot/screenshot-gnome-shell.h
new file mode 100644
index 0000000..f9c7746
--- /dev/null
+++ b/plug-ins/screenshot/screenshot-gnome-shell.h
@@ -0,0 +1,31 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __SCREENSHOT_GNOME_SHELL_H__
+#define __SCREENSHOT_GNOME_SHELL_H__
+
+
+gboolean screenshot_gnome_shell_available (void);
+
+ScreenshotCapabilities screenshot_gnome_shell_get_capabilities (void);
+
+GimpPDBStatusType screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
+ GdkScreen *screen,
+ gint32 *image_ID);
+
+
+#endif /* __SCREENSHOT_GNOME_SHELL_H__ */
diff --git a/plug-ins/screenshot/screenshot-osx.c b/plug-ins/screenshot/screenshot-osx.c
index 0645135..9042aeb 100644
--- a/plug-ins/screenshot/screenshot-osx.c
+++ b/plug-ins/screenshot/screenshot-osx.c
@@ -53,6 +53,12 @@
* This routines works well with X11 and as a navtive build
*/
+gboolean
+screenshot_osx_available (void)
+{
+ return TRUE;
+}
+
ScreenshotCapabilities
screenshot_osx_get_capabilities (void)
{
diff --git a/plug-ins/screenshot/screenshot-osx.h b/plug-ins/screenshot/screenshot-osx.h
index 9bd2dfc..a97414d 100644
--- a/plug-ins/screenshot/screenshot-osx.h
+++ b/plug-ins/screenshot/screenshot-osx.h
@@ -21,6 +21,8 @@
#ifdef PLATFORM_OSX
+gboolean screenshot_osx_available (void);
+
ScreenshotCapabilities screenshot_osx_get_capabilities (void);
GimpPDBStatusType screenshot_osx_shoot (ScreenshotValues *shootvals,
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index 48e0516..2677212 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -540,10 +540,16 @@ add_cursor_image (gint32 image,
/* The main Screenshot function */
+gboolean
+screenshot_x11_available (void)
+{
+ return TRUE;
+}
+
ScreenshotCapabilities
screenshot_x11_get_capabilities (void)
{
- ScreenshotCapabilities capabilities = 0;
+ ScreenshotCapabilities capabilities = SCREENSHOT_CAN_PICK_NONINTERACTIVELY;
#ifdef HAVE_X11_XMU_WINUTIL_H
capabilities |= SCREENSHOT_CAN_SHOOT_DECORATIONS;
diff --git a/plug-ins/screenshot/screenshot-x11.h b/plug-ins/screenshot/screenshot-x11.h
index 0a76c34..72b5169 100644
--- a/plug-ins/screenshot/screenshot-x11.h
+++ b/plug-ins/screenshot/screenshot-x11.h
@@ -21,6 +21,8 @@
#ifdef GDK_WINDOWING_X11
+gboolean screenshot_x11_available (void);
+
ScreenshotCapabilities screenshot_x11_get_capabilities (void);
GimpPDBStatusType screenshot_x11_shoot (ScreenshotValues *shootvals,
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 2f91204..24f6c29 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -27,6 +27,7 @@
#include "screenshot.h"
#include "screenshot-osx.h"
+#include "screenshot-gnome-shell.h"
#include "screenshot-x11.h"
#include "libgimp/stdplugins-intl.h"
@@ -115,6 +116,7 @@ static const guint8 screenshot_icon[] =
/* Defines */
+
#define PLUG_IN_PROC "plug-in-screenshot"
#define PLUG_IN_BINARY "screenshot"
#define PLUG_IN_ROLE "gimp-screenshot"
@@ -128,24 +130,6 @@ static const guint8 screenshot_icon[] =
#endif
-static ScreenshotValues shootvals =
-{
- SHOOT_WINDOW, /* root window */
-#ifdef PLATFORM_OSX
- FALSE,
-#else
- TRUE, /* include WM decorations */
-#endif
- 0, /* window ID */
- 0, /* select delay */
- 0, /* coords of region dragged out by pointer */
- 0,
- 0,
- 0,
- FALSE
-};
-
-
static void query (void);
static void run (const gchar *name,
gint nparams,
@@ -162,8 +146,26 @@ static gboolean shoot_quit_timeout (gpointer data);
/* Global Variables */
+static ScreenshotBackend backend = SCREENSHOT_BACKEND_NONE;
static ScreenshotCapabilities capabilities = 0;
+static ScreenshotValues shootvals =
+{
+ SHOOT_WINDOW, /* root window */
+#ifdef PLATFORM_OSX
+ FALSE,
+#else
+ TRUE, /* include WM decorations */
+#endif
+ 0, /* window ID */
+ 0, /* select delay */
+ 0, /* coords of region dragged out by pointer */
+ 0,
+ 0,
+ 0,
+ FALSE
+};
+
const GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
@@ -256,9 +258,25 @@ run (const gchar *name,
values[0].data.d_status = status;
#ifdef PLATFORM_OSX
- capabilities = screenshot_osx_get_capabilities ();
-#elif defined (GDK_WINDOWING_X11)
- capabilities = screenshot_x11_get_capabilities ();
+ if (! backend && screenshot_osx_available ())
+ {
+ backend = SCREENSHOT_BACKEND_OSX;
+ capabilities = screenshot_osx_get_capabilities ();
+ }
+#endif
+
+ if (! backend && screenshot_gnome_shell_available ())
+ {
+ backend = SCREENSHOT_BACKEND_GNOME_SHELL;
+ capabilities = screenshot_gnome_shell_get_capabilities ();
+ }
+
+#ifdef GDK_WINDOWING_X11
+ if (! backend && screenshot_x11_available ())
+ {
+ backend = SCREENSHOT_BACKEND_X11;
+ capabilities = screenshot_x11_get_capabilities ();
+ }
#endif
/* how are we running today? */
@@ -301,11 +319,12 @@ run (const gchar *name,
if (! gdk_init_check (NULL, NULL))
status = GIMP_PDB_CALLING_ERROR;
-#ifdef PLATFORM_OSX
- if (shootvals.shoot_type == SHOOT_WINDOW ||
- shootvals.shoot_type == SHOOT_REGION)
- status = GIMP_PDB_CALLING_ERROR;
-#endif
+ if (! (capabilities & SCREENSHOT_CAN_PICK_NONINTERACTIVELY))
+ {
+ if (shootvals.shoot_type == SHOOT_WINDOW ||
+ shootvals.shoot_type == SHOOT_REGION)
+ status = GIMP_PDB_CALLING_ERROR;
+ }
break;
case GIMP_RUN_WITH_LAST_VALS:
@@ -357,11 +376,16 @@ shoot (GdkScreen *screen,
gint32 *image_ID)
{
#ifdef PLATFORM_OSX
- return screenshot_osx_shoot (&shootvals, screen, image_ID);
+ if (backend == SCREENSHOT_BACKEND_OSX)
+ return screenshot_osx_shoot (&shootvals, screen, image_ID);
#endif
+ if (backend == SCREENSHOT_BACKEND_GNOME_SHELL)
+ return screenshot_gnome_shell_shoot (&shootvals, screen, image_ID);
+
#ifdef GDK_WINDOWING_X11
- return screenshot_x11_shoot (&shootvals, screen, image_ID);
+ if (backend == SCREENSHOT_BACKEND_X11)
+ return screenshot_x11_shoot (&shootvals, screen, image_ID);
#endif
return GIMP_PDB_CALLING_ERROR; /* silence compiler */
diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h
index 8841c0b..1848a50 100644
--- a/plug-ins/screenshot/screenshot.h
+++ b/plug-ins/screenshot/screenshot.h
@@ -21,8 +21,17 @@
typedef enum
{
- SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0,
- SCREENSHOT_CAN_SHOOT_POINTER = 0x1 << 1
+ SCREENSHOT_BACKEND_NONE,
+ SCREENSHOT_BACKEND_OSX,
+ SCREENSHOT_BACKEND_GNOME_SHELL,
+ SCREENSHOT_BACKEND_X11
+} ScreenshotBackend;
+
+typedef enum
+{
+ SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0,
+ SCREENSHOT_CAN_SHOOT_POINTER = 0x1 << 1,
+ SCREENSHOT_CAN_PICK_NONINTERACTIVELY = 0x1 << 2
} ScreenshotCapabilities;
typedef enum
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]