From b584834bfcf87f5f977fdb546ce4f0bffb7d399e Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Sat, 15 Jan 2022 12:50:49 -0700 Subject: [PATCH] add colorspace fix for window borders with transparency --- src/FbTk/FbWindow.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index b2347f3e..38ed8913 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -252,7 +252,19 @@ void FbWindow::updateBackground(bool only_if_alpha) { } void FbWindow::setBorderColor(const FbTk::Color &border_color) { - XSetWindowBorder(display(), m_window, border_color.pixel()); + unsigned long pixel = border_color.pixel(); + XWindowAttributes attr; + if (XGetWindowAttributes(display(), m_window, &attr) + && attr.colormap != DefaultColormap(display(), m_screen_num)) { + XColor color; + color.red = border_color.red() * 0x101; + color.green = border_color.green() * 0x101; + color.blue = border_color.blue() * 0x101; + if (XAllocColor(display(), attr.colormap, &color)){ + pixel = color.pixel; + } + } + XSetWindowBorder(display(), m_window, pixel); m_border_color = border_color.pixel(); }