Skip to content
Myr

application.h

This file

Path

application.h

129 lines · 3.7 KiB · C

Last changed by

launch-prefix: Pass more environment variablesMark Stosbergbefore adoption72f6b2f

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#if defined(FUZZEL_ENABLE_SVG_RESVG)16 #include <resvg.h>17#endif1819#include <fcft/fcft.h>20#include <tllist.h>2122#include "prompt.h"2324enum icon_type { ICON_NONE, ICON_PNG, ICON_SVG };2526struct rasterized {27    pixman_image_t *pix;28    int size;29};30typedef tll(struct rasterized) rasterized_list_t;3132struct icon {33    char *name;34    char *path;35    enum icon_type type;36    union {37#if defined(FUZZEL_ENABLE_PNG_LIBPNG)38        pixman_image_t *png;39#else40        void *png;41#endif42#if defined(FUZZEL_ENABLE_SVG_LIBRSVG)43        RsvgHandle *svg;44#elif defined(FUZZEL_ENABLE_SVG_NANOSVG)45        NSVGimage *svg;46#elif defined(FUZZEL_ENABLE_SVG_RESVG)47        resvg_render_tree *svg;48#else49        void *svg;50#endif51    };5253    /* Icon is "too large" and we've already warned about this */54    bool png_size_warned;5556    /* List of cached rasterizations (used with SVGs) */57    rasterized_list_t rasterized;58};5960typedef tll(char32_t *) char32_list_t;61typedef tll(char *) char_list_t;6263struct application {64    char *id; /* Desktop File ID, as defined in the Desktop Entry specicication65                 https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html */66    char *path;67    char *exec;68    char *app_id;69    char32_t *title;70    char32_t *render_title;71    size_t index;7273    /* Additional metadata for desktop entries */74    char *desktop_file_path;  /* Full path to the .desktop file */75    char *action_id;          /* Action identifier if this is an action entry */76    char32_t *original_name;  /* Non-localized name */77    char32_t *localized_name; /* Localized name */78    char32_t *action_name;    /* Action name (if applicable) */79    char32_t *localized_action_name; /* Localized action name */80    char32_t *original_generic_name;  /* Non-localized generic name */81    char32_t *localized_generic_name; /* Localized generic name */8283    /*84     * To get good search performance, we cache both the lower-case85     * versions of metadata, and their (string) lengths. This way, we86     * can avoid having to call c32len() and toc32lower() over and87     * over and over again when searching...88     */89    char32_t *title_lowercase; /* Lower cased! */90    char32_t *basename;        /* Lower cased! */91    char32_t *wexec;           /* Lower cased! Same as ‘exec’, but for matching purposes */92    char32_t *generic_name;    /* Lower cased! */93    char32_t *comment;         /* Lower cased! */94    char32_list_t keywords;    /* Lower cased! */95    char32_list_t categories;  /* Lower cased! */9697    char32_t *dmenu_input;     /* Full dmenu input, may contain multiple columns */98    char32_t *dmenu_match_nth; /* What to match against, with --match-nth= */99100    size_t title_len;101    size_t basename_len;102    size_t wexec_len;103    size_t generic_name_len;104    size_t comment_len;105    size_t dmenu_match_nth_len;106    /* keywords and categories lengths not cached */107108    struct icon icon;109    bool visible;110    bool startup_notify;111    unsigned count;112    struct fcft_text_run *shaped;113    struct fcft_text_run *shaped_bold;114};115116bool application_execute(117    const struct application *app, const struct prompt *prompt,118    const char *launch_prefix, const char *xdg_activation_token);119120struct application_list {121    struct application **v;122    size_t count;123    size_t visible_count;124    mtx_t lock;125};126127struct application_list *applications_init(void);128void applications_destroy(struct application_list *apps);129void applications_flush_text_run_cache(struct application_list *apps);