From 4d3aa646c1d1d1de4fdb31f938f6ea62fd5dd21e Mon Sep 17 00:00:00 2001 From: Jim Ramsay Date: Wed, 6 May 2009 08:18:56 -0400 Subject: Force window borders to be opaque color This is needed until we support full ARGB colors everywhere. Until then, since the outer-most "frame" window in FbWinFrame is the only 32-bit window we create, and the only part seen is the border, we only need to worry about forcing this one color to be opaque. --- src/FbTk/FbWindow.cc | 27 ++++++++++++++++++++++++++- src/FbTk/FbWindow.hh | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 9179cb3..18cec3f 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -41,6 +41,10 @@ #include #endif +#if HAVE_XRENDER +#include +#endif + namespace FbTk { FbWindow::FbWindow(): @@ -251,7 +255,20 @@ 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(); +#if HAVE_XRENDER + XRenderPictFormat *format = XRenderFindVisualFormat(display(), visual()); + if (depth() == 32 && format) { + /* TODO: Temporarily, until we have full ARGB color support, hack in the + * alpha channel of this pixel to be opaque + */ + pixel |= ((0xffff * (format->direct.alphaMask + 1) >> 16) + << format->direct.alpha); + } +#endif + XSetWindowBorder(display(), m_window, pixel); + + /* Important: Use the original color here, it is matched in FbWinFrame.cc */ m_border_color = border_color.pixel(); } @@ -613,6 +630,14 @@ bool FbWindow::updateGeometry() { old_height != m_height); } +Visual *FbWindow::visual() { + XWindowAttributes attr; + if (XGetWindowAttributes(display(), m_window, &attr)) { + return attr.visual; + } + return 0; +} + void FbWindow::create(Window parent, int x, int y, unsigned int width, unsigned int height, long eventmask, bool override_redirect, diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index b9f5e18..e5298b0 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -204,6 +204,8 @@ public: /// updates x,y, width, height and screen num from X window bool updateGeometry(); + Visual *visual(); + protected: /// creates a window with x window client (m_window = client) explicit FbWindow(Window client); -- cgit v0.11.2