… | |
… | |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
|
|
8 | * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> |
8 | * |
9 | * |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
11 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
12 | * the Free Software Foundation; either version 2 of the License, or |
12 | * (at your option) any later version. |
13 | * (at your option) any later version. |
… | |
… | |
175 | { |
176 | { |
176 | # ifdef HAVE_AFTERIMAGE |
177 | # ifdef HAVE_AFTERIMAGE |
177 | if (original_asim) |
178 | if (original_asim) |
178 | return true; |
179 | return true; |
179 | # endif |
180 | # endif |
180 | # ifdef ENABLE_TRANSPARENCY |
|
|
181 | if (flags & isTransparent) |
|
|
182 | { |
|
|
183 | # ifdef HAVE_AFTERIMAGE |
|
|
184 | if ((flags & blurNeeded) && !(flags & blurServerSide)) |
|
|
185 | return true; |
|
|
186 | # endif |
|
|
187 | if ((flags & tintNeeded) && !(flags & tintServerSide)) |
|
|
188 | return true; |
|
|
189 | } |
|
|
190 | # endif |
|
|
191 | return false; |
181 | return false; |
192 | } |
182 | } |
193 | |
183 | |
194 | # ifdef BG_IMAGE_FROM_FILE |
184 | # ifdef BG_IMAGE_FROM_FILE |
195 | static inline bool |
185 | static inline bool |
… | |
… | |
941 | } |
931 | } |
942 | |
932 | |
943 | # ifdef HAVE_AFTERIMAGE |
933 | # ifdef HAVE_AFTERIMAGE |
944 | if (!target->asimman) |
934 | if (!target->asimman) |
945 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
935 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
946 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
936 | ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
|
|
937 | if (image) |
|
|
938 | { |
947 | if (original_asim) |
939 | if (original_asim) |
|
|
940 | safe_asimage_destroy (original_asim); |
|
|
941 | original_asim = image; |
948 | have_image = true; |
942 | have_image = true; |
949 | return have_image; |
943 | return true; |
|
|
944 | } |
950 | # endif |
945 | # endif |
951 | |
946 | |
952 | # ifdef HAVE_PIXBUF |
947 | # ifdef HAVE_PIXBUF |
953 | pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
948 | GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); |
|
|
949 | if (image) |
|
|
950 | { |
954 | if (pixbuf) |
951 | if (pixbuf) |
|
|
952 | g_object_unref (pixbuf); |
|
|
953 | pixbuf = image; |
955 | have_image = true; |
954 | have_image = true; |
956 | return have_image; |
955 | return true; |
|
|
956 | } |
957 | # endif |
957 | # endif |
958 | } |
958 | } |
959 | |
959 | |
960 | return false; |
960 | return false; |
961 | } |
961 | } |
… | |
… | |
1113 | } |
1113 | } |
1114 | |
1114 | |
1115 | return false; |
1115 | return false; |
1116 | } |
1116 | } |
1117 | |
1117 | |
|
|
1118 | #if XFT |
1118 | static void |
1119 | static void |
1119 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
1120 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
1120 | { |
1121 | { |
1121 | double sigma = radius / 2.0; |
1122 | double sigma = radius / 2.0; |
1122 | double scale = sqrt (2.0 * M_PI) * sigma; |
1123 | double scale = sqrt (2.0 * M_PI) * sigma; |
… | |
… | |
1133 | params[1] = XDoubleToFixed (1); |
1134 | params[1] = XDoubleToFixed (1); |
1134 | |
1135 | |
1135 | for (int i = 0; i < width; i++) |
1136 | for (int i = 0; i < width; i++) |
1136 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1137 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
1137 | } |
1138 | } |
|
|
1139 | #endif |
1138 | |
1140 | |
1139 | bool |
1141 | bool |
1140 | bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1142 | bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1141 | { |
1143 | { |
1142 | bool ret = false; |
1144 | bool ret = false; |
… | |
… | |
1316 | unsigned int root_pmap_width, root_pmap_height; |
1318 | unsigned int root_pmap_width, root_pmap_height; |
1317 | int window_width = target->szHint.width; |
1319 | int window_width = target->szHint.width; |
1318 | int window_height = target->szHint.height; |
1320 | int window_height = target->szHint.height; |
1319 | int sx, sy; |
1321 | int sx, sy; |
1320 | XGCValues gcv; |
1322 | XGCValues gcv; |
|
|
1323 | GC gc; |
1321 | |
1324 | |
1322 | TIMING_TEST_START (tp); |
1325 | TIMING_TEST_START (tp); |
1323 | target->get_window_origin (sx, sy); |
1326 | target->get_window_origin (sx, sy); |
1324 | |
1327 | |
1325 | /* check if we are outside of the visible part of the virtual screen : */ |
1328 | /* check if we are outside of the visible part of the virtual screen : */ |
… | |
… | |
1339 | root_pixmap = None; |
1342 | root_pixmap = None; |
1340 | |
1343 | |
1341 | target->allowedxerror = 0; |
1344 | target->allowedxerror = 0; |
1342 | } |
1345 | } |
1343 | |
1346 | |
|
|
1347 | if (root_pixmap == None) |
|
|
1348 | return 0; |
|
|
1349 | |
1344 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
1350 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
1345 | GC gc = NULL; |
|
|
1346 | |
1351 | |
1347 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1352 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1348 | return 0; |
1353 | return 0; |
1349 | |
1354 | |
1350 | if (root_pixmap == None) |
|
|
1351 | { |
|
|
1352 | /* use tricks to obtain the root background image :*/ |
|
|
1353 | /* we want to create Overrideredirect window overlapping out window |
|
|
1354 | with background type of Parent Relative and then grab it */ |
|
|
1355 | XSetWindowAttributes attr; |
|
|
1356 | Window src; |
|
|
1357 | bool success = false; |
|
|
1358 | |
|
|
1359 | attr.background_pixmap = ParentRelative; |
|
|
1360 | attr.backing_store = Always; |
|
|
1361 | attr.event_mask = ExposureMask; |
|
|
1362 | attr.override_redirect = True; |
|
|
1363 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
|
|
1364 | CopyFromParent, CopyFromParent, CopyFromParent, |
|
|
1365 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
|
|
1366 | &attr); |
|
|
1367 | |
|
|
1368 | if (src != None) |
|
|
1369 | { |
|
|
1370 | XEvent event; |
|
|
1371 | int ev_count = 0; |
|
|
1372 | XGrabServer (dpy); |
|
|
1373 | XMapRaised (dpy, src); |
|
|
1374 | XSync (dpy, False); |
|
|
1375 | |
|
|
1376 | /* XSync should get window where it's properly exposed, |
|
|
1377 | * but to be on the safe side - let's check for the actual event to arrive : */ |
|
|
1378 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
|
|
1379 | ++ev_count; |
|
|
1380 | |
|
|
1381 | if (ev_count > 0); |
|
|
1382 | { |
|
|
1383 | /* hooray! - we can grab the image! */ |
|
|
1384 | gc = XCreateGC (dpy, root, 0, NULL); |
|
|
1385 | if (gc) |
|
|
1386 | { |
|
|
1387 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
|
|
1388 | success = true; |
|
|
1389 | } |
|
|
1390 | } |
|
|
1391 | |
|
|
1392 | XDestroyWindow (dpy, src); |
|
|
1393 | XUngrabServer (dpy); |
|
|
1394 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
|
|
1395 | } |
|
|
1396 | |
|
|
1397 | if (!success) |
|
|
1398 | { |
|
|
1399 | XFreePixmap (dpy, tiled_root_pmap); |
|
|
1400 | tiled_root_pmap = None; |
|
|
1401 | } |
|
|
1402 | else |
|
|
1403 | result |= transpPmapTiled; |
|
|
1404 | } |
|
|
1405 | else |
|
|
1406 | { |
|
|
1407 | /* straightforward pixmap copy */ |
1355 | /* straightforward pixmap copy */ |
1408 | gcv.tile = root_pixmap; |
1356 | gcv.tile = root_pixmap; |
1409 | gcv.fill_style = FillTiled; |
1357 | gcv.fill_style = FillTiled; |
1410 | |
1358 | |
1411 | while (sx < 0) sx += (int)root_width; |
1359 | while (sx < 0) sx += (int)root_width; |
1412 | while (sy < 0) sy += (int)root_height; |
1360 | while (sy < 0) sy += (int)root_height; |
1413 | |
1361 | |
1414 | gcv.ts_x_origin = -sx; |
1362 | gcv.ts_x_origin = -sx; |
1415 | gcv.ts_y_origin = -sy; |
1363 | gcv.ts_y_origin = -sy; |
1416 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1364 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1417 | |
1365 | |
1418 | if (gc) |
1366 | if (gc) |
1419 | { |
1367 | { |
1420 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1368 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
1421 | result |= transpPmapTiled; |
1369 | result |= transpPmapTiled; |
1422 | } |
1370 | XFreeGC (dpy, gc); |
1423 | } |
1371 | } |
1424 | TIMING_TEST_PRINT_RESULT (tp); |
1372 | TIMING_TEST_PRINT_RESULT (tp); |
1425 | |
1373 | |
1426 | if (tiled_root_pmap != None) |
1374 | if (tiled_root_pmap != None) |
1427 | { |
1375 | { |
1428 | if (!need_client_side_rendering ()) |
1376 | if (!need_client_side_rendering ()) |
1429 | { |
1377 | { |
1430 | if ((flags & blurNeeded)) |
1378 | if (flags & (blurNeeded | blurServerSide)) |
1431 | { |
1379 | { |
1432 | if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) |
1380 | if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) |
1433 | result |= transpPmapBlurred; |
1381 | result |= transpPmapBlurred; |
1434 | } |
1382 | } |
1435 | if ((flags & tintNeeded)) |
1383 | if (flags & (tintNeeded | tintServerSide)) |
1436 | { |
1384 | { |
1437 | if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) |
1385 | if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) |
1438 | result |= transpPmapTinted; |
1386 | result |= transpPmapTinted; |
1439 | } |
1387 | } |
1440 | } /* server side rendering completed */ |
1388 | } /* server side rendering completed */ |
… | |
… | |
1445 | pixmap = tiled_root_pmap; |
1393 | pixmap = tiled_root_pmap; |
1446 | pmap_width = window_width; |
1394 | pmap_width = window_width; |
1447 | pmap_height = window_height; |
1395 | pmap_height = window_height; |
1448 | pmap_depth = root_depth; |
1396 | pmap_depth = root_depth; |
1449 | } |
1397 | } |
1450 | |
|
|
1451 | if (gc) |
|
|
1452 | XFreeGC (dpy, gc); |
|
|
1453 | |
1398 | |
1454 | TIMING_TEST_PRINT_RESULT (tp); |
1399 | TIMING_TEST_PRINT_RESULT (tp); |
1455 | |
1400 | |
1456 | return result; |
1401 | return result; |
1457 | } |
1402 | } |