Commit 35bd419e authored by Sebastian Ramacher's avatar Sebastian Ramacher

Emit signal from main context

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent e733e032
......@@ -6,6 +6,7 @@ girara user interface library and several document libraries.
Requirements
------------
gtk2 (>= 2.28)
glib (>= 2.28)
girara
sqlite3 (optional, >= 3.5.9)
check (for tests)
......
......@@ -52,6 +52,9 @@ GTHREAD_LIB ?= $(shell pkg-config --libs gthread-2.0)
GMODULE_INC ?= $(shell pkg-config --cflags gmodule-no-export-2.0)
GMODULE_LIB ?= $(shell pkg-config --libs gmodule-no-export-2.0)
GLIB_INC ?= $(shell pkg-config --cflags --atleast-version=2.28 glib-2.0)
GLIB_LIB ?= $(shell pkg-config --libs --atleast-version=2.28 glib-2.0)
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk${ZATHURA_GTK_VERSION})
......@@ -65,8 +68,8 @@ MAGIC_INC ?=
MAGIC_LIB ?= -lmagic
endif
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} -lpthread -lm
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} -lpthread -lm
# flags
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
......
......@@ -405,6 +405,23 @@ colorumax(const double* h, double l, double l1, double l2)
return fmin(u, v);
}
typedef struct emit_completed_signal_s
{
ZathuraRenderRequest* request;
cairo_surface_t* surface;
} emit_completed_signal_t;
static gboolean
emit_completed_signal(void* data)
{
emit_completed_signal_t* ecs = data;
/* emit the signal */
g_signal_emit(ecs->request, request_signals[REQUEST_COMPLETED], 0, ecs->surface);
/* clean up the data */
cairo_surface_destroy(ecs->surface);
g_free(ecs);
return true;
}
static bool
render(ZathuraRenderRequest* request, ZathuraRenderer* renderer)
......@@ -534,16 +551,13 @@ render(ZathuraRenderRequest* request, ZathuraRenderer* renderer)
}
if (priv->about_to_close == false && request_priv->aborted == false) {
/* update the widget */
/*
gdk_threads_enter();
GtkWidget* widget = zathura_page_get_widget(zathura, page);
zathura_page_widget_update_surface(ZATHURA_PAGE(widget), surface);
gdk_threads_leave(); */
emit_completed_signal_t* ecs = g_malloc(sizeof(ecs));
ecs->request = request;
ecs->surface = surface;
cairo_surface_reference(surface);
gdk_threads_enter();
g_signal_emit(request, request_signals[REQUEST_COMPLETED], 0, surface);
gdk_threads_leave();
/* emit signal from the main context, i.e. the main thread */
g_main_context_invoke(NULL, emit_completed_signal, ecs);
}
cairo_surface_destroy(surface);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment