mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 07:06:00 +01:00
Restore compatibility with earlier versions of glib
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
b0d5cdd7c0
commit
edde1bf00f
3 changed files with 38 additions and 10 deletions
23
glib-compat.h
Normal file
23
glib-compat.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/* See LICENSE file for license and copyright information */
|
||||||
|
|
||||||
|
#ifndef GLIB_COMPAT_H
|
||||||
|
#define GLIB_COMPAT_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
/* GStaticMutex is deprecated starting with glib 2.32 */
|
||||||
|
#if !GLIB_CHECK_VERSION(2, 31, 0)
|
||||||
|
#define mutex GStaticMutex
|
||||||
|
#define mutex_init(m) g_static_mutex_init((m))
|
||||||
|
#define mutex_lock(m) g_static_mutex_lock((m))
|
||||||
|
#define mutex_unlock(m) g_static_mutex_unlock((m))
|
||||||
|
#define mutex_free(m) g_static_mutex_free((m))
|
||||||
|
#else
|
||||||
|
#define mutex GMutex
|
||||||
|
#define mutex_init(m) g_mutex_init((m))
|
||||||
|
#define mutex_lock(m) g_mutex_lock((m))
|
||||||
|
#define mutex_unlock(m) g_mutex_unlock((m))
|
||||||
|
#define mutex_free(m) g_mutex_clear((m))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,6 +7,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "glib-compat.h"
|
||||||
#include "links.h"
|
#include "links.h"
|
||||||
#include "page-widget.h"
|
#include "page-widget.h"
|
||||||
#include "page.h"
|
#include "page.h"
|
||||||
|
@ -22,7 +23,7 @@ typedef struct zathura_page_widget_private_s {
|
||||||
zathura_t* zathura; /**< Zathura object */
|
zathura_t* zathura; /**< Zathura object */
|
||||||
cairo_surface_t* surface; /**< Cairo surface */
|
cairo_surface_t* surface; /**< Cairo surface */
|
||||||
gint64 last_view; /**< Last time the page has been viewed */
|
gint64 last_view; /**< Last time the page has been viewed */
|
||||||
GMutex lock; /**< Lock */
|
mutex lock; /**< Lock */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
girara_list_t* list; /**< List of links on the page */
|
girara_list_t* list; /**< List of links on the page */
|
||||||
|
@ -162,7 +163,7 @@ zathura_page_widget_init(ZathuraPage* widget)
|
||||||
priv->mouse.selection_basepoint.x = -1;
|
priv->mouse.selection_basepoint.x = -1;
|
||||||
priv->mouse.selection_basepoint.y = -1;
|
priv->mouse.selection_basepoint.y = -1;
|
||||||
|
|
||||||
g_mutex_init(&(priv->lock));
|
mutex_init(&(priv->lock));
|
||||||
|
|
||||||
/* we want mouse events */
|
/* we want mouse events */
|
||||||
gtk_widget_add_events(GTK_WIDGET(widget),
|
gtk_widget_add_events(GTK_WIDGET(widget),
|
||||||
|
@ -195,6 +196,8 @@ zathura_page_widget_finalize(GObject* object)
|
||||||
girara_list_free(priv->links.list);
|
girara_list_free(priv->links.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_free(&(priv->lock));
|
||||||
|
|
||||||
G_OBJECT_CLASS(zathura_page_widget_parent_class)->finalize(object);
|
G_OBJECT_CLASS(zathura_page_widget_parent_class)->finalize(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +326,7 @@ static gboolean
|
||||||
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||||
g_mutex_lock(&(priv->lock));
|
mutex_lock(&(priv->lock));
|
||||||
|
|
||||||
zathura_document_t* document = zathura_page_get_document(priv->page);
|
zathura_document_t* document = zathura_page_get_document(priv->page);
|
||||||
|
|
||||||
|
@ -464,7 +467,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
/* render real page */
|
/* render real page */
|
||||||
render_page(priv->zathura->sync.render_thread, priv->page);
|
render_page(priv->zathura->sync.render_thread, priv->page);
|
||||||
}
|
}
|
||||||
g_mutex_unlock(&(priv->lock));
|
mutex_unlock(&(priv->lock));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,13 +482,13 @@ void
|
||||||
zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface)
|
zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||||
g_mutex_lock(&(priv->lock));
|
mutex_lock(&(priv->lock));
|
||||||
if (priv->surface != NULL) {
|
if (priv->surface != NULL) {
|
||||||
cairo_surface_finish(priv->surface);
|
cairo_surface_finish(priv->surface);
|
||||||
cairo_surface_destroy(priv->surface);
|
cairo_surface_destroy(priv->surface);
|
||||||
}
|
}
|
||||||
priv->surface = surface;
|
priv->surface = surface;
|
||||||
g_mutex_unlock(&(priv->lock));
|
mutex_unlock(&(priv->lock));
|
||||||
/* force a redraw here */
|
/* force a redraw here */
|
||||||
zathura_page_widget_redraw_canvas(widget);
|
zathura_page_widget_redraw_canvas(widget);
|
||||||
}
|
}
|
||||||
|
|
10
render.c
10
render.c
|
@ -6,6 +6,7 @@
|
||||||
#include <girara/session.h>
|
#include <girara/session.h>
|
||||||
#include <girara/settings.h>
|
#include <girara/settings.h>
|
||||||
|
|
||||||
|
#include "glib-compat.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "zathura.h"
|
#include "zathura.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
@ -19,7 +20,7 @@ static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data);
|
||||||
|
|
||||||
struct render_thread_s {
|
struct render_thread_s {
|
||||||
GThreadPool* pool; /**< Pool of threads */
|
GThreadPool* pool; /**< Pool of threads */
|
||||||
GMutex mutex; /**< Render lock */
|
mutex mutex; /**< Render lock */
|
||||||
bool about_to_close; /**< Render thread is to be freed */
|
bool about_to_close; /**< Render thread is to be freed */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ render_init(zathura_t* zathura)
|
||||||
|
|
||||||
render_thread->about_to_close = false;
|
render_thread->about_to_close = false;
|
||||||
g_thread_pool_set_sort_function(render_thread->pool, render_thread_sort, zathura);
|
g_thread_pool_set_sort_function(render_thread->pool, render_thread_sort, zathura);
|
||||||
g_mutex_init(&render_thread->mutex);
|
mutex_init(&render_thread->mutex);
|
||||||
|
|
||||||
return render_thread;
|
return render_thread;
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ render_free(render_thread_t* render_thread)
|
||||||
g_thread_pool_free(render_thread->pool, TRUE, TRUE);
|
g_thread_pool_free(render_thread->pool, TRUE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_free(&(render_thread->mutex));
|
||||||
g_free(render_thread);
|
g_free(render_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +330,7 @@ render_lock(render_thread_t* render_thread)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock(&render_thread->mutex);
|
mutex_lock(&render_thread->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -338,5 +340,5 @@ render_unlock(render_thread_t* render_thread)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock(&render_thread->mutex);
|
mutex_unlock(&render_thread->mutex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue