mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 11:36:01 +01:00
HiDPI: add preprocessor conditionals
This commit is contained in:
parent
5fa4b8907e
commit
36d9ece978
4 changed files with 19 additions and 0 deletions
|
@ -47,6 +47,15 @@ WITH_SYNCTEX ?= $(shell (${PKG_CONFIG} synctex && echo 1) || echo 0)
|
|||
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
|
||||
WITH_MAGIC ?= 1
|
||||
|
||||
# HiDPI
|
||||
HIDPI_SUPPORT_CAIRO = $(shell (${PKG_CONFIG} --atleast-version=1.14 cairo && echo 1) || echo 0)
|
||||
HIDPI_SUPPORT_GTK = $(shell (${PKG_CONFIG} --atleast-version=3.10 ${GTK_PKG_CONFIG_NAME} && echo 1) || echo 0)
|
||||
ifeq (${HIDPI_SUPPORT_CAIRO},1)
|
||||
ifeq (${HIDPI_SUPPORT_GTK},1)
|
||||
CPPFLAGS += -DHAVE_HIDPI_SUPPORT
|
||||
endif
|
||||
endif
|
||||
|
||||
# paths
|
||||
PREFIX ?= /usr
|
||||
MANPREFIX ?= ${PREFIX}/share/man
|
||||
|
|
|
@ -223,7 +223,11 @@ cb_scale_factor(GtkWidget* widget, GParamSpec* UNUSED(pspec), zathura_t* zathura
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_HIDPI_SUPPORT
|
||||
int new_factor = gtk_widget_get_scale_factor(widget);
|
||||
#else
|
||||
int new_factor = 1;
|
||||
#endif
|
||||
|
||||
double current_x;
|
||||
double current_y;
|
||||
|
|
|
@ -740,6 +740,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
|||
&page_height, &page_width,
|
||||
false);
|
||||
|
||||
#ifdef HAVE_HIDPI_SUPPORT
|
||||
double device_scale_x;
|
||||
double device_scale_y;
|
||||
zathura_document_get_device_scale(document, &device_scale_x, &device_scale_y);
|
||||
|
@ -748,6 +749,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
|||
page_width *= device_scale_x;
|
||||
page_height *= device_scale_y;
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
|
||||
page_width, page_height);
|
||||
|
@ -759,6 +761,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_HIDPI_SUPPORT
|
||||
if (device_scale_x != 0.0 && device_scale_y != 0.0) {
|
||||
cairo_surface_set_device_scale(surface, device_scale_x, device_scale_y);
|
||||
if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
|
||||
|
@ -766,6 +769,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
|||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_t* cairo = cairo_create(surface);
|
||||
if (cairo == NULL) {
|
||||
|
|
|
@ -153,8 +153,10 @@ init_ui(zathura_t* zathura)
|
|||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "refresh-view",
|
||||
G_CALLBACK(cb_refresh_view), zathura);
|
||||
|
||||
#ifdef HAVE_HIDPI_SUPPORT
|
||||
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view),
|
||||
"notify::scale-factor", G_CALLBACK(cb_scale_factor), zathura);
|
||||
#endif
|
||||
|
||||
/* page view */
|
||||
zathura->ui.page_widget = gtk_grid_new();
|
||||
|
|
Loading…
Reference in a new issue