From be0445110dc2afcdd3c4c2d69420390033f4fee7 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 28 Dec 2009 20:10:47 +0100 Subject: [PATCH] Render pages in a thread --- config.mk | 2 +- zathura.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config.mk b/config.mk index d62e8ca..d082697 100644 --- a/config.mk +++ b/config.mk @@ -12,7 +12,7 @@ GTK_INC = $(shell pkg-config --cflags gtk+-2.0 poppler-glib) GTK_LIB = $(shell pkg-config --libs gtk+-2.0 poppler-glib) INCS = -I. -I/usr/include ${GTK_INC} -LIBS = -L/usr/lib -lc ${GTK_LIB} +LIBS = -L/usr/lib -lc ${GTK_LIB} -lpthread # flags CFLAGS = -std=c99 -pedantic -Wall $(INCS) diff --git a/zathura.c b/zathura.c index 8a69cfc..7480d43 100644 --- a/zathura.c +++ b/zathura.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -186,7 +187,7 @@ void set_page(int); GtkEventBox* createCompletionRow(GtkBox*, char*, char*, gboolean); /* thread declaration */ -void render(void*); +void* render(void*); /* shortcut declarations */ void sc_abort(Argument*); @@ -555,18 +556,17 @@ set_page(int page) } /* thread implementation */ -void +void* render(void* parameter) { if(!Zathura.PDF.document) - return; + pthread_exit(NULL); int page; for(page = 0; page < Zathura.PDF.number_of_pages; page++) - { - printf("Render page %d\n", page); draw(page); - } + + pthread_exit(NULL); } /* shortcut implementation */ @@ -1036,7 +1036,10 @@ cmd_open(int argc, char** argv) Zathura.PDF.pages[i]->surface = NULL; } - render(NULL); + /* render pages */ + pthread_t render_thread; + pthread_create(&render_thread, NULL, render, NULL); + set_page(0); update_status();