aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-03-05 08:24:40 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-03-05 08:24:40 (GMT)
commit1b1262e01b96c20daea1d9ca0b306ee6941e727a (patch)
tree320acc7d6949ce5ccce52055c08977f612e8c19b /src
parent73848440ceb0b3980d5790cadeb0f4913e11cfc8 (diff)
downloadfluxbox-1b1262e01b96c20daea1d9ca0b306ee6941e727a.zip
fluxbox-1b1262e01b96c20daea1d9ca0b306ee6941e727a.tar.bz2
transform _NET_WM_ICON data to correct depth
Diffstat (limited to 'src')
-rw-r--r--src/Ewmh.cc49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 9db7777..17253bd 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -75,7 +75,8 @@ namespace {
75 * This is an array of 32bit packed CARDINAL ARGB with high byte being A, low 75 * This is an array of 32bit packed CARDINAL ARGB with high byte being A, low
76 * byte being B. The first two cardinals are width, height. Data is in rows, 76 * byte being B. The first two cardinals are width, height. Data is in rows,
77 * left to right and top to bottom. 77 * left to right and top to bottom.
78 */ 78 *
79 * TODO: maybe move the pixmap-creation code to FbTk? */
79void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) { 80void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
80 81
81 typedef std::pair<int, int> Size; 82 typedef std::pair<int, int> Size;
@@ -160,7 +161,8 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
160 161
161 162
162 const unsigned long* src = icon_data.begin()->second; 163 const unsigned long* src = icon_data.begin()->second;
163 unsigned int pixel; 164 unsigned int rgba;
165 unsigned long pixel;
164 int x; 166 int x;
165 int y; 167 int y;
166 unsigned char r, g, b, a; 168 unsigned char r, g, b, a;
@@ -168,15 +170,40 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
168 for (y = 0; y < height; y++) { 170 for (y = 0; y < height; y++) {
169 for (x = 0; x < width; x++, src++) { 171 for (x = 0; x < width; x++, src++) {
170 172
171 pixel = *src; // use only 32bit 173 rgba = *src; // use only 32bit
174
175 a = ( rgba & 0xff000000 ) >> 24;
176 r = ( rgba & 0x00ff0000 ) >> 16;
177 g = ( rgba & 0x0000ff00 ) >> 8;
178 b = ( rgba & 0x000000ff );
179
180 // 15 bit display, 5R 5G 5B
181 if (img_pm->red_mask == 0x7c00
182 && img_pm->green_mask == 0x03e0
183 && img_pm->blue_mask == 0x1f) {
184
185 pixel = ((r << 7) & 0x7c00) | ((g << 2) & 0x03e0) | ((b >> 3) & 0x001f);
186
187 // 16 bit display, 5R 6G 5B
188 } else if (img_pm->red_mask == 0xf800
189 && img_pm->green_mask == 0x07e0
190 && img_pm->blue_mask == 0x1f) {
172 191
173 a = ( pixel & 0xff000000 ) >> 24; 192 pixel = ((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | ((b >> 3) & 0x001f);
174 r = ( pixel & 0x00ff0000 ) >> 16; 193
175 g = ( pixel & 0x0000ff00 ) >> 8; 194 // 24/32 bit display, 8R 8G 8B
176 b = ( pixel & 0x000000ff ); 195 } else if (img_pm->red_mask == 0xff0000
196 && img_pm->green_mask == 0xff00
197 && img_pm->blue_mask == 0xff) {
198
199 pixel = rgba & 0x00ffffff;
200
201 } else {
202 pixel = 0;
203 }
177 204
178 // transfer color data 205 // transfer rgb data
179 XPutPixel(img_pm, x, y, pixel & 0x00ffffff ); // TODO: this only works in 24bit depth 206 XPutPixel(img_pm, x, y, pixel);
180 207
181 // transfer mask data 208 // transfer mask data
182 XPutPixel(img_mask, x, y, a > 127 ? 0 : 1); 209 XPutPixel(img_mask, x, y, a > 127 ? 0 : 1);
@@ -194,8 +221,8 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
194 XPutImage(dpy, icon.pixmap().drawable(), gc_pm.gc(), img_pm, 0, 0, 0, 0, width, height); 221 XPutImage(dpy, icon.pixmap().drawable(), gc_pm.gc(), img_pm, 0, 0, 0, 0, width, height);
195 XPutImage(dpy, icon.mask().drawable(), gc_mask.gc(), img_mask, 0, 0, 0, 0, width, height); 222 XPutImage(dpy, icon.mask().drawable(), gc_mask.gc(), img_mask, 0, 0, 0, 0, width, height);
196 223
197 XDestroyImage(img_pm); // also frees img_pm->data 224 XDestroyImage(img_pm); // frees img_pm->data as well
198 XDestroyImage(img_mask); // also frees img_mask->data 225 XDestroyImage(img_mask); // frees img_mask->data as well
199 226
200 XFree(raw_data); 227 XFree(raw_data);
201 228