- Add MT6797 CONSYS Wi-Fi/BT factory-firmware patch (0005), native EAPOL TX, 5 GHz NO_IR/regulatory-notifier fixes, TKIP/CCMP admission, initramfs regdb, and geminux-wifi-nvram - Order OpenRC polkit startup before NetworkManager/ModemManager and harden geminux-net with non-blocking scans, mesh SSID grouping, password masking toggle, and BT A2DP/HFP/LE/HID support - Add geminux-audio PipeWire/WirePlumber/UCM2 playback & recording control GUI alongside st and dmenu XFixes cursor autohide - Preinstall requested CLI/dev tools (bash, coreutils, build-base, git, nmtui, perl/SSL, curl-dev, janet, jpm, etc.) and set bash as system-wide default shell
171 lines
5.9 KiB
C
171 lines
5.9 KiB
C
/*
|
|
* Geminux UI Toolkit (libgemui)
|
|
* Pure C11 X11 + Cairo + Pango/HarfBuzz landscape HiDPI UI library with live .Xresources theming.
|
|
*/
|
|
#ifndef GEMUI_H
|
|
#define GEMUI_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/keysym.h>
|
|
#include <cairo/cairo.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define GEMUI_ALIGN_LEFT 0
|
|
#define GEMUI_ALIGN_CENTER 1
|
|
#define GEMUI_ALIGN_RIGHT 2
|
|
|
|
#define GEMUI_PTR_DOWN 0
|
|
#define GEMUI_PTR_MOVE 1
|
|
#define GEMUI_PTR_UP 2
|
|
#define GEMUI_PTR_SCROLL_UP 3
|
|
#define GEMUI_PTR_SCROLL_DOWN 4
|
|
|
|
#define GEMUI_MAX_HITS 192
|
|
#define GEMUI_MAX_FDS 16
|
|
|
|
typedef struct {
|
|
double r;
|
|
double g;
|
|
double b;
|
|
double a;
|
|
uint32_t argb;
|
|
} gemui_color_t;
|
|
|
|
typedef struct {
|
|
int x;
|
|
int y;
|
|
int w;
|
|
int h;
|
|
} gemui_rect_t;
|
|
|
|
typedef struct {
|
|
gemui_rect_t r;
|
|
int id;
|
|
int val;
|
|
} gemui_hit_t;
|
|
|
|
typedef struct {
|
|
char name[64];
|
|
char font_face[96];
|
|
char icon_font_face[96];
|
|
int base_font_size;
|
|
int dpi;
|
|
gemui_color_t bg_main;
|
|
gemui_color_t bg_bar;
|
|
gemui_color_t bg_header;
|
|
gemui_color_t bg_footer;
|
|
gemui_color_t bg_overlay;
|
|
gemui_color_t bg_alt_even;
|
|
gemui_color_t bg_alt_odd;
|
|
gemui_color_t bg_input;
|
|
gemui_color_t bg_input_focus;
|
|
gemui_color_t bg_button;
|
|
gemui_color_t bg_search;
|
|
gemui_color_t bg_bubble_in;
|
|
gemui_color_t bg_bubble_out;
|
|
gemui_color_t bg_toast;
|
|
gemui_color_t fg_main;
|
|
gemui_color_t fg_bright;
|
|
gemui_color_t fg_muted;
|
|
gemui_color_t sel_bg;
|
|
gemui_color_t sel_fg;
|
|
gemui_color_t accent;
|
|
gemui_color_t accent_alt;
|
|
gemui_color_t highlight;
|
|
gemui_color_t border;
|
|
gemui_color_t divider;
|
|
gemui_color_t success;
|
|
gemui_color_t info;
|
|
gemui_color_t warning;
|
|
gemui_color_t danger;
|
|
gemui_color_t danger_bg;
|
|
} gemui_theme_t;
|
|
|
|
typedef struct gemui_app gemui_app_t;
|
|
|
|
typedef void (*gemui_fd_cb)(gemui_app_t *app, int fd, void *ud);
|
|
typedef void (*gemui_timer_cb)(gemui_app_t *app, void *ud);
|
|
|
|
typedef struct {
|
|
void (*on_draw)(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud);
|
|
void (*on_key)(gemui_app_t *app, KeySym ks, unsigned int state, const char *utf8, void *ud);
|
|
void (*on_ptr)(gemui_app_t *app, int type, int x, int y, unsigned int btn, void *ud);
|
|
void (*on_theme)(gemui_app_t *app, void *ud);
|
|
void (*on_resize)(gemui_app_t *app, int w, int h, void *ud);
|
|
} gemui_handlers_t;
|
|
|
|
bool gemui_color_parse(const char *hex, gemui_color_t *out);
|
|
void gemui_theme_defaults(gemui_theme_t *t);
|
|
bool gemui_theme_load_file(const char *path, gemui_theme_t *out);
|
|
void gemui_theme_reload(gemui_app_t *app);
|
|
|
|
gemui_app_t *gemui_create(const char *res_name, const char *title,
|
|
int w, int h, bool fullscreen_override);
|
|
void gemui_destroy(gemui_app_t *app);
|
|
void gemui_set_handlers(gemui_app_t *app, const gemui_handlers_t *h, void *userdata);
|
|
void gemui_set_title(gemui_app_t *app, const char *title);
|
|
Display *gemui_display(const gemui_app_t *app);
|
|
Window gemui_window(const gemui_app_t *app);
|
|
const gemui_theme_t *gemui_theme(const gemui_app_t *app);
|
|
int gemui_width(const gemui_app_t *app);
|
|
int gemui_height(const gemui_app_t *app);
|
|
int gemui_scale_px(const gemui_app_t *app, int logical_px);
|
|
|
|
int gemui_add_fd(gemui_app_t *app, int fd, gemui_fd_cb cb, void *userdata);
|
|
void gemui_del_fd(gemui_app_t *app, int fd);
|
|
void gemui_set_timer_ms(gemui_app_t *app, int interval_ms, gemui_timer_cb cb, void *userdata);
|
|
void gemui_request_redraw(gemui_app_t *app);
|
|
void gemui_flush_draw(gemui_app_t *app);
|
|
void gemui_show_toast(gemui_app_t *app, const char *msg, int duration_ms);
|
|
int gemui_run(gemui_app_t *app);
|
|
void gemui_quit(gemui_app_t *app, int code);
|
|
bool gemui_grab_input(gemui_app_t *app);
|
|
void gemui_ungrab_input(gemui_app_t *app);
|
|
|
|
void gemui_hits_clear(gemui_app_t *app);
|
|
void gemui_hit_add(gemui_app_t *app, gemui_rect_t r, int id, int val);
|
|
const gemui_hit_t *gemui_hit_test(const gemui_app_t *app, int x, int y);
|
|
|
|
void gemui_set_source(cairo_t *cr, gemui_color_t c);
|
|
void gemui_rounded_rect(cairo_t *cr, gemui_rect_t r, double radius);
|
|
void gemui_fill_rect(cairo_t *cr, gemui_rect_t r, gemui_color_t c);
|
|
void gemui_fill_round(cairo_t *cr, gemui_rect_t r, double radius, gemui_color_t c);
|
|
void gemui_stroke_round(cairo_t *cr, gemui_rect_t r, double radius, double lw, gemui_color_t c);
|
|
int gemui_draw_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
|
const char *text, int pt_delta, bool bold, int align, gemui_color_t c);
|
|
int gemui_draw_icon(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
|
const char *icon_utf8, int pt_delta, int align, gemui_color_t c);
|
|
void gemui_draw_header(gemui_app_t *app, cairo_t *cr, const char *icon,
|
|
const char *title, const char *right_badge);
|
|
void gemui_draw_button(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
|
const char *label, int hit_id, int hit_val,
|
|
bool primary, bool active, bool focused);
|
|
void gemui_draw_toggle(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
|
const char *label, bool on, int hit_id, int hit_val, bool focused);
|
|
void gemui_draw_slider(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
|
const char *label, double norm_val, const char *val_text,
|
|
int hit_id, int hit_val, bool focused);
|
|
void gemui_draw_input(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
|
const char *placeholder, const char *text, bool mask_bullets,
|
|
bool focused, int hit_id, int hit_val);
|
|
void gemui_draw_toast(gemui_app_t *app, cairo_t *cr);
|
|
|
|
int gemui_unix_cmd(const char *sock_path, const char *cmd, char *resp, size_t resp_sz);
|
|
int gemui_read_file_line(const char *path, char *buf, size_t sz);
|
|
int gemui_run_cmd_timeout(const char *const argv[], char *out, size_t out_sz, int timeout_ms);
|
|
int gemui_run_cmd_capture(const char *const argv[], char *out, size_t out_sz);
|
|
int gemui_spawn_detached(const char *const argv[]);
|
|
void gemui_utf8_pop_char(char *buf);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* GEMUI_H */
|