Fix SSD2092 wake, fuel-gauge jump, XLibre rotation, media keys, and popup rendering

This commit is contained in:
Luxferre committed 2026-11-24 11:05:18 +02:00
1 parent 7f3b3c2c0c
commit dbc0275979
43 files changed
+3388 -115

No files matched your search

+267
View File
@@ -122,6 +122,273 @@ new2 = """ n->icon = icon_get_for_data(new_icon, &n->icon_id,
assert old1 in ntxt and old2 in ntxt
ntxt = ntxt.replace(old1, new1).replace(old2, new2)
open(notif_p, "w").write(ntxt)
def must_sub(txt, old, new, label):
assert txt.count(old) == 1, f"{label}: expected 1 match, got {txt.count(old)}"
return txt.replace(old, new)
draw_p = os.path.join(work, "src", "draw.c")
dtxt = open(draw_p).read()
old_pos = """void calc_window_pos(const struct screen_info *scr, int width, int height, int *ret_x, int *ret_y)
{
if(!ret_x || !ret_y)
return;
// horizontal
switch (settings.origin) {"""
new_pos = """void calc_window_pos(const struct screen_info *scr, int width, int height, int *ret_x, int *ret_y)
{
if(!ret_x || !ret_y)
return;
enum origin_values eff_origin = settings.origin;
GList *disp = queues_get_displayed();
if (disp && disp->data) {
const struct notification *n = disp->data;
if (n->appname && strcmp(n->appname, "geminux-osd") == 0)
eff_origin = ORIGIN_CENTER;
}
// horizontal
switch (eff_origin) {"""
dtxt = must_sub(dtxt, old_pos, new_pos, "draw.c calc_window_pos horiz")
dtxt = must_sub(dtxt, "// vertical\n switch (settings.origin) {", "// vertical\n switch (eff_origin) {", "draw.c calc_window_pos vert")
open(draw_p, "w").write(dtxt)
x11_p = os.path.join(work, "src", "x11", "x.c")
xtxt = open(x11_p).read()
xtxt = must_sub(
xtxt,
"""struct window_x11 {
Window xwin;
cairo_surface_t *root_surface;
cairo_t *c_ctx;
GSource *esrc;
int cur_screen;
bool visible;
struct dimensions dim;
};""",
"""struct window_x11 {
Window xwin;
cairo_surface_t *root_surface;
cairo_t *c_ctx;
Pixmap backbuf;
GC gc;
Visual *vis;
int depth;
int bw;
int bh;
bool shaped;
GSource *esrc;
int cur_screen;
bool visible;
struct dimensions dim;
};""",
"x.c struct window_x11",
)
xtxt = must_sub(
xtxt,
"""void x_display_surface(cairo_surface_t *srf, window winptr, const struct dimensions *dim)
{
struct window_x11 *win = (struct window_x11*)winptr;
const struct screen_info *scr = get_active_screen();
double scale = x_get_scale();
int x, y;
calc_window_pos(scr, round(dim->w * scale), round(dim->h * scale), &x, &y);
x_win_move(win, x, y, round(dim->w * scale), round(dim->h * scale));
cairo_xlib_surface_set_size(win->root_surface, round(dim->w * scale), round(dim->h * scale));
XClearWindow(xctx.dpy, win->xwin);
cairo_set_source_surface(win->c_ctx, srf, 0, 0);
cairo_paint(win->c_ctx);
cairo_show_page(win->c_ctx);
if (settings.corner_radius != 0 && ! x_win_composited(win))
x_win_corners_shape(win, round(dim->corner_radius * scale));
else
x_win_corners_unshape(win);
XFlush(xctx.dpy);
}""",
"""void x_display_surface(cairo_surface_t *srf, window winptr, const struct dimensions *dim)
{
struct window_x11 *win = (struct window_x11*)winptr;
const struct screen_info *scr = get_active_screen();
double scale = x_get_scale();
int w = round(dim->w * scale);
int h = round(dim->h * scale);
if (w < 1) w = 1;
if (h < 1) h = 1;
int x, y;
calc_window_pos(scr, w, h, &x, &y);
if (!win->backbuf || win->bw != w || win->bh != h) {
if (win->backbuf)
XFreePixmap(xctx.dpy, win->backbuf);
win->backbuf = XCreatePixmap(xctx.dpy, win->xwin, w, h, win->depth);
win->bw = w;
win->bh = h;
}
cairo_surface_t *bbsrf = cairo_xlib_surface_create(xctx.dpy, win->backbuf,
win->vis, w, h);
cairo_t *bbcr = cairo_create(bbsrf);
cairo_set_operator(bbcr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(bbcr, srf, 0, 0);
cairo_paint(bbcr);
cairo_destroy(bbcr);
cairo_surface_flush(bbsrf);
cairo_surface_destroy(bbsrf);
XSetWindowBackgroundPixmap(xctx.dpy, win->xwin, win->backbuf);
x_win_move(win, x, y, w, h);
cairo_xlib_surface_set_size(win->root_surface, w, h);
if (settings.corner_radius != 0 && !x_win_composited(win)) {
x_win_corners_shape(win, round(dim->corner_radius * scale));
win->shaped = true;
} else if (win->shaped) {
x_win_corners_unshape(win);
win->shaped = false;
}
if (win->visible)
XCopyArea(xctx.dpy, win->backbuf, win->xwin, win->gc, 0, 0, w, h, 0, 0);
XFlush(xctx.dpy);
}""",
"x.c x_display_surface",
)
xtxt = must_sub(
xtxt,
""" case Expose:
LOG_D("XEvent: processing '\''Expose'\''");
if (ev.xexpose.count == 0 && win->visible) {
draw();
}
break;""",
""" case Expose:
LOG_D("XEvent: processing '\''Expose'\''");
if (ev.xexpose.count == 0 && win->visible) {
if (win->backbuf && win->bw == win->dim.w && win->bh == win->dim.h) {
XCopyArea(xctx.dpy, win->backbuf, win->xwin, win->gc,
0, 0, win->bw, win->bh, 0, 0);
XFlush(xctx.dpy);
} else {
draw();
}
}
break;""",
"x.c Expose handler",
)
xtxt = must_sub(
xtxt,
""" scr_n = DefaultScreen(xctx.dpy);
root = RootWindow(xctx.dpy, scr_n);
if (XMatchVisualInfo(xctx.dpy, scr_n, 32, TrueColor, &vi)) {
vis = vi.visual;
depth = vi.depth;
} else {
vis = DefaultVisual(xctx.dpy, scr_n);
depth = DefaultDepth(xctx.dpy, scr_n);
}
wa.override_redirect = true;
wa.background_pixmap = None;
wa.background_pixel = 0;
wa.border_pixel = 0;
wa.colormap = XCreateColormap(xctx.dpy, root, vis, AllocNone);
wa.event_mask =
ExposureMask | KeyPressMask | VisibilityChangeMask |
ButtonReleaseMask | FocusChangeMask| StructureNotifyMask;
const struct screen_info *scr = get_active_screen();
win->xwin = XCreateWindow(xctx.dpy,
root,
scr->x,
scr->y,
scr->w,
1,
0,
depth,
CopyFromParent,
vis,
CWOverrideRedirect | CWBackPixmap | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask,
&wa);""",
""" scr_n = DefaultScreen(xctx.dpy);
root = RootWindow(xctx.dpy, scr_n);
win->cur_screen = scr_n;
if (x_win_composited(win) && XMatchVisualInfo(xctx.dpy, scr_n, 32, TrueColor, &vi)) {
vis = vi.visual;
depth = vi.depth;
} else {
vis = DefaultVisual(xctx.dpy, scr_n);
depth = DefaultDepth(xctx.dpy, scr_n);
}
win->vis = vis;
win->depth = depth;
wa.override_redirect = true;
wa.background_pixmap = None;
wa.border_pixel = 0;
wa.colormap = (vis == DefaultVisual(xctx.dpy, scr_n))
? DefaultColormap(xctx.dpy, scr_n)
: XCreateColormap(xctx.dpy, root, vis, AllocNone);
wa.event_mask =
ExposureMask | KeyPressMask | VisibilityChangeMask |
ButtonReleaseMask | FocusChangeMask| StructureNotifyMask;
const struct screen_info *scr = get_active_screen();
win->xwin = XCreateWindow(xctx.dpy,
root,
scr->x,
scr->y,
scr->w,
1,
0,
depth,
CopyFromParent,
vis,
CWOverrideRedirect | CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask,
&wa);
win->gc = XCreateGC(xctx.dpy, win->xwin, 0, NULL);""",
"x.c x_win_create",
)
xtxt = must_sub(
xtxt,
""" cairo_destroy(win->c_ctx);
cairo_surface_destroy(win->root_surface);
XDestroyWindow(xctx.dpy, win->xwin);""",
""" cairo_destroy(win->c_ctx);
cairo_surface_destroy(win->root_surface);
if (win->backbuf)
XFreePixmap(xctx.dpy, win->backbuf);
if (win->gc)
XFreeGC(xctx.dpy, win->gc);
XDestroyWindow(xctx.dpy, win->xwin);""",
"x.c x_win_destroy",
)
xtxt = must_sub(
xtxt,
""" XMapRaised(xctx.dpy, win->xwin);
win->visible = true;
x_display_surface(win->root_surface, win, &win->dim);""",
""" XMapRaised(xctx.dpy, win->xwin);
win->visible = true;
if (win->backbuf)
XCopyArea(xctx.dpy, win->backbuf, win->xwin, win->gc,
0, 0, win->bw, win->bh, 0, 0);
XFlush(xctx.dpy);""",
"x.c x_win_show",
)
open(x11_p, "w").write(xtxt)
print("PATCHED dunst src OK")
PYEOF