[gnome-screenshot/wip/exalm/gtk4: 2/2] Drop X11 support
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-screenshot/wip/exalm/gtk4: 2/2] Drop X11 support
- Date: Mon, 21 Dec 2020 09:59:12 +0000 (UTC)
commit 0ba61788b4a10eb040d2d4e0814123cc95a4c677
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Oct 3 15:49:15 2020 +0500
Drop X11 support
meson.build | 11 -
meson_options.txt | 6 -
src/cheese-flash.c | 226 ----------------
src/cheese-flash.h | 46 ----
src/meson.build | 5 -
src/screenshot-area-selection.c | 231 +---------------
src/screenshot-backend-x11.c | 579 ----------------------------------------
src/screenshot-backend-x11.h | 33 ---
src/screenshot-utils.c | 33 +--
9 files changed, 4 insertions(+), 1166 deletions(-)
---
diff --git a/meson.build b/meson.build
index 3bfb619..bdc4332 100644
--- a/meson.build
+++ b/meson.build
@@ -34,8 +34,6 @@ gtk_req_version = '>= 3.12.0'
libhandy_req_version = '>= 0.90.0'
mathlib_dep = cc.find_library('m', required: false)
-x11_dep = dependency('x11', required: get_option ('x11'))
-xext_dep = dependency('xext', required: get_option ('x11'))
glib_dep = dependency('glib-2.0', version: glib_req_version)
gtk_dep = dependency('gtk+-3.0', version: gtk_req_version)
libhandy_dep = dependency('libhandy-1', version: libhandy_req_version)
@@ -45,15 +43,6 @@ config_h = configuration_data()
config_h.set_quoted('VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
-has_x11 = x11_dep.found() and xext_dep.found()
-if has_x11
- config_h.set('HAVE_X11', 1)
-
- if cc.has_header('X11/extensions/shape.h')
- config_h.set('HAVE_X11_EXTENSIONS_SHAPE_H', 1)
- endif
-endif
-
configure_file(output: 'config.h', configuration: config_h)
root_inc = include_directories('.')
diff --git a/src/meson.build b/src/meson.build
index 91b97e7..212e9bf 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,13 +1,10 @@
sources = [
'gnome-screenshot.c',
- 'cheese-flash.c',
-
'screenshot-application.c',
'screenshot-area-selection.c',
'screenshot-backend.c',
'screenshot-backend-shell.c',
- 'screenshot-backend-x11.c',
'screenshot-config.c',
'screenshot-dialog.c',
'screenshot-filename-builder.c',
@@ -22,8 +19,6 @@ include_directories = [
dependencies = [
mathlib_dep,
- x11_dep,
- xext_dep,
glib_dep,
gtk_dep,
libhandy_dep,
diff --git a/src/screenshot-area-selection.c b/src/screenshot-area-selection.c
index 224d93d..eae754f 100644
--- a/src/screenshot-area-selection.c
+++ b/src/screenshot-area-selection.c
@@ -24,183 +24,6 @@
#include "screenshot-area-selection.h"
-typedef struct {
- GdkRectangle rect;
- gboolean button_pressed;
- GtkWidget *window;
-
- gboolean aborted;
-} select_area_filter_data;
-
-static gboolean
-select_area_button_press (GtkWidget *window,
- GdkEventButton *event,
- select_area_filter_data *data)
-{
- if (data->button_pressed)
- return TRUE;
-
- data->button_pressed = TRUE;
- data->rect.x = event->x_root;
- data->rect.y = event->y_root;
-
- return TRUE;
-}
-
-static gboolean
-select_area_motion_notify (GtkWidget *window,
- GdkEventMotion *event,
- select_area_filter_data *data)
-{
- GdkRectangle draw_rect;
-
- if (!data->button_pressed)
- return TRUE;
-
- draw_rect.width = ABS (data->rect.x - event->x_root);
- draw_rect.height = ABS (data->rect.y - event->y_root);
- draw_rect.x = MIN (data->rect.x, event->x_root);
- draw_rect.y = MIN (data->rect.y, event->y_root);
-
- if (draw_rect.width <= 0 || draw_rect.height <= 0)
- {
- gtk_window_move (GTK_WINDOW (window), -100, -100);
- gtk_window_resize (GTK_WINDOW (window), 10, 10);
- return TRUE;
- }
-
- gtk_window_move (GTK_WINDOW (window), draw_rect.x, draw_rect.y);
- gtk_window_resize (GTK_WINDOW (window), draw_rect.width, draw_rect.height);
-
- /* We (ab)use app-paintable to indicate if we have an RGBA window */
- if (!gtk_widget_get_app_paintable (window))
- {
- GdkWindow *gdkwindow = gtk_widget_get_window (window);
-
- /* Shape the window to make only the outline visible */
- if (draw_rect.width > 2 && draw_rect.height > 2)
- {
- cairo_region_t *region;
- cairo_rectangle_int_t region_rect = {
- 0, 0,
- draw_rect.width, draw_rect.height
- };
-
- region = cairo_region_create_rectangle (®ion_rect);
- region_rect.x++;
- region_rect.y++;
- region_rect.width -= 2;
- region_rect.height -= 2;
- cairo_region_subtract_rectangle (region, ®ion_rect);
-
- gdk_window_shape_combine_region (gdkwindow, region, 0, 0);
-
- cairo_region_destroy (region);
- }
- else
- gdk_window_shape_combine_region (gdkwindow, NULL, 0, 0);
- }
-
- return TRUE;
-}
-
-static gboolean
-select_area_button_release (GtkWidget *window,
- GdkEventButton *event,
- select_area_filter_data *data)
-{
- if (!data->button_pressed)
- return TRUE;
-
- data->rect.width = ABS (data->rect.x - event->x_root);
- data->rect.height = ABS (data->rect.y - event->y_root);
- data->rect.x = MIN (data->rect.x, event->x_root);
- data->rect.y = MIN (data->rect.y, event->y_root);
-
- if (data->rect.width == 0 || data->rect.height == 0)
- data->aborted = TRUE;
-
- gtk_main_quit ();
-
- return TRUE;
-}
-
-static gboolean
-select_area_key_press (GtkWidget *window,
- GdkEventKey *event,
- select_area_filter_data *data)
-{
- if (event->keyval == GDK_KEY_Escape)
- {
- data->rect.x = 0;
- data->rect.y = 0;
- data->rect.width = 0;
- data->rect.height = 0;
- data->aborted = TRUE;
-
- gtk_main_quit ();
- }
-
- return TRUE;
-}
-
-static gboolean
-select_window_draw (GtkWidget *window, cairo_t *cr, gpointer unused)
-{
- GtkStyleContext *style;
-
- style = gtk_widget_get_style_context (window);
-
- if (gtk_widget_get_app_paintable (window))
- {
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_rgba (cr, 0, 0, 0, 0);
- cairo_paint (cr);
-
- gtk_style_context_save (style);
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_RUBBERBAND);
-
- gtk_render_background (style, cr,
- 0, 0,
- gtk_widget_get_allocated_width (window),
- gtk_widget_get_allocated_height (window));
- gtk_render_frame (style, cr,
- 0, 0,
- gtk_widget_get_allocated_width (window),
- gtk_widget_get_allocated_height (window));
-
- gtk_style_context_restore (style);
- }
-
- return TRUE;
-}
-
-static GtkWidget *
-create_select_window (void)
-{
- GtkWidget *window;
- GdkScreen *screen;
- GdkVisual *visual;
-
- screen = gdk_screen_get_default ();
- visual = gdk_screen_get_rgba_visual (screen);
-
- window = gtk_window_new (GTK_WINDOW_POPUP);
- if (gdk_screen_is_composited (screen) && visual)
- {
- gtk_widget_set_visual (window, visual);
- gtk_widget_set_app_paintable (window, TRUE);
- }
-
- g_signal_connect (window, "draw", G_CALLBACK (select_window_draw), NULL);
-
- gtk_window_move (GTK_WINDOW (window), -100, -100);
- gtk_window_resize (GTK_WINDOW (window), 10, 10);
- gtk_widget_show (window);
-
- return window;
-}
-
typedef struct {
GdkRectangle rectangle;
SelectAreaCallback callback;
@@ -223,56 +46,6 @@ emit_select_callback_in_idle (gpointer user_data)
return FALSE;
}
-static void
-screenshot_select_area_x11_async (CallbackData *cb_data)
-{
- g_autoptr(GdkCursor) cursor = NULL;
- GdkDisplay *display;
- select_area_filter_data data;
- GdkSeat *seat;
-
- data.rect.x = 0;
- data.rect.y = 0;
- data.rect.width = 0;
- data.rect.height = 0;
- data.button_pressed = FALSE;
- data.aborted = FALSE;
- data.window = create_select_window();
-
- g_signal_connect (data.window, "key-press-event", G_CALLBACK (select_area_key_press), &data);
- g_signal_connect (data.window, "button-press-event", G_CALLBACK (select_area_button_press), &data);
- g_signal_connect (data.window, "button-release-event", G_CALLBACK (select_area_button_release), &data);
- g_signal_connect (data.window, "motion-notify-event", G_CALLBACK (select_area_motion_notify), &data);
-
- display = gtk_widget_get_display (data.window);
- cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
- seat = gdk_display_get_default_seat (display);
-
- gdk_seat_grab (seat,
- gtk_widget_get_window (data.window),
- GDK_SEAT_CAPABILITY_ALL,
- FALSE,
- cursor,
- NULL,
- NULL,
- NULL);
-
- gtk_main ();
-
- gdk_seat_ungrab (seat);
-
- gtk_widget_destroy (data.window);
-
- cb_data->aborted = data.aborted;
- cb_data->rectangle = data.rect;
-
- /* FIXME: we should actually be emitting the callback When
- * the compositor has finished re-drawing, but there seems to be no easy
- * way to know that.
- */
- g_timeout_add (200, emit_select_callback_in_idle, cb_data);
-}
-
static void
select_area_done (GObject *source_object,
GAsyncResult *res,
@@ -292,10 +65,8 @@ select_area_done (GObject *source_object,
return;
}
- g_message ("Unable to select area using GNOME Shell's builtin screenshot "
- "interface, resorting to fallback X11.");
+ g_message ("Unable to select area.");
- screenshot_select_area_x11_async (cb_data);
return;
}
diff --git a/src/screenshot-utils.c b/src/screenshot-utils.c
index 09ff4af..9279e94 100644
--- a/src/screenshot-utils.c
+++ b/src/screenshot-utils.c
@@ -29,10 +29,6 @@
#include "screenshot-backend-shell.h"
-#ifdef HAVE_X11
-#include "screenshot-backend-x11.h"
-#endif
-
void
screenshot_play_sound_effect (const gchar *event_id,
const gchar *event_desc)
@@ -69,36 +65,13 @@ GdkPixbuf *
screenshot_get_pixbuf (GdkRectangle *rectangle)
{
GdkPixbuf *screenshot = NULL;
- gboolean force_fallback = FALSE;
g_autoptr (ScreenshotBackend) backend = NULL;
-#ifdef HAVE_X11
- force_fallback = g_getenv ("GNOME_SCREENSHOT_FORCE_FALLBACK") != NULL;
-#endif
-
- if (!force_fallback)
- {
- backend = screenshot_backend_shell_new ();
- screenshot = screenshot_backend_get_pixbuf (backend, rectangle);
- if (!screenshot)
-#ifdef HAVE_X11
- g_message ("Unable to use GNOME Shell's builtin screenshot interface, "
- "resorting to fallback X11.");
-#else
- g_message ("Unable to use GNOME Shell's builtin screenshot interface.");
-#endif
- }
- else
- g_message ("Using fallback X11 as requested");
+ backend = screenshot_backend_shell_new ();
+ screenshot = screenshot_backend_get_pixbuf (backend, rectangle);
-#ifdef HAVE_X11
if (!screenshot)
- {
- g_clear_object (&backend);
- backend = screenshot_backend_x11_new ();
- screenshot = screenshot_backend_get_pixbuf (backend, rectangle);
- }
-#endif
+ g_message ("Unable to use GNOME Shell's builtin screenshot interface.");
return screenshot;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]