--- a/ui/gtk/draw_cairo.c Mon Sep 16 22:09:32 2024 +0200 +++ b/ui/gtk/draw_cairo.c Tue Sep 17 22:00:07 2024 +0200 @@ -33,17 +33,19 @@ #include "draw_cairo.h" -#if UI_GTK3 || UI_GTK4 -gboolean ui_drawingarea_expose(GtkWidget *w, cairo_t *cr, void *data) { + +#if GTK_MAJOR_VERSION >= 3 +static void ui_drawingarea_draw( + GtkDrawingArea *area, + cairo_t *cr, + int width, + int height, + gpointer data) +{ UiCairoGraphics g; -#ifdef UI_GTK4 - g.g.width = gtk_widget_get_width(w); - g.g.height = gtk_widget_get_height(w); -#else - g.g.width = gtk_widget_get_allocated_width(w); - g.g.height = gtk_widget_get_allocated_height(w); -#endif - g.widget = w; + g.g.width = width; + g.g.height = height; + g.widget = GTK_WIDGET(area); g.cr = cr; UiDrawEvent *event = data; @@ -53,7 +55,14 @@ ev.document = event->obj->ctx->document; event->callback(&ev, &g.g, event->userdata); - +} +#endif + +#if UI_GTK3 +gboolean ui_drawingarea_expose(GtkWidget *w, cairo_t *cr, void *data) { + int width = gtk_widget_get_allocated_width(w); + int height = gtk_widget_get_allocated_height(w); + ui_drawingarea_draw(w, cr, width, height, data); return FALSE; } #endif @@ -80,7 +89,9 @@ // function from graphics.h void ui_connect_draw_handler(GtkWidget *widget, UiDrawEvent *event) { -#if UI_GTK3 || UI_GTK4 +#if GTK_MAJOR_VERSION >= 4 + gtk_drawing_area_set_draw_func(GTK_DRAWING_AREA(widget), ui_drawingarea_draw, event, NULL); +#elif GTK_MAJOR_VERSION == 3 g_signal_connect(G_OBJECT(widget), "draw", G_CALLBACK(ui_drawingarea_expose),