tAllow setting window border as ARGB values - libwm - X windows manipulation library
(HTM) git clone git://z3bra.org/libwm
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 61d8c057d116e7db273a6d8fa3237f5a76c75779
(DIR) parent a43614c6a4f9f8e59697ab76cab14407082a6bfc
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Thu, 31 Oct 2019 11:44:51 +0100
Allow setting window border as ARGB values
Border colors are represented as 32 bits integers, out of which the 2
first byte reprensent the alpha channel (in TrueColor mode, which
we assume).
When the very first bit is set (eg. 0x80123456), the signed integer
representation would be a negative number.
If we want to handle the alpha channel correctly, we cannot check the
color value as an integer, and accept any value.
The obvious advantage is that setting transparency now works as
expected. The drawback being that if you only want to change the border
size, you still have to set the border color. Deal with it :)
Diffstat:
M libwm.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
---
(DIR) diff --git a/libwm.c b/libwm.c
t@@ -266,22 +266,24 @@ int
wm_set_border(int width, int color, xcb_window_t wid)
{
uint32_t values[1];
- int mask, retval = 0;
- /* change width if > 0 */
+ int mask;
+
+ /* change width if >= 0 */
if (width > -1) {
values[0] = width;
mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
xcb_configure_window(conn, wid, mask, values);
- retval++;
}
- /* change color if > 0 */
- if (color > -1) {
- values[0] = color;
- mask = XCB_CW_BORDER_PIXEL;
- xcb_change_window_attributes(conn, wid, mask, values);
- retval++;
- }
+ /*
+ * color is an ARGB representation (eg. 0x80ff0000) for
+ * translucent red.
+ * Absolutely all values are valid color representations, so we
+ * will set it no matter what.
+ */
+ values[0] = color;
+ mask = XCB_CW_BORDER_PIXEL;
+ xcb_change_window_attributes(conn, wid, mask, values);
return 0;
}