diff options
Diffstat (limited to 'src/FbTk/FbWindow.cc')
-rw-r--r-- | src/FbTk/FbWindow.cc | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index fb0ad1d..e2dcf70 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc | |||
@@ -41,6 +41,10 @@ | |||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #if HAVE_XRENDER | ||
45 | #include <X11/extensions/Xrender.h> | ||
46 | #endif | ||
47 | |||
44 | namespace FbTk { | 48 | namespace FbTk { |
45 | 49 | ||
46 | FbWindow::FbWindow(): | 50 | FbWindow::FbWindow(): |
@@ -75,7 +79,9 @@ FbWindow::FbWindow(int screen_num, | |||
75 | bool override_redirect, | 79 | bool override_redirect, |
76 | bool save_unders, | 80 | bool save_unders, |
77 | unsigned int depth, | 81 | unsigned int depth, |
78 | int class_type): | 82 | int class_type, |
83 | Visual *visual, | ||
84 | Colormap cmap): | ||
79 | FbDrawable(), | 85 | FbDrawable(), |
80 | m_parent(0), | 86 | m_parent(0), |
81 | m_screen_num(screen_num), | 87 | m_screen_num(screen_num), |
@@ -86,7 +92,7 @@ FbWindow::FbWindow(int screen_num, | |||
86 | 92 | ||
87 | create(RootWindow(display(), screen_num), | 93 | create(RootWindow(display(), screen_num), |
88 | x, y, width, height, eventmask, | 94 | x, y, width, height, eventmask, |
89 | override_redirect, save_unders, depth, class_type); | 95 | override_redirect, save_unders, depth, class_type, visual, cmap); |
90 | } | 96 | } |
91 | 97 | ||
92 | FbWindow::FbWindow(const FbWindow &parent, | 98 | FbWindow::FbWindow(const FbWindow &parent, |
@@ -101,8 +107,19 @@ FbWindow::FbWindow(const FbWindow &parent, | |||
101 | m_lastbg_color_set(false), m_lastbg_color(0), | 107 | m_lastbg_color_set(false), m_lastbg_color(0), |
102 | m_lastbg_pm(0), m_renderer(0) { | 108 | m_lastbg_pm(0), m_renderer(0) { |
103 | 109 | ||
110 | Visual *visual = CopyFromParent; | ||
111 | Colormap cmap = CopyFromParent; | ||
112 | |||
113 | if (class_type == InputOutput) { | ||
114 | visual = DefaultVisual(display(), m_screen_num); | ||
115 | cmap = DefaultColormap(display(), m_screen_num); | ||
116 | if (depth == CopyFromParent) { | ||
117 | depth = DefaultDepth(display(), m_screen_num); | ||
118 | } | ||
119 | } | ||
120 | |||
104 | create(parent.window(), x, y, width, height, eventmask, | 121 | create(parent.window(), x, y, width, height, eventmask, |
105 | override_redirect, save_unders, depth, class_type); | 122 | override_redirect, save_unders, depth, class_type, visual, cmap); |
106 | 123 | ||
107 | 124 | ||
108 | } | 125 | } |
@@ -238,7 +255,20 @@ void FbWindow::updateBackground(bool only_if_alpha) { | |||
238 | } | 255 | } |
239 | 256 | ||
240 | void FbWindow::setBorderColor(const FbTk::Color &border_color) { | 257 | void FbWindow::setBorderColor(const FbTk::Color &border_color) { |
241 | XSetWindowBorder(display(), m_window, border_color.pixel()); | 258 | unsigned long pixel = border_color.pixel(); |
259 | #if HAVE_XRENDER | ||
260 | XRenderPictFormat *format = XRenderFindVisualFormat(display(), visual()); | ||
261 | if (depth() == 32 && format) { | ||
262 | /* TODO: Temporarily, until we have full ARGB color support, hack in the | ||
263 | * alpha channel of this pixel to be opaque | ||
264 | */ | ||
265 | pixel |= ((0xffff * (format->direct.alphaMask + 1) >> 16) | ||
266 | << format->direct.alpha); | ||
267 | } | ||
268 | #endif | ||
269 | XSetWindowBorder(display(), m_window, pixel); | ||
270 | |||
271 | /* Important: Use the original color here, it is matched in FbWinFrame.cc */ | ||
242 | m_border_color = border_color.pixel(); | 272 | m_border_color = border_color.pixel(); |
243 | } | 273 | } |
244 | 274 | ||
@@ -600,10 +630,19 @@ bool FbWindow::updateGeometry() { | |||
600 | old_height != m_height); | 630 | old_height != m_height); |
601 | } | 631 | } |
602 | 632 | ||
633 | Visual *FbWindow::visual() { | ||
634 | XWindowAttributes attr; | ||
635 | if (XGetWindowAttributes(display(), m_window, &attr)) { | ||
636 | return attr.visual; | ||
637 | } | ||
638 | return 0; | ||
639 | } | ||
640 | |||
603 | void FbWindow::create(Window parent, int x, int y, | 641 | void FbWindow::create(Window parent, int x, int y, |
604 | unsigned int width, unsigned int height, | 642 | unsigned int width, unsigned int height, |
605 | long eventmask, bool override_redirect, | 643 | long eventmask, bool override_redirect, |
606 | bool save_unders, unsigned int depth, int class_type) { | 644 | bool save_unders, unsigned int depth, int class_type, |
645 | Visual *visual, Colormap cmap) { | ||
607 | 646 | ||
608 | 647 | ||
609 | m_border_width = 0; | 648 | m_border_width = 0; |
@@ -623,11 +662,19 @@ void FbWindow::create(Window parent, int x, int y, | |||
623 | values.save_under = True; | 662 | values.save_under = True; |
624 | } | 663 | } |
625 | 664 | ||
665 | if (cmap != CopyFromParent) { | ||
666 | valmask |= CWColormap | CWBackPixel | CWBorderPixel; | ||
667 | values.colormap = cmap; | ||
668 | /* Why do we need to specify these for a 32-bit visual? */ | ||
669 | values.background_pixel = XWhitePixel(display(), 0); | ||
670 | values.border_pixel = XBlackPixel(display(), 0); | ||
671 | } | ||
672 | |||
626 | m_window = XCreateWindow(display(), parent, x, y, width, height, | 673 | m_window = XCreateWindow(display(), parent, x, y, width, height, |
627 | 0, // border width | 674 | 0, // border width |
628 | depth, // depth | 675 | depth, // depth |
629 | class_type, // class | 676 | class_type, // class |
630 | CopyFromParent, // visual | 677 | visual, // visual |
631 | valmask, // create mask | 678 | valmask, // create mask |
632 | &values); // create atrribs | 679 | &values); // create atrribs |
633 | 680 | ||