1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: background.C - former xpm.C |
2 | * File: background.C - former xpm.C |
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-2006 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 | * |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * 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 |
10 | * 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 |
11 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
259 | int geom_flags = 0, changed = 0; |
259 | int geom_flags = 0, changed = 0; |
260 | int x = 0, y = 0; |
260 | int x = 0, y = 0; |
261 | unsigned int w = 0, h = 0; |
261 | unsigned int w = 0, h = 0; |
262 | unsigned int n; |
262 | unsigned int n; |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | char *p; |
264 | const char *p; |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | |
266 | |
267 | if (geom == NULL) |
267 | if (geom == NULL) |
268 | return false; |
268 | return false; |
269 | |
269 | |
… | |
… | |
449 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
449 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
450 | { |
450 | { |
451 | if (target == NULL) |
451 | if (target == NULL) |
452 | return false; |
452 | return false; |
453 | |
453 | |
|
|
454 | target->init_asv (); |
|
|
455 | |
|
|
456 | ASImage *result = 0; |
|
|
457 | |
454 | int target_width = (int)target->szHint.width; |
458 | int target_width = target->szHint.width; |
455 | int target_height = (int)target->szHint.height; |
459 | int target_height = target->szHint.height; |
456 | int new_pmap_width = target_width, new_pmap_height = target_height; |
460 | int new_pmap_width = target_width; |
457 | ASImage *result = NULL; |
461 | int new_pmap_height = target_height; |
458 | |
462 | |
459 | int x = 0; |
463 | int x = 0; |
460 | int y = 0; |
464 | int y = 0; |
461 | int w = h_scale * target_width / 100; |
465 | int w = h_scale * target_width / 100; |
462 | int h = v_scale * target_height / 100; |
466 | int h = v_scale * target_height / 100; |
… | |
… | |
663 | # endif /* HAVE_AFTERIMAGE */ |
667 | # endif /* HAVE_AFTERIMAGE */ |
664 | |
668 | |
665 | bool |
669 | bool |
666 | bgPixmap_t::set_file (const char *file) |
670 | bgPixmap_t::set_file (const char *file) |
667 | { |
671 | { |
668 | char *f; |
|
|
669 | |
|
|
670 | assert (file); |
672 | assert (file); |
671 | |
673 | |
672 | if (*file) |
674 | if (*file) |
673 | { |
675 | { |
674 | # ifdef HAVE_AFTERIMAGE |
676 | # ifdef HAVE_AFTERIMAGE |
675 | if (target->asimman == NULL) |
677 | if (!target->asimman) |
676 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
678 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
677 | |
679 | |
678 | if ((f = strchr (file, ';')) == NULL) |
680 | if (const char *p = strchr (file, ';')) |
679 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
|
|
680 | else |
|
|
681 | { |
681 | { |
682 | size_t len = f - file; |
682 | size_t len = p - file; |
683 | f = (char *)malloc (len + 1); |
683 | char *f = (char *)malloc (len + 1); |
684 | memcpy (f, file, len); |
684 | memcpy (f, file, len); |
685 | f[len] = '\0'; |
685 | f[len] = '\0'; |
686 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
686 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
687 | free (f); |
687 | free (f); |
688 | } |
688 | } |
|
|
689 | else |
|
|
690 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
689 | |
691 | |
690 | return original_asim; |
692 | return original_asim; |
691 | # endif |
693 | # endif |
692 | } |
694 | } |
693 | |
695 | |
… | |
… | |
1119 | if (target == NULL) |
1121 | if (target == NULL) |
1120 | return false; |
1122 | return false; |
1121 | |
1123 | |
1122 | TIMING_TEST_START (tp); |
1124 | TIMING_TEST_START (tp); |
1123 | |
1125 | |
1124 | invalidate(); |
1126 | invalidate (); |
1125 | # ifdef ENABLE_TRANSPARENCY |
1127 | # ifdef ENABLE_TRANSPARENCY |
1126 | if (flags & isTransparent) |
1128 | if (flags & isTransparent) |
1127 | { |
1129 | { |
1128 | /* we need to re-generate transparency pixmap in that case ! */ |
1130 | /* we need to re-generate transparency pixmap in that case ! */ |
1129 | background_flags = make_transparency_pixmap (); |
1131 | background_flags = make_transparency_pixmap (); |
… | |
… | |
1138 | XImage *result = NULL; |
1140 | XImage *result = NULL; |
1139 | # ifdef HAVE_AFTERIMAGE |
1141 | # ifdef HAVE_AFTERIMAGE |
1140 | if (original_asim |
1142 | if (original_asim |
1141 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1143 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1142 | { |
1144 | { |
|
|
1145 | target->init_asv (); |
|
|
1146 | |
1143 | ASImage *background = NULL; |
1147 | ASImage *background = NULL; |
1144 | ARGB32 as_tint = TINT_LEAVE_SAME; |
1148 | ARGB32 as_tint = TINT_LEAVE_SAME; |
1145 | if (background_flags) |
1149 | if (background_flags) |
1146 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
1150 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
1147 | |
1151 | |
1148 | # ifdef ENABLE_TRANSPARENCY |
1152 | # ifdef ENABLE_TRANSPARENCY |
1149 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1153 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1150 | { |
1154 | { |
1151 | ShadingInfo as_shade; |
1155 | ShadingInfo as_shade; |
… | |
… | |
1158 | as_shade.tintColor.green = c.g; |
1162 | as_shade.tintColor.green = c.g; |
1159 | as_shade.tintColor.blue = c.b; |
1163 | as_shade.tintColor.blue = c.b; |
1160 | |
1164 | |
1161 | as_tint = shading2tint32 (&as_shade); |
1165 | as_tint = shading2tint32 (&as_shade); |
1162 | } |
1166 | } |
|
|
1167 | |
1163 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
1168 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
1164 | { |
1169 | { |
1165 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
1170 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
1166 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
1171 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
1167 | 100, ASIMAGE_QUALITY_DEFAULT); |
1172 | 100, ASIMAGE_QUALITY_DEFAULT); |
… | |
… | |
1174 | # endif |
1179 | # endif |
1175 | |
1180 | |
1176 | if (render_asim (background, as_tint)) |
1181 | if (render_asim (background, as_tint)) |
1177 | flags = flags & ~isInvalid; |
1182 | flags = flags & ~isInvalid; |
1178 | if (background) |
1183 | if (background) |
1179 | destroy_asimage (&background); |
1184 | destroy_asimage (&background); |
1180 | } |
1185 | } |
1181 | else if (background_flags && pmap_depth != target->depth) |
1186 | else if (background_flags && pmap_depth != target->depth) |
1182 | { |
|
|
1183 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1187 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1184 | } |
|
|
1185 | |
1188 | |
1186 | # elif !XFT /* our own client-side tinting */ |
1189 | # elif !XFT /* our own client-side tinting */ |
1187 | |
1190 | |
1188 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
1191 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
1189 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1192 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1190 | |
1193 | |
1191 | if (background_flags && (flags & isInvalid)) |
1194 | if (background_flags && (flags & isInvalid)) |
1192 | { |
1195 | { |
1193 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1196 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1197 | |
1194 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1198 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1195 | { |
1199 | { |
1196 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1200 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1197 | if (flags & tintSet) |
1201 | if (flags & tintSet) |
1198 | tint.get (c); |
1202 | tint.get (c); |
… | |
… | |
1273 | # ifdef ENABLE_TRANSPARENCY |
1277 | # ifdef ENABLE_TRANSPARENCY |
1274 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1278 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1275 | # endif |
1279 | # endif |
1276 | return true; |
1280 | return true; |
1277 | } |
1281 | } |
|
|
1282 | |
1278 | return false; |
1283 | return false; |
1279 | } |
1284 | } |
1280 | |
1285 | |
1281 | void |
1286 | void |
1282 | bgPixmap_t::apply () |
1287 | bgPixmap_t::apply () |
… | |
… | |
1322 | |
1327 | |
1323 | /* don't want Expose on the parent or vt. It is better to use |
1328 | /* don't want Expose on the parent or vt. It is better to use |
1324 | scr_touch or we get a great deal of flicker otherwise: */ |
1329 | scr_touch or we get a great deal of flicker otherwise: */ |
1325 | XClearWindow (target->dpy, target->parent[0]); |
1330 | XClearWindow (target->dpy, target->parent[0]); |
1326 | |
1331 | |
1327 | if (target->scrollBar.win) |
1332 | if (target->scrollBar.state && target->scrollBar.win) |
1328 | { |
1333 | { |
1329 | target->scrollBar.state = STATE_IDLE; |
1334 | target->scrollBar.state = STATE_IDLE; |
1330 | target->scrollBar.show (0); |
1335 | target->scrollBar.show (0); |
1331 | } |
1336 | } |
1332 | |
1337 | |