… | |
… | |
275 | if (ops == NULL) |
275 | if (ops == NULL) |
276 | n = strlen (geom); |
276 | n = strlen (geom); |
277 | else |
277 | else |
278 | n = ops - geom; |
278 | n = ops - geom; |
279 | |
279 | |
280 | if (n < MAXLEN_GEOM) |
280 | if (n >= MAXLEN_GEOM) |
281 | { |
281 | return false; |
|
|
282 | |
282 | memcpy (str, geom, n); |
283 | memcpy (str, geom, n); |
283 | str[n] = '\0'; |
284 | str[n] = '\0'; |
284 | rxvt_strtrim (str); |
285 | rxvt_strtrim (str); |
285 | |
286 | |
286 | if (str[0]) |
287 | if (str[0]) |
287 | { |
288 | { |
288 | /* we have geometry string - let's handle it prior to applying ops */ |
289 | /* we have geometry string - let's handle it prior to applying ops */ |
289 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
290 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
290 | } /* done parsing geometry string */ |
291 | } /* done parsing geometry string */ |
291 | |
292 | |
292 | if (!update) |
293 | if (!update) |
293 | { |
294 | { |
294 | if (!(geom_flags & XValue)) |
295 | if (!(geom_flags & XValue)) |
295 | x = y = defaultAlign; |
296 | x = y = defaultAlign; |
296 | else if (!(geom_flags & YValue)) |
297 | else if (!(geom_flags & YValue)) |
297 | y = x; |
298 | y = x; |
298 | |
299 | |
299 | if (!(geom_flags & (WidthValue|HeightValue))) |
300 | if (!(geom_flags & (WidthValue|HeightValue))) |
300 | w = h = defaultScale; |
301 | w = h = defaultScale; |
301 | else if (!(geom_flags & HeightValue)) |
302 | else if (!(geom_flags & HeightValue)) |
302 | h = w; |
303 | h = w; |
303 | else if (!(geom_flags & WidthValue)) |
304 | else if (!(geom_flags & WidthValue)) |
304 | w = h; |
305 | w = h; |
305 | |
306 | |
306 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
307 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
307 | } |
308 | } |
308 | |
309 | |
309 | if (ops) |
310 | if (ops) |
310 | { |
311 | { |
311 | while (*ops) |
312 | while (*ops) |
312 | { |
313 | { |
313 | while (*ops == ':' || isspace(*ops)) ++ops; |
314 | while (*ops == ':' || isspace(*ops)) ++ops; |
314 | |
315 | |
315 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) |
316 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof (op_str) - 1) == 0) |
316 | if (CHECK_GEOM_OPS ("tile")) |
317 | if (CHECK_GEOM_OPS ("tile")) |
317 | { |
318 | { |
318 | w = h = noScale; |
319 | w = h = noScale; |
319 | geom_flags |= WidthValue|HeightValue; |
320 | geom_flags |= WidthValue|HeightValue; |
320 | } |
321 | } |
321 | else if (CHECK_GEOM_OPS ("propscale")) |
322 | else if (CHECK_GEOM_OPS ("propscale")) |
322 | { |
323 | { |
323 | new_flags |= propScale; |
324 | new_flags |= propScale; |
324 | } |
325 | } |
325 | else if (CHECK_GEOM_OPS ("hscale")) |
326 | else if (CHECK_GEOM_OPS ("hscale")) |
326 | { |
327 | { |
327 | if (w == 0) w = windowScale; |
328 | if (w == 0) w = windowScale; |
328 | |
329 | |
329 | h = noScale; |
330 | h = noScale; |
330 | geom_flags |= WidthValue|HeightValue; |
331 | geom_flags |= WidthValue|HeightValue; |
331 | } |
332 | } |
332 | else if (CHECK_GEOM_OPS ("vscale")) |
333 | else if (CHECK_GEOM_OPS ("vscale")) |
333 | { |
334 | { |
334 | if (h == 0) h = windowScale; |
335 | if (h == 0) h = windowScale; |
335 | |
336 | |
336 | w = noScale; |
337 | w = noScale; |
337 | geom_flags |= WidthValue|HeightValue; |
338 | geom_flags |= WidthValue|HeightValue; |
338 | } |
339 | } |
339 | else if (CHECK_GEOM_OPS ("scale")) |
340 | else if (CHECK_GEOM_OPS ("scale")) |
340 | { |
341 | { |
341 | if (h == 0) h = windowScale; |
342 | if (h == 0) h = windowScale; |
342 | if (w == 0) w = windowScale; |
343 | if (w == 0) w = windowScale; |
343 | |
344 | |
344 | geom_flags |= WidthValue|HeightValue; |
345 | geom_flags |= WidthValue|HeightValue; |
345 | } |
346 | } |
346 | else if (CHECK_GEOM_OPS ("auto")) |
347 | else if (CHECK_GEOM_OPS ("auto")) |
347 | { |
348 | { |
348 | w = h = windowScale; |
349 | w = h = windowScale; |
349 | x = y = centerAlign; |
350 | x = y = centerAlign; |
350 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
351 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
351 | } |
352 | } |
352 | else if (CHECK_GEOM_OPS ("root")) |
353 | else if (CHECK_GEOM_OPS ("root")) |
353 | { |
354 | { |
354 | new_flags |= rootAlign; |
355 | new_flags |= rootAlign; |
355 | w = h = noScale; |
356 | w = h = noScale; |
356 | geom_flags |= WidthValue|HeightValue; |
357 | geom_flags |= WidthValue|HeightValue; |
357 | } |
358 | } |
358 | # undef CHECK_GEOM_OPS |
359 | # undef CHECK_GEOM_OPS |
359 | |
360 | |
360 | while (*ops != ':' && *ops != '\0') ++ops; |
361 | while (*ops != ':' && *ops != '\0') ++ops; |
361 | } /* done parsing ops */ |
362 | } /* done parsing ops */ |
362 | } |
363 | } |
363 | |
364 | |
364 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
365 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
365 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
366 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
366 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
367 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
367 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
368 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
368 | } |
|
|
369 | |
369 | |
370 | if (new_flags != flags) |
370 | if (new_flags != flags) |
371 | { |
371 | { |
372 | flags = new_flags; |
372 | flags = new_flags; |
373 | changed = true; |
373 | changed = true; |
… | |
… | |
940 | bool has_shade = shade != 100; |
940 | bool has_shade = shade != 100; |
941 | |
941 | |
942 | if (tint) |
942 | if (tint) |
943 | { |
943 | { |
944 | tint->get (c); |
944 | tint->get (c); |
945 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
945 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x00ff || (cmp) >= 0xff00) |
|
|
946 | if (!has_shade |
946 | if (!has_shade && IS_COMPONENT_WHOLESOME (c.r) |
947 | && IS_COMPONENT_WHOLESOME (c.r) |
947 | && IS_COMPONENT_WHOLESOME (c.g) |
948 | && IS_COMPONENT_WHOLESOME (c.g) |
948 | && IS_COMPONENT_WHOLESOME (c.b)) |
949 | && IS_COMPONENT_WHOLESOME (c.b)) |
949 | flags |= bgPixmap_t::tintWholesome; |
950 | flags |= bgPixmap_t::tintWholesome; |
950 | # undef IS_COMPONENT_WHOLESOME |
951 | # undef IS_COMPONENT_WHOLESOME |
951 | } |
952 | } |
952 | |
953 | |
953 | if (has_shade) |
954 | if (has_shade || tint) |
954 | flags |= bgPixmap_t::tintNeeded; |
955 | flags |= bgPixmap_t::tintNeeded; |
955 | else if (tint) |
|
|
956 | { |
|
|
957 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
|
|
958 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
|
|
959 | { |
|
|
960 | flags |= bgPixmap_t::tintNeeded; |
|
|
961 | } |
|
|
962 | } |
|
|
963 | |
956 | |
964 | return flags; |
957 | return flags; |
965 | } |
958 | } |
966 | |
959 | |
967 | bool |
960 | bool |
… | |
… | |
1138 | c.g = (c.g * shade) / 100; |
1131 | c.g = (c.g * shade) / 100; |
1139 | c.b = (c.b * shade) / 100; |
1132 | c.b = (c.b * shade) / 100; |
1140 | } |
1133 | } |
1141 | else |
1134 | else |
1142 | { |
1135 | { |
1143 | c.r = ((0xffff - c.r) * (200 - shade)) / 100; |
1136 | c.r = (c.r * (200 - shade)) / 100; |
1144 | c.g = ((0xffff - c.g) * (200 - shade)) / 100; |
1137 | c.g = (c.g * (200 - shade)) / 100; |
1145 | c.b = ((0xffff - c.b) * (200 - shade)) / 100; |
1138 | c.b = (c.b * (200 - shade)) / 100; |
1146 | } |
1139 | } |
1147 | |
1140 | |
1148 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1141 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
1149 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1142 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1150 | XRenderPictureAttributes pa; |
1143 | XRenderPictureAttributes pa; |
… | |
… | |
1164 | |
1157 | |
1165 | if (mask_pic && overlay_pic && back_pic) |
1158 | if (mask_pic && overlay_pic && back_pic) |
1166 | { |
1159 | { |
1167 | XRenderColor mask_c; |
1160 | XRenderColor mask_c; |
1168 | |
1161 | |
1169 | mask_c.red = mask_c.green = mask_c.blue = shade > 100 ? 0xffff : 0; |
1162 | mask_c.red = mask_c.green = mask_c.blue = 0; |
1170 | mask_c.alpha = 0xffff; |
1163 | mask_c.alpha = 0xffff; |
1171 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1164 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
1172 | |
1165 | |
1173 | mask_c.alpha = 0; |
1166 | mask_c.alpha = 0; |
1174 | mask_c.red = 0xffff - c.r; |
1167 | mask_c.red = 0xffff - c.r; |
1175 | mask_c.green = 0xffff - c.g; |
1168 | mask_c.green = 0xffff - c.g; |
1176 | mask_c.blue = 0xffff - c.b; |
1169 | mask_c.blue = 0xffff - c.b; |
1177 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1170 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
1178 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
1171 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1172 | |
|
|
1173 | if (shade > 100) |
|
|
1174 | { |
|
|
1175 | mask_c.red = mask_c.green = mask_c.blue = 0xffff * (shade - 100) / 100; |
|
|
1176 | mask_c.alpha = 0; |
|
|
1177 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
1178 | |
|
|
1179 | XRenderComposite (dpy, PictOpOver, overlay_pic, None, back_pic, 0, 0, 0, 0, 0, 0, width, height); |
|
|
1180 | } |
|
|
1181 | |
1179 | ret = true; |
1182 | ret = true; |
1180 | } |
1183 | } |
1181 | |
1184 | |
1182 | XRenderFreePicture (dpy, mask_pic); |
1185 | XRenderFreePicture (dpy, mask_pic); |
1183 | XRenderFreePicture (dpy, overlay_pic); |
1186 | XRenderFreePicture (dpy, overlay_pic); |
… | |
… | |
1278 | |
1281 | |
1279 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1282 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
1280 | return 0; |
1283 | return 0; |
1281 | |
1284 | |
1282 | /* straightforward pixmap copy */ |
1285 | /* straightforward pixmap copy */ |
|
|
1286 | while (sx < 0) sx += (int)root_width; |
|
|
1287 | while (sy < 0) sy += (int)root_height; |
|
|
1288 | |
1283 | gcv.tile = recoded_root_pmap; |
1289 | gcv.tile = recoded_root_pmap; |
1284 | gcv.fill_style = FillTiled; |
1290 | gcv.fill_style = FillTiled; |
1285 | |
|
|
1286 | while (sx < 0) sx += (int)root_width; |
|
|
1287 | while (sy < 0) sy += (int)root_height; |
|
|
1288 | |
|
|
1289 | gcv.ts_x_origin = -sx; |
1291 | gcv.ts_x_origin = -sx; |
1290 | gcv.ts_y_origin = -sy; |
1292 | gcv.ts_y_origin = -sy; |
1291 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1293 | gc = XCreateGC (dpy, target->vt, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
1292 | |
1294 | |
1293 | if (gc) |
1295 | if (gc) |
… | |
… | |
1359 | /* we need to re-generate transparency pixmap in that case ! */ |
1361 | /* we need to re-generate transparency pixmap in that case ! */ |
1360 | background_flags = make_transparency_pixmap (); |
1362 | background_flags = make_transparency_pixmap (); |
1361 | if (background_flags == 0) |
1363 | if (background_flags == 0) |
1362 | return false; |
1364 | return false; |
1363 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1365 | else if ((background_flags & transpTransformations) == (flags & transpTransformations)) |
1364 | flags = flags & ~isInvalid; |
1366 | flags &= ~isInvalid; |
1365 | } |
1367 | } |
1366 | # endif |
1368 | # endif |
1367 | |
1369 | |
1368 | # ifdef BG_IMAGE_FROM_FILE |
1370 | # ifdef BG_IMAGE_FROM_FILE |
1369 | if (have_image |
1371 | if (have_image |
1370 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1372 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1371 | { |
1373 | { |
1372 | if (render_image (background_flags)) |
1374 | if (render_image (background_flags)) |
1373 | flags = flags & ~isInvalid; |
1375 | flags &= ~isInvalid; |
1374 | } |
1376 | } |
1375 | # endif |
1377 | # endif |
1376 | |
1378 | |
1377 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1379 | # if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1378 | XImage *result = NULL; |
1380 | XImage *result = NULL; |
… | |
… | |
1398 | if (gc) |
1400 | if (gc) |
1399 | { |
1401 | { |
1400 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1402 | XPutImage (target->dpy, pixmap, gc, result, 0, 0, 0, 0, result->width, result->height); |
1401 | |
1403 | |
1402 | XFreeGC (target->dpy, gc); |
1404 | XFreeGC (target->dpy, gc); |
1403 | flags = flags & ~isInvalid; |
1405 | flags &= ~isInvalid; |
1404 | } |
1406 | } |
1405 | |
1407 | |
1406 | XDestroyImage (result); |
1408 | XDestroyImage (result); |
1407 | } |
1409 | } |
1408 | # endif |
1410 | # endif |
… | |
… | |
1584 | /* prepare limits for color transformation (each channel is handled separately) */ |
1586 | /* prepare limits for color transformation (each channel is handled separately) */ |
1585 | if (shade > 100) |
1587 | if (shade > 100) |
1586 | { |
1588 | { |
1587 | shade = 200 - shade; |
1589 | shade = 200 - shade; |
1588 | |
1590 | |
1589 | high.r = (65535 - c.r) * shade / 100; |
1591 | high.r = c.r * shade / 100; |
1590 | high.g = (65535 - c.g) * shade / 100; |
1592 | high.g = c.g * shade / 100; |
1591 | high.b = (65535 - c.b) * shade / 100; |
1593 | high.b = c.b * shade / 100; |
1592 | |
1594 | |
1593 | low.r = 65535 - high.r; |
1595 | low.r = 65535 * (100 - shade) / 100; |
1594 | low.g = 65535 - high.g; |
1596 | low.g = 65535 * (100 - shade) / 100; |
1595 | low.b = 65535 - high.b; |
1597 | low.b = 65535 * (100 - shade) / 100; |
1596 | } |
1598 | } |
1597 | else |
1599 | else |
1598 | { |
1600 | { |
1599 | high.r = c.r * shade / 100; |
1601 | high.r = c.r * shade / 100; |
1600 | high.g = c.g * shade / 100; |
1602 | high.g = c.g * shade / 100; |