Skip to content
Myr

application.h

This file

Path

application.h

111 lines · 2.9 KiB · C

Last changed by

dmenu: --with-nth: don't match "other" columnsDaniel Eklöfbefore adoption56526e8

History of this file

Take it

1#pragma once23#include <stdbool.h>4#include <pixman.h>5#include <threads.h>67#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)8 #include <librsvg/rsvg.h>9#endif1011#if defined(FUZZEL_ENABLE_SVG_NANOSVG)12 #include <nanosvg/nanosvg.h>13#endif1415#include <fcft/fcft.h>16#include <tllist.h>1718#include "prompt.h"1920enum icon_type { ICON_NONE, ICON_PNG, ICON_SVG };2122struct rasterized {23    pixman_image_t *pix;24    int size;25};26typedef tll(struct rasterized) rasterized_list_t;2728struct icon {29    char *name;30    char *path;31    enum icon_type type;32    union {33#if defined(FUZZEL_ENABLE_PNG_LIBPNG)34        pixman_image_t *png;35#else36        void *png;37#endif38#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)39        RsvgHandle *svg;40#elif defined(FUZZEL_ENABLE_SVG_NANOSVG)41        NSVGimage *svg;42#else43        void *svg;44#endif45    };4647    /* Icon is "too large" and we've already warned about this */48    bool png_size_warned;4950    /* List of cached rasterizations (used with SVGs) */51    rasterized_list_t rasterized;52};5354typedef tll(char32_t *) char32_list_t;55typedef tll(char *) char_list_t;5657struct application {58    char *id; /* Desktop File ID, as defined in the Desktop Entry specicication59                 https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html */60    char *path;61    char *exec;62    char *app_id;63    char32_t *title;64    char32_t *render_title;65    size_t index;6667    /*68     * To get good search performance, we cache both the lower-case69     * versions of metadata, and their (string) lengths. This way, we70     * can avoid having to call c32len() and toc32lower() over and71     * over and over again when searching...72     */73    char32_t *title_lowercase; /* Lower cased! */74    char32_t *basename;        /* Lower cased! */75    char32_t *wexec;           /* Lower cased! Same as ‘exec’, but for matching purposes */76    char32_t *generic_name;    /* Lower cased! */77    char32_t *comment;         /* Lower cased! */78    char32_list_t keywords;    /* Lower cased! */79    char32_list_t categories;  /* Lower cased! */8081    char32_t *dmenu_input;     /* Full dmenu input, may contain multiple columns */8283    size_t title_len;84    size_t basename_len;85    size_t wexec_len;86    size_t generic_name_len;87    size_t comment_len;88    /* keywords and categories lengths not cached */8990    struct icon icon;91    bool visible;92    bool startup_notify;93    unsigned count;94    struct fcft_text_run *shaped;95    struct fcft_text_run *shaped_bold;96};9798bool application_execute(99    const struct application *app, const struct prompt *prompt,100    const char *launch_prefix, const char *xdg_activation_token);101102struct application_list {103    struct application **v;104    size_t count;105    size_t visible_count;106    mtx_t lock;107};108109struct application_list *applications_init(void);110void applications_destroy(struct application_list *apps);111void applications_flush_text_run_cache(struct application_list *apps);