aboutsummaryrefslogtreecommitdiff
path: root/src/Ewmh.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
commite169d33552c8e7070aa6e13da0187f2013b4cfc3 (patch)
treeae9e92c7e885791c7f47645184070cbcd441ab94 /src/Ewmh.cc
parentc82e7c0080f8a5c14dcf95ec92dc42f59ea9dd8b (diff)
parent91ca3bc5c8e2b892a9a81b18246f72aba7deebfd (diff)
downloadfluxbox_paul-e169d33552c8e7070aa6e13da0187f2013b4cfc3.zip
fluxbox_paul-e169d33552c8e7070aa6e13da0187f2013b4cfc3.tar.bz2
Merge branch 'master' into to_push
Diffstat (limited to 'src/Ewmh.cc')
-rw-r--r--src/Ewmh.cc59
1 files changed, 43 insertions, 16 deletions
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 9db7777..3453b7e 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;
@@ -155,12 +156,13 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
155 } 156 }
156 157
157 // allocate some memory for the icons at client side 158 // allocate some memory for the icons at client side
158 img_pm->data = new char[img_pm->bytes_per_line * height]; 159 img_pm->data = static_cast<char*>(malloc(img_pm->bytes_per_line * height));
159 img_mask->data = new char[img_mask->bytes_per_line * height]; 160 img_mask->data = static_cast<char*>(malloc(img_mask->bytes_per_line * height));
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
@@ -1126,8 +1153,8 @@ bool Ewmh::checkClientMessage(const XClientMessageEvent &ce,
1126 return true; 1153 return true;
1127 FbTk::ThemeProxy<FbWinFrameTheme> &theme = screen->focusedWinFrameTheme(); 1154 FbTk::ThemeProxy<FbWinFrameTheme> &theme = screen->focusedWinFrameTheme();
1128 unsigned int bw = theme->border().width(); 1155 unsigned int bw = theme->border().width();
1129 long title_h = theme->titleHeight() || 1156 long title_h = theme->titleHeight() ? theme->titleHeight() + 2*bw :
1130 theme->font().height() + 2*theme->bevelWidth() + 2 + 2*bw; 1157 theme->font().height() + 2*theme->bevelWidth() + 2 + 2*bw;
1131 long handle_h = theme->handleWidth() + 2*bw; 1158 long handle_h = theme->handleWidth() + 2*bw;
1132 long extents[4]; 1159 long extents[4];
1133 // our frames currently don't protrude from left/right 1160 // our frames currently don't protrude from left/right
@@ -1438,7 +1465,7 @@ void Ewmh::updateFrameExtents(FluxboxWindow &win) {
1438 for (; it != it_end; ++it) { 1465 for (; it != it_end; ++it) {
1439 long extents[4]; 1466 long extents[4];
1440 // our frames currently don't protrude from left/right 1467 // our frames currently don't protrude from left/right
1441 int bw = win.frame().window().borderWidth() - (*it)->old_bw; 1468 int bw = win.frame().window().borderWidth();
1442 extents[0] = bw; 1469 extents[0] = bw;
1443 extents[1] = bw; 1470 extents[1] = bw;
1444 extents[2] = win.frame().titlebarHeight() + bw; 1471 extents[2] = win.frame().titlebarHeight() + bw;