Make this work at all in macOS/Homebrew
This commit is contained in:
		@@ -18,8 +18,8 @@ a package with the latest development version from Archlinux's AUR.
 | 
				
			|||||||
Building and Running
 | 
					Building and Running
 | 
				
			||||||
--------------------
 | 
					--------------------
 | 
				
			||||||
Build dependencies: Meson, pkg-config +
 | 
					Build dependencies: Meson, pkg-config +
 | 
				
			||||||
Runtime dependencies: gtk+-3.0, pixman-1, shared-mime-info, spng>=0.7.0,
 | 
					Runtime dependencies: gtk+-3.0, glib>=2.64, pixman-1, shared-mime-info,
 | 
				
			||||||
libturbojpeg, LibRaw (optional), librsvg-2.0 (optional),
 | 
					spng>=0.7.0, libturbojpeg, LibRaw (optional), librsvg-2.0 (optional),
 | 
				
			||||||
gdk-pixbuf-2.0 (optional)
 | 
					gdk-pixbuf-2.0 (optional)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 $ git clone --recursive https://git.janouch.name/p/fastiv.git
 | 
					 $ git clone --recursive https://git.janouch.name/p/fastiv.git
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										17
									
								
								fastiv-io.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								fastiv-io.c
									
									
									
									
									
								
							@@ -18,7 +18,11 @@
 | 
				
			|||||||
#include "config.h"
 | 
					#include "config.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <cairo.h>
 | 
					#include <cairo.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
#include <glib.h>
 | 
					#include <glib.h>
 | 
				
			||||||
 | 
					#include <glib/gstdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <spng.h>
 | 
				
			||||||
#include <turbojpeg.h>
 | 
					#include <turbojpeg.h>
 | 
				
			||||||
#ifdef HAVE_LIBRAW
 | 
					#ifdef HAVE_LIBRAW
 | 
				
			||||||
#include <libraw.h>
 | 
					#include <libraw.h>
 | 
				
			||||||
@@ -44,9 +48,6 @@
 | 
				
			|||||||
#define WUFFS_CONFIG__MODULE__ZLIB
 | 
					#define WUFFS_CONFIG__MODULE__ZLIB
 | 
				
			||||||
#include "wuffs-mirror-release-c/release/c/wuffs-v0.3.c"
 | 
					#include "wuffs-mirror-release-c/release/c/wuffs-v0.3.c"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <glib/gstdio.h>
 | 
					 | 
				
			||||||
#include <spng.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "xdg.h"
 | 
					#include "xdg.h"
 | 
				
			||||||
#include "fastiv-io.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);
 | 
						rsvg_handle_set_dpi(handle, 96);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	double w = 0, h = 0;
 | 
						double w = 0, h = 0;
 | 
				
			||||||
 | 
					#if LIBRSVG_CHECK_VERSION(2, 51, 0)
 | 
				
			||||||
	if (!rsvg_handle_get_intrinsic_size_in_pixels(handle, &w, &h)) {
 | 
						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 = {};
 | 
							RsvgRectangle viewbox = {};
 | 
				
			||||||
		gboolean has_viewport = FALSE;
 | 
							gboolean has_viewport = FALSE;
 | 
				
			||||||
		rsvg_handle_get_intrinsic_dimensions(handle, NULL, NULL, NULL, NULL,
 | 
							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 --------------------------------------------------------------
 | 
					// --- Thumbnails --------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __linux__
 | 
				
			||||||
 | 
					#define st_mtim st_mtimespec
 | 
				
			||||||
 | 
					#endif  // ! __linux__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int  // tri-state
 | 
					static int  // tri-state
 | 
				
			||||||
check_spng_thumbnail_texts(struct spng_text *texts, uint32_t texts_len,
 | 
					check_spng_thumbnail_texts(struct spng_text *texts, uint32_t texts_len,
 | 
				
			||||||
	const gchar *target, time_t mtime)
 | 
						const gchar *target, time_t mtime)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,14 @@
 | 
				
			|||||||
#include <math.h>
 | 
					#include <math.h>
 | 
				
			||||||
#include <stdbool.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-io.h"
 | 
				
			||||||
#include "fastiv-view.h"
 | 
					#include "fastiv-view.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -178,13 +186,17 @@ fastiv_view_realize(GtkWidget *widget)
 | 
				
			|||||||
	// We need this window to receive input events at all.
 | 
						// We need this window to receive input events at all.
 | 
				
			||||||
	GdkWindow *window = gdk_window_new(gtk_widget_get_parent_window(widget),
 | 
						GdkWindow *window = gdk_window_new(gtk_widget_get_parent_window(widget),
 | 
				
			||||||
		&attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL);
 | 
							&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_register_window(widget, window);
 | 
				
			||||||
	gtk_widget_set_window(widget, window);
 | 
						gtk_widget_set_window(widget, window);
 | 
				
			||||||
	gtk_widget_set_realized(widget, TRUE);
 | 
						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
 | 
					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.
 | 
						// TODO(p): Prescale it ourselves to an off-screen bitmap, gamma-correctly.
 | 
				
			||||||
	cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
 | 
						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);
 | 
						cairo_paint(cr);
 | 
				
			||||||
	return TRUE;
 | 
						return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user