Make this work at all in macOS/Homebrew

This commit is contained in:
Přemysl Eric Janouch 2021-11-16 07:38:42 +01:00
parent 11b7969459
commit 9bebb0a3fe
Signed by: p
GPG Key ID: A0420B94F92B9493
4 changed files with 39 additions and 9 deletions

View File

@ -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

View File

@ -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)

View File

@ -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;
}

View File

@ -22,6 +22,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fnmatch.h>