Bring up SSD2092 display/touch, USB NCM, HiDPI XLibre/DWM, and USB charging
This commit is contained in:
1 parent
034c1f61b1
commit
9db15e30ce
150 files changed
+2356
-446
No files matched your search
@@ -4,7 +4,7 @@
|
||||
static int topbar = 1;
|
||||
static int fuzzy = 1;
|
||||
static const char *fonts[] = {
|
||||
"Fira Code, DejaVuSansM Nerd Font 20px"
|
||||
"Fira Code, DejaVuSansM Nerd Font 40px"
|
||||
};
|
||||
static const char *prompt = NULL;
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
@@ -14,6 +14,6 @@ static const char *colors[SchemeLast][2] = {
|
||||
[SchemeOut] = { "#ffffff", "#243040" },
|
||||
};
|
||||
static unsigned int lines = 0;
|
||||
static unsigned int lineheight = 48;
|
||||
static unsigned int min_lineheight = 48;
|
||||
static unsigned int lineheight = 82;
|
||||
static unsigned int min_lineheight = 82;
|
||||
static const char worddelimiters[] = " ";
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
static int topbar = 1;
|
||||
static int fuzzy = 1;
|
||||
static const char *fonts[] = {
|
||||
"Fira Code, DejaVuSansM Nerd Font 20px"
|
||||
"Fira Code, DejaVuSansM Nerd Font 40px"
|
||||
};
|
||||
static const char *prompt = NULL;
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
@@ -14,6 +14,6 @@ static const char *colors[SchemeLast][2] = {
|
||||
[SchemeOut] = { "#ffffff", "#243040" },
|
||||
};
|
||||
static unsigned int lines = 0;
|
||||
static unsigned int lineheight = 48;
|
||||
static unsigned int min_lineheight = 48;
|
||||
static unsigned int lineheight = 82;
|
||||
static unsigned int min_lineheight = 82;
|
||||
static const char worddelimiters[] = " ";
|
||||
+7
-6
@@ -110,15 +110,15 @@ static void load_xresources(void) {
|
||||
const char *th_face = xrm_get(xdb, "theme.fontFace", NULL, NULL);
|
||||
const char *th_icon = xrm_get(xdb, "theme.iconFontFace", NULL, NULL);
|
||||
const char *th_size = xrm_get(xdb, "theme.baseFontSize", NULL, NULL);
|
||||
if (th_face) {
|
||||
int px = th_size ? atoi(th_size) : 22;
|
||||
if (px < 12 || px > 48) px = 22;
|
||||
if (dm_font) {
|
||||
snprintf(xres_font, sizeof(xres_font), "%s", dm_font);
|
||||
fonts[0] = xres_font;
|
||||
} else if (th_face) {
|
||||
int px = th_size ? atoi(th_size) + 8 : 40;
|
||||
if (px < 12 || px > 72) px = 40;
|
||||
snprintf(xres_font, sizeof(xres_font), "%s, %s %dpx",
|
||||
th_face, th_icon ? th_icon : "DejaVuSansM Nerd Font", px);
|
||||
fonts[0] = xres_font;
|
||||
} else if (dm_font) {
|
||||
snprintf(xres_font, sizeof(xres_font), "%s", dm_font);
|
||||
fonts[0] = xres_font;
|
||||
}
|
||||
|
||||
struct { int scm; int col; const char *k1; const char *k2; } map[] = {
|
||||
@@ -267,6 +267,7 @@ static void grabkeyboard(void) {
|
||||
return;
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
die("cannot grab keyboard");
|
||||
}
|
||||
|
||||
static int compare_distance(const void *a, const void *b) {
|
||||
|
||||
+7
-10
@@ -3,16 +3,16 @@
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
/* appearance */
|
||||
static unsigned int borderpx = 3;
|
||||
static unsigned int snap = 24;
|
||||
static unsigned int borderpx = 4;
|
||||
static unsigned int snap = 36;
|
||||
static const int showbar = 1;
|
||||
static const int topbar = 1;
|
||||
static const unsigned int systraypinning = 0;
|
||||
static const unsigned int systrayonleft = 0;
|
||||
static const unsigned int systrayspacing = 6;
|
||||
static const unsigned int systrayspacing = 8;
|
||||
static const int systraypinningfailfirst = 1;
|
||||
static const int showsystray = 1;
|
||||
static const char *font = "Fira Code, DejaVuSansM Nerd Font 20px";
|
||||
static const char *font = "Fira Code, DejaVuSansM Nerd Font 38px";
|
||||
static char normbgcolor[64] = "#0b0e14";
|
||||
static char normbordercolor[64] = "#283444";
|
||||
static char normfgcolor[64] = "#e6e1cf";
|
||||
@@ -26,7 +26,7 @@ static char *colors[][3] = {
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
@@ -117,7 +117,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XK_o, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
{ MODKEY, XK_space, spawn, {.v = launchercmd} },
|
||||
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_q, killclient, {0} },
|
||||
@@ -140,10 +141,6 @@ static const Key keys[] = {
|
||||
TAGKEYS( XK_3, 2)
|
||||
TAGKEYS( XK_4, 3)
|
||||
TAGKEYS( XK_5, 4)
|
||||
TAGKEYS( XK_6, 5)
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
|
||||
+7
-10
@@ -3,16 +3,16 @@
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
/* appearance */
|
||||
static unsigned int borderpx = 3;
|
||||
static unsigned int snap = 24;
|
||||
static unsigned int borderpx = 4;
|
||||
static unsigned int snap = 36;
|
||||
static const int showbar = 1;
|
||||
static const int topbar = 1;
|
||||
static const unsigned int systraypinning = 0;
|
||||
static const unsigned int systrayonleft = 0;
|
||||
static const unsigned int systrayspacing = 6;
|
||||
static const unsigned int systrayspacing = 8;
|
||||
static const int systraypinningfailfirst = 1;
|
||||
static const int showsystray = 1;
|
||||
static const char *font = "Fira Code, DejaVuSansM Nerd Font 20px";
|
||||
static const char *font = "Fira Code, DejaVuSansM Nerd Font 38px";
|
||||
static char normbgcolor[64] = "#0b0e14";
|
||||
static char normbordercolor[64] = "#283444";
|
||||
static char normfgcolor[64] = "#e6e1cf";
|
||||
@@ -26,7 +26,7 @@ static char *colors[][3] = {
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
@@ -117,7 +117,8 @@ static const Key keys[] = {
|
||||
{ MODKEY, XK_o, incnmaster, {.i = -1} },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_space, zoom, {0} },
|
||||
{ MODKEY, XK_space, spawn, {.v = launchercmd} },
|
||||
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
{ MODKEY, XK_Tab, view, {0} },
|
||||
{ MODKEY|ShiftMask, XK_q, killclient, {0} },
|
||||
@@ -140,10 +141,6 @@ static const Key keys[] = {
|
||||
TAGKEYS( XK_3, 2)
|
||||
TAGKEYS( XK_4, 3)
|
||||
TAGKEYS( XK_5, 4)
|
||||
TAGKEYS( XK_6, 5)
|
||||
TAGKEYS( XK_7, 6)
|
||||
TAGKEYS( XK_8, 7)
|
||||
TAGKEYS( XK_9, 8)
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {0} },
|
||||
};
|
||||
|
||||
|
||||
+21
-15
@@ -53,8 +53,8 @@
|
||||
#define VERSION_MINOR 0
|
||||
#define XEMBED_EMBEDDED_VERSION_VAL ((VERSION_MAJOR << 16) | VERSION_MINOR)
|
||||
|
||||
#define LAUNCHER_W 58
|
||||
#define CLOSEBTN_W 52
|
||||
#define LAUNCHER_W 84
|
||||
#define CLOSEBTN_W 76
|
||||
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
enum { SchemeNorm, SchemeSel };
|
||||
@@ -556,7 +556,7 @@ static void clientmessage(XEvent *e) {
|
||||
XReparentWindow(dpy, c->win, systray->win, 0, 0);
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
XChangeWindowAttributes(dpy, c->win, CWBackPixel, &swa);
|
||||
sendevent(c->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
|
||||
sendevent(c->win, xatom[Xembed], StructureNotifyMask, CurrentTime,
|
||||
XEMBED_EMBEDDED_NOTIFY, 0, (long)systray->win, XEMBED_EMBEDDED_VERSION_VAL);
|
||||
XSync(dpy, False);
|
||||
resizebarwin(selmon);
|
||||
@@ -613,6 +613,7 @@ static void configurenotify(XEvent *e) {
|
||||
if (c->isfullscreen) resizeclient(c, m->mx, m->my, m->mw, m->mh);
|
||||
resizebarwin(m);
|
||||
}
|
||||
updatesystray(0);
|
||||
focus(NULL);
|
||||
arrange(NULL);
|
||||
}
|
||||
@@ -736,7 +737,8 @@ static void drawbar(Monitor *m) {
|
||||
|
||||
/* Launcher touch button */
|
||||
drw_setscheme(drw, scheme[SchemeSel]);
|
||||
drw_text(drw, 0, 0, LAUNCHER_W, (unsigned int)bh, 14, "\xef\x83\x89", 0, False);
|
||||
int lpad = (LAUNCHER_W - (int)drw_font_getwidth(drw, "\xef\x83\x89", False)) / 2;
|
||||
drw_text(drw, 0, 0, LAUNCHER_W, (unsigned int)bh, (unsigned int)MAX(lpad, 8), "\xef\x83\x89", 0, False);
|
||||
x = LAUNCHER_W;
|
||||
|
||||
for (i = 0; i < LENGTH(tags); i++) {
|
||||
@@ -763,8 +765,9 @@ static void drawbar(Monitor *m) {
|
||||
if (m->sel->isfloating)
|
||||
drw_rect(drw, x + boxs, boxs, (unsigned int)boxw, (unsigned int)boxw, m->sel->isfixed, 0);
|
||||
if (avail > CLOSEBTN_W + 40) {
|
||||
int cpad = (CLOSEBTN_W - (int)drw_font_getwidth(drw, "\xc3\x97", False)) / 2;
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, x + title_w, 0, CLOSEBTN_W, (unsigned int)bh, 14, "\xc3\x97", 0, False);
|
||||
drw_text(drw, x + title_w, 0, CLOSEBTN_W, (unsigned int)bh, (unsigned int)MAX(cpad, 8), "\xc3\x97", 0, False);
|
||||
}
|
||||
} else {
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
@@ -971,8 +974,10 @@ static void grabkeys(void) {
|
||||
for (j = 0; j < LENGTH(modifiers); j++) {
|
||||
XGrabKey(dpy, kc, keys[i].mod | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
if (keys[i].mod & Mod4Mask) {
|
||||
/* Fn+Alt frequently preserves Mod5Mask alongside Mod4Mask under XKB */
|
||||
/* Fn+Alt frequently preserves Mod1Mask and/or Mod5Mask alongside Mod4Mask under XKB */
|
||||
XGrabKey(dpy, kc, keys[i].mod | Mod5Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, kc, keys[i].mod | Mod1Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, kc, keys[i].mod | Mod1Mask | Mod5Mask | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
if (active_latch) {
|
||||
XGrabKey(dpy, kc, (keys[i].mod & ~Mod4Mask) | modifiers[j], root, True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
@@ -1037,10 +1042,10 @@ static void keypress(XEvent *e) {
|
||||
if (CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)) {
|
||||
matched = 1;
|
||||
} else if ((keys[i].mod & Mod4Mask) &&
|
||||
CLEANMASK(keys[i].mod) == CLEANMASK(ev->state & ~Mod5Mask)) {
|
||||
CLEANMASK(keys[i].mod) == CLEANMASK(ev->state & ~(Mod1Mask | Mod5Mask))) {
|
||||
matched = 1;
|
||||
} else if (active_latch && (keys[i].mod & Mod4Mask) &&
|
||||
CLEANMASK(keys[i].mod & ~Mod4Mask) == CLEANMASK(ev->state & ~Mod5Mask)) {
|
||||
CLEANMASK(keys[i].mod & ~Mod4Mask) == CLEANMASK(ev->state & ~(Mod1Mask | Mod5Mask))) {
|
||||
matched = 1;
|
||||
super_latched = 0;
|
||||
grabkeys();
|
||||
@@ -1118,8 +1123,8 @@ static void loadxres(void) {
|
||||
} else if ((v = xrm_lookup(db, "theme.fontFace", NULL, NULL))) {
|
||||
const char *ic = xrm_lookup(db, "theme.iconFontFace", NULL, NULL);
|
||||
const char *bs = xrm_lookup(db, "theme.baseFontSize", NULL, NULL);
|
||||
int px = bs ? atoi(bs) : 20;
|
||||
if (px < 12 || px > 42) px = 20;
|
||||
int px = bs ? atoi(bs) : 30;
|
||||
if (px < 12 || px > 64) px = 30;
|
||||
snprintf(xres_font, sizeof(xres_font), "%s, %s %dpx",
|
||||
v, ic ? ic : "DejaVuSansM Nerd Font", px);
|
||||
font = xres_font;
|
||||
@@ -1155,8 +1160,8 @@ static void reloadxres(const Arg *arg) {
|
||||
}
|
||||
dwmfont = drw_font_create(drw, font);
|
||||
drw_setfont(drw, dwmfont);
|
||||
lrpad = (int)dwmfont->h + 4;
|
||||
bh = MAX((int)dwmfont->h + 18, 44);
|
||||
lrpad = (int)dwmfont->h + 8;
|
||||
bh = MAX((int)dwmfont->h + 24, 78);
|
||||
drw_resize(drw, (unsigned int)sw, (unsigned int)bh);
|
||||
|
||||
free(scheme[SchemeNorm]);
|
||||
@@ -1247,10 +1252,11 @@ static void maprequest(XEvent *e) {
|
||||
XMapRequestEvent *ev = &e->xmaprequest;
|
||||
Client *i;
|
||||
if ((i = wintosystrayicon(ev->window))) {
|
||||
sendevent(i->win, netatom[Xembed], StructureNotifyMask, CurrentTime,
|
||||
sendevent(i->win, xatom[Xembed], StructureNotifyMask, CurrentTime,
|
||||
XEMBED_WINDOW_ACTIVATE, 0, (long)systray->win, 0);
|
||||
resizebarwin(selmon);
|
||||
updatesystray(0);
|
||||
return;
|
||||
}
|
||||
if (!XGetWindowAttributes(dpy, ev->window, &wa) || wa.override_redirect)
|
||||
return;
|
||||
@@ -1694,8 +1700,8 @@ static void setup(void) {
|
||||
drw = drw_create(dpy, screen, root, (unsigned int)sw, (unsigned int)sh);
|
||||
dwmfont = drw_font_create(drw, font);
|
||||
drw_setfont(drw, dwmfont);
|
||||
lrpad = (int)dwmfont->h + 4;
|
||||
bh = MAX((int)dwmfont->h + 18, 44);
|
||||
lrpad = (int)dwmfont->h + 8;
|
||||
bh = MAX((int)dwmfont->h + 24, 78);
|
||||
updategeom();
|
||||
|
||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
|
||||
@@ -195,7 +195,7 @@ int main(int argc, char **argv) {
|
||||
snprintf(st.state_label, sizeof(st.state_label), "Connecting Voice Call...");
|
||||
}
|
||||
|
||||
st.app = gemui_create("geminux-callscreen", "Geminux Voice Call", 1600, 860, false);
|
||||
st.app = gemui_create("geminux-callscreen", "Geminux Voice Call", 1900, 920, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
|
||||
@@ -429,7 +429,8 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_header(app, cr, "\xef\x80\xb0", "Geminux Camera", badge);
|
||||
|
||||
int pad = 20;
|
||||
gemui_rect_t vf = {pad, 80, w - 260 - pad * 3, h - 100};
|
||||
int rw = 320;
|
||||
gemui_rect_t vf = {pad, 92, w - rw - pad * 3, h - 112};
|
||||
gemui_fill_round(cr, vf, 14, t->bg_overlay);
|
||||
gemui_stroke_round(cr, vf, 14, 2.0, st->recording ? t->danger : t->border);
|
||||
|
||||
@@ -448,25 +449,24 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
cairo_paint(cr);
|
||||
cairo_restore(cr);
|
||||
} else {
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){vf.x + 24, vf.y + vf.h / 2 - 40, vf.w - 48, 40},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){vf.x + 24, vf.y + vf.h / 2 - 48, vf.w - 48, 48},
|
||||
"Camera Stream Unavailable", 4, true, GEMUI_ALIGN_CENTER, t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){vf.x + 24, vf.y + vf.h / 2 + 8, vf.w - 48, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){vf.x + 24, vf.y + vf.h / 2 + 10, vf.w - 48, 42},
|
||||
"Waiting for hi556 / mt6797-seninf V4L2 /dev/video* device",
|
||||
-2, false, GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
}
|
||||
|
||||
int rx = vf.x + vf.w + pad;
|
||||
int rw = 260;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 96, rw, 92},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 96, rw, 96},
|
||||
"Photo (JPEG)", HIT_SHUTTER, 0, true, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 208, rw, 92},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 210, rw, 96},
|
||||
st->recording ? "Stop AVI" : "Record AVI", HIT_RECORD, 0, false, st->recording, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 320, rw, 76},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){rx, 324, rw, 80},
|
||||
"Switch Sensor", HIT_SWITCH, 0, false, false, false);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rx, 430, rw, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rx, 430, rw, 40},
|
||||
st->last_file[0] ? "Last Saved:" : "", -3, true, GEMUI_ALIGN_LEFT, t->fg_muted);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rx, 466, rw, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rx, 474, rw, 40},
|
||||
st->last_file[0] ? st->last_file : "Space: Shutter",
|
||||
-3, false, GEMUI_ALIGN_LEFT, t->accent);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ int main(void) {
|
||||
st.vfd = -1;
|
||||
discover_cameras(&st);
|
||||
|
||||
st.app = gemui_create("geminux-camera", "Geminux Camera", 1640, 900, false);
|
||||
st.app = gemui_create("geminux-camera", "Geminux Camera", 1920, 940, false);
|
||||
if (!st.app) return 1;
|
||||
if (st.num_devs > 0) open_camera_idx(&st, 0);
|
||||
|
||||
|
||||
@@ -124,18 +124,18 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_header(app, cr, "\xef\x8a\xb9", "Geminux Contacts", badge);
|
||||
|
||||
int pad = 20;
|
||||
int top = 80;
|
||||
int top = 92;
|
||||
int left_w = (w - pad * 3) / 2;
|
||||
int right_x = pad * 2 + left_w;
|
||||
int right_w = w - right_x - pad;
|
||||
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, top, left_w - 148, 60},
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, top, left_w - 172, 68},
|
||||
"Search name or number...", st->search, false,
|
||||
st->focus == 0, HIT_SEARCH, 0);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + left_w - 136, top, 136, 60},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + left_w - 160, top, 160, 68},
|
||||
"+ New", HIT_NEW, 0, true, false, false);
|
||||
|
||||
gemui_rect_t list = {pad, top + 74, left_w, h - (top + 74) - pad};
|
||||
gemui_rect_t list = {pad, top + 82, left_w, h - (top + 82) - pad};
|
||||
gemui_fill_round(cr, list, 12, t->bg_bar);
|
||||
gemui_stroke_round(cr, list, 12, 1.5, t->border);
|
||||
|
||||
@@ -143,17 +143,17 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_text(cr, t, list, "No matching contacts", 0, false,
|
||||
GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
} else {
|
||||
int rh = 72;
|
||||
int rh = 84;
|
||||
for (int i = 0; i < st->num_filtered; i++) {
|
||||
int idx = st->filtered[i];
|
||||
gemui_rect_t rr = {list.x + 10, list.y + 8 + i * rh, list.w - 20, rh - 6};
|
||||
if (rr.y + rr.h > list.y + list.h) break;
|
||||
bool sel = (idx == st->sel_idx);
|
||||
gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 28, 32},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 28, 38},
|
||||
st->items[idx].name, -1, true, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 34, rr.w - 28, 28},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 42, rr.w - 28, 34},
|
||||
st->items[idx].number, -2, false, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->accent_alt);
|
||||
gemui_hit_add(app, rr, HIT_ROW, idx);
|
||||
@@ -165,31 +165,31 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_fill_round(cr, card, 14, t->bg_overlay);
|
||||
gemui_stroke_round(cr, card, 14, 1.5, t->border);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 20, card.w - 48, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 20, card.w - 48, 42},
|
||||
st->sel_idx >= 0 ? "Edit Contact" : "New Contact",
|
||||
4, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 74, card.w - 48, 30},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 82, card.w - 48, 36},
|
||||
"Full Name", -2, false, GEMUI_ALIGN_LEFT, t->fg_muted);
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 24, card.y + 108, card.w - 48, 66},
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 24, card.y + 122, card.w - 48, 72},
|
||||
"Enter contact name", st->edit_name, false,
|
||||
st->focus == 1, HIT_NAME, 0);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 194, card.w - 48, 30},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 212, card.w - 48, 36},
|
||||
"Phone Number", -2, false, GEMUI_ALIGN_LEFT, t->fg_muted);
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 24, card.y + 228, card.w - 48, 66},
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 24, card.y + 252, card.w - 48, 72},
|
||||
"+1...", st->edit_phone, false,
|
||||
st->focus == 2, HIT_PHONE, 0);
|
||||
|
||||
int bw = (card.w - 60) / 2;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 24, card.y + 324, bw, 72},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 24, card.y + 352, bw, 78},
|
||||
"Save Contact", HIT_SAVE, 0, true, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 36 + bw, card.y + 324, bw, 72},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 36 + bw, card.y + 352, bw, 78},
|
||||
"Delete", HIT_DEL, 0, false, false, false);
|
||||
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 24, card.y + 420, bw, 76},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 24, card.y + 452, bw, 82},
|
||||
"Call Contact", HIT_CALL, 0, false, st->edit_phone[0] != '\0', false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 36 + bw, card.y + 420, bw, 76},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 36 + bw, card.y + 452, bw, 82},
|
||||
"Send SMS", HIT_SMS, 0, false, false, false);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ int main(void) {
|
||||
load_contacts(&st);
|
||||
if (st.num_items > 0) select_contact(&st, 0);
|
||||
|
||||
st.app = gemui_create("geminux-contacts", "Geminux Contacts", 1640, 900, false);
|
||||
st.app = gemui_create("geminux-contacts", "Geminux Contacts", 1920, 940, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
|
||||
@@ -98,45 +98,45 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
int pad = 24;
|
||||
int cw = (w - pad * 2);
|
||||
|
||||
st->bri_rect = (gemui_rect_t){pad, 88, cw, 92};
|
||||
st->bri_rect = (gemui_rect_t){pad, 92, cw, 104};
|
||||
char btxt[32];
|
||||
double bnorm = st->bl_max > 0 ? (double)st->bl_cur / st->bl_max : 0.5;
|
||||
snprintf(btxt, sizeof(btxt), "%d%%", (int)(bnorm * 100.0 + 0.5));
|
||||
gemui_draw_slider(app, cr, st->bri_rect, "Display Backlight", bnorm, btxt, HIT_BRI, 0, false);
|
||||
|
||||
st->vol_rect = (gemui_rect_t){pad, 196, cw, 92};
|
||||
st->vol_rect = (gemui_rect_t){pad, 210, cw, 104};
|
||||
char vtxt[32];
|
||||
snprintf(vtxt, sizeof(vtxt), "%d%%", st->vol_pct);
|
||||
gemui_draw_slider(app, cr, st->vol_rect, "Master Audio Volume", st->vol_pct / 100.0, vtxt, HIT_VOL, 0, false);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){pad, 308, cw, 34},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){pad, 330, cw, 40},
|
||||
"MT6797X Power Profile (A72 Big Cluster + Schedutil)",
|
||||
-1, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
int pw = (cw - 24) / 3;
|
||||
static const char *profs[3] = {"Eco (A53 Only)", "Balanced", "Performance (10-Core)"};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (pw + 12), 348, pw, 72},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (pw + 12), 376, pw, 78},
|
||||
profs[i], HIT_PROF, i, false, st->profile == i, false);
|
||||
}
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){pad, 444, cw, 34},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){pad, 472, cw, 40},
|
||||
"AW9120 LED Strip Indicator", -1, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
int lw = (cw - 36) / 4;
|
||||
static const char *leds[4] = {"Off", "Cyan Pulse", "Green OK", "Amber Warn"};
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (lw + 12), 484, lw, 68},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (lw + 12), 518, lw, 76},
|
||||
leds[i], HIT_LED, i, false, false, false);
|
||||
}
|
||||
|
||||
int ay = h - 104;
|
||||
int ay = h - 106;
|
||||
int aw = (cw - 36) / 4;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad, ay, aw, 78},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad, ay, aw, 82},
|
||||
"Lock Screen", HIT_LOCK, 0, false, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + aw + 12, ay, aw, 78},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + aw + 12, ay, aw, 82},
|
||||
"Suspend Now", HIT_SUSPEND, 0, true, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (aw + 12), ay, aw, 78},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (aw + 12), ay, aw, 82},
|
||||
"Reboot", HIT_REBOOT, 0, false, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + 3 * (aw + 12), ay, aw, 78},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + 3 * (aw + 12), ay, aw, 82},
|
||||
"Power Off", HIT_POWER, 0, false, false, false);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ int main(void) {
|
||||
st.profile = 1;
|
||||
refresh_hw(&st);
|
||||
|
||||
st.app = gemui_create("geminux-control", "Geminux Control Center", 1480, 720, false);
|
||||
st.app = gemui_create("geminux-control", "Geminux Control Center", 1880, 900, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
|
||||
@@ -120,21 +120,21 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_header(app, cr, "\xef\x82\x95", "Geminux Dialer", st->modem_status);
|
||||
|
||||
int pad = 20;
|
||||
int top = 80;
|
||||
int top = 92;
|
||||
int left_w = (w - pad * 3) / 2;
|
||||
int right_x = pad * 2 + left_w;
|
||||
int right_w = w - right_x - pad;
|
||||
|
||||
/* Number input box */
|
||||
gemui_rect_t disp = {pad, top, left_w, 80};
|
||||
gemui_rect_t disp = {pad, top, left_w, 88};
|
||||
gemui_fill_round(cr, disp, 12, t->bg_input_focus);
|
||||
gemui_stroke_round(cr, disp, 12, 2.0, t->accent);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){disp.x + 18, disp.y, disp.w - 130, disp.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){disp.x + 18, disp.y, disp.w - 140, disp.h},
|
||||
st->number[0] ? st->number : "Type or tap number...",
|
||||
10, true, GEMUI_ALIGN_LEFT,
|
||||
st->number[0] ? t->fg_bright : t->fg_muted);
|
||||
|
||||
gemui_rect_t clr = {disp.x + disp.w - 108, disp.y + 10, 96, 60};
|
||||
gemui_rect_t clr = {disp.x + disp.w - 116, disp.y + 12, 104, 64};
|
||||
gemui_draw_button(app, cr, clr, "CLR", HIT_CLEAR, 0, false, false, false);
|
||||
|
||||
/* DTMF 4x3 keypad + Back/Dial action bar */
|
||||
@@ -144,9 +144,9 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
"7 PQRS", "8 TUV", "9 WXYZ",
|
||||
"*", "0 +", "#"
|
||||
};
|
||||
int kp_top = top + 96;
|
||||
int btn_h = (h - kp_top - 104 - 3 * 12) / 4;
|
||||
if (btn_h < 64) btn_h = 64;
|
||||
int kp_top = top + 104;
|
||||
int btn_h = (h - kp_top - 110 - 3 * 12) / 4;
|
||||
if (btn_h < 68) btn_h = 68;
|
||||
int btn_w = (left_w - 2 * 12) / 3;
|
||||
|
||||
for (int i = 0; i < 12; i++) {
|
||||
@@ -161,24 +161,24 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_button(app, cr, br, keys[i], HIT_DIGIT, i, false, false, false);
|
||||
}
|
||||
|
||||
int act_y = h - 88;
|
||||
int act_y = h - 94;
|
||||
int third = (left_w - 24) / 3;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad, act_y, third, 68},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad, act_y, third, 74},
|
||||
"Backspace", HIT_BACK, 0, false, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + third + 12, act_y, third, 68},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + third + 12, act_y, third, 74},
|
||||
"Send SMS", HIT_SMS, 0, false, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + 2 * (third + 12), act_y,
|
||||
left_w - 2 * (third + 12), 68},
|
||||
left_w - 2 * (third + 12), 74},
|
||||
"Call Now", HIT_DIAL, 0, true, false, false);
|
||||
|
||||
/* Right panel: Recents / Contacts tabs */
|
||||
int tab_w = (right_w - 12) / 2;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x, top, tab_w, 60},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x, top, tab_w, 66},
|
||||
"Recent Calls", HIT_RECENT, -1, false, st->list_tab == 0, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x + tab_w + 12, top, tab_w, 60},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x + tab_w + 12, top, tab_w, 66},
|
||||
"Contacts", HIT_CONTACT, -1, false, st->list_tab == 1, false);
|
||||
|
||||
gemui_rect_t list_box = {right_x, top + 74, right_w, h - (top + 74) - 20};
|
||||
gemui_rect_t list_box = {right_x, top + 80, right_w, h - (top + 80) - 20};
|
||||
gemui_fill_round(cr, list_box, 12, t->bg_bar);
|
||||
gemui_stroke_round(cr, list_box, 12, 1.5, t->border);
|
||||
|
||||
@@ -191,20 +191,20 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
return;
|
||||
}
|
||||
|
||||
int row_h = 72;
|
||||
int row_h = 84;
|
||||
int max_rows = (list_box.h - 16) / row_h;
|
||||
for (int i = 0; i < count && i < max_rows; i++) {
|
||||
int idx = (st->list_tab == 0) ? (count - 1 - i) : i;
|
||||
gemui_rect_t rr = {list_box.x + 10, list_box.y + 8 + i * row_h, list_box.w - 20, row_h - 6};
|
||||
bool sel = (idx == st->selected);
|
||||
gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 220, 32},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 240, 38},
|
||||
arr[idx].name, -1, true, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 34, rr.w - 220, 28},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 42, rr.w - 240, 34},
|
||||
arr[idx].number, -2, false, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->accent_alt);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 200, rr.y, 186, rr.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 220, rr.y, 206, rr.h},
|
||||
arr[idx].detail, -3, false, GEMUI_ALIGN_RIGHT,
|
||||
sel ? t->sel_fg : t->fg_muted);
|
||||
gemui_hit_add(app, rr, (st->list_tab == 0) ? HIT_RECENT : HIT_CONTACT, idx);
|
||||
@@ -299,7 +299,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
refresh_state(&st);
|
||||
|
||||
st.app = gemui_create("geminux-dialer", "Geminux Dialer", 1600, 900, false);
|
||||
st.app = gemui_create("geminux-dialer", "Geminux Dialer", 1920, 940, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
|
||||
@@ -117,36 +117,36 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
strftime(clock_str, sizeof(clock_str), "%H:%M", &tm);
|
||||
strftime(date_str, sizeof(date_str), "%A, %d %B %Y", &tm);
|
||||
|
||||
int cw = 760;
|
||||
int cw = 920;
|
||||
if (cw > w - 80) cw = w - 80;
|
||||
gemui_rect_t card = {(w - cw) / 2, (h - 520) / 2, cw, 520};
|
||||
gemui_rect_t card = {(w - cw) / 2, (h - 620) / 2, cw, 620};
|
||||
gemui_fill_round(cr, card, 18, t->bg_overlay);
|
||||
gemui_stroke_round(cr, card, 18, 2.0, t->border);
|
||||
|
||||
gemui_draw_icon(cr, t, (gemui_rect_t){card.x, card.y + 28, card.w, 52},
|
||||
gemui_draw_icon(cr, t, (gemui_rect_t){card.x, card.y + 32, card.w, 60},
|
||||
"\xef\x80\xa3", 14, GEMUI_ALIGN_CENTER, t->accent);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 84, card.w - 48, 84},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 96, card.w - 48, 100},
|
||||
clock_str, 26, true, GEMUI_ALIGN_CENTER, t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 172, card.w - 48, 40},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 204, card.w - 48, 46},
|
||||
date_str, 2, false, GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
|
||||
char status[128];
|
||||
snprintf(status, sizeof(status), "%s | User: %s", st->bat_text, st->user);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 220, card.w - 48, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 24, card.y + 256, card.w - 48, 42},
|
||||
status, -1, false, GEMUI_ALIGN_CENTER, t->accent_alt);
|
||||
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 48, card.y + 280, card.w - 96, 72},
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){card.x + 48, card.y + 322, card.w - 96, 82},
|
||||
"Type password and press Enter...", st->password, true, true, -1, 0);
|
||||
|
||||
if (st->err_msg[0]) {
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 48, card.y + 362, card.w - 96, 36},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){card.x + 48, card.y + 414, card.w - 96, 42},
|
||||
st->err_msg, -1, true, GEMUI_ALIGN_CENTER, t->danger);
|
||||
}
|
||||
|
||||
int bw = (card.w - 112) / 2;
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 48, card.y + 414, bw, 72},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 48, card.y + 474, bw, 84},
|
||||
"Clear", HIT_CLEAR, 0, false, false, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 64 + bw, card.y + 414, bw, 72},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){card.x + 64 + bw, card.y + 474, bw, 84},
|
||||
"Unlock", HIT_UNLOCK, 0, true, false, false);
|
||||
}
|
||||
|
||||
@@ -198,6 +198,17 @@ int main(void) {
|
||||
if (!st.app) return 1;
|
||||
st.grabbed = gemui_grab_input(st.app);
|
||||
|
||||
const char *rfd_s = getenv("GEMINUX_LOCK_READY_FD");
|
||||
if (rfd_s && rfd_s[0]) {
|
||||
int rfd = atoi(rfd_s);
|
||||
if (rfd >= 0) {
|
||||
ssize_t wr = write(rfd, "1", 1);
|
||||
(void)wr;
|
||||
close(rfd);
|
||||
}
|
||||
unsetenv("GEMINUX_LOCK_READY_FD");
|
||||
}
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
gemui_set_handlers(st.app, &h, &st);
|
||||
gemui_set_timer_ms(st.app, 1000, on_timer, &st);
|
||||
|
||||
@@ -118,40 +118,40 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_header(app, cr, "\xef\x87\xab", "Geminux Network & Radios", st->status_text);
|
||||
|
||||
int pad = 20;
|
||||
int top = 80;
|
||||
int top = 92;
|
||||
int tab_w = (w - pad * 2 - 3 * 12) / 4;
|
||||
static const char *tabs[4] = {"Wi-Fi", "4G / CCCI", "Bluetooth", "USB & HDMI"};
|
||||
for (int i = 0; i < 4; i++) {
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (tab_w + 12), top, tab_w, 60},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + i * (tab_w + 12), top, tab_w, 66},
|
||||
tabs[i], HIT_TAB, i, false, st->tab == i, false);
|
||||
}
|
||||
|
||||
int cy = top + 76;
|
||||
int cy = top + 82;
|
||||
int ctrl_w = (w - pad * 2 - 12) / 2;
|
||||
if (st->tab == 0) {
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 66},
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
|
||||
"Wi-Fi Radio", st->wifi_on, HIT_TOGGLE, 0, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 66},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
|
||||
"Rescan Networks", HIT_ACTION, 0, true, false, false);
|
||||
} else if (st->tab == 1) {
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 66},
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
|
||||
"MT6797 Modem Active", st->cellular_on, HIT_TOGGLE, 1, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 66},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
|
||||
"Reset CCCI Modem", HIT_ACTION, 1, false, false, false);
|
||||
} else if (st->tab == 2) {
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 66},
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
|
||||
"Bluetooth Radio", st->bt_on, HIT_TOGGLE, 2, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 66},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
|
||||
"Scan 10s", HIT_ACTION, 2, true, false, false);
|
||||
} else {
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 66},
|
||||
gemui_draw_toggle(app, cr, (gemui_rect_t){pad, cy, ctrl_w, 72},
|
||||
"SiI9024 HDMI Extend", st->hdmi_on, HIT_TOGGLE, 3, false);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 66},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){pad + ctrl_w + 12, cy, ctrl_w, 72},
|
||||
"Mirror Primary Display", HIT_ACTION, 3, true, false, false);
|
||||
}
|
||||
|
||||
int foot_h = (st->tab == 0) ? 84 : 0;
|
||||
gemui_rect_t box = {pad, cy + 80, w - pad * 2, h - (cy + 80) - pad - foot_h};
|
||||
int foot_h = (st->tab == 0) ? 94 : 0;
|
||||
gemui_rect_t box = {pad, cy + 88, w - pad * 2, h - (cy + 88) - pad - foot_h};
|
||||
gemui_fill_round(cr, box, 12, t->bg_bar);
|
||||
gemui_stroke_round(cr, box, 12, 1.5, t->border);
|
||||
|
||||
@@ -159,19 +159,19 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_text(cr, t, box, "No interfaces or scan results available", 0, false,
|
||||
GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
} else {
|
||||
int rh = 64;
|
||||
int rh = 72;
|
||||
for (int i = 0; i < st->num_rows; i++) {
|
||||
gemui_rect_t rr = {box.x + 10, box.y + 8 + i * rh, box.w - 20, rh - 6};
|
||||
if (rr.y + rr.h > box.y + box.h) break;
|
||||
bool sel = (i == st->sel_row);
|
||||
gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 320, rr.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 16, rr.y, rr.w - 360, rr.h},
|
||||
st->rows[i].col1, -1, true, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 300, rr.y, 160, rr.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 340, rr.y, 190, rr.h},
|
||||
st->rows[i].col2, -2, false, GEMUI_ALIGN_RIGHT,
|
||||
sel ? t->sel_fg : t->accent_alt);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 130, rr.y, 116, rr.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + rr.w - 140, rr.y, 126, rr.h},
|
||||
st->rows[i].col3, -2, false, GEMUI_ALIGN_RIGHT,
|
||||
sel ? t->sel_fg : t->fg_muted);
|
||||
gemui_hit_add(app, rr, HIT_ROW, i);
|
||||
@@ -179,11 +179,11 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
}
|
||||
|
||||
if (st->tab == 0) {
|
||||
int cw = 220;
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, h - 84, w - pad * 2 - cw - 12, 64},
|
||||
int cw = 260;
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, h - 92, w - pad * 2 - cw - 12, 72},
|
||||
"Wi-Fi passphrase (if connecting to secured SSID)...",
|
||||
st->psk, true, st->focus_psk, HIT_PSK, 0);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){w - pad - cw, h - 84, cw, 64},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){w - pad - cw, h - 92, cw, 72},
|
||||
"Connect Wi-Fi", HIT_CONNECT, 0, true, false, false);
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ int main(void) {
|
||||
st.sel_row = -1;
|
||||
refresh_tab(&st);
|
||||
|
||||
st.app = gemui_create("geminux-net", "Geminux Network & Radios", 1680, 920, false);
|
||||
st.app = gemui_create("geminux-net", "Geminux Network & Radios", 1920, 940, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
gemui_handlers_t h = { .on_draw = on_draw, .on_key = on_key, .on_ptr = on_ptr };
|
||||
|
||||
@@ -147,18 +147,18 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
"Tab: Switch Field | Enter: Send");
|
||||
|
||||
int pad = 20;
|
||||
int top = 80;
|
||||
int left_w = 520;
|
||||
int top = 92;
|
||||
int left_w = 560;
|
||||
if (left_w > w / 3) left_w = w / 3;
|
||||
int right_x = pad * 2 + left_w;
|
||||
int right_w = w - right_x - pad;
|
||||
|
||||
/* Left pane: recipient input + thread list */
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, top, left_w, 60},
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){pad, top, left_w, 68},
|
||||
"New recipient number...", st->new_peer, false,
|
||||
st->focus_mode == 1, HIT_NEW, 0);
|
||||
|
||||
gemui_rect_t pane = {pad, top + 74, left_w, h - (top + 74) - pad};
|
||||
gemui_rect_t pane = {pad, top + 82, left_w, h - (top + 82) - pad};
|
||||
gemui_fill_round(cr, pane, 12, t->bg_bar);
|
||||
gemui_stroke_round(cr, pane, 12, 1.5, t->border);
|
||||
|
||||
@@ -166,18 +166,18 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_text(cr, t, pane, "No SMS threads yet", 0, false,
|
||||
GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
} else {
|
||||
int rh = 76;
|
||||
int rh = 84;
|
||||
for (int i = 0; i < st->num_threads; i++) {
|
||||
gemui_rect_t rr = {pane.x + 10, pane.y + 10 + i * rh, pane.w - 20, rh - 8};
|
||||
if (rr.y + rr.h > pane.y + pane.h) break;
|
||||
bool sel = (i == st->sel_thread);
|
||||
gemui_fill_round(cr, rr, 10, sel ? t->sel_bg : (i % 2 ? t->bg_alt_odd : t->bg_alt_even));
|
||||
thread_t *th = &st->threads[i];
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 28, 32},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 4, rr.w - 28, 38},
|
||||
th->peer, -1, true, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_bright);
|
||||
const char *preview = (th->num_msgs > 0) ? th->msgs[th->num_msgs - 1].text : "";
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 34, rr.w - 28, 28},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 14, rr.y + 42, rr.w - 28, 34},
|
||||
preview, -2, false, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_muted);
|
||||
gemui_hit_add(app, rr, HIT_THREAD, i);
|
||||
@@ -185,13 +185,13 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
}
|
||||
|
||||
/* Right pane: chat history bubbles + compose bar */
|
||||
gemui_rect_t chat = {right_x, top, right_w, h - top - 104};
|
||||
gemui_rect_t chat = {right_x, top, right_w, h - top - 114};
|
||||
gemui_fill_round(cr, chat, 12, t->bg_overlay);
|
||||
gemui_stroke_round(cr, chat, 12, 1.5, t->border);
|
||||
|
||||
if (st->sel_thread >= 0 && st->sel_thread < st->num_threads) {
|
||||
thread_t *th = &st->threads[st->sel_thread];
|
||||
int bh = 84;
|
||||
int bh = 94;
|
||||
int cap = (chat.h - 24) / bh;
|
||||
int start = (th->num_msgs > cap) ? (th->num_msgs - cap) : 0;
|
||||
int y = chat.y + 12;
|
||||
@@ -201,9 +201,9 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
int bx = m->outgoing ? (chat.x + chat.w - bw - 16) : (chat.x + 16);
|
||||
gemui_rect_t br = {bx, y, bw, bh - 10};
|
||||
gemui_fill_round(cr, br, 12, m->outgoing ? t->bg_bubble_out : t->bg_bubble_in);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){br.x + 14, br.y + 6, br.w - 28, 34},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){br.x + 14, br.y + 6, br.w - 28, 42},
|
||||
m->text, -1, false, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){br.x + 14, br.y + 42, br.w - 28, 22},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){br.x + 14, br.y + 50, br.w - 28, 28},
|
||||
m->ts, -4, false, m->outgoing ? GEMUI_ALIGN_RIGHT : GEMUI_ALIGN_LEFT, t->fg_muted);
|
||||
y += bh;
|
||||
}
|
||||
@@ -212,11 +212,11 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
false, GEMUI_ALIGN_CENTER, t->fg_muted);
|
||||
}
|
||||
|
||||
int send_w = 180;
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){right_x, h - 88, right_w - send_w - 12, 68},
|
||||
int send_w = 210;
|
||||
gemui_draw_input(app, cr, (gemui_rect_t){right_x, h - 94, right_w - send_w - 12, 74},
|
||||
"Type SMS message...", st->compose, false,
|
||||
st->focus_mode == 0, HIT_INPUT, 0);
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x + right_w - send_w, h - 88, send_w, 68},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x + right_w - send_w, h - 94, send_w, 74},
|
||||
"Send", HIT_SEND, 0, true, false, false);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
load_threads(&st);
|
||||
|
||||
st.app = gemui_create("geminux-sms", "Geminux SMS Messages", 1640, 900, false);
|
||||
st.app = gemui_create("geminux-sms", "Geminux SMS Messages", 1920, 940, false);
|
||||
if (!st.app) return 1;
|
||||
|
||||
st.inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||
|
||||
@@ -90,7 +90,7 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_draw_header(app, cr, "\xee\x88\xab", "Geminux Unified Themes", t->name);
|
||||
|
||||
int pad = 20;
|
||||
int top = 80;
|
||||
int top = 92;
|
||||
int left_w = (w - pad * 3) / 2;
|
||||
int right_x = pad * 2 + left_w;
|
||||
int right_w = w - right_x - pad;
|
||||
@@ -99,7 +99,7 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
gemui_fill_round(cr, list, 12, t->bg_bar);
|
||||
gemui_stroke_round(cr, list, 12, 1.5, t->border);
|
||||
|
||||
int rh = 64;
|
||||
int rh = 70;
|
||||
int cap = (list.h - 16) / rh;
|
||||
int start = (st->sel >= cap) ? (st->sel - cap + 1) : 0;
|
||||
for (int i = start; i < st->num_items && (i - start) < cap; i++) {
|
||||
@@ -110,42 +110,42 @@ static void on_draw(gemui_app_t *app, cairo_t *cr, int w, int h, void *ud) {
|
||||
const gemui_theme_t *pt = &st->items[i].parsed;
|
||||
gemui_color_t sw[4] = {pt->bg_main, pt->accent, pt->success, pt->danger};
|
||||
for (int k = 0; k < 4; k++) {
|
||||
gemui_fill_round(cr, (gemui_rect_t){rr.x + 12 + k * 28, rr.y + 18, 22, 22}, 5, sw[k]);
|
||||
gemui_fill_round(cr, (gemui_rect_t){rr.x + 12 + k * 30, rr.y + 20, 24, 24}, 6, sw[k]);
|
||||
}
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 132, rr.y, rr.w - 144, rr.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){rr.x + 140, rr.y, rr.w - 152, rr.h},
|
||||
st->items[i].name, -1, sel, GEMUI_ALIGN_LEFT,
|
||||
sel ? t->sel_fg : t->fg_bright);
|
||||
gemui_hit_add(app, rr, HIT_ITEM, i);
|
||||
}
|
||||
|
||||
/* Live Preview Card */
|
||||
gemui_rect_t prev = {right_x, top, right_w, h - top - 104};
|
||||
gemui_rect_t prev = {right_x, top, right_w, h - top - 114};
|
||||
const gemui_theme_t *pt = (st->sel >= 0 && st->sel < st->num_items) ? &st->items[st->sel].parsed : t;
|
||||
gemui_fill_round(cr, prev, 14, pt->bg_main);
|
||||
gemui_stroke_round(cr, prev, 14, 2.0, pt->border);
|
||||
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 16, prev.y + 16, prev.w - 32, 56}, 10, pt->bg_header);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 32, prev.y + 16, prev.w - 64, 56},
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 16, prev.y + 16, prev.w - 32, 64}, 10, pt->bg_header);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 32, prev.y + 16, prev.w - 64, 64},
|
||||
pt->name, 2, true, GEMUI_ALIGN_LEFT, pt->fg_bright);
|
||||
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 24, prev.y + 92, prev.w - 48, 72}, 10, pt->bg_bubble_in);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 40, prev.y + 92, prev.w - 80, 72},
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 24, prev.y + 96, prev.w - 48, 80}, 10, pt->bg_bubble_in);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 40, prev.y + 96, prev.w - 80, 80},
|
||||
"Fira Code Ligatures: -> => !== <= >=", -1, false, GEMUI_ALIGN_LEFT, pt->fg_main);
|
||||
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 24, prev.y + 180, prev.w - 48, 72}, 10, pt->sel_bg);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 40, prev.y + 180, prev.w - 80, 72},
|
||||
gemui_fill_round(cr, (gemui_rect_t){prev.x + 24, prev.y + 192, prev.w - 48, 80}, 10, pt->sel_bg);
|
||||
gemui_draw_text(cr, pt, (gemui_rect_t){prev.x + 40, prev.y + 192, prev.w - 80, 80},
|
||||
"Selected Item & Accent Highlight", -1, true, GEMUI_ALIGN_LEFT, pt->sel_fg);
|
||||
|
||||
int sw_w = (prev.w - 48 - 4 * 10) / 5;
|
||||
gemui_color_t badges[5] = {pt->accent, pt->success, pt->info, pt->warning, pt->danger};
|
||||
static const char *labels[5] = {"Accent", "Success", "Info", "Warn", "Danger"};
|
||||
for (int i = 0; i < 5; i++) {
|
||||
gemui_rect_t br = {prev.x + 24 + i * (sw_w + 10), prev.y + 276, sw_w, 60};
|
||||
gemui_rect_t br = {prev.x + 24 + i * (sw_w + 10), prev.y + 294, sw_w, 68};
|
||||
gemui_fill_round(cr, br, 8, badges[i]);
|
||||
gemui_draw_text(cr, pt, br, labels[i], -3, true, GEMUI_ALIGN_CENTER, pt->bg_main);
|
||||
}
|
||||
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x, h - 88, right_w, 68},
|
||||
gemui_draw_button(app, cr, (gemui_rect_t){right_x, h - 94, right_w, 74},
|
||||
"Apply Across DWM, st, dmenu, dunst & Apps", HIT_APPLY, 0, true, false, false);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ static void on_ptr(gemui_app_t *app, int type, int x, int y, unsigned int btn, v
|
||||
int main(void) {
|
||||
themes_state_t st;
|
||||
memset(&st, 0, sizeof(st));
|
||||
st.app = gemui_create("geminux-themes", "Geminux Unified Themes", 1560, 860, false);
|
||||
st.app = gemui_create("geminux-themes", "Geminux Unified Themes", 1900, 920, false);
|
||||
if (!st.app) return 1;
|
||||
load_themes(&st);
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MODEM_SOCK "/run/geminux/modem.sock"
|
||||
#define STATE_FILE "/run/geminux/modem-state"
|
||||
#define AT_DEV "/dev/ttyC0"
|
||||
#define MODEM_SOCK "/run/geminux/modem.sock"
|
||||
#define MODEM_SOCK_FALLBACK "/tmp/geminux-modem.sock"
|
||||
#define STATE_FILE "/run/geminux/modem-state"
|
||||
#define AT_DEV "/dev/ttyC0"
|
||||
|
||||
typedef struct {
|
||||
int epfd;
|
||||
@@ -29,6 +30,7 @@ typedef struct {
|
||||
bool muted;
|
||||
bool speaker;
|
||||
char active_peer[64];
|
||||
char sock_path[64];
|
||||
} modem_ctx_t;
|
||||
|
||||
static void spawn_bg(const char *const argv[]) {
|
||||
@@ -182,9 +184,31 @@ static void handle_cmd(modem_ctx_t *ctx, int cfd) {
|
||||
}
|
||||
}
|
||||
|
||||
static int bind_modem_socket(modem_ctx_t *ctx) {
|
||||
const char *candidates[2] = { MODEM_SOCK, MODEM_SOCK_FALLBACK };
|
||||
for (int i = 0; i < 2; i++) {
|
||||
unlink(candidates[i]);
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM | O_NONBLOCK | O_CLOEXEC, 0);
|
||||
if (fd < 0) return -1;
|
||||
struct sockaddr_un addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", candidates[i]);
|
||||
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) == 0 && listen(fd, 8) == 0) {
|
||||
chmod(candidates[i], 0660);
|
||||
snprintf(ctx->sock_path, sizeof(ctx->sock_path), "%s", candidates[i]);
|
||||
return fd;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
ctx->sock_path[0] = '\0';
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
modem_ctx_t ctx;
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.srv_fd = -1;
|
||||
ctx.at_fd = -1;
|
||||
mkdir("/run/geminux", 0755);
|
||||
|
||||
@@ -195,18 +219,7 @@ int main(void) {
|
||||
sigprocmask(SIG_BLOCK, &mask, NULL);
|
||||
ctx.sig_fd = signalfd(-1, &mask, SFD_NONBLOCK | SFD_CLOEXEC);
|
||||
|
||||
unlink(MODEM_SOCK);
|
||||
ctx.srv_fd = socket(AF_UNIX, SOCK_STREAM | O_NONBLOCK | O_CLOEXEC, 0);
|
||||
if (ctx.srv_fd >= 0) {
|
||||
struct sockaddr_un addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", MODEM_SOCK);
|
||||
if (bind(ctx.srv_fd, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
|
||||
listen(ctx.srv_fd, 8);
|
||||
chmod(MODEM_SOCK, 0660);
|
||||
}
|
||||
}
|
||||
ctx.srv_fd = bind_modem_socket(&ctx);
|
||||
|
||||
ctx.epfd = epoll_create1(EPOLL_CLOEXEC);
|
||||
int fixed[2] = {ctx.sig_fd, ctx.srv_fd};
|
||||
@@ -232,15 +245,38 @@ int main(void) {
|
||||
if (fd == ctx.sig_fd) {
|
||||
running = false;
|
||||
} else if (fd == ctx.srv_fd) {
|
||||
if (events[i].events & (EPOLLERR | EPOLLHUP)) {
|
||||
epoll_ctl(ctx.epfd, EPOLL_CTL_DEL, ctx.srv_fd, NULL);
|
||||
close(ctx.srv_fd);
|
||||
ctx.srv_fd = -1;
|
||||
continue;
|
||||
}
|
||||
int cfd;
|
||||
while ((cfd = accept4(ctx.srv_fd, NULL, NULL, SOCK_CLOEXEC)) >= 0) {
|
||||
handle_cmd(&ctx, cfd);
|
||||
close(cfd);
|
||||
}
|
||||
if (errno == EINVAL || errno == EBADF || errno == ENOTSOCK || errno == EOPNOTSUPP) {
|
||||
epoll_ctl(ctx.epfd, EPOLL_CTL_DEL, ctx.srv_fd, NULL);
|
||||
close(ctx.srv_fd);
|
||||
ctx.srv_fd = -1;
|
||||
}
|
||||
} else if (fd == ctx.at_fd) {
|
||||
if (events[i].events & (EPOLLHUP | EPOLLERR)) {
|
||||
epoll_ctl(ctx.epfd, EPOLL_CTL_DEL, ctx.at_fd, NULL);
|
||||
close(ctx.at_fd);
|
||||
ctx.at_fd = -1;
|
||||
write_state(&ctx);
|
||||
continue;
|
||||
}
|
||||
char atbuf[512] = {0};
|
||||
ssize_t r = read(ctx.at_fd, atbuf, sizeof(atbuf) - 1);
|
||||
if (r > 0) {
|
||||
if (r == 0 || (r < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)) {
|
||||
epoll_ctl(ctx.epfd, EPOLL_CTL_DEL, ctx.at_fd, NULL);
|
||||
close(ctx.at_fd);
|
||||
ctx.at_fd = -1;
|
||||
write_state(&ctx);
|
||||
} else if (r > 0) {
|
||||
if (strstr(atbuf, "RING")) {
|
||||
const char *ntf[] = {"notify-send", "Incoming Call", "Voice call on MT6797 LTE", NULL};
|
||||
spawn_bg(ntf);
|
||||
@@ -255,7 +291,7 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
|
||||
unlink(MODEM_SOCK);
|
||||
if (ctx.sock_path[0]) unlink(ctx.sock_path);
|
||||
close(ctx.epfd);
|
||||
return 0;
|
||||
}
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <grp.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <poll.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -18,6 +20,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SOCK_PATH "/run/geminux/powerd.sock"
|
||||
@@ -57,7 +60,15 @@ static int read_sysfs_line(const char *path, char *buf, size_t sz) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ensure_run_dir(void) {
|
||||
mkdir("/run/geminux", 0775);
|
||||
chmod("/run/geminux", 0775);
|
||||
struct group *gr = getgrnam("wheel");
|
||||
if (gr) chown("/run/geminux", 0, gr->gr_gid);
|
||||
}
|
||||
|
||||
static void refresh_ac_and_hdmi(powerd_ctx_t *ctx) {
|
||||
write_sysfs_str("/sys/class/power_supply/battery/charge_control_end_threshold", "100");
|
||||
ctx->policy.on_ac_power = false;
|
||||
DIR *d = opendir("/sys/class/power_supply");
|
||||
if (d) {
|
||||
@@ -97,10 +108,13 @@ static void refresh_ac_and_hdmi(powerd_ctx_t *ctx) {
|
||||
static void apply_cpu_policy(powerd_ctx_t *ctx) {
|
||||
geminux_profile_params_t par = geminux_policy_params(ctx->policy.profile, ctx->policy.on_ac_power);
|
||||
|
||||
for (int cpu = 8; cpu <= 9; cpu++) {
|
||||
char p[128];
|
||||
snprintf(p, sizeof(p), "/sys/devices/system/cpu/cpu%d/online", cpu);
|
||||
write_sysfs_str(p, par.a72_online ? "1" : "0");
|
||||
bool a72_ready = (access("/sys/module/mt6797_a72", F_OK) == 0);
|
||||
if (!par.a72_online || a72_ready) {
|
||||
for (int cpu = 8; cpu <= 9; cpu++) {
|
||||
char p[128];
|
||||
snprintf(p, sizeof(p), "/sys/devices/system/cpu/cpu%d/online", cpu);
|
||||
write_sysfs_str(p, par.a72_online ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
||||
DIR *d = opendir("/sys/devices/system/cpu/cpufreq");
|
||||
@@ -123,7 +137,7 @@ static void apply_cpu_policy(powerd_ctx_t *ctx) {
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
mkdir("/run/geminux", 0755);
|
||||
ensure_run_dir();
|
||||
write_sysfs_str(PROFILE_FILE, geminux_policy_profile_name(ctx->policy.profile));
|
||||
|
||||
struct itimerspec its;
|
||||
@@ -158,14 +172,92 @@ static void toggle_backlight(powerd_ctx_t *ctx, bool on) {
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
static bool is_lock_running(void) {
|
||||
DIR *d = opendir("/proc");
|
||||
if (!d) return false;
|
||||
struct dirent *de;
|
||||
while ((de = readdir(d)) != NULL) {
|
||||
if (de->d_name[0] < '0' || de->d_name[0] > '9') continue;
|
||||
char p[300], comm[32] = {0};
|
||||
snprintf(p, sizeof(p), "/proc/%s/comm", de->d_name);
|
||||
if (read_sysfs_line(p, comm, sizeof(comm)) == 0 && strcmp(comm, "geminux-lock") == 0) {
|
||||
closedir(d);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void lock_x11_session(void) {
|
||||
if (access("/tmp/.X11-unix/X0", F_OK) != 0) return;
|
||||
if (is_lock_running()) return;
|
||||
|
||||
struct passwd *pw = getpwnam("user");
|
||||
if (!pw) return;
|
||||
|
||||
int pfd[2];
|
||||
if (pipe(pfd) < 0) return;
|
||||
fcntl(pfd[0], F_SETFD, FD_CLOEXEC);
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
close(pfd[0]);
|
||||
close(pfd[1]);
|
||||
return;
|
||||
}
|
||||
if (pid == 0) {
|
||||
close(pfd[0]);
|
||||
setsid();
|
||||
pid_t p2 = fork();
|
||||
if (p2 == 0) {
|
||||
int devnull = open("/dev/null", O_RDWR);
|
||||
if (devnull >= 0) {
|
||||
if (devnull != STDIN_FILENO) dup2(devnull, STDIN_FILENO);
|
||||
if (devnull != STDOUT_FILENO) dup2(devnull, STDOUT_FILENO);
|
||||
if (devnull != STDERR_FILENO) dup2(devnull, STDERR_FILENO);
|
||||
if (devnull > 2 && devnull != pfd[1]) close(devnull);
|
||||
}
|
||||
initgroups(pw->pw_name, pw->pw_gid);
|
||||
if (setgid(pw->pw_gid) == 0 && setuid(pw->pw_uid) == 0) {
|
||||
const char *home = (pw->pw_dir && pw->pw_dir[0]) ? pw->pw_dir : "/home/user";
|
||||
char xauth[256], rfd_str[16];
|
||||
snprintf(xauth, sizeof(xauth), "%s/.Xauthority", home);
|
||||
snprintf(rfd_str, sizeof(rfd_str), "%d", pfd[1]);
|
||||
setenv("HOME", home, 1);
|
||||
setenv("USER", pw->pw_name, 1);
|
||||
setenv("LOGNAME", pw->pw_name, 1);
|
||||
setenv("DISPLAY", ":0", 1);
|
||||
setenv("XAUTHORITY", xauth, 1);
|
||||
setenv("GEMINUX_LOCK_READY_FD", rfd_str, 1);
|
||||
const char *argv[] = {"/usr/bin/geminux-lock", NULL};
|
||||
execv(argv[0], (char *const *)argv);
|
||||
}
|
||||
_exit(127);
|
||||
}
|
||||
close(pfd[1]);
|
||||
_exit(0);
|
||||
}
|
||||
close(pfd[1]);
|
||||
waitpid(pid, NULL, 0);
|
||||
|
||||
struct pollfd pf = { .fd = pfd[0], .events = POLLIN };
|
||||
poll(&pf, 1, 500);
|
||||
close(pfd[0]);
|
||||
}
|
||||
|
||||
static void trigger_suspend(powerd_ctx_t *ctx) {
|
||||
lock_x11_session();
|
||||
toggle_backlight(ctx, false);
|
||||
write_sysfs_str("/sys/power/mem_sleep", "deep");
|
||||
if (write_sysfs_str("/sys/power/state", "mem") == 0) {
|
||||
/* Woken back up from S3 suspend */
|
||||
if (write_sysfs_str("/sys/power/state", "mem") == 0 ||
|
||||
write_sysfs_str("/sys/power/state", "freeze") == 0) {
|
||||
/* Woken back up from suspend */
|
||||
toggle_backlight(ctx, true);
|
||||
refresh_ac_and_hdmi(ctx);
|
||||
apply_cpu_policy(ctx);
|
||||
} else if (!ctx->policy.lid_closed) {
|
||||
toggle_backlight(ctx, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +267,7 @@ static void scan_input_devices(powerd_ctx_t *ctx) {
|
||||
close(ctx->ev_fds[i]);
|
||||
}
|
||||
ctx->num_ev = 0;
|
||||
ctx->policy.lid_closed = false;
|
||||
|
||||
for (int i = 0; i < 32 && ctx->num_ev < MAX_EVDEVS; i++) {
|
||||
char p[64];
|
||||
@@ -184,6 +277,14 @@ static void scan_input_devices(powerd_ctx_t *ctx) {
|
||||
unsigned long evbits = 0;
|
||||
if (ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), &evbits) >= 0 &&
|
||||
((evbits & (1UL << EV_SW)) || (evbits & (1UL << EV_KEY)))) {
|
||||
if (evbits & (1UL << EV_SW)) {
|
||||
unsigned long swbits = 0, swstate = 0;
|
||||
if (ioctl(fd, EVIOCGBIT(EV_SW, sizeof(swbits)), &swbits) >= 0 &&
|
||||
(swbits & (1UL << SW_LID)) &&
|
||||
ioctl(fd, EVIOCGSW(sizeof(swstate)), &swstate) >= 0) {
|
||||
ctx->policy.lid_closed = !!(swstate & (1UL << SW_LID));
|
||||
}
|
||||
}
|
||||
struct epoll_event ev = { .events = EPOLLIN, .data.fd = fd };
|
||||
if (epoll_ctl(ctx->epfd, EPOLL_CTL_ADD, fd, &ev) == 0) {
|
||||
ctx->ev_fds[ctx->num_ev++] = fd;
|
||||
@@ -238,7 +339,7 @@ static void handle_client_cmd(powerd_ctx_t *ctx, int cfd) {
|
||||
}
|
||||
|
||||
static int setup_unix_server(void) {
|
||||
mkdir("/run/geminux", 0755);
|
||||
ensure_run_dir();
|
||||
unlink(SOCK_PATH);
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM | O_NONBLOCK | O_CLOEXEC, 0);
|
||||
if (fd < 0) return -1;
|
||||
@@ -337,7 +438,14 @@ int main(void) {
|
||||
}
|
||||
} else if (fd == ctx.uev_fd) {
|
||||
char ubuf[2048];
|
||||
while (recv(ctx.uev_fd, ubuf, sizeof(ubuf), 0) > 0) {}
|
||||
ssize_t ur;
|
||||
bool need_ev_rescan = false;
|
||||
while ((ur = recv(ctx.uev_fd, ubuf, sizeof(ubuf), 0)) > 0) {
|
||||
if (memmem(ubuf, (size_t)ur, "SUBSYSTEM=input", 15)) {
|
||||
need_ev_rescan = true;
|
||||
}
|
||||
}
|
||||
if (need_ev_rescan) scan_input_devices(&ctx);
|
||||
refresh_ac_and_hdmi(&ctx);
|
||||
apply_cpu_policy(&ctx);
|
||||
} else {
|
||||
@@ -346,11 +454,15 @@ int main(void) {
|
||||
if (iev.type == EV_SW && iev.code == SW_LID) {
|
||||
ctx.policy.lid_closed = (iev.value != 0);
|
||||
if (ctx.policy.lid_closed) {
|
||||
lock_x11_session();
|
||||
if (geminux_should_suspend_on_lid(&ctx.policy)) {
|
||||
trigger_suspend(&ctx);
|
||||
} else {
|
||||
toggle_backlight(&ctx, false);
|
||||
}
|
||||
} else {
|
||||
toggle_backlight(&ctx, true);
|
||||
refresh_ac_and_hdmi(&ctx);
|
||||
apply_cpu_policy(&ctx);
|
||||
}
|
||||
} else if (iev.type == EV_KEY && iev.code == KEY_POWER && iev.value == 1) {
|
||||
|
||||
@@ -41,34 +41,48 @@ static void read_battery(char *out, size_t sz) {
|
||||
snprintf(out, sz, "BAT:--");
|
||||
DIR *d = opendir("/sys/class/power_supply");
|
||||
if (!d) return;
|
||||
bool usb_online = false;
|
||||
char cap[16] = {0}, st[24] = {0};
|
||||
bool have_bat = false;
|
||||
struct dirent *de;
|
||||
while ((de = readdir(d)) != NULL) {
|
||||
if (de->d_name[0] == '.') continue;
|
||||
char p[320], typ[32] = {0}, cap[16] = {0}, st[24] = {0};
|
||||
char p[320], typ[32] = {0};
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/type", de->d_name);
|
||||
if (read_line(p, typ, sizeof(typ)) != 0 || strcmp(typ, "Battery") != 0) continue;
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/capacity", de->d_name);
|
||||
read_line(p, cap, sizeof(cap));
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/status", de->d_name);
|
||||
read_line(p, st, sizeof(st));
|
||||
const char *tag = (strcmp(st, "Charging") == 0) ? "+" :
|
||||
(strcmp(st, "Full") == 0) ? "=" : "";
|
||||
snprintf(out, sz, "%s%% %s%s", cap[0] ? cap : "?", tag,
|
||||
strcmp(st, "Charging") == 0 ? "CHG" : "BAT");
|
||||
break;
|
||||
if (read_line(p, typ, sizeof(typ)) != 0) continue;
|
||||
if (strcmp(typ, "Battery") == 0 && !have_bat) {
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/capacity", de->d_name);
|
||||
read_line(p, cap, sizeof(cap));
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/status", de->d_name);
|
||||
read_line(p, st, sizeof(st));
|
||||
have_bat = true;
|
||||
} else if (strcmp(typ, "Battery") != 0) {
|
||||
char onl[16] = {0};
|
||||
snprintf(p, sizeof(p), "/sys/class/power_supply/%s/online", de->d_name);
|
||||
if (read_line(p, onl, sizeof(onl)) == 0 && atoi(onl) == 1) {
|
||||
usb_online = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
if (!have_bat) return;
|
||||
if (strcmp(st, "Charging") == 0) {
|
||||
snprintf(out, sz, "%s%% +CHG", cap[0] ? cap : "?");
|
||||
} else if (strcmp(st, "Full") == 0) {
|
||||
snprintf(out, sz, "%s%% =FULL", cap[0] ? cap : "?");
|
||||
} else if (usb_online) {
|
||||
snprintf(out, sz, "%s%% ~USB", cap[0] ? cap : "?");
|
||||
} else {
|
||||
snprintf(out, sz, "%s%% BAT", cap[0] ? cap : "?");
|
||||
}
|
||||
}
|
||||
|
||||
static void update_status(Display *dpy) {
|
||||
char bat[48], mdm[64] = {0}, prof[32] = {0}, net[64] = {0};
|
||||
char bat[48], mdm[64] = {0}, net[64] = {0};
|
||||
read_battery(bat, sizeof(bat));
|
||||
if (read_line("/run/geminux/modem-state", mdm, sizeof(mdm)) != 0) {
|
||||
snprintf(mdm, sizeof(mdm), "4G:OFF");
|
||||
}
|
||||
if (read_line("/run/geminux/power-profile", prof, sizeof(prof)) != 0) {
|
||||
snprintf(prof, sizeof(prof), "balanced");
|
||||
}
|
||||
|
||||
if (iface_up("wlan0")) snprintf(net, sizeof(net), "WiFi:UP");
|
||||
else if (iface_up("usb0")) snprintf(net, sizeof(net), "USB:UP");
|
||||
@@ -82,7 +96,7 @@ static void update_status(Display *dpy) {
|
||||
strftime(clk, sizeof(clk), "%a %d %H:%M", &tm);
|
||||
|
||||
char bar[256];
|
||||
snprintf(bar, sizeof(bar), " %s | %s | %s | %s | %s ", net, mdm, prof, bat, clk);
|
||||
snprintf(bar, sizeof(bar), " %s | %s | %s | %s ", net, mdm, bat, clk);
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), bar);
|
||||
XFlush(dpy);
|
||||
}
|
||||
|
||||
+36
-28
@@ -19,6 +19,7 @@
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xresource.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/cursorfont.h>
|
||||
#include <cairo/cairo-xlib.h>
|
||||
|
||||
typedef struct {
|
||||
@@ -143,8 +144,8 @@ void gemui_theme_defaults(gemui_theme_t *t) {
|
||||
snprintf(t->name, sizeof(t->name), "GeminuxHelio");
|
||||
snprintf(t->font_face, sizeof(t->font_face), "Fira Code");
|
||||
snprintf(t->icon_font_face, sizeof(t->icon_font_face), "DejaVuSansM Nerd Font");
|
||||
t->base_font_size = 22;
|
||||
t->dpi = 168;
|
||||
t->base_font_size = 32;
|
||||
t->dpi = 192;
|
||||
gemui_color_parse("#11141a", &t->bg_main);
|
||||
gemui_color_parse("#161b23", &t->bg_bar);
|
||||
gemui_color_parse("#1b212b", &t->bg_header);
|
||||
@@ -232,7 +233,7 @@ static void gemui_apply_xrm_db(XrmDatabase db, gemui_theme_t *t) {
|
||||
}
|
||||
if (XrmGetResource(db, "theme.baseFontSize", "Theme.BaseFontSize", &type, &val) && val.addr) {
|
||||
int sz = atoi(val.addr);
|
||||
if (sz >= 10 && sz <= 48) t->base_font_size = sz;
|
||||
if (sz >= 10 && sz <= 64) t->base_font_size = sz;
|
||||
}
|
||||
if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &val) && val.addr) {
|
||||
int d = atoi(val.addr);
|
||||
@@ -342,6 +343,13 @@ gemui_app_t *gemui_create(const char *res_name, const char *title,
|
||||
unsigned long mask = CWBackPixel | CWEventMask | (fullscreen_override ? CWOverrideRedirect : 0);
|
||||
app->win = XCreateWindow(dpy, app->root, 0, 0, (unsigned int)w, (unsigned int)h, 0,
|
||||
CopyFromParent, InputOutput, CopyFromParent, mask, &swa);
|
||||
{
|
||||
Cursor cur = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
if (cur != None) {
|
||||
XDefineCursor(dpy, app->win, cur);
|
||||
XFreeCursor(dpy, cur);
|
||||
}
|
||||
}
|
||||
app->gc = XCreateGC(dpy, app->win, 0, NULL);
|
||||
|
||||
XClassHint *ch = XAllocClassHint();
|
||||
@@ -413,7 +421,7 @@ int gemui_width(const gemui_app_t *app) { return app ? app->w : 0; }
|
||||
int gemui_height(const gemui_app_t *app) { return app ? app->h : 0; }
|
||||
|
||||
int gemui_scale_px(const gemui_app_t *app, int logical_px) {
|
||||
int dpi = app ? app->theme.dpi : 168;
|
||||
int dpi = app ? app->theme.dpi : 180;
|
||||
return (logical_px * dpi + 48) / 96;
|
||||
}
|
||||
|
||||
@@ -791,7 +799,7 @@ static int gemui_draw_pango(cairo_t *cr, const char *face, int px_size,
|
||||
|
||||
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 px = (t ? t->base_font_size : 22) + pt_delta;
|
||||
int px = (t ? t->base_font_size : 28) + pt_delta;
|
||||
char fam[200];
|
||||
snprintf(fam, sizeof(fam), "%s, %s",
|
||||
(t && t->font_face[0]) ? t->font_face : "Fira Code",
|
||||
@@ -801,7 +809,7 @@ int gemui_draw_text(cairo_t *cr, const gemui_theme_t *t, gemui_rect_t r,
|
||||
|
||||
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) {
|
||||
int px = (t ? t->base_font_size : 22) + pt_delta;
|
||||
int px = (t ? t->base_font_size : 28) + pt_delta;
|
||||
const char *iface = (t && t->icon_font_face[0]) ? t->icon_font_face : "DejaVuSansM Nerd Font";
|
||||
return gemui_draw_pango(cr, iface, px, r, icon_utf8, false, align, c);
|
||||
}
|
||||
@@ -810,22 +818,22 @@ void gemui_draw_header(gemui_app_t *app, cairo_t *cr, const char *icon,
|
||||
const char *title, const char *right_badge) {
|
||||
if (!app) return;
|
||||
const gemui_theme_t *t = &app->theme;
|
||||
int hh = 64;
|
||||
int hh = 76;
|
||||
gemui_fill_rect(cr, (gemui_rect_t){0, 0, app->w, hh}, t->bg_header);
|
||||
gemui_fill_rect(cr, (gemui_rect_t){0, hh - 2, app->w, 2}, t->divider);
|
||||
|
||||
int x = 20;
|
||||
if (icon && icon[0]) {
|
||||
gemui_draw_icon(cr, t, (gemui_rect_t){x, 6, 44, hh - 12}, icon, 6, GEMUI_ALIGN_CENTER, t->accent);
|
||||
x += 48;
|
||||
gemui_draw_icon(cr, t, (gemui_rect_t){x, 6, 52, hh - 12}, icon, 6, GEMUI_ALIGN_CENTER, t->accent);
|
||||
x += 56;
|
||||
}
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){x, 6, app->w - x - 320, hh - 12},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){x, 6, app->w - x - 420, hh - 12},
|
||||
title ? title : "", 4, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
|
||||
if (right_badge && right_badge[0]) {
|
||||
gemui_rect_t br = {app->w - 300, 12, 280, hh - 24};
|
||||
gemui_fill_round(cr, br, 10, t->bg_overlay);
|
||||
gemui_stroke_round(cr, br, 10, 1.5, t->border);
|
||||
gemui_rect_t br = {app->w - 400, 12, 380, hh - 24};
|
||||
gemui_fill_round(cr, br, 12, t->bg_overlay);
|
||||
gemui_stroke_round(cr, br, 12, 1.5, t->border);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){br.x + 12, br.y, br.w - 24, br.h},
|
||||
right_badge, -2, false, GEMUI_ALIGN_CENTER, t->fg_main);
|
||||
}
|
||||
@@ -856,15 +864,15 @@ void gemui_draw_toggle(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
||||
gemui_fill_round(cr, r, 10, t->bg_alt_even);
|
||||
gemui_stroke_round(cr, r, 10, focused ? 3.0 : 1.5, focused ? t->highlight : t->border);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + 16, r.y, r.w - 128, r.h},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + 16, r.y, r.w - 144, r.h},
|
||||
label ? label : "", 0, false, GEMUI_ALIGN_LEFT, t->fg_main);
|
||||
|
||||
gemui_rect_t pill = {r.x + r.w - 102, r.y + (r.h - 38) / 2, 84, 38};
|
||||
gemui_fill_round(cr, pill, 19, on ? t->success : t->bg_overlay);
|
||||
gemui_stroke_round(cr, pill, 19, 1.5, on ? t->success : t->border);
|
||||
gemui_rect_t pill = {r.x + r.w - 114, r.y + (r.h - 44) / 2, 96, 44};
|
||||
gemui_fill_round(cr, pill, 22, on ? t->success : t->bg_overlay);
|
||||
gemui_stroke_round(cr, pill, 22, 1.5, on ? t->success : t->border);
|
||||
|
||||
gemui_rect_t knob = {on ? (pill.x + pill.w - 34) : (pill.x + 4), pill.y + 4, 30, 30};
|
||||
gemui_fill_round(cr, knob, 15, t->fg_bright);
|
||||
gemui_rect_t knob = {on ? (pill.x + pill.w - 40) : (pill.x + 4), pill.y + 4, 36, 36};
|
||||
gemui_fill_round(cr, knob, 18, t->fg_bright);
|
||||
if (hit_id >= 0) {
|
||||
gemui_hit_add(app, r, hit_id, hit_val);
|
||||
}
|
||||
@@ -881,21 +889,21 @@ void gemui_draw_slider(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
||||
gemui_fill_round(cr, r, 10, t->bg_alt_even);
|
||||
gemui_stroke_round(cr, r, 10, focused ? 3.0 : 1.5, focused ? t->highlight : t->border);
|
||||
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + 16, r.y + 6, r.w / 2, 32},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + 16, r.y + 8, r.w / 2, 40},
|
||||
label ? label : "", -1, true, GEMUI_ALIGN_LEFT, t->fg_bright);
|
||||
if (val_text && val_text[0]) {
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + r.w / 2, r.y + 6, r.w / 2 - 16, 32},
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + r.w / 2, r.y + 8, r.w / 2 - 16, 40},
|
||||
val_text, -1, false, GEMUI_ALIGN_RIGHT, t->accent);
|
||||
}
|
||||
|
||||
gemui_rect_t track = {r.x + 16, r.y + r.h - 24, r.w - 32, 12};
|
||||
gemui_fill_round(cr, track, 6, t->bg_overlay);
|
||||
gemui_rect_t track = {r.x + 18, r.y + r.h - 24, r.w - 36, 14};
|
||||
gemui_fill_round(cr, track, 7, t->bg_overlay);
|
||||
int fw = (int)(track.w * norm_val);
|
||||
if (fw > 0) {
|
||||
gemui_fill_round(cr, (gemui_rect_t){track.x, track.y, fw, track.h}, 6, t->accent);
|
||||
gemui_fill_round(cr, (gemui_rect_t){track.x, track.y, fw, track.h}, 7, t->accent);
|
||||
}
|
||||
gemui_rect_t knob = {track.x + fw - 12, track.y - 6, 24, 24};
|
||||
gemui_fill_round(cr, knob, 12, t->fg_bright);
|
||||
gemui_rect_t knob = {track.x + fw - 14, track.y - 7, 28, 28};
|
||||
gemui_fill_round(cr, knob, 14, t->fg_bright);
|
||||
if (hit_id >= 0) {
|
||||
gemui_hit_add(app, r, hit_id, hit_val);
|
||||
}
|
||||
@@ -935,9 +943,9 @@ void gemui_draw_input(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
||||
void gemui_draw_toast(gemui_app_t *app, cairo_t *cr) {
|
||||
if (!app || !app->toast_msg[0]) return;
|
||||
const gemui_theme_t *t = &app->theme;
|
||||
int tw = 640;
|
||||
int tw = 820;
|
||||
if (tw > app->w - 80) tw = app->w - 80;
|
||||
gemui_rect_t r = {(app->w - tw) / 2, app->h - 92, tw, 56};
|
||||
gemui_rect_t r = {(app->w - tw) / 2, app->h - 104, tw, 68};
|
||||
gemui_fill_round(cr, r, 12, t->bg_toast);
|
||||
gemui_stroke_round(cr, r, 12, 2.0, t->accent);
|
||||
gemui_draw_text(cr, t, (gemui_rect_t){r.x + 16, r.y + 4, r.w - 32, r.h - 8},
|
||||
|
||||
+5
-5
@@ -5,8 +5,8 @@
|
||||
*
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font = "Fira Code:pixelsize=24:style=Regular:antialias=true:autohint=true";
|
||||
static int borderpx = 2;
|
||||
static char *font = "Fira Code:pixelsize=44:style=Regular:antialias=true:autohint=true";
|
||||
static int borderpx = 6;
|
||||
|
||||
/*
|
||||
* What program is execed by st depends of these precedence rules:
|
||||
@@ -65,7 +65,7 @@ static unsigned int blinktimeout = 800;
|
||||
/*
|
||||
* thickness of underline and bar cursors
|
||||
*/
|
||||
static unsigned int cursorthickness = 2;
|
||||
static unsigned int cursorthickness = 4;
|
||||
|
||||
/*
|
||||
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
|
||||
@@ -280,9 +280,9 @@ static KeySym mappedkeys[] = { -1 };
|
||||
|
||||
/*
|
||||
* State bits to ignore when matching key or button events. By default,
|
||||
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
|
||||
* numlock (Mod2Mask), AltGr/Fn (Mod5Mask), and keyboard layout (XK_SWITCH_MOD) are ignored.
|
||||
*/
|
||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
||||
static uint ignoremod = Mod2Mask|Mod5Mask|XK_SWITCH_MOD;
|
||||
|
||||
/*
|
||||
* This is the huge key array which defines all compatibility to the Linux
|
||||
|
||||
+5
-5
@@ -5,8 +5,8 @@
|
||||
*
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font = "Fira Code:pixelsize=24:style=Regular:antialias=true:autohint=true";
|
||||
static int borderpx = 2;
|
||||
static char *font = "Fira Code:pixelsize=44:style=Regular:antialias=true:autohint=true";
|
||||
static int borderpx = 6;
|
||||
|
||||
/*
|
||||
* What program is execed by st depends of these precedence rules:
|
||||
@@ -65,7 +65,7 @@ static unsigned int blinktimeout = 800;
|
||||
/*
|
||||
* thickness of underline and bar cursors
|
||||
*/
|
||||
static unsigned int cursorthickness = 2;
|
||||
static unsigned int cursorthickness = 4;
|
||||
|
||||
/*
|
||||
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
|
||||
@@ -280,9 +280,9 @@ static KeySym mappedkeys[] = { -1 };
|
||||
|
||||
/*
|
||||
* State bits to ignore when matching key or button events. By default,
|
||||
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
|
||||
* numlock (Mod2Mask), AltGr/Fn (Mod5Mask), and keyboard layout (XK_SWITCH_MOD) are ignored.
|
||||
*/
|
||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
||||
static uint ignoremod = Mod2Mask|Mod5Mask|XK_SWITCH_MOD;
|
||||
|
||||
/*
|
||||
* This is the huge key array which defines all compatibility to the Linux
|
||||
|
||||
+5
-5
@@ -2093,7 +2093,7 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
||||
|
||||
switch (rtype) {
|
||||
case STRING:
|
||||
*sdst = ret.addr;
|
||||
*sdst = strdup(ret.addr);
|
||||
break;
|
||||
case INTEGER:
|
||||
*idst = strtoul(ret.addr, NULL, 10);
|
||||
@@ -2150,12 +2150,12 @@ config_init(void)
|
||||
if (XrmGetResource(db, "theme.baseFontSize", "*", &type, &ret) && ret.addr && ret.addr[0])
|
||||
bsz = ret.addr;
|
||||
if (ff || bsz) {
|
||||
int base_sz = bsz ? atoi(bsz) : 22;
|
||||
if (base_sz < 10 || base_sz > 48)
|
||||
base_sz = 22;
|
||||
int base_sz = bsz ? atoi(bsz) : 32;
|
||||
if (base_sz < 10 || base_sz > 64)
|
||||
base_sz = 32;
|
||||
snprintf(st_theme_font, sizeof(st_theme_font),
|
||||
"%s:pixelsize=%d:style=Regular:antialias=true:autohint=true",
|
||||
ff ? ff : "Fira Code", base_sz + 2);
|
||||
ff ? ff : "Fira Code", base_sz + 12);
|
||||
font = st_theme_font;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user