aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-16 07:38:42 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-16 08:51:29 +0100
commit9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d (patch)
tree0cdf448899f2c2714d2ffd00b83c1b2541ac4afc
parent11b796945941d33beff624dabdbb20fbc0aabe3c (diff)
downloadfiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.tar.gz
fiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.tar.xz
fiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.zip
Make this work at all in macOS/Homebrew
-rw-r--r--README.adoc4
-rw-r--r--fastiv-io.c17
-rw-r--r--fastiv-view.c26
-rw-r--r--fastiv.c1
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 <cairo.h>
+#include <errno.h>
#include <glib.h>
+#include <glib/gstdio.h>
+
+#include <spng.h>
#include <turbojpeg.h>
#ifdef HAVE_LIBRAW
#include <libraw.h>
@@ -44,9 +48,6 @@
#define WUFFS_CONFIG__MODULE__ZLIB
#include "wuffs-mirror-release-c/release/c/wuffs-v0.3.c"
-#include <glib/gstdio.h>
-#include <spng.h>
-
#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 <math.h>
#include <stdbool.h>
+#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif // GDK_WINDOWING_X11
+#ifdef GDK_WINDOWING_QUARTZ
+#include <gdk/gdkquartz.h>
+#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 <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <errno.h>
#include <fnmatch.h>