diff --git a/document.c b/document.c index 7af7f23..99a41fb 100644 --- a/document.c +++ b/document.c @@ -385,9 +385,13 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id) zathura_page_t* page = document->functions.page_get(document, page_id); if (page) { - page->number = page_id; - page->rendered = false; - page->event_box = gtk_event_box_new(); + page->number = page_id; + page->rendered = false; + page->event_box = gtk_event_box_new(); + page->drawing_area = gtk_drawing_area_new(); + + gtk_container_add(GTK_CONTAINER(page->event_box), page->drawing_area); + g_static_mutex_init(&(page->lock)); } diff --git a/document.h b/document.h index c39d8e1..5fb78e2 100644 --- a/document.h +++ b/document.h @@ -147,7 +147,8 @@ typedef struct zathura_page_s zathura_document_t* document; /**> Document */ void* data; /**> Custom data */ bool rendered; /**> Page has been rendered */ - GtkWidget* event_box; /**> Widget wrapper */ + GtkWidget* event_box; /**> Widget wrapper for mouse events */ + GtkWidget* drawing_area; /**> Drawing area */ GStaticMutex lock; /**> Lock */ } zathura_page_t; diff --git a/render.c b/render.c index 61fd660..02208b7 100644 --- a/render.c +++ b/render.c @@ -170,10 +170,7 @@ render(zathura_page_t* page) } /* draw to gtk widget */ - GtkWidget* drawing_area = gtk_drawing_area_new(); - gtk_container_add(GTK_CONTAINER(page->event_box), drawing_area); - - cairo_t* cairo = gdk_cairo_create(drawing_area->window); + cairo_t* cairo = gdk_cairo_create(page->drawing_area->window); cairo_set_source_surface(cairo, surface, 0, 0); cairo_paint(cairo); cairo_destroy(cairo); diff --git a/zathura.c b/zathura.c index 2bdc7ff..df916b2 100644 --- a/zathura.c +++ b/zathura.c @@ -224,16 +224,12 @@ create_blank_pages() zathura_page_t* page = Zathura.document->pages[i]; g_static_mutex_lock(&(page->lock)); - /* create blank page */ - GtkWidget* image = page_blank(page->width, page->height); + cairo_t* cairo = gdk_cairo_create(page->drawing_area->window); + cairo_set_source_rgb(cairo, 1, 1, 1); + cairo_rectangle(cairo, 0, 0, page->width, page->height); + cairo_fill(cairo); + cairo_destroy(cairo); - if (!image) { - g_static_mutex_unlock(&(page->lock)); - continue; - } - - /* pack to page view */ - gtk_container_add(GTK_CONTAINER(page->event_box), image); g_static_mutex_unlock(&(page->lock)); } }