diff --git a/README.md b/README.md index 92f9889..f1b88b8 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: +2025-10-28 - Added the selectionbg-alpha patch + 2025-02-20 - Added the drag-n-drop and open-selected-text patches 2024-05-31 - Added the anygeometry patch @@ -260,6 +262,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [right-click-to-plumb](https://st.suckless.org/patches/right_click_to_plumb/) - allows you to right-click on some selected text to send it to the plumbing program of choice + - [selectionbg-alpha](https://st.suckless.org/patches/selectionbg-alpha/) + - allows for the selection to have a transparent background when combined with the alpha + and selection colors patches + - [scrollback](https://st.suckless.org/patches/scrollback/) - allows you scroll back through terminal output using keyboard shortcuts or mousewheel diff --git a/patches.def.h b/patches.def.h index 466b057..691e45f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -380,6 +380,12 @@ */ #define SELECTION_COLORS_PATCH 0 +/* This patch works with selectioncolors and alpha patches to make selection + * background color transparent. + * https://st.suckless.org/patches/selectionbg-alpha/ + */ +#define SELECTIONBG_ALPHA_PATCH 0 + /* This is the single drawable buffer patch as outlined in the FAQ to get images * in w3m to display. While this patch does not break the alpha patch it images * are not shown in w3m if the alpha patch is applied. diff --git a/x.c b/x.c index 627e352..e761c84 100644 --- a/x.c +++ b/x.c @@ -980,6 +980,11 @@ xloadalpha(void) dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha); dc.col[defaultbg].pixel &= 0x00FFFFFF; dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24; + #if SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH + dc.col[selectionbg].color.alpha = (unsigned short)(0xffff * usedAlpha); + dc.col[selectionbg].pixel &= 0x00FFFFFF; + dc.col[selectionbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24; + #endif // SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH } #endif // ALPHA_FOCUS_HIGHLIGHT_PATCH @@ -1041,6 +1046,18 @@ xloadcols(void) dc.col[defaultbg].color.red *= alpha; dc.col[defaultbg].color.green *= alpha; dc.col[defaultbg].color.blue *= alpha; + #if SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH + /* set alpha value of selbg color */ + dc.col[selectionbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[selectionbg].pixel &= 0x00FFFFFF; + dc.col[selectionbg].pixel |= (unsigned char)(0xff * alpha) << 24; + dc.col[selectionbg].color.red = + ((unsigned short)(dc.col[selectionbg].color.red * alpha)) & 0xff00; + dc.col[selectionbg].color.green = + ((unsigned short)(dc.col[selectionbg].color.green * alpha)) & 0xff00; + dc.col[selectionbg].color.blue = + ((unsigned short)(dc.col[selectionbg].color.blue * alpha)) & 0xff00; + #endif // SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH #endif // ALPHA_PATCH loaded = 1; }