mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 21:06:01 +01:00
Emit signal from main context
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
e733e032ce
commit
35bd419e49
3 changed files with 29 additions and 11 deletions
1
README
1
README
|
@ -6,6 +6,7 @@ girara user interface library and several document libraries.
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
gtk2 (>= 2.28)
|
gtk2 (>= 2.28)
|
||||||
|
glib (>= 2.28)
|
||||||
girara
|
girara
|
||||||
sqlite3 (optional, >= 3.5.9)
|
sqlite3 (optional, >= 3.5.9)
|
||||||
check (for tests)
|
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_INC ?= $(shell pkg-config --cflags gmodule-no-export-2.0)
|
||||||
GMODULE_LIB ?= $(shell pkg-config --libs 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_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION})
|
||||||
GIRARA_LIB ?= $(shell pkg-config --libs 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
|
MAGIC_LIB ?= -lmagic
|
||||||
endif
|
endif
|
||||||
|
|
||||||
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC}
|
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC}
|
||||||
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} -lpthread -lm
|
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} -lpthread -lm
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
|
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
|
||||||
|
|
32
render.c
32
render.c
|
@ -405,6 +405,23 @@ colorumax(const double* h, double l, double l1, double l2)
|
||||||
return fmin(u, v);
|
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
|
static bool
|
||||||
render(ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
render(ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
||||||
|
@ -534,16 +551,13 @@ render(ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->about_to_close == false && request_priv->aborted == false) {
|
if (priv->about_to_close == false && request_priv->aborted == false) {
|
||||||
/* update the widget */
|
emit_completed_signal_t* ecs = g_malloc(sizeof(ecs));
|
||||||
/*
|
ecs->request = request;
|
||||||
gdk_threads_enter();
|
ecs->surface = surface;
|
||||||
GtkWidget* widget = zathura_page_get_widget(zathura, page);
|
cairo_surface_reference(surface);
|
||||||
zathura_page_widget_update_surface(ZATHURA_PAGE(widget), surface);
|
|
||||||
gdk_threads_leave(); */
|
|
||||||
|
|
||||||
gdk_threads_enter();
|
/* emit signal from the main context, i.e. the main thread */
|
||||||
g_signal_emit(request, request_signals[REQUEST_COMPLETED], 0, surface);
|
g_main_context_invoke(NULL, emit_completed_signal, ecs);
|
||||||
gdk_threads_leave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
|
Loading…
Reference in a new issue