summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/FbRootWindow.cc6
-rw-r--r--src/FbTk/FbWindow.cc59
-rw-r--r--src/FbTk/FbWindow.hh13
-rw-r--r--src/FbWinFrame.cc5
4 files changed, 71 insertions, 12 deletions
diff --git a/src/FbRootWindow.cc b/src/FbRootWindow.cc
index 7e2b77e..b5db823 100644
--- a/src/FbRootWindow.cc
+++ b/src/FbRootWindow.cc
@@ -44,9 +44,10 @@ FbRootWindow::FbRootWindow(int screen_num):
44 vinfo_nitems > 0) { 44 vinfo_nitems > 0) {
45 45
46 for (int i = 0; i < vinfo_nitems; i++) { 46 for (int i = 0; i < vinfo_nitems; i++) {
47 // We can't handle 32-bit visuals just yet (Composite ARGB) 47 if (DefaultDepth(disp, screen_num) < vinfo_return[i].depth) {
48 if (vinfo_return[i].depth != 32 && DefaultDepth(disp, screen_num) < vinfo_return[i].depth)
49 m_visual = vinfo_return[i].visual; 48 m_visual = vinfo_return[i].visual;
49 setDepth(vinfo_return[i].depth);
50 }
50 } 51 }
51 52
52 XFree(vinfo_return); 53 XFree(vinfo_return);
@@ -58,5 +59,6 @@ FbRootWindow::FbRootWindow(int screen_num):
58 } else { 59 } else {
59 m_visual = DefaultVisual(disp, screen_num); 60 m_visual = DefaultVisual(disp, screen_num);
60 m_colormap = DefaultColormap(disp, screen_num); 61 m_colormap = DefaultColormap(disp, screen_num);
62 setDepth(DefaultDepth(disp, screen_num));
61 } 63 }
62} 64}
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
44namespace FbTk { 48namespace FbTk {
45 49
46FbWindow::FbWindow(): 50FbWindow::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
92FbWindow::FbWindow(const FbWindow &parent, 98FbWindow::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
240void FbWindow::setBorderColor(const FbTk::Color &border_color) { 257void 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
633Visual *FbWindow::visual() {
634 XWindowAttributes attr;
635 if (XGetWindowAttributes(display(), m_window, &attr)) {
636 return attr.visual;
637 }
638 return 0;
639}
640
603void FbWindow::create(Window parent, int x, int y, 641void 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
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh
index edeffe1..e5298b0 100644
--- a/src/FbTk/FbWindow.hh
+++ b/src/FbTk/FbWindow.hh
@@ -57,7 +57,9 @@ public:
57 bool overrride_redirect = false, 57 bool overrride_redirect = false,
58 bool save_unders = false, 58 bool save_unders = false,
59 unsigned int depth = CopyFromParent, 59 unsigned int depth = CopyFromParent,
60 int class_type = InputOutput); 60 int class_type = InputOutput,
61 Visual *visual = CopyFromParent,
62 Colormap cmap = CopyFromParent);
61 63
62 FbWindow(const FbWindow &parent, 64 FbWindow(const FbWindow &parent,
63 int x, int y, 65 int x, int y,
@@ -202,10 +204,14 @@ public:
202 /// updates x,y, width, height and screen num from X window 204 /// updates x,y, width, height and screen num from X window
203 bool updateGeometry(); 205 bool updateGeometry();
204 206
207 Visual *visual();
208
205protected: 209protected:
206 /// creates a window with x window client (m_window = client) 210 /// creates a window with x window client (m_window = client)
207 explicit FbWindow(Window client); 211 explicit FbWindow(Window client);
208 212
213 void setDepth(unsigned int depth) { m_depth = depth; }
214
209private: 215private:
210 /// sets new X window and destroys old 216 /// sets new X window and destroys old
211 void setNew(Window win); 217 void setNew(Window win);
@@ -215,7 +221,9 @@ private:
215 bool override_redirect, 221 bool override_redirect,
216 bool save_unders, 222 bool save_unders,
217 unsigned int depth, 223 unsigned int depth,
218 int class_type); 224 int class_type,
225 Visual *visual,
226 Colormap cmap);
219 227
220 const FbWindow *m_parent; ///< parent FbWindow 228 const FbWindow *m_parent; ///< parent FbWindow
221 int m_screen_num; ///< screen num on which this window exist 229 int m_screen_num; ///< screen num on which this window exist
@@ -249,7 +257,6 @@ public:
249 virtual ~FbWindowRenderer() { } 257 virtual ~FbWindowRenderer() { }
250}; 258};
251 259
252
253} // end namespace FbTk 260} // end namespace FbTk
254 261
255#endif // FBTK_FBWINDOW_HH 262#endif // FBTK_FBWINDOW_HH
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index 2975252..ac457be 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -51,7 +51,10 @@ FbWinFrame::FbWinFrame(BScreen &screen, WindowState &state,
51 m_window(theme->screenNum(), state.x, state.y, state.width, state.height, 51 m_window(theme->screenNum(), state.x, state.y, state.width, state.height,
52 ButtonPressMask | ButtonReleaseMask | 52 ButtonPressMask | ButtonReleaseMask |
53 ButtonMotionMask | EnterWindowMask | 53 ButtonMotionMask | EnterWindowMask |
54 LeaveWindowMask, true), 54 LeaveWindowMask, true, false,
55 screen.rootWindow().depth(), InputOutput,
56 screen.rootWindow().visual(),
57 screen.rootWindow().colormap()),
55 m_layeritem(window(), *screen.layerManager().getLayer(Layer::NORMAL)), 58 m_layeritem(window(), *screen.layerManager().getLayer(Layer::NORMAL)),
56 m_titlebar(m_window, 0, 0, 100, 16, 59 m_titlebar(m_window, 0, 0, 100, 16,
57 ButtonPressMask | ButtonReleaseMask | 60 ButtonPressMask | ButtonReleaseMask |