From 9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d Mon Sep 17 00:00:00 2001
From: Přemysl Eric Janouch
Date: Tue, 16 Nov 2021 07:38:42 +0100
Subject: Make this work at all in macOS/Homebrew
---
README.adoc | 4 ++--
fastiv-io.c | 17 ++++++++++++++---
fastiv-view.c | 26 ++++++++++++++++++++++----
fastiv.c | 1 +
4 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/README.adoc b/README.adoc
index f196ef2..dde19d4 100644
--- a/README.adoc
+++ b/README.adoc
@@ -18,8 +18,8 @@ a package with the latest development version from Archlinux's AUR.
Building and Running
--------------------
Build dependencies: Meson, pkg-config +
-Runtime dependencies: gtk+-3.0, pixman-1, shared-mime-info, spng>=0.7.0,
-libturbojpeg, LibRaw (optional), librsvg-2.0 (optional),
+Runtime dependencies: gtk+-3.0, glib>=2.64, pixman-1, shared-mime-info,
+spng>=0.7.0, libturbojpeg, LibRaw (optional), librsvg-2.0 (optional),
gdk-pixbuf-2.0 (optional)
$ git clone --recursive https://git.janouch.name/p/fastiv.git
diff --git a/fastiv-io.c b/fastiv-io.c
index d02c2fe..ee43cd8 100644
--- a/fastiv-io.c
+++ b/fastiv-io.c
@@ -18,7 +18,11 @@
#include "config.h"
#include
+#include
#include
+#include
+
+#include
#include
#ifdef HAVE_LIBRAW
#include
@@ -44,9 +48,6 @@
#define WUFFS_CONFIG__MODULE__ZLIB
#include "wuffs-mirror-release-c/release/c/wuffs-v0.3.c"
-#include
-#include
-
#include "xdg.h"
#include "fastiv-io.h"
@@ -495,7 +496,13 @@ open_librsvg(const gchar *data, gsize len, const gchar *path, GError **error)
rsvg_handle_set_dpi(handle, 96);
double w = 0, h = 0;
+#if LIBRSVG_CHECK_VERSION(2, 51, 0)
if (!rsvg_handle_get_intrinsic_size_in_pixels(handle, &w, &h)) {
+#else
+ RsvgDimensionData dd = {};
+ rsvg_handle_get_dimensions(handle, &dd);
+ if ((w = dd.width) <= 0 || (h = dd.height) <= 0) {
+#endif
RsvgRectangle viewbox = {};
gboolean has_viewport = FALSE;
rsvg_handle_get_intrinsic_dimensions(handle, NULL, NULL, NULL, NULL,
@@ -675,6 +682,10 @@ fastiv_io_open_from_data(const char *data, size_t len, const gchar *path,
// --- Thumbnails --------------------------------------------------------------
+#ifndef __linux__
+#define st_mtim st_mtimespec
+#endif // ! __linux__
+
static int // tri-state
check_spng_thumbnail_texts(struct spng_text *texts, uint32_t texts_len,
const gchar *target, time_t mtime)
diff --git a/fastiv-view.c b/fastiv-view.c
index a9ba5cf..f55fd49 100644
--- a/fastiv-view.c
+++ b/fastiv-view.c
@@ -18,6 +18,14 @@
#include
#include
+#include
+#ifdef GDK_WINDOWING_X11
+#include
+#endif // GDK_WINDOWING_X11
+#ifdef GDK_WINDOWING_QUARTZ
+#include
+#endif // GDK_WINDOWING_QUARTZ
+
#include "fastiv-io.h"
#include "fastiv-view.h"
@@ -178,13 +186,17 @@ fastiv_view_realize(GtkWidget *widget)
// We need this window to receive input events at all.
GdkWindow *window = gdk_window_new(gtk_widget_get_parent_window(widget),
&attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL);
+
+ // Without the following call, or the rendering mode set to "recording",
+ // RGB30 degrades to RGB24. It completely breaks the Quartz backend.
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_WINDOW(window))
+ gdk_window_ensure_native(window);
+#endif // GDK_WINDOWING_X11
+
gtk_widget_register_window(widget, window);
gtk_widget_set_window(widget, window);
gtk_widget_set_realized(widget, TRUE);
-
- // Without the following call, or the rendering mode set to "recording",
- // RGB30 degrades to RGB24.
- gdk_window_ensure_native(window);
}
static gboolean
@@ -241,6 +253,12 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
// TODO(p): Prescale it ourselves to an off-screen bitmap, gamma-correctly.
cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
+#ifdef GDK_WINDOWING_QUARTZ
+ // Not supported there. Acts a bit like repeating, but weirdly offset.
+ if (GDK_IS_QUARTZ_WINDOW(gtk_widget_get_window(widget)))
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
+#endif // GDK_WINDOWING_QUARTZ
+
cairo_paint(cr);
return TRUE;
}
diff --git a/fastiv.c b/fastiv.c
index f5fd463..4d2da78 100644
--- a/fastiv.c
+++ b/fastiv.c
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
--
cgit v1.2.3-70-g09d2