aboutsummaryrefslogtreecommitdiff
path: root/fastiv-view.c
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 /fastiv-view.c
parent11b796945941d33beff624dabdbb20fbc0aabe3c (diff)
downloadfiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.tar.gz
fiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.tar.xz
fiv-9bebb0a3fecb8fa8bca102f48d10e09e494a6b4d.zip
Make this work at all in macOS/Homebrew
Diffstat (limited to 'fastiv-view.c')
-rw-r--r--fastiv-view.c26
1 files changed, 22 insertions, 4 deletions
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;
}