diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1024882..114e7db 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -152,3 +152,39 @@ test:ubuntu-jammy: except: - tags +# Ubuntu 24.04 LTS (noble) +build:ubuntu-noble: + tags: + - pwmt + stage: build + image: registry.pwmt.org/pwmt/gitlab-runner-images/ubuntu:noble + script: + - meson subprojects update + - mkdir -p build && cd build + - meson --force-fallback-for=girara .. + - ninja + cache: + <<: *girara_cache + artifacts: + expire_in: 6 hours + paths: + - build + except: + - tags + +test:ubuntu-noble: + tags: + - pwmt + stage: test + image: registry.pwmt.org/pwmt/gitlab-runner-images/ubuntu:noble + script: + - cd build + - ninja test + cache: + <<: *girara_cache + policy: pull + dependencies: + - build:ubuntu-noble + except: + - tags + diff --git a/data/bash-completion.in b/data/bash-completion.in index cd65896..14b0913 100644 --- a/data/bash-completion.in +++ b/data/bash-completion.in @@ -1,4 +1,3 @@ -#!/bin/bash _zathura() { _init_completion 2>/dev/null || true diff --git a/doc/configuration/options.rst b/doc/configuration/options.rst index efa2298..bc78cbf 100644 --- a/doc/configuration/options.rst +++ b/doc/configuration/options.rst @@ -154,7 +154,7 @@ General settings Defines the background color when displaying additional information for signatures with warnings. :type: String - :default: rgba(100%,%84,0%,0.9) + :default: rgba(100%,84%,0%,0.9) .. describe:: scroll-wrap diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index 142d457..f559807 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -915,7 +915,7 @@ zathura signatures with warnings. * Value type: String - * Default value: rgba(100%,%84,0%,0.9) + * Default value: rgba(100%,84%,0%,0.9) *show-directories* Defines if the directories should be displayed in completion. diff --git a/meson.build b/meson.build index 92623ee..3a4ea47 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('zathura', 'c', - version: '0.5.3', + version: '0.5.4', meson_version: '>=0.61', default_options: ['c_std=c17', 'warning_level=3'], ) diff --git a/tests/meson.build b/tests/meson.build index d2bed1d..1b2e81a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -44,18 +44,18 @@ if check.found() test('session', xvfb, args: ['-a', '-s', '-screen 0 1400x900x24 -ac +extension GLX +render -noreset', session], timeout: 60*60 - ) + ) if seccomp.found() - sandbox = executable('test_sandbox', ['test_sandbox.c', 'tests.c'], - dependencies: build_dependencies + test_dependencies, - include_directories: include_directories, - c_args: defines + flags - ) - test('sandbox', xvfb, - args: ['-a', '-s', '-screen 0 1400x900x24 -ac +extension GLX +render -noreset', sandbox], - timeout: 60*60 - ) - endif + sandbox = executable('test_sandbox', ['test_sandbox.c', 'tests.c'], + dependencies: build_dependencies + test_dependencies, + include_directories: include_directories, + c_args: defines + flags + ) + test('sandbox', xvfb, + args: ['-a', '-s', '-screen 0 1400x900x24 -ac +extension GLX +render -noreset', sandbox], + timeout: 60*60 + ) + endif endif endif diff --git a/zathura/config.c b/zathura/config.c index 69a7188..751e119 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -295,7 +295,7 @@ void config_load_default(zathura_t* zathura) { girara_setting_set(gsession, "signature-success-color", "rgba(18%,80%,33%,0.9)"); girara_setting_add(gsession, "signature-warning-color", NULL, STRING, false, _("Color used to highlight signatures with warnings"), cb_color_change, NULL); - girara_setting_set(gsession, "signature-warning-color", "rgba(100%,%84,0%,0.9)"); + girara_setting_set(gsession, "signature-warning-color", "rgba(100%,84%,0%,0.9)"); girara_setting_add(gsession, "signature-error-color", NULL, STRING, false, _("Color used to highlight invalid signatures"), cb_color_change, NULL); girara_setting_set(gsession, "signature-error-color", "rgba(92%,11%,14%,0.9)"); diff --git a/zathura/seccomp-filters.c b/zathura/seccomp-filters.c index 8e4bb7f..fa88450 100644 --- a/zathura/seccomp-filters.c +++ b/zathura/seccomp-filters.c @@ -86,7 +86,7 @@ seccomp_enable_basic_filter(void) DENY_RULE(migrate_pages); DENY_RULE(modify_ldt); DENY_RULE(mount); -#ifdef __NR_mount_setattr +#if defined(__NR_mount_setattr) && defined(__SNR_mount_setattr) DENY_RULE(mount_setattr); #endif DENY_RULE(move_pages); @@ -153,7 +153,7 @@ seccomp_enable_strict_filter(zathura_t* zathura) * allowing for a potential fallback function to execute * scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_ERRNO(ENOSYS));*/ scmp_filter_ctx ctx = seccomp_init(SCMP_ACT_KILL_PROCESS); - if (ctx == NULL){ + if (ctx == NULL) { girara_error("seccomp_init failed"); return -1; } @@ -254,7 +254,7 @@ seccomp_enable_strict_filter(zathura_t* zathura) #ifdef GDK_WINDOWING_X11 GdkDisplay* display = gtk_widget_get_display(zathura->ui.session->gtk.view); - if (GDK_IS_X11_DISPLAY (display)) { + if (GDK_IS_X11_DISPLAY(display)) { girara_debug("On X11, supporting X11 syscalls"); girara_warning("Running strict sandbox mode on X11 provides only \ incomplete process isolation."); @@ -269,14 +269,13 @@ seccomp_enable_strict_filter(zathura_t* zathura) ALLOW_RULE(connect); ALLOW_RULE(umask); ALLOW_RULE(uname); - ALLOW_RULE(shmat); + ALLOW_RULE(shmat); ALLOW_RULE(shmctl); ALLOW_RULE(shmdt); ALLOW_RULE(shmget); ALLOW_RULE(recvfrom); ALLOW_RULE(writev); /* pwritev, pwritev2 */ - } - else { + } else { girara_debug("On Wayland, blocking X11 syscalls"); } #endif @@ -339,16 +338,13 @@ seccomp_enable_strict_filter(zathura_t* zathura) ERRNO_RULE(openat2); ERRNO_RULE(faccessat2); ERRNO_RULE(pwritev2); -#ifdef __NR_readfile +#if defined(__NR_readfile) && defined(__SNR_readfile) ERRNO_RULE(readfile); #endif -#ifdef __NR_fchmodat2 +#if defined(__NR_fchmodat2) && defined(__SNR_fchmodat2) ERRNO_RULE(fchmodat2); #endif - - - /* Sandbox Status Notes: * * write: no actual files on the filesystem are opened with write permissions @@ -373,11 +369,9 @@ seccomp_enable_strict_filter(zathura_t* zathura) * */ - /* when zathura is run on wayland, with X11 server available but blocked, unset the DISPLAY variable */ /* otherwise it will try to connect to X11 using inet socket protocol */ - /* applying filter... */ if (seccomp_load(ctx) >= 0) { /* free ctx after the filter has been loaded into the kernel */ diff --git a/zathura/utils.c b/zathura/utils.c index ae7cd70..802757f 100644 --- a/zathura/utils.c +++ b/zathura/utils.c @@ -60,7 +60,7 @@ file_valid_extension(zathura_t* zathura, const char* path) zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type); g_free(content_type); - return (plugin == NULL) ? false : true; + return plugin == NULL; } static void @@ -100,34 +100,29 @@ void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_ } } -zathura_rectangle_t -rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, double height, double width) -{ +zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, double height, double width) { zathura_rectangle_t tmp; switch (degree) { - case 90: - tmp.x1 = height - rectangle.y2; - tmp.x2 = height - rectangle.y1; - tmp.y1 = rectangle.x1; - tmp.y2 = rectangle.x2; - break; - case 180: - tmp.x1 = width - rectangle.x2; - tmp.x2 = width - rectangle.x1; - tmp.y1 = height - rectangle.y2; - tmp.y2 = height - rectangle.y1; - break; - case 270: - tmp.x1 = rectangle.y1; - tmp.x2 = rectangle.y2; - tmp.y1 = width - rectangle.x2; - tmp.y2 = width - rectangle.x1; - break; - default: - tmp.x1 = rectangle.x1; - tmp.x2 = rectangle.x2; - tmp.y1 = rectangle.y1; - tmp.y2 = rectangle.y2; + case 90: + tmp.x1 = height - rectangle.y2; + tmp.x2 = height - rectangle.y1; + tmp.y1 = rectangle.x1; + tmp.y2 = rectangle.x2; + break; + case 180: + tmp.x1 = width - rectangle.x2; + tmp.x2 = width - rectangle.x1; + tmp.y1 = height - rectangle.y2; + tmp.y2 = height - rectangle.y1; + break; + case 270: + tmp.x1 = rectangle.y1; + tmp.x2 = rectangle.y2; + tmp.y1 = width - rectangle.x2; + tmp.y2 = width - rectangle.x1; + break; + default: + return rectangle; } return tmp; @@ -141,7 +136,6 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle) } zathura_document_t* document = zathura_page_get_document(page); - if (document == NULL) { goto error_ret; } @@ -159,7 +153,6 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle) return tmp; error_ret: - return rectangle; } @@ -301,14 +294,12 @@ running_under_wsl(void) return result; } -typedef struct zathura_point_s -{ - unsigned int x; - unsigned int y; +typedef struct zathura_point_s { + uintptr_t x; + uintptr_t y; } zathura_point_t; -static int -cmp_point(const void* va, const void* vb) { +static int cmp_point(const void* va, const void* vb) { const zathura_point_t* a = va; const zathura_point_t* b = vb; @@ -323,38 +314,32 @@ cmp_point(const void* va, const void* vb) { return a->x < b->x ? -1 : 1; } -static unsigned int -ufloor(double f) { +static uintptr_t ufloor(double f) { return floor(f); } -static unsigned int -uceil(double f) { +static uintptr_t uceil(double f) { return ceil(f); } -static int -cmp_uint(const void* vx, const void* vy) { - const unsigned int* x = vx; - const unsigned int* y = vy; +static int cmp_uint(const void* vx, const void* vy) { + const uintptr_t x = (uintptr_t)vx; + const uintptr_t y = (uintptr_t)vy; - return *x == *y ? 0 : (*x > *y ? 1 : -1); + return x == y ? 0 : (x > y ? 1 : -1); } -static int -cmp_rectangle(const void* vr1, const void* vr2) { +static int cmp_rectangle(const void* vr1, const void* vr2) { const zathura_rectangle_t* r1 = vr1; const zathura_rectangle_t* r2 = vr2; - return (ufloor(r1->x1) == ufloor(r2->x1) && uceil(r1->x2) == uceil(r2->x2) && - ufloor(r1->y1) == ufloor(r2->y1) && uceil(r1->y2) == uceil(r2->y2)) - ? 0 - : -1; + return (ufloor(r1->x1) == ufloor(r2->x1) && uceil(r1->x2) == uceil(r2->x2) && ufloor(r1->y1) == ufloor(r2->y1) && + uceil(r1->y2) == uceil(r2->y2)) + ? 0 + : -1; } - -static bool -girara_list_append_unique(girara_list_t* l, girara_compare_function_t cmp, void* item) { +static bool girara_list_append_unique(girara_list_t* l, girara_compare_function_t cmp, void* item) { if (girara_list_find(l, cmp, item) != NULL) { return false; } @@ -363,8 +348,7 @@ girara_list_append_unique(girara_list_t* l, girara_compare_function_t cmp, void* return true; } -static void -append_unique_point(girara_list_t* list, const unsigned int x, const unsigned int y) { +static void append_unique_point(girara_list_t* list, const uintptr_t x, const uintptr_t y) { zathura_point_t* p = g_try_malloc(sizeof(zathura_point_t)); if (p == NULL) { return; @@ -378,10 +362,9 @@ append_unique_point(girara_list_t* list, const unsigned int x, const unsigned in } } -static void -rectangle_to_points(void* vrect, void* vlist) { +static void rectangle_to_points(void* vrect, void* vlist) { const zathura_rectangle_t* rect = vrect; - girara_list_t* list = vlist; + girara_list_t* list = vlist; append_unique_point(list, ufloor(rect->x1), ufloor(rect->y1)); append_unique_point(list, ufloor(rect->x1), uceil(rect->y2)); @@ -389,25 +372,15 @@ rectangle_to_points(void* vrect, void* vlist) { append_unique_point(list, uceil(rect->x2), uceil(rect->y2)); } -static void -append_unique_uint(girara_list_t* list, const unsigned int v) { - unsigned int* p = g_try_malloc(sizeof(unsigned int)); - if (p == NULL) { - return; - } - - *p = v; - - if (girara_list_append_unique(list, cmp_uint, p) == false) { - g_free(p); - } +static void append_unique_uint(girara_list_t* list, const uintptr_t v) { + girara_list_append_unique(list, cmp_uint, (void*)v); } // transform a rectangle into multiple new ones according a grid of points static void cut_rectangle(const zathura_rectangle_t* rect, girara_list_t* points, girara_list_t* rectangles) { // Lists of ordred relevant points - girara_list_t* xs = girara_sorted_list_new2(cmp_uint, g_free); - girara_list_t* ys = girara_sorted_list_new2(cmp_uint, g_free); + girara_list_t* xs = girara_sorted_list_new(cmp_uint); + girara_list_t* ys = girara_sorted_list_new(cmp_uint); append_unique_uint(xs, uceil(rect->x2)); append_unique_uint(ys, uceil(rect->y2)); @@ -424,17 +397,17 @@ static void cut_rectangle(const zathura_rectangle_t* rect, girara_list_t* points double x = ufloor(rect->x1); for (size_t idx = 0; idx != girara_list_size(xs); ++idx) { - const unsigned int* cx = girara_list_nth(xs, idx); - double y = ufloor(rect->y1); + const uintptr_t cx = (uintptr_t)girara_list_nth(xs, idx); + double y = ufloor(rect->y1); for (size_t inner_idx = 0; inner_idx != girara_list_size(ys); ++inner_idx) { - const unsigned int* cy = girara_list_nth(ys, inner_idx); + const uintptr_t cy = (uintptr_t)girara_list_nth(ys, inner_idx); zathura_rectangle_t* r = g_try_malloc(sizeof(zathura_rectangle_t)); - *r = (zathura_rectangle_t){x, y, *cx, *cy}; - y = *cy; + *r = (zathura_rectangle_t){x, y, cx, cy}; + y = cy; girara_list_append_unique(rectangles, cmp_rectangle, r); } - x = *cx; + x = cx; } girara_list_free(xs); diff --git a/zathura/zathura.c b/zathura/zathura.c index c0ff579..95cf1f5 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -61,7 +61,6 @@ typedef struct zathura_document_info_s { char* search_string; } zathura_document_info_t; - static gboolean document_info_open(gpointer data); #ifdef G_OS_UNIX @@ -189,8 +188,7 @@ zathura_update_view_ppi(zathura_t* zathura) /* work around apparent bug in GDK: on Wayland, monitor geometry doesn't * return values in application pixels as documented, but in device pixels. * */ - if (GDK_IS_WAYLAND_DISPLAY(display)) - { + if (GDK_IS_WAYLAND_DISPLAY(display)) { /* not using the cached value for the scale factor here to avoid issues * if this function is called before the cached value is updated */ const int device_factor = gtk_widget_get_scale_factor(zathura->ui.session->gtk.view); @@ -211,9 +209,11 @@ zathura_update_view_ppi(zathura_t* zathura) } } -static bool -init_ui(zathura_t* zathura) -{ +static void weak_ref_object_unref(void* data, GObject* UNUSED(object)) { + g_object_unref(data); +} + +static bool init_ui(zathura_t* zathura) { if (girara_session_init(zathura->ui.session, "zathura") == false) { girara_error("Failed to initialize girara."); return false; @@ -228,7 +228,8 @@ init_ui(zathura_t* zathura) GtkGesture* zoom = gtk_gesture_zoom_new(GTK_WIDGET(zathura->ui.session->gtk.view)); g_signal_connect(zoom, "scale-changed", G_CALLBACK(cb_gesture_zoom_scale_changed), zathura); g_signal_connect(zoom, "begin", G_CALLBACK(cb_gesture_zoom_begin), zathura); - gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(zathura->ui.session->gtk.view), GTK_PHASE_BUBBLE); + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(zoom), GTK_PHASE_BUBBLE); + g_object_weak_ref(G_OBJECT(zathura->ui.session->gtk.view), weak_ref_object_unref, zoom); /* zathura signals */ zathura->signals.refresh_view = g_signal_new( @@ -482,7 +483,7 @@ zathura_init(zathura_t* zathura) } /* disable unsupported features in strict sandbox mode */ - if (zathura->global.sandbox != ZATHURA_SANDBOX_STRICT){ + if (zathura->global.sandbox != ZATHURA_SANDBOX_STRICT) { /* database */ init_database(zathura); } @@ -760,7 +761,6 @@ prepare_document_open_from_stdin(const char* path) if (input_stream == NULL) { girara_error("Can not read from file descriptor."); return NULL; - } GFileIOStream* iostream = NULL; @@ -861,8 +861,7 @@ document_info_open(gpointer data) if (g_file_is_native(gf) == TRUE) { /* file was given as a native path */ file = g_file_get_path(gf); - } - else { + } else { /* copy file with GIO */ uri = g_file_get_uri(gf); file = prepare_document_open_from_gfile(gf); @@ -1592,7 +1591,7 @@ document_close(zathura_t* zathura, bool keep_monitor) /* free predecessor buffer if we want to overwrite it or if we destroy the document for good */ if (override_predecessor || !keep_monitor || !smooth_reload) { - document_predecessor_free(zathura); + document_predecessor_free(zathura); } /* remove widgets */ diff --git a/zathura/zathura.h b/zathura/zathura.h index 1b878e5..f28df54 100644 --- a/zathura/zathura.h +++ b/zathura/zathura.h @@ -234,10 +234,9 @@ struct zathura_s * Storage for gestures. */ struct { - double initial_zoom; + double initial_zoom; } gesture; - /** * Context for MIME type detection */