diff options
author | fluxgen <fluxgen> | 2004-10-06 06:51:21 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-10-06 06:51:21 (GMT) |
commit | fa8c8699d412dce1536839400587d1e74d769718 (patch) | |
tree | fb9864c4434efc89ac7e6824aedd47f974ae85da /util | |
parent | 662d1a459c15fb1616b5075a41529048520f7606 (diff) | |
download | fluxbox-fa8c8699d412dce1536839400587d1e74d769718.zip fluxbox-fa8c8699d412dce1536839400587d1e74d769718.tar.bz2 |
fixed gradient bug, cleaning, version bump
Diffstat (limited to 'util')
-rw-r--r-- | util/bsetroot.cc | 115 |
1 files changed, 46 insertions, 69 deletions
diff --git a/util/bsetroot.cc b/util/bsetroot.cc index 86d1efb..e8dcfa9 100644 --- a/util/bsetroot.cc +++ b/util/bsetroot.cc | |||
@@ -18,12 +18,13 @@ | |||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | 20 | ||
21 | // $Id: bsetroot.cc,v 1.22 2004/08/31 15:26:40 rathnor Exp $ | 21 | // $Id: bsetroot.cc,v 1.23 2004/10/06 06:51:21 fluxgen Exp $ |
22 | 22 | ||
23 | #include "bsetroot.hh" | 23 | #include "bsetroot.hh" |
24 | 24 | ||
25 | #include "../src/FbTk/I18n.hh" | 25 | #include "../src/FbTk/I18n.hh" |
26 | #include "../src/FbTk/ImageControl.hh" | 26 | #include "../src/FbTk/ImageControl.hh" |
27 | #include "../src/FbTk/GContext.hh" | ||
27 | #include "../src/FbRootWindow.hh" | 28 | #include "../src/FbRootWindow.hh" |
28 | 29 | ||
29 | #ifdef HAVE_CONFIG_H | 30 | #ifdef HAVE_CONFIG_H |
@@ -151,8 +152,7 @@ bsetroot::~bsetroot() { | |||
151 | } | 152 | } |
152 | 153 | ||
153 | if (img_ctrl != 0) { | 154 | if (img_ctrl != 0) { |
154 | int i = 0; | 155 | for (int i=0; i < num_screens; i++) |
155 | for (; i < num_screens; i++) | ||
156 | delete img_ctrl[i]; | 156 | delete img_ctrl[i]; |
157 | 157 | ||
158 | delete [] img_ctrl; | 158 | delete [] img_ctrl; |
@@ -176,15 +176,12 @@ void bsetroot::setRootAtoms(Pixmap pixmap, int screen) { | |||
176 | 176 | ||
177 | // doing this to clean up after old background | 177 | // doing this to clean up after old background |
178 | if (atom_root != None && atom_eroot != None) { | 178 | if (atom_root != None && atom_eroot != None) { |
179 | 179 | root.property(atom_root, 0L, 1L, false, AnyPropertyType, | |
180 | XGetWindowProperty(display(), root.window(), | 180 | &type, &format, &length, &after, &data_root); |
181 | atom_root, 0L, 1L, false, AnyPropertyType, | ||
182 | &type, &format, &length, &after, &data_root); | ||
183 | 181 | ||
184 | if (type == XA_PIXMAP) { | 182 | if (type == XA_PIXMAP) { |
185 | XGetWindowProperty(display(), root.window(), | 183 | root.property(atom_eroot, 0L, 1L, False, AnyPropertyType, |
186 | atom_eroot, 0L, 1L, False, AnyPropertyType, | 184 | &type, &format, &length, &after, &data_eroot); |
187 | &type, &format, &length, &after, &data_eroot); | ||
188 | 185 | ||
189 | if (data_root && data_eroot && type == XA_PIXMAP && | 186 | if (data_root && data_eroot && type == XA_PIXMAP && |
190 | *((Pixmap *) data_root) == *((Pixmap *) data_eroot)) { | 187 | *((Pixmap *) data_root) == *((Pixmap *) data_eroot)) { |
@@ -204,10 +201,8 @@ void bsetroot::setRootAtoms(Pixmap pixmap, int screen) { | |||
204 | } | 201 | } |
205 | 202 | ||
206 | // setting new background atoms | 203 | // setting new background atoms |
207 | XChangeProperty(display(), root.window(), | 204 | root.changeProperty(atom_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pixmap, 1); |
208 | atom_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pixmap, 1); | 205 | root.changeProperty(atom_eroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pixmap, 1); |
209 | XChangeProperty(display(), root.window(), | ||
210 | atom_eroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pixmap, 1); | ||
211 | 206 | ||
212 | } | 207 | } |
213 | 208 | ||
@@ -220,38 +215,28 @@ void bsetroot::solid() { | |||
220 | pixmaps = new Pixmap[ScreenCount(display())]; | 215 | pixmaps = new Pixmap[ScreenCount(display())]; |
221 | 216 | ||
222 | for (; screen < ScreenCount(display()); screen++) { | 217 | for (; screen < ScreenCount(display()); screen++) { |
223 | FbTk::Color c; | ||
224 | if (!c.setFromString(fore, screen)) // just report error | ||
225 | continue; | ||
226 | |||
227 | FbRootWindow root(screen); | ||
228 | |||
229 | GC gc; | ||
230 | XGCValues gcv; | ||
231 | 218 | ||
219 | FbTk::Color c(fore, screen); | ||
232 | if (! c.isAllocated()) | 220 | if (! c.isAllocated()) |
233 | c.setPixel(BlackPixel(display(), screen)); | 221 | c.setPixel(BlackPixel(display(), screen)); |
234 | 222 | ||
235 | gcv.foreground = c.pixel(); | 223 | FbRootWindow root(screen); |
236 | gc = XCreateGC(display(), root.window(), | 224 | |
237 | GCForeground , &gcv); | 225 | FbTk::GContext gc(screen); |
226 | gc.setForeground(c); | ||
238 | 227 | ||
239 | pixmaps[screen] = XCreatePixmap(display(), | 228 | pixmaps[screen] = XCreatePixmap(display(), |
240 | root.window(), | 229 | root.window(), |
241 | root.width(), root.height(), | 230 | root.width(), root.height(), |
242 | root.depth()); | 231 | root.depth()); |
243 | 232 | ||
244 | XFillRectangle(display(), pixmaps[screen], gc, 0, 0, | 233 | XFillRectangle(display(), pixmaps[screen], gc.gc(), 0, 0, |
245 | root.width(), root.height()); | 234 | root.width(), root.height()); |
246 | 235 | ||
247 | setRootAtoms(pixmaps[screen], screen); | 236 | setRootAtoms(pixmaps[screen], screen); |
248 | 237 | ||
249 | XSetWindowBackgroundPixmap(display(), | 238 | root.setBackgroundPixmap(pixmaps[screen]); |
250 | root.window(), pixmaps[screen]); | 239 | root.clear(); |
251 | |||
252 | XClearWindow(display(), root.window()); | ||
253 | |||
254 | XFreeGC(display(), gc); | ||
255 | } | 240 | } |
256 | } | 241 | } |
257 | 242 | ||
@@ -286,10 +271,9 @@ void bsetroot::modula(int x, int y) { | |||
286 | } | 271 | } |
287 | } | 272 | } |
288 | 273 | ||
289 | FbTk::Color f, b; | 274 | |
290 | GC gc; | ||
291 | Pixmap bitmap, r_bitmap; | 275 | Pixmap bitmap, r_bitmap; |
292 | XGCValues gcv; | 276 | |
293 | 277 | ||
294 | bitmap = XCreateBitmapFromData(display(), | 278 | bitmap = XCreateBitmapFromData(display(), |
295 | root.window(), data, 16, 16); | 279 | root.window(), data, 16, 16); |
@@ -299,43 +283,37 @@ void bsetroot::modula(int x, int y) { | |||
299 | root.window(), 16, 16, | 283 | root.window(), 16, 16, |
300 | root.depth()); | 284 | root.depth()); |
301 | 285 | ||
302 | f.setFromString(fore, screen); | 286 | FbTk::Color f(fore, screen), b(back, screen); |
303 | b.setFromString(back, screen); | ||
304 | 287 | ||
305 | if (! f.isAllocated()) | 288 | if (! f.isAllocated()) |
306 | f.setPixel(WhitePixel(display(), screen)); | 289 | f.setPixel(WhitePixel(display(), screen)); |
307 | if (! b.isAllocated()) | 290 | if (! b.isAllocated()) |
308 | b.setPixel(BlackPixel(display(), screen)); | 291 | b.setPixel(BlackPixel(display(), screen)); |
309 | 292 | ||
310 | gcv.foreground = f.pixel(); | 293 | FbTk::GContext gc(screen); |
311 | gcv.background = b.pixel(); | ||
312 | 294 | ||
313 | gc = XCreateGC(display(), root.window(), | 295 | gc.setForeground(f); |
314 | GCForeground | GCBackground, &gcv); | 296 | gc.setBackground(b); |
315 | 297 | ||
316 | // copying bitmap to the one going to be used as tile | 298 | // copying bitmap to the one going to be used as tile |
317 | XCopyPlane(display(), bitmap, r_bitmap, gc, | 299 | XCopyPlane(display(), bitmap, r_bitmap, gc.gc(), |
318 | 0, 0, 16, 16, 0, 0, 1l); | 300 | 0, 0, 16, 16, 0, 0, 1l); |
319 | 301 | ||
320 | XSetTile(display(), gc, r_bitmap); | 302 | gc.setTile(r_bitmap); |
321 | XSetFillStyle(display(), gc, FillTiled); | 303 | gc.setFillStyle(FillTiled); |
322 | 304 | ||
323 | pixmaps[screen] = XCreatePixmap(display(), | 305 | pixmaps[screen] = XCreatePixmap(display(), |
324 | root.window(), | 306 | root.window(), |
325 | root.width(), root.height(), | 307 | root.width(), root.height(), |
326 | root.depth()); | 308 | root.depth()); |
327 | 309 | ||
328 | XFillRectangle(display(), pixmaps[screen], gc, 0, 0, | 310 | XFillRectangle(display(), pixmaps[screen], gc.gc(), 0, 0, |
329 | root.width(), root.height()); | 311 | root.width(), root.height()); |
330 | 312 | ||
331 | setRootAtoms(pixmaps[screen], screen); | 313 | setRootAtoms(pixmaps[screen], screen); |
314 | root.setBackgroundPixmap(pixmaps[screen]); | ||
315 | root.clear(); | ||
332 | 316 | ||
333 | XSetWindowBackgroundPixmap(display(), | ||
334 | root.window(), pixmaps[screen]); | ||
335 | |||
336 | XClearWindow(display(), root.window()); | ||
337 | |||
338 | XFreeGC(display(), gc); | ||
339 | XFreePixmap(display(), bitmap); | 317 | XFreePixmap(display(), bitmap); |
340 | XFreePixmap(display(), r_bitmap); | 318 | XFreePixmap(display(), r_bitmap); |
341 | } | 319 | } |
@@ -350,51 +328,50 @@ void bsetroot::gradient() { | |||
350 | // as the pixmap has been destroyed | 328 | // as the pixmap has been destroyed |
351 | Pixmap tmp; | 329 | Pixmap tmp; |
352 | pixmaps = new Pixmap[ScreenCount(display())]; | 330 | pixmaps = new Pixmap[ScreenCount(display())]; |
353 | 331 | // we must insert gradient text | |
332 | string texture_value = grad ? grad : "solid"; | ||
333 | texture_value.insert(0, "gradient "); | ||
334 | FbTk::Texture texture; | ||
335 | texture.setFromString(texture_value.c_str()); | ||
336 | |||
354 | for (int screen = 0; screen < ScreenCount(display()); screen++) { | 337 | for (int screen = 0; screen < ScreenCount(display()); screen++) { |
355 | FbRootWindow root(screen); | 338 | FbRootWindow root(screen); |
356 | 339 | ||
357 | FbTk::Texture texture; | ||
358 | GC gc; | ||
359 | XGCValues gcv; | ||
360 | 340 | ||
361 | texture.setFromString(grad); | 341 | FbTk::GContext gc(root); |
362 | texture.color().setFromString(fore, screen); | 342 | texture.color().setFromString(fore, screen); |
363 | texture.colorTo().setFromString(back, screen); | 343 | texture.colorTo().setFromString(back, screen); |
364 | 344 | ||
345 | |||
365 | if (! texture.color().isAllocated()) | 346 | if (! texture.color().isAllocated()) |
366 | texture.color().setPixel(WhitePixel(display(), screen)); | 347 | texture.color().setPixel(WhitePixel(display(), screen)); |
348 | |||
367 | if (! texture.colorTo().isAllocated()) | 349 | if (! texture.colorTo().isAllocated()) |
368 | texture.colorTo().setPixel(BlackPixel(display(), screen)); | 350 | texture.colorTo().setPixel(BlackPixel(display(), screen)); |
369 | 351 | ||
370 | tmp = img_ctrl[screen]->renderImage(root.width(), | 352 | tmp = img_ctrl[screen]->renderImage(root.width(), root.height(), |
371 | root.height(), texture); | 353 | texture); |
372 | 354 | ||
373 | pixmaps[screen] = XCreatePixmap(display(), | 355 | pixmaps[screen] = XCreatePixmap(display(), |
374 | root.window(), | 356 | root.window(), |
375 | root.width(), root.height(), | 357 | root.width(), root.height(), |
376 | root.depth()); | 358 | root.depth()); |
377 | 359 | ||
378 | gc = XCreateGC(display(), root.window(), | 360 | |
379 | GCForeground , &gcv); | 361 | XCopyArea(display(), tmp, pixmaps[screen], gc.gc(), 0, 0, |
380 | |||
381 | XCopyArea(display(), tmp, pixmaps[screen], gc, 0, 0, | ||
382 | root.width(), root.height(), | 362 | root.width(), root.height(), |
383 | 0, 0); | 363 | 0, 0); |
384 | 364 | ||
385 | setRootAtoms(pixmaps[screen], screen); | 365 | setRootAtoms(pixmaps[screen], screen); |
386 | 366 | ||
387 | XSetWindowBackgroundPixmap(display(), | 367 | root.setBackgroundPixmap(pixmaps[screen]); |
388 | root.window(), pixmaps[screen]); | 368 | root.clear(); |
389 | |||
390 | XClearWindow(display(), root.window()); | ||
391 | 369 | ||
392 | if (! (root.visual()->c_class & 1)) { | 370 | if (! (root.visual()->c_class & 1)) { |
393 | img_ctrl[screen]->removeImage(tmp); | 371 | img_ctrl[screen]->removeImage(tmp); |
394 | img_ctrl[screen]->cleanCache(); | 372 | img_ctrl[screen]->cleanCache(); |
395 | } | 373 | } |
396 | 374 | ||
397 | XFreeGC(display(), gc); | ||
398 | } | 375 | } |
399 | } | 376 | } |
400 | 377 | ||
@@ -403,7 +380,7 @@ void bsetroot::gradient() { | |||
403 | */ | 380 | */ |
404 | void bsetroot::usage(int exit_code) { | 381 | void bsetroot::usage(int exit_code) { |
405 | _FB_USES_NLS; | 382 | _FB_USES_NLS; |
406 | cerr<<m_app_name<<" 2.2 : (c) 2003 Fluxbox Development Team"<<endl; | 383 | cerr<<m_app_name<<" 2.3 : (c) 2003-2004 Fluxbox Development Team"<<endl; |
407 | cerr<<m_app_name<<" 2.1 : (c) 2002 Claes Nasten"<<endl; | 384 | cerr<<m_app_name<<" 2.1 : (c) 2002 Claes Nasten"<<endl; |
408 | cerr<<m_app_name<<" 2.0 : (c) 1997-2000 Brad Hughes\n"<<endl; | 385 | cerr<<m_app_name<<" 2.0 : (c) 1997-2000 Brad Hughes\n"<<endl; |
409 | cerr<<_FBTEXT(bsetroot, Usage, | 386 | cerr<<_FBTEXT(bsetroot, Usage, |