Fix PMIC/SPM deep-sleep wakeups and backport DE fixes, Anodized theme, and theme editor
- kernel: add 0013-gemini-pmic-wake-and-spm-safety.patch to arm MT6397/MT6351 wake IRQs in late suspend and enable PCM WDT, IM wait, and CNTP backstop on s.sleep - geminux-powerd: distinguish real input/lid-open wakes from spurious open-lid wakes and re-suspend cleanly on battery timer wakes - DE/WM: backport systray (32-bit ARGB, XEmbed race fix, lockscreen stacking), NETWM/EWMH/ICCCM and Wine/DXVK focus fixes, bar drawing fixes, and live Xresources reload across dwm, drw, st, libgemui, geminux-apply-theme, and geminux-session - themes: backport Anodized.xth, geminux-xth.h, and interactive geminux-themes editor/importer (--install), rebuild prebuilt binaries/kernel modules, and update verification scripts
This commit is contained in:
1 parent
f65dbb28a2
commit
6fcc263256
28 files changed
+3802
-355
No files matched your search
+150
-15
@@ -49,6 +49,7 @@ struct gemui_app {
|
||||
Atom utf8_string;
|
||||
Atom net_wm_state;
|
||||
Atom net_wm_state_fs;
|
||||
Atom sel_prop;
|
||||
XIM xim;
|
||||
XIC xic;
|
||||
bool fullscreen_override;
|
||||
@@ -265,15 +266,6 @@ void gemui_theme_reload(gemui_app_t *app) {
|
||||
XrmInitialize();
|
||||
gemui_theme_defaults(&app->theme);
|
||||
|
||||
const char *xrm_str = XResourceManagerString(app->dpy);
|
||||
if (xrm_str) {
|
||||
XrmDatabase mem_db = XrmGetStringDatabase(xrm_str);
|
||||
if (mem_db) {
|
||||
gemui_apply_xrm_db(mem_db, &app->theme);
|
||||
XrmDestroyDatabase(mem_db);
|
||||
}
|
||||
}
|
||||
|
||||
const char *home = getenv("HOME");
|
||||
char path[512];
|
||||
if (home && home[0]) {
|
||||
@@ -293,6 +285,31 @@ void gemui_theme_reload(gemui_app_t *app) {
|
||||
XrmDestroyDatabase(fdb);
|
||||
}
|
||||
}
|
||||
|
||||
/* Always read XA_RESOURCE_MANAGER directly so live xrdb -load updates win over
|
||||
disk fallbacks or stale XResourceManagerString() startup caches. */
|
||||
Atom actual_type = None;
|
||||
int actual_format = 0;
|
||||
unsigned long nitems = 0, bytes_after = 0;
|
||||
unsigned char *prop = NULL;
|
||||
if (XGetWindowProperty(app->dpy, app->root, XA_RESOURCE_MANAGER,
|
||||
0L, 262144L, False, XA_STRING, &actual_type,
|
||||
&actual_format, &nitems, &bytes_after, &prop) == Success && prop) {
|
||||
if (actual_type == XA_STRING && actual_format == 8 && nitems > 0) {
|
||||
char *buf = malloc(nitems + 1);
|
||||
if (buf) {
|
||||
memcpy(buf, prop, nitems);
|
||||
buf[nitems] = '\0';
|
||||
XrmDatabase mem_db = XrmGetStringDatabase(buf);
|
||||
free(buf);
|
||||
if (mem_db) {
|
||||
gemui_apply_xrm_db(mem_db, &app->theme);
|
||||
XrmDestroyDatabase(mem_db);
|
||||
}
|
||||
}
|
||||
}
|
||||
XFree(prop);
|
||||
}
|
||||
}
|
||||
|
||||
static void gemui_ensure_backbuf(gemui_app_t *app) {
|
||||
@@ -408,6 +425,7 @@ gemui_app_t *gemui_create(const char *res_name, const char *title,
|
||||
StructureNotifyMask | FocusChangeMask;
|
||||
if (fullscreen_override) {
|
||||
swa.override_redirect = True;
|
||||
swa.event_mask |= VisibilityChangeMask;
|
||||
}
|
||||
|
||||
unsigned long mask = CWBackPixmap | CWEventMask | (fullscreen_override ? CWOverrideRedirect : 0);
|
||||
@@ -447,8 +465,13 @@ gemui_app_t *gemui_create(const char *res_name, const char *title,
|
||||
app->utf8_string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||
app->net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
|
||||
app->net_wm_state_fs = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
app->sel_prop = XInternAtom(dpy, "GEMUI_CLIP_DATA", False);
|
||||
XSetWMProtocols(dpy, app->win, &app->wm_delete, 1);
|
||||
|
||||
XSelectInput(dpy, app->root,
|
||||
fullscreen_override ? (PropertyChangeMask | SubstructureNotifyMask)
|
||||
: PropertyChangeMask);
|
||||
|
||||
if (fullscreen_override) {
|
||||
XChangeProperty(dpy, app->win, app->net_wm_state, XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)&app->net_wm_state_fs, 1);
|
||||
@@ -509,6 +532,55 @@ const gemui_theme_t *gemui_theme(const gemui_app_t *app) { return app ? &app->th
|
||||
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; }
|
||||
|
||||
static bool gemui_read_selection(gemui_app_t *app, Atom sel, Atom target, char *out, size_t out_sz) {
|
||||
XDeleteProperty(app->dpy, app->win, app->sel_prop);
|
||||
XConvertSelection(app->dpy, sel, target, app->sel_prop, app->win, CurrentTime);
|
||||
XFlush(app->dpy);
|
||||
|
||||
uint64_t deadline = gemui_now_ms() + 150ULL;
|
||||
int xfd = ConnectionNumber(app->dpy);
|
||||
XEvent nev;
|
||||
bool got = false;
|
||||
while (gemui_now_ms() < deadline) {
|
||||
XEventsQueued(app->dpy, QueuedAfterReading);
|
||||
if (XCheckTypedWindowEvent(app->dpy, app->win, SelectionNotify, &nev)) {
|
||||
got = true;
|
||||
break;
|
||||
}
|
||||
struct pollfd pfd = { .fd = xfd, .events = POLLIN };
|
||||
poll(&pfd, 1, 20);
|
||||
}
|
||||
if (!got || nev.xselection.property == None) return false;
|
||||
|
||||
Atom da = None;
|
||||
int di = 0;
|
||||
unsigned long n = 0, after = 0;
|
||||
unsigned char *prop = NULL;
|
||||
bool ok = false;
|
||||
if (XGetWindowProperty(app->dpy, app->win, app->sel_prop, 0L, (long)(out_sz / 4 + 16),
|
||||
True, AnyPropertyType, &da, &di, &n, &after, &prop) == Success && prop) {
|
||||
if (di == 8 && n > 0) {
|
||||
size_t copy = n < out_sz - 1 ? n : out_sz - 1;
|
||||
memcpy(out, prop, copy);
|
||||
out[copy] = '\0';
|
||||
ok = true;
|
||||
}
|
||||
XFree(prop);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool gemui_clipboard_get(gemui_app_t *app, char *out, size_t out_sz) {
|
||||
if (!app || !out || out_sz == 0) return false;
|
||||
out[0] = '\0';
|
||||
Atom clip = XInternAtom(app->dpy, "CLIPBOARD", False);
|
||||
if (gemui_read_selection(app, clip, app->utf8_string, out, out_sz)) return true;
|
||||
if (gemui_read_selection(app, clip, XA_STRING, out, out_sz)) return true;
|
||||
if (gemui_read_selection(app, XA_PRIMARY, app->utf8_string, out, out_sz)) return true;
|
||||
if (gemui_read_selection(app, XA_PRIMARY, XA_STRING, out, out_sz)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int gemui_scale_px(const gemui_app_t *app, int logical_px) {
|
||||
int dpi = app ? app->theme.dpi : 180;
|
||||
return (logical_px * dpi + 48) / 96;
|
||||
@@ -660,6 +732,32 @@ void gemui_flush_draw(gemui_app_t *app) {
|
||||
gemui_render_frame(app);
|
||||
}
|
||||
|
||||
static void gemui_keep_fullscreen_on_top(gemui_app_t *app) {
|
||||
if (!app || !app->fullscreen_override || !app->mapped || !app->dpy || app->win == None) return;
|
||||
Window root_ret = None, parent_ret = None;
|
||||
Window *children = NULL;
|
||||
unsigned int nchildren = 0;
|
||||
int (*old_handler)(Display *, XErrorEvent *) = XSetErrorHandler(gemui_ignore_xerror);
|
||||
if (!XQueryTree(app->dpy, app->root, &root_ret, &parent_ret, &children, &nchildren)) {
|
||||
XSetErrorHandler(old_handler);
|
||||
return;
|
||||
}
|
||||
Window top_viewable = None;
|
||||
for (int i = (int)nchildren - 1; i >= 0; i--) {
|
||||
Window cw = children[i];
|
||||
XWindowAttributes wa;
|
||||
if (!XGetWindowAttributes(app->dpy, cw, &wa) || wa.map_state != IsViewable) continue;
|
||||
top_viewable = cw;
|
||||
break;
|
||||
}
|
||||
if (top_viewable != None && top_viewable != app->win) {
|
||||
XRaiseWindow(app->dpy, app->win);
|
||||
XFlush(app->dpy);
|
||||
}
|
||||
if (children) XFree(children);
|
||||
XSetErrorHandler(old_handler);
|
||||
}
|
||||
|
||||
static void gemui_handle_x_events(gemui_app_t *app) {
|
||||
while (XPending(app->dpy) > 0 && app->running) {
|
||||
XEvent ev;
|
||||
@@ -671,11 +769,37 @@ static void gemui_handle_x_events(gemui_app_t *app) {
|
||||
if (ev.xexpose.count == 0) app->need_redraw = true;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (ev.xconfigure.width != app->w || ev.xconfigure.height != app->h) {
|
||||
app->w = ev.xconfigure.width;
|
||||
app->h = ev.xconfigure.height;
|
||||
if (app->handlers.on_resize) {
|
||||
app->handlers.on_resize(app, app->w, app->h, app->userdata);
|
||||
if (ev.xconfigure.window == app->win) {
|
||||
if (ev.xconfigure.width != app->w || ev.xconfigure.height != app->h) {
|
||||
app->w = ev.xconfigure.width;
|
||||
app->h = ev.xconfigure.height;
|
||||
if (app->handlers.on_resize) {
|
||||
app->handlers.on_resize(app, app->w, app->h, app->userdata);
|
||||
}
|
||||
app->need_redraw = true;
|
||||
}
|
||||
} else if (app->fullscreen_override) {
|
||||
gemui_keep_fullscreen_on_top(app);
|
||||
}
|
||||
break;
|
||||
case MapNotify:
|
||||
if (app->fullscreen_override && ev.xmap.window != app->win) {
|
||||
gemui_keep_fullscreen_on_top(app);
|
||||
}
|
||||
break;
|
||||
case VisibilityNotify:
|
||||
if (app->fullscreen_override && ev.xvisibility.window == app->win &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
gemui_keep_fullscreen_on_top(app);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
if (ev.xproperty.window == app->root &&
|
||||
ev.xproperty.atom == XA_RESOURCE_MANAGER &&
|
||||
ev.xproperty.state != PropertyDelete) {
|
||||
gemui_theme_reload(app);
|
||||
if (app->handlers.on_theme) {
|
||||
app->handlers.on_theme(app, app->userdata);
|
||||
}
|
||||
app->need_redraw = true;
|
||||
}
|
||||
@@ -892,6 +1016,7 @@ static int gemui_draw_pango(cairo_t *cr, const char *face, int px_size,
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_layout_set_width(layout, r.w * PANGO_SCALE);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
pango_layout_set_height(layout, 0);
|
||||
pango_layout_set_single_paragraph_mode(layout, True);
|
||||
if (align == GEMUI_ALIGN_CENTER) {
|
||||
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
||||
@@ -905,9 +1030,13 @@ static int gemui_draw_pango(cairo_t *cr, const char *face, int px_size,
|
||||
int tw = 0, th = 0;
|
||||
pango_layout_get_pixel_size(layout, &tw, &th);
|
||||
int dy = r.y + (r.h - th) / 2;
|
||||
cairo_save(cr);
|
||||
cairo_rectangle(cr, r.x, r.y - 4, r.w, r.h + 8);
|
||||
cairo_clip(cr);
|
||||
gemui_set_source(cr, c);
|
||||
cairo_move_to(cr, r.x, dy);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
cairo_restore(cr);
|
||||
|
||||
pango_font_description_free(desc);
|
||||
if (!g_active_layout) g_object_unref(layout);
|
||||
@@ -962,7 +1091,13 @@ void gemui_draw_button(gemui_app_t *app, cairo_t *cr, gemui_rect_t r,
|
||||
if (!app) return;
|
||||
const gemui_theme_t *t = &app->theme;
|
||||
gemui_color_t bg = active ? t->sel_bg : (primary ? t->accent : t->bg_button);
|
||||
gemui_color_t fg = (active || primary) ? t->sel_fg : t->fg_bright;
|
||||
double bg_lum = 0.299 * bg.r + 0.587 * bg.g + 0.114 * bg.b;
|
||||
double bgm_lum = 0.299 * t->bg_main.r + 0.587 * t->bg_main.g + 0.114 * t->bg_main.b;
|
||||
double fgm_lum = 0.299 * t->fg_main.r + 0.587 * t->fg_main.g + 0.114 * t->fg_main.b;
|
||||
gemui_color_t dark_ink = (bgm_lum < 0.35) ? t->bg_main
|
||||
: (fgm_lum < 0.35) ? t->fg_main
|
||||
: (gemui_color_t){0.031, 0.035, 0.043, 1.0, 0xff08090bU};
|
||||
gemui_color_t fg = (bg_lum > 0.58) ? dark_ink : ((active || primary) ? t->sel_fg : t->fg_bright);
|
||||
gemui_color_t bd = focused ? t->highlight : (active ? t->sel_bg : t->border);
|
||||
|
||||
gemui_fill_round(cr, r, 10, bg);
|
||||
|
||||
@@ -26,7 +26,7 @@ extern "C" {
|
||||
#define GEMUI_PTR_SCROLL_UP 3
|
||||
#define GEMUI_PTR_SCROLL_DOWN 4
|
||||
|
||||
#define GEMUI_MAX_HITS 192
|
||||
#define GEMUI_MAX_HITS 256
|
||||
#define GEMUI_MAX_FDS 16
|
||||
|
||||
typedef struct {
|
||||
@@ -115,6 +115,7 @@ 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);
|
||||
bool gemui_clipboard_get(gemui_app_t *app, char *out, size_t out_sz);
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user