9cc5e2
From 7b5ee288d992f85eaefbfbc4dac663a29fcae446 Mon Sep 17 00:00:00 2001
9cc5e2
From: Ray Strode <rstrode@redhat.com>
9cc5e2
Date: Wed, 5 May 2021 11:06:58 -0400
9cc5e2
Subject: [PATCH] 0001-utils-Drop-gdm-screenshot.patch
9cc5e2
9cc5e2
---
9cc5e2
 utils/gdm-screenshot.c | 296 -----------------------------------------
9cc5e2
 utils/meson.build      |  15 ---
9cc5e2
 2 files changed, 311 deletions(-)
9cc5e2
 delete mode 100644 utils/gdm-screenshot.c
9cc5e2
9cc5e2
diff --git a/utils/gdm-screenshot.c b/utils/gdm-screenshot.c
9cc5e2
deleted file mode 100644
9cc5e2
index 5d20929a3..000000000
9cc5e2
--- a/utils/gdm-screenshot.c
9cc5e2
+++ /dev/null
9cc5e2
@@ -1,296 +0,0 @@
9cc5e2
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
9cc5e2
- *
9cc5e2
- * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
9cc5e2
- *
9cc5e2
- * This program is free software; you can redistribute it and/or modify
9cc5e2
- * it under the terms of the GNU General Public License as published by
9cc5e2
- * the Free Software Foundation; either version 2 of the License, or
9cc5e2
- * (at your option) any later version.
9cc5e2
- *
9cc5e2
- * This program is distributed in the hope that it will be useful,
9cc5e2
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9cc5e2
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9cc5e2
- * GNU General Public License for more details.
9cc5e2
- *
9cc5e2
- * You should have received a copy of the GNU General Public License
9cc5e2
- * along with this program; if not, write to the Free Software
9cc5e2
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9cc5e2
- *
9cc5e2
- */
9cc5e2
-
9cc5e2
-#include "config.h"
9cc5e2
-
9cc5e2
-#include <stdlib.h>
9cc5e2
-#include <stdio.h>
9cc5e2
-#include <unistd.h>
9cc5e2
-#include <string.h>
9cc5e2
-#include <locale.h>
9cc5e2
-
9cc5e2
-#include <glib/gi18n.h>
9cc5e2
-#include <gtk/gtk.h>
9cc5e2
-#include <canberra-gtk.h>
9cc5e2
-
9cc5e2
-#include <X11/Xatom.h>
9cc5e2
-#include <gdk/gdkx.h>
9cc5e2
-
9cc5e2
-#define SELECTION_NAME "_GDM_SCREENSHOT"
9cc5e2
-static GtkWidget *selection_window;
9cc5e2
-
9cc5e2
-static gboolean debug_in;
9cc5e2
-
9cc5e2
-/* Keep all config options for compatibility even if they are noops */
9cc5e2
-GOptionEntry options [] = {
9cc5e2
-        { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_in, N_("Debugging output"), NULL },
9cc5e2
-        { NULL }
9cc5e2
-};
9cc5e2
-
9cc5e2
-/* To make sure there is only one screenshot taken at a time,
9cc5e2
- * (Imagine key repeat for the print screen key) we hold a selection
9cc5e2
- * until we are done taking the screenshot
9cc5e2
- */
9cc5e2
-/*  * Copyright (C) 2001-2006  Jonathan Blandford <jrb@alum.mit.edu> */
9cc5e2
-static gboolean
9cc5e2
-screenshot_grab_lock (void)
9cc5e2
-{
9cc5e2
-        Atom       selection_atom;
9cc5e2
-        GdkCursor *cursor;
9cc5e2
-        gboolean   result = FALSE;
9cc5e2
-
9cc5e2
-        selection_atom = gdk_x11_get_xatom_by_name (SELECTION_NAME);
9cc5e2
-        XGrabServer (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
9cc5e2
-        if (XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), selection_atom) != None) {
9cc5e2
-                goto out;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        selection_window = gtk_invisible_new ();
9cc5e2
-        gtk_widget_show (selection_window);
9cc5e2
-
9cc5e2
-        if (!gtk_selection_owner_set (selection_window,
9cc5e2
-                                      gdk_atom_intern (SELECTION_NAME, FALSE),
9cc5e2
-                                      GDK_CURRENT_TIME)) {
9cc5e2
-                gtk_widget_destroy (selection_window);
9cc5e2
-                selection_window = NULL;
9cc5e2
-                goto out;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_WATCH);
9cc5e2
-        gdk_pointer_grab (gtk_widget_get_window (selection_window), FALSE, 0, NULL,
9cc5e2
-                          cursor, GDK_CURRENT_TIME);
9cc5e2
-        g_object_unref (cursor);
9cc5e2
-
9cc5e2
-        result = TRUE;
9cc5e2
-
9cc5e2
- out:
9cc5e2
-        XUngrabServer (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
9cc5e2
-        gdk_flush ();
9cc5e2
-
9cc5e2
-        return result;
9cc5e2
-}
9cc5e2
-
9cc5e2
-/*  * Copyright (C) 2001-2006  Jonathan Blandford <jrb@alum.mit.edu> */
9cc5e2
-static void
9cc5e2
-screenshot_release_lock (void)
9cc5e2
-{
9cc5e2
-        if (selection_window != NULL) {
9cc5e2
-                gtk_widget_destroy (selection_window);
9cc5e2
-                selection_window = NULL;
9cc5e2
-        }
9cc5e2
-        gdk_flush ();
9cc5e2
-}
9cc5e2
-
9cc5e2
-/*  * Copyright (C) 2001-2006  Jonathan Blandford <jrb@alum.mit.edu> */
9cc5e2
-static GdkPixbuf *
9cc5e2
-screenshot_get_pixbuf (Window w)
9cc5e2
-{
9cc5e2
-        GdkWindow *window;
9cc5e2
-        GdkWindow *root;
9cc5e2
-        GdkPixbuf *screenshot;
9cc5e2
-        int        x_real_orig;
9cc5e2
-        int        y_real_orig;
9cc5e2
-        int        x_orig;
9cc5e2
-        int        y_orig;
9cc5e2
-        int        real_width;
9cc5e2
-        int        real_height;
9cc5e2
-        int        width;
9cc5e2
-        int        height;
9cc5e2
-
9cc5e2
-        window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), w);
9cc5e2
-        if (window == NULL) {
9cc5e2
-                return NULL;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        root = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), GDK_ROOT_WINDOW ());
9cc5e2
-        gdk_window_get_geometry (window, NULL, NULL, &real_width, &real_height);
9cc5e2
-        gdk_window_get_origin (window, &x_real_orig, &y_real_orig);
9cc5e2
-
9cc5e2
-        x_orig = x_real_orig;
9cc5e2
-        y_orig = y_real_orig;
9cc5e2
-        width = real_width;
9cc5e2
-        height = real_height;
9cc5e2
-
9cc5e2
-        if (x_orig < 0) {
9cc5e2
-                width = width + x_orig;
9cc5e2
-                x_orig = 0;
9cc5e2
-        }
9cc5e2
-        if (y_orig < 0) {
9cc5e2
-                height = height + y_orig;
9cc5e2
-                y_orig = 0;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        if (x_orig + width > gdk_screen_width ()) {
9cc5e2
-                width = gdk_screen_width () - x_orig;
9cc5e2
-        }
9cc5e2
-        if (y_orig + height > gdk_screen_height ()) {
9cc5e2
-                height = gdk_screen_height () - y_orig;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        screenshot = gdk_pixbuf_get_from_window (root,
9cc5e2
-                                                 x_orig,
9cc5e2
-                                                 y_orig,
9cc5e2
-                                                 width,
9cc5e2
-                                                 height);
9cc5e2
-
9cc5e2
-        return screenshot;
9cc5e2
-}
9cc5e2
-
9cc5e2
-static char *
9cc5e2
-screenshot_save (GdkPixbuf *pixbuf)
9cc5e2
-{
9cc5e2
-        char       *filename;
9cc5e2
-        gboolean    res;
9cc5e2
-        GError     *error;
9cc5e2
-
9cc5e2
-        filename = g_build_filename (GDM_SCREENSHOT_DIR,
9cc5e2
-                                     "GDM-Screenshot.png",
9cc5e2
-                                     NULL);
9cc5e2
-
9cc5e2
-        error = NULL;
9cc5e2
-        res = gdk_pixbuf_save (pixbuf,
9cc5e2
-                               filename,
9cc5e2
-                               "png",
9cc5e2
-                               &error,
9cc5e2
-                               "tEXt::CREATOR", "gdm-screenshot",
9cc5e2
-                               NULL);
9cc5e2
-        if (! res) {
9cc5e2
-                g_warning ("Unable to save screenshot: %s", error->message);
9cc5e2
-                g_error_free (error);
9cc5e2
-                g_free (filename);
9cc5e2
-                filename = NULL;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        return filename;
9cc5e2
-}
9cc5e2
-
9cc5e2
-static void
9cc5e2
-sound_effect_finished (ca_context *c,
9cc5e2
-                       uint32_t    id,
9cc5e2
-                       int         error_code,
9cc5e2
-                       void       *userdata)
9cc5e2
-{
9cc5e2
-}
9cc5e2
-
9cc5e2
-static void
9cc5e2
-play_sound_effect (Window xid)
9cc5e2
-{
9cc5e2
-        ca_context  *c;
9cc5e2
-        ca_proplist *p;
9cc5e2
-        int          res;
9cc5e2
-
9cc5e2
-        c = ca_gtk_context_get ();
9cc5e2
-
9cc5e2
-        p = NULL;
9cc5e2
-        res = ca_proplist_create (&p);
9cc5e2
-        if (res < 0) {
9cc5e2
-                goto done;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        res = ca_proplist_sets (p, CA_PROP_EVENT_ID, "screen-capture");
9cc5e2
-        if (res < 0) {
9cc5e2
-                goto done;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        res = ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, _("Screenshot taken"));
9cc5e2
-        if (res < 0) {
9cc5e2
-                goto done;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        res = ca_proplist_setf (p,
9cc5e2
-                                CA_PROP_WINDOW_X11_XID,
9cc5e2
-                                "%lu",
9cc5e2
-                                (unsigned long) xid);
9cc5e2
-        if (res < 0) {
9cc5e2
-                goto done;
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        ca_context_play_full (c, 0, p, sound_effect_finished, NULL);
9cc5e2
-
9cc5e2
- done:
9cc5e2
-        if (p != NULL) {
9cc5e2
-                ca_proplist_destroy (p);
9cc5e2
-        }
9cc5e2
-
9cc5e2
-}
9cc5e2
-
9cc5e2
-static void
9cc5e2
-prepare_screenshot (void)
9cc5e2
-{
9cc5e2
-        Window     win;
9cc5e2
-        GdkPixbuf *screenshot;
9cc5e2
-        char      *filename;
9cc5e2
-
9cc5e2
-        if (!screenshot_grab_lock ()) {
9cc5e2
-                exit (EXIT_SUCCESS);
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        win = GDK_ROOT_WINDOW ();
9cc5e2
-
9cc5e2
-        screenshot = screenshot_get_pixbuf (win);
9cc5e2
-
9cc5e2
-        screenshot_release_lock ();
9cc5e2
-
9cc5e2
-        if (screenshot == NULL) {
9cc5e2
-                /* FIXME: dialog? */
9cc5e2
-                exit (EXIT_FAILURE);
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        play_sound_effect (win);
9cc5e2
-
9cc5e2
-        filename = screenshot_save (screenshot);
9cc5e2
-        if (filename != NULL) {
9cc5e2
-                g_print ("Wrote %s\n", filename);
9cc5e2
-                /* FIXME: show a dialog or something */
9cc5e2
-                g_free (filename);
9cc5e2
-        }
9cc5e2
-}
9cc5e2
-
9cc5e2
-int
9cc5e2
-main (int argc, char *argv[])
9cc5e2
-{
9cc5e2
-        GOptionContext *ctx;
9cc5e2
-        gboolean        res;
9cc5e2
-        GError         *error;
9cc5e2
-
9cc5e2
-        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
9cc5e2
-        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
9cc5e2
-        textdomain (GETTEXT_PACKAGE);
9cc5e2
-        setlocale (LC_ALL, "");
9cc5e2
-
9cc5e2
-        /* Option parsing */
9cc5e2
-        ctx = g_option_context_new (N_("Take a picture of the screen"));
9cc5e2
-        g_option_context_set_translation_domain (ctx, GETTEXT_PACKAGE);
9cc5e2
-        g_option_context_add_main_entries (ctx, options, NULL);
9cc5e2
-        g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
9cc5e2
-        error = NULL;
9cc5e2
-        res = g_option_context_parse (ctx, &argc, &argv, &error);
9cc5e2
-        g_option_context_free (ctx);
9cc5e2
-
9cc5e2
-        if (! res) {
9cc5e2
-                g_warning ("%s", error->message);
9cc5e2
-                g_error_free (error);
9cc5e2
-                exit (EXIT_FAILURE);
9cc5e2
-        }
9cc5e2
-
9cc5e2
-        prepare_screenshot ();
9cc5e2
-
9cc5e2
-        return 1;
9cc5e2
-}
9cc5e2
diff --git a/utils/meson.build b/utils/meson.build
9cc5e2
index d59f167b0..1edd7bce4 100644
9cc5e2
--- a/utils/meson.build
9cc5e2
+++ b/utils/meson.build
9cc5e2
@@ -1,41 +1,26 @@
9cc5e2
 # gdm-flexiserver
9cc5e2
 gdm_flexiserver_deps = [
9cc5e2
   glib_dep,
9cc5e2
   libgdmcommon_dep,
9cc5e2
 ]
9cc5e2
 
9cc5e2
 gdm_flexiserver = executable('gdmflexiserver',
9cc5e2
   'gdmflexiserver.c',
9cc5e2
   dependencies: gdm_flexiserver_deps,
9cc5e2
   include_directories: config_h_dir,
9cc5e2
   install: true,
9cc5e2
 )
9cc5e2
 
9cc5e2
-# gdm-screenshot
9cc5e2
-gdm_screenshot_deps = [
9cc5e2
-  glib_dep,
9cc5e2
-  gtk_dep,
9cc5e2
-  x_deps,
9cc5e2
-  libcanberra_gtk_dep,
9cc5e2
-]
9cc5e2
-
9cc5e2
-gdm_screenshot = executable('gdm-screenshot',
9cc5e2
-  'gdm-screenshot.c',
9cc5e2
-  dependencies: gdm_screenshot_deps,
9cc5e2
-  include_directories: config_h_dir,
9cc5e2
-  install: true,
9cc5e2
-)
9cc5e2
-
9cc5e2
 # gdm-runtime-config
9cc5e2
 gdm_runtime_config_deps = [
9cc5e2
   glib_dep,
9cc5e2
 ]
9cc5e2
 
9cc5e2
 gdm_runtime_config = executable('gdm-runtime-config',
9cc5e2
   'gdm-runtime-config.c',
9cc5e2
   dependencies: gdm_runtime_config_deps,
9cc5e2
   include_directories: config_h_dir,
9cc5e2
   install: true,
9cc5e2
   install_dir: get_option('libexecdir'),
9cc5e2
 )
9cc5e2
 
9cc5e2
-- 
9cc5e2
2.31.1
9cc5e2