Commit a1785e98 authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 0119e284
......@@ -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
/* 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;
}
/* 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__ */
......@@ -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)
{
......
......@@ -21,6 +21,8 @@
#ifdef PLATFORM_OSX
gboolean screenshot_osx_available (void);
ScreenshotCapabilities screenshot_osx_get_capabilities (void);
GimpPDBStatusType screenshot_osx_shoot (ScreenshotValues *shootvals,
......
......@@ -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;
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment